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
b744aaa3
Commit
b744aaa3
authored
Jul 22, 2013
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure parsed times are set to UTC
parent
af522af2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
19 deletions
+41
-19
common/djangoapps/student/views.py
+2
-2
common/lib/capa/capa/capa_problem.py
+39
-17
No files found.
common/djangoapps/student/views.py
View file @
b744aaa3
...
...
@@ -111,9 +111,9 @@ def get_date_for_press(publish_date):
# strip off extra months, and just use the first:
date
=
re
.
sub
(
multimonth_pattern
,
", "
,
publish_date
)
if
re
.
search
(
day_pattern
,
date
):
date
=
datetime
.
datetime
.
strptime
(
date
,
"
%
B
%
d,
%
Y"
)
date
=
datetime
.
datetime
.
strptime
(
date
,
"
%
B
%
d,
%
Y"
)
.
replace
(
tzinfo
=
UTC
)
else
:
date
=
datetime
.
datetime
.
strptime
(
date
,
"
%
B,
%
Y"
)
date
=
datetime
.
datetime
.
strptime
(
date
,
"
%
B,
%
Y"
)
.
replace
(
tzinfo
=
UTC
)
return
date
...
...
common/lib/capa/capa/capa_problem.py
View file @
b744aaa3
...
...
@@ -32,6 +32,8 @@ import capa.xqueue_interface as xqueue_interface
import
capa.responsetypes
as
responsetypes
from
capa.safe_exec
import
safe_exec
from
pytz
import
UTC
# dict of tagname, Response Class -- this should come from auto-registering
response_tag_dict
=
dict
([(
x
.
response_tag
,
x
)
for
x
in
responsetypes
.
__all__
])
...
...
@@ -42,13 +44,22 @@ solution_tags = ['solution']
response_properties
=
[
"codeparam"
,
"responseparam"
,
"answer"
,
"openendedparam"
]
# special problem tags which should be turned into innocuous HTML
html_transforms
=
{
'problem'
:
{
'tag'
:
'div'
},
'text'
:
{
'tag'
:
'span'
},
'math'
:
{
'tag'
:
'span'
},
}
html_transforms
=
{
'problem'
:
{
'tag'
:
'div'
},
'text'
:
{
'tag'
:
'span'
},
'math'
:
{
'tag'
:
'span'
},
}
# These should be removed from HTML output, including all subelements
html_problem_semantics
=
[
"codeparam"
,
"responseparam"
,
"answer"
,
"script"
,
"hintgroup"
,
"openendedparam"
,
"openendedrubric"
]
html_problem_semantics
=
[
"codeparam"
,
"responseparam"
,
"answer"
,
"script"
,
"hintgroup"
,
"openendedparam"
,
"openendedrubric"
]
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -248,7 +259,7 @@ class LoncapaProblem(object):
if
self
.
correct_map
.
is_queued
(
answer_id
)
]
queuetimes
=
[
datetime
.
strptime
(
qt_str
,
xqueue_interface
.
dateformat
)
datetime
.
strptime
(
qt_str
,
xqueue_interface
.
dateformat
)
.
replace
(
tzinfo
=
UTC
)
for
qt_str
in
queuetime_strs
]
...
...
@@ -408,10 +419,16 @@ class LoncapaProblem(object):
# open using ModuleSystem OSFS filestore
ifp
=
self
.
system
.
filestore
.
open
(
filename
)
except
Exception
as
err
:
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
log
.
warning
(
'Cannot find file
%
s in
%
s'
%
(
filename
,
self
.
system
.
filestore
))
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)
)
)
log
.
warning
(
'Cannot find file
%
s in
%
s'
%
(
filename
,
self
.
system
.
filestore
)
)
# if debugging, don't fail - just log error
# TODO (vshnayder): need real error handling, display to users
if
not
self
.
system
.
get
(
'DEBUG'
):
...
...
@@ -422,8 +439,11 @@ class LoncapaProblem(object):
# read in and convert to XML
incxml
=
etree
.
XML
(
ifp
.
read
())
except
Exception
as
err
:
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)
)
)
log
.
warning
(
'Cannot parse XML in
%
s'
%
(
filename
))
# if debugging, don't fail - just log error
# TODO (vshnayder): same as above
...
...
@@ -583,8 +603,9 @@ class LoncapaProblem(object):
# let each Response render itself
if
problemtree
in
self
.
responders
:
overall_msg
=
self
.
correct_map
.
get_overall_message
()
return
self
.
responders
[
problemtree
]
.
render_html
(
self
.
_extract_html
,
response_msg
=
overall_msg
)
return
self
.
responders
[
problemtree
]
.
render_html
(
self
.
_extract_html
,
response_msg
=
overall_msg
)
# let each custom renderer render itself:
if
problemtree
.
tag
in
customrender
.
registry
.
registered_tags
():
...
...
@@ -632,9 +653,10 @@ class LoncapaProblem(object):
answer_id
=
1
input_tags
=
inputtypes
.
registry
.
registered_tags
()
inputfields
=
tree
.
xpath
(
"|"
.
join
([
'//'
+
response
.
tag
+
'[@id=$id]//'
+
x
for
x
in
(
input_tags
+
solution_tags
)]),
id
=
response_id_str
)
inputfields
=
tree
.
xpath
(
"|"
.
join
([
'//'
+
response
.
tag
+
'[@id=$id]//'
+
x
for
x
in
(
input_tags
+
solution_tags
)]),
id
=
response_id_str
)
# assign one answer_id for each input type or solution type
for
entry
in
inputfields
:
...
...
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