Commit 0fc16dff by Don Mitchell

Gradable impl'd for overview page

parent 6c64032f
...@@ -199,7 +199,7 @@ class CourseGradingModel: ...@@ -199,7 +199,7 @@ class CourseGradingModel:
course_location = Location(course_location) course_location = Location(course_location)
descriptor = get_modulestore(course_location).get_item(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) get_modulestore(course_location).update_metadata(course_location, descriptor.metadata)
@staticmethod @staticmethod
...@@ -209,7 +209,7 @@ class CourseGradingModel: ...@@ -209,7 +209,7 @@ class CourseGradingModel:
descriptor = get_modulestore(location).get_item(location) descriptor = get_modulestore(location).get_item(location)
return { return {
"grader-type" : descriptor.metadata.get('format', "Not Graded"), "graderType" : descriptor.metadata.get('format', u"Not Graded"),
"location" : location, "location" : location,
"id" : 99 # just an arbitrary value to "id" : 99 # just an arbitrary value to
} }
...@@ -220,12 +220,12 @@ class CourseGradingModel: ...@@ -220,12 +220,12 @@ class CourseGradingModel:
location = Location(location) location = Location(location)
descriptor = get_modulestore(location).get_item(location) descriptor = get_modulestore(location).get_item(location)
if 'grader-type' in jsondict: if 'graderType' in jsondict and jsondict['graderType'] != u"Not Graded":
descriptor.metadata['format'] = jsondict.get('grader-type') descriptor.metadata['format'] = jsondict.get('graderType')
descriptor.metadata['graded'] = True descriptor.metadata['graded'] = True
else: else:
del descriptor.metadata['format'] if 'format' in descriptor.metadata: del descriptor.metadata['format']
descriptor.metadata['graded'] = False if 'graded' in descriptor.metadata: del descriptor.metadata['graded']
get_modulestore(location).update_metadata(location, descriptor.metadata) get_modulestore(location).update_metadata(location, descriptor.metadata)
......
CMS.Models.AssignmentGrade = Backbone.Model.extend({ CMS.Models.AssignmentGrade = Backbone.Model.extend({
idAttribute : "cid", // not sure if this is kosher idAttribute : "cid", // not sure if this is kosher
defaults : { 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 location : null // A location object
}, },
initialize : function(attrs) { initialize : function(attrs) {
if (attrs['assignment-url']) { if (attrs['assignmentUrl']) {
this.set('location') = new CMS.Models.Location(attrs['assignment-url'], {parse: true}); this.set('location', new CMS.Models.Location(attrs['assignmentUrl'], {parse: true}));
} }
}, },
parse : function(attrs) { parse : function(attrs) {
if (attrs['location']) { if (attrs && attrs['location']) {
attrs.location = new CMS.Models.Location(attrs['location'], {parse: true}); attrs.location = new CMS.Models.Location(attrs['location'], {parse: true});
} }
} },
urlRoot : function() { urlRoot : function() {
if (this.has('location')) { if (this.has('location')) {
var location = this.get('location'); var location = this.get('location');
...@@ -31,26 +31,29 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({ ...@@ -31,26 +31,29 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
"click .menu" : "selectGradeType" "click .menu" : "selectGradeType"
}, },
initialize : function() { initialize : function() {
// call template w/ {assignment-type : formatname, graders : CourseGraderCollection instance } // call template w/ {assignmentType : formatname, graders : CourseGraderCollection instance }
this.template = _.template( this.template = _.template(
'<h4 class="status-label"><%= assignment-type %></h4>' + // TODO move to a template file
'<h4 class="status-label"><%= assignmentType %></h4>' +
'<a data-tooltip="Mark/unmark this section as graded" class="menu-toggle" href="#">' + '<a data-tooltip="Mark/unmark this section as graded" class="menu-toggle" href="#">' +
'<span class="ss-icon ss-standard">&#x2713;</span>' + '<span class="ss-icon ss-standard">&#x2713;</span>' +
'</a>' + '</a>' +
'<ul class="menu">' + '<ul class="menu">' +
'<% graders.each(function(option) { %>' + '<% graders.each(function(option) { %>' +
'<li><a <% if (option.get("type") == assignment-type) {%>class="is-selected" <%}%> href="#"><%= option.get("type") %></a></li>' + '<li><a <% if (option.get("type") == assignmentType) {%>class="is-selected" <%}%> href="#"><%= option.get("type") %></a></li>' +
'<% }) %>' '<% }) %>' +
'<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>' '<li><a class="gradable-status-notgraded" href="#">Not Graded</a></li>' +
'</ul>'); '</ul>');
this.assignmentGrade = new CMS.Models.AssignmentGrade({ this.assignmentGrade = new CMS.Models.AssignmentGrade({
assignment-url : this.$el.closest('section.branch').data('id'), assignmentUrl : this.$el.closest('.branch').data('id'),
grader-type : this.$el.data('initial-status')}); graderType : this.$el.data('initial-status')});
// TODO throw exception if graders is null
this.graders = this.options['graders'];
this.render(); this.render();
}, },
render : function() { render : function() {
this.$el.html(this.template({ assignment-type : this.assignmentGrade.get('grader-type'), graders : this.graders })); this.$el.html(this.template({ assignmentType : this.assignmentGrade.get('graderType'), graders : this.graders }));
if (this.assignmentGrade.has('grader-type') && assignmentGrade.get('grader-type') != "Not Graded") { if (this.assignmentGrade.has('graderType') && this.assignmentGrade.get('graderType') != "Not Graded") {
this.$el.addClass('is-set'); this.$el.addClass('is-set');
} }
else { else {
...@@ -63,10 +66,12 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({ ...@@ -63,10 +66,12 @@ CMS.Views.OverviewAssignmentGrader = Backbone.View.extend({
}, },
selectGradeType : function(e) { selectGradeType : function(e) {
e.preventDefault(); e.preventDefault();
this.$el.toggleClass('is-active');
// 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 // 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) // 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.assignmentGrade.save('graderType', $(e.target).text());
this.render(); this.render();
} }
......
...@@ -16,15 +16,18 @@ ...@@ -16,15 +16,18 @@
<script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script> <script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script>
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script> <script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
<script src="${static.url('js/vendor/date.js')}"></script> <script src="${static.url('js/vendor/date.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/settings/course_grading_policy.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/course_relative.js')}"></script> <script type="text/javascript" src="${static.url('js/models/course_relative.js')}"></script>
<script type="text/javascript" src="${static.url('js/views/grader-select-view.js')}"></script>
<script type="text/javascript" src="${static.url('js/models/settings/course_grading_policy.js')}"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
// TODO figure out whether these should be in window or someplace else? // TODO figure out whether these should be in window or someplace else or whether they're only needed as local vars
// I believe that current (New Section/New Subsection) cause full page reloads which means these aren't needed globally
// but we really should change that behavior.
window.graderTypes = new CMS.Models.Settings.CourseGraderCollection(); window.graderTypes = new CMS.Models.Settings.CourseGraderCollection();
window.graderTypes.course_location = new CMS.Models.Location('${parent_location}');
window.graderTypes.reset(${course_graders|n}); window.graderTypes.reset(${course_graders|n});
window.graderTypes.course_location(new CMS.Models.Location('${parent_location}'));
$(".gradable-status").each(function(index, ele) { $(".gradable-status").each(function(index, ele) {
var gradeView = new CMS.Views.OverviewAssignmentGrader({ var gradeView = new CMS.Views.OverviewAssignmentGrader({
......
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