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
62f54447
Commit
62f54447
authored
Dec 13, 2012
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1143 from MITx/feature/christina/misc
Protect against graceperiodjson being null.
parents
aee4fd91
e77a67a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
13 deletions
+15
-13
cms/djangoapps/models/settings/course_grading.py
+15
-13
No files found.
cms/djangoapps/models/settings/course_grading.py
View file @
62f54447
from
xmodule.modulestore
import
Location
from
contentstore.utils
import
get_modulestore
import
datetime
import
re
from
util
import
converters
import
time
class
CourseGradingModel
:
...
...
@@ -145,19 +143,23 @@ class CourseGradingModel:
def
update_grace_period_from_json
(
course_location
,
graceperiodjson
):
"""
Update the course's default grace period. Incoming dict is {hours: h, minutes: m} possibly as a
grace_period entry in an enclosing dict.
grace_period entry in an enclosing dict. It is also safe to call this method with a value of
None for graceperiodjson.
"""
if
not
isinstance
(
course_location
,
Location
):
course_location
=
Location
(
course_location
)
if
'grace_period'
in
graceperiodjson
:
graceperiodjson
=
graceperiodjson
[
'grace_period'
]
grace_rep
=
" "
.
join
([
"
%
s
%
s"
%
(
value
,
key
)
for
(
key
,
value
)
in
graceperiodjson
.
iteritems
()])
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
.
metadata
[
'graceperiod'
]
=
grace_rep
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
# Before a graceperiod has ever been created, it will be None (once it has been
# created, it cannot be set back to None).
if
graceperiodjson
is
not
None
:
if
'grace_period'
in
graceperiodjson
:
graceperiodjson
=
graceperiodjson
[
'grace_period'
]
grace_rep
=
" "
.
join
([
"
%
s
%
s"
%
(
value
,
key
)
for
(
key
,
value
)
in
graceperiodjson
.
iteritems
()])
descriptor
=
get_modulestore
(
course_location
)
.
get_item
(
course_location
)
descriptor
.
metadata
[
'graceperiod'
]
=
grace_rep
get_modulestore
(
course_location
)
.
update_metadata
(
course_location
,
descriptor
.
metadata
)
@staticmethod
def
delete_grader
(
course_location
,
index
):
...
...
@@ -171,7 +173,7 @@ class CourseGradingModel:
index
=
int
(
index
)
if
index
<
len
(
descriptor
.
raw_grader
):
del
descriptor
.
raw_grader
[
index
]
# force propagation to defintion
# force propagation to defin
i
tion
descriptor
.
raw_grader
=
descriptor
.
raw_grader
get_modulestore
(
course_location
)
.
update_item
(
course_location
,
descriptor
.
definition
[
'data'
])
...
...
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