Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
985211a3
Commit
985211a3
authored
Feb 04, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Showing due dates and section types on profile page.
parent
32f69d64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
courseware/content_parser.py
+2
-3
courseware/modules/capa_module.py
+5
-0
courseware/views.py
+7
-1
No files found.
courseware/content_parser.py
View file @
985211a3
...
...
@@ -185,9 +185,8 @@ def toc_from_xml(dom, active_chapter, active_section):
sections
=
list
()
for
s
in
dom
.
xpath
(
'//course[@name=$name]/chapter[@name=$chname]/section'
,
name
=
name
,
chname
=
c
.
get
(
'name'
)):
sections
.
append
({
'name'
:
s
.
get
(
"name"
)
or
""
,
'time'
:
s
.
get
(
"time"
)
or
""
,
'format'
:
s
.
get
(
"format"
)
or
""
,
'due'
:
s
.
get
(
"display_due_date"
)
or
""
,
'format'
:
s
.
get
(
"subtitle"
)
if
s
.
get
(
"subtitle"
)
else
s
.
get
(
"format"
)
or
""
,
'due'
:
s
.
get
(
"due"
)
or
""
,
'active'
:(
c
.
get
(
"name"
)
==
active_chapter
and
\
s
.
get
(
"name"
)
==
active_section
)})
ch
.
append
({
'name'
:
c
.
get
(
"name"
),
...
...
courseware/modules/capa_module.py
View file @
985211a3
...
...
@@ -3,6 +3,7 @@ import datetime
import
dateutil
import
dateutil.parser
import
json
import
logging
import
math
import
numpy
import
os
...
...
@@ -23,6 +24,8 @@ from x_module import XModule
from
courseware.capa.capa_problem
import
LoncapaProblem
import
courseware.content_parser
as
content_parser
log
=
logging
.
getLogger
(
"mitx.courseware"
)
class
LoncapaModule
(
XModule
):
''' Interface between capa_problem and x_module. Originally a hack
meant to be refactored out, but it seems to be serving a useful
...
...
@@ -128,6 +131,7 @@ class LoncapaModule(XModule):
display_due_date_string
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
if
len
(
display_due_date_string
)
>
0
:
self
.
display_due_date
=
dateutil
.
parser
.
parse
(
display_due_date_string
)
log
.
debug
(
"Parsed "
+
display_due_date_string
+
" to "
+
str
(
self
.
display_due_date
))
else
:
self
.
display_due_date
=
None
...
...
@@ -136,6 +140,7 @@ class LoncapaModule(XModule):
if
len
(
grace_period_string
)
>
0
and
self
.
display_due_date
:
self
.
grace_period
=
content_parser
.
parse_timedelta
(
grace_period_string
)
self
.
close_date
=
self
.
display_due_date
+
self
.
grace_period
log
.
debug
(
"Then parsed "
+
grace_period_string
+
" to closing date"
+
str
(
self
.
close_date
))
else
:
self
.
grace_period
=
None
self
.
close_date
=
self
.
display_due_date
...
...
courseware/views.py
View file @
985211a3
...
...
@@ -59,6 +59,8 @@ def profile(request):
course
=
course
,
chname
=
chname
):
problems
=
dom
.
xpath
(
'//course[@name=$course]/chapter[@name=$chname]/section[@name=$section]//problem'
,
course
=
course
,
chname
=
chname
,
section
=
s
.
get
(
'name'
))
graded
=
True
if
s
.
get
(
'graded'
)
==
"true"
else
False
scores
=
[]
if
len
(
problems
)
>
0
:
for
p
in
problems
:
...
...
@@ -70,7 +72,7 @@ def profile(request):
correct
=
response
.
grade
total
=
courseware
.
modules
.
capa_module
.
LoncapaModule
(
etree
.
tostring
(
p
),
"id"
)
.
max_score
()
# TODO: Add state. Not useful now, but maybe someday problems will have randomized max scores?
scores
.
append
((
int
(
correct
),
total
,
(
True
if
s
.
get
(
'graded'
)
==
"true"
else
False
)
))
scores
.
append
((
int
(
correct
),
total
,
graded
))
section_total
=
(
sum
([
score
[
0
]
for
score
in
scores
]),
...
...
@@ -81,6 +83,7 @@ def profile(request):
#Add the graded total to total_scores
format
=
s
.
get
(
'format'
)
if
s
.
get
(
'format'
)
else
""
subtitle
=
s
.
get
(
'subtitle'
)
if
s
.
get
(
'subtitle'
)
else
format
if
format
and
graded_total
[
1
]
>
0
:
format_scores
=
total_scores
[
format
]
if
format
in
total_scores
else
[]
format_scores
.
append
(
graded_total
)
...
...
@@ -92,6 +95,9 @@ def profile(request):
'scores'
:
scores
,
'section_total'
:
section_total
,
'format'
:
format
,
'subtitle'
:
subtitle
,
'due'
:
s
.
get
(
"due"
)
or
""
,
'graded'
:
graded
,
}
hw
.
append
(
score
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment