Commit 6c64032f by Don Mitchell

Overview should be ready to test.

parent e0849e8b
...@@ -204,23 +204,30 @@ class CourseGradingModel: ...@@ -204,23 +204,30 @@ class CourseGradingModel:
@staticmethod @staticmethod
def get_section_grader_type(location): def get_section_grader_type(location):
"""
"""
if not isinstance(location, Location): if not isinstance(location, Location):
location = Location(location) location = Location(location)
# TODO impl to return {grader-type, location, id (random)} descriptor = get_modulestore(location).get_item(location)
return {
"grader-type" : descriptor.metadata.get('format', "Not Graded"),
"location" : location,
"id" : 99 # just an arbitrary value to
}
@staticmethod @staticmethod
def update_section_grader_type(location, jsondict): def update_section_grader_type(location, jsondict):
"""
"""
if not isinstance(location, Location): if not isinstance(location, Location):
location = Location(location) location = Location(location)
descriptor = get_modulestore(location).get_item(location)
if 'grader-type' in jsondict:
descriptor.metadata['format'] = jsondict.get('grader-type')
descriptor.metadata['graded'] = True
else:
del descriptor.metadata['format']
descriptor.metadata['graded'] = False
# TODO impl to return {grader-type, location, id (random)} get_modulestore(location).update_metadata(location, descriptor.metadata)
@staticmethod @staticmethod
......
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
location : null // A location object
},
initialize : function(attrs) {
if (attrs['assignment-url']) {
this.set('location') = new CMS.Models.Location(attrs['assignment-url'], {parse: true});
}
},
parse : function(attrs) {
if (attrs['location']) {
attrs.location = new CMS.Models.Location(attrs['location'], {parse: true});
}
}
urlRoot : function() {
if (this.has('location')) {
var location = this.get('location');
return '/' + location.get('org') + "/" + location.get('course') + '/' + location.get('category') + '/'
+ location.get('name') + '/gradeas/';
}
else return "";
}
});
CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
// instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> }
events : {
"click .menu-toggle" : "showGradeMenu",
"click .menu" : "selectGradeType"
},
initialize : function() {
// call template w/ {assignment-type : formatname, graders : CourseGraderCollection instance }
this.template = _.template(
'<h4 class="status-label"><%= assignment-type %></h4>' +
'<a data-tooltip="Mark/unmark this section as graded" class="menu-toggle" href="#">' +
'<span class="ss-icon ss-standard">&#x2713;</span>' +
'</a>' +
'<ul class="menu">' +
'<% graders.each(function(option) { %>' +
'<li><a <% if (option.get("type") == assignment-type) {%>class="is-selected" <%}%> href="#"><%= option.get("type") %></a></li>' +
'<% }) %>'
'<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>'
'</ul>');
this.assignmentGrade = new CMS.Models.AssignmentGrade({
assignment-url : this.$el.closest('section.branch').data('id'),
grader-type : this.$el.data('initial-status')});
this.render();
},
render : function() {
this.$el.html(this.template({ assignment-type : this.assignmentGrade.get('grader-type'), graders : this.graders }));
if (this.assignmentGrade.has('grader-type') && assignmentGrade.get('grader-type') != "Not Graded") {
this.$el.addClass('is-set');
}
else {
this.$el.removeClass('is-set');
}
},
showGradeMenu : function(e) {
e.preventDefault();
this.$el.toggleClass('is-active');
},
selectGradeType : function(e) {
e.preventDefault();
// TODO I'm not happy with this string fetch via the html for what should be an id. I'd rather use the id attr
// of the CourseGradingPolicy model or null for Not Graded (NOTE, change template's if check for is-selected accordingly)
this.assignmentGrade.save('grader-type', $(e.target).html());
this.render();
}
})
\ No newline at end of file
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