Commit e77a67a9 by cahrens

Protect against graceperiodjson being null.

r.don
parent aee4fd91
from xmodule.modulestore import Location from xmodule.modulestore import Location
from contentstore.utils import get_modulestore from contentstore.utils import get_modulestore
import datetime
import re import re
from util import converters from util import converters
import time
class CourseGradingModel: class CourseGradingModel:
...@@ -145,11 +143,15 @@ class CourseGradingModel: ...@@ -145,11 +143,15 @@ class CourseGradingModel:
def update_grace_period_from_json(course_location, graceperiodjson): 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 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): if not isinstance(course_location, Location):
course_location = Location(course_location) course_location = Location(course_location)
# 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: if 'grace_period' in graceperiodjson:
graceperiodjson = graceperiodjson['grace_period'] graceperiodjson = graceperiodjson['grace_period']
...@@ -171,7 +173,7 @@ class CourseGradingModel: ...@@ -171,7 +173,7 @@ class CourseGradingModel:
index = int(index) index = int(index)
if index < len(descriptor.raw_grader): if index < len(descriptor.raw_grader):
del descriptor.raw_grader[index] del descriptor.raw_grader[index]
# force propagation to defintion # force propagation to definition
descriptor.raw_grader = descriptor.raw_grader descriptor.raw_grader = descriptor.raw_grader
get_modulestore(course_location).update_item(course_location, descriptor.definition['data']) get_modulestore(course_location).update_item(course_location, descriptor.definition['data'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment