diff --git a/cms/djangoapps/models/settings/course_grading.py b/cms/djangoapps/models/settings/course_grading.py index 5a998bb044..358e0a851b 100644 --- a/cms/djangoapps/models/settings/course_grading.py +++ b/cms/djangoapps/models/settings/course_grading.py @@ -199,7 +199,7 @@ class CourseGradingModel: course_location = Location(course_location) descriptor = get_modulestore(course_location).get_item(course_location) - del descriptor.metadata['graceperiod'] + if 'graceperiod' in descriptor.metadata: del descriptor.metadata['graceperiod'] get_modulestore(course_location).update_metadata(course_location, descriptor.metadata) @staticmethod @@ -209,7 +209,7 @@ class CourseGradingModel: descriptor = get_modulestore(location).get_item(location) return { - "grader-type" : descriptor.metadata.get('format', "Not Graded"), + "graderType" : descriptor.metadata.get('format', u"Not Graded"), "location" : location, "id" : 99 # just an arbitrary value to } @@ -220,12 +220,12 @@ class CourseGradingModel: location = Location(location) descriptor = get_modulestore(location).get_item(location) - if 'grader-type' in jsondict: - descriptor.metadata['format'] = jsondict.get('grader-type') + if 'graderType' in jsondict and jsondict['graderType'] != u"Not Graded": + descriptor.metadata['format'] = jsondict.get('graderType') descriptor.metadata['graded'] = True else: - del descriptor.metadata['format'] - descriptor.metadata['graded'] = False + if 'format' in descriptor.metadata: del descriptor.metadata['format'] + if 'graded' in descriptor.metadata: del descriptor.metadata['graded'] get_modulestore(location).update_metadata(location, descriptor.metadata) diff --git a/cms/static/js/views/grader-select-view.js b/cms/static/js/views/grader-select-view.js index 1107273cff..a6528f6205 100644 --- a/cms/static/js/views/grader-select-view.js +++ b/cms/static/js/views/grader-select-view.js @@ -1,19 +1,19 @@ CMS.Models.AssignmentGrade = Backbone.Model.extend({ idAttribute : "cid", // not sure if this is kosher defaults : { - grader-type : null, // the type label (string). May be "Not Graded" which implies None. I'd like to use id but that's ephemeral + graderType : null, // the type label (string). May be "Not Graded" which implies None. I'd like to use id but that's ephemeral location : null // A location object }, initialize : function(attrs) { - if (attrs['assignment-url']) { - this.set('location') = new CMS.Models.Location(attrs['assignment-url'], {parse: true}); + if (attrs['assignmentUrl']) { + this.set('location', new CMS.Models.Location(attrs['assignmentUrl'], {parse: true})); } }, parse : function(attrs) { - if (attrs['location']) { + if (attrs && attrs['location']) { attrs.location = new CMS.Models.Location(attrs['location'], {parse: true}); } - } + }, urlRoot : function() { if (this.has('location')) { var location = this.get('location'); @@ -31,26 +31,29 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({ "click .menu" : "selectGradeType" }, initialize : function() { - // call template w/ {assignment-type : formatname, graders : CourseGraderCollection instance } + // call template w/ {assignmentType : formatname, graders : CourseGraderCollection instance } this.template = _.template( - '