Commit e07c80e1 by Adam Palay

Internationalize "Not Graded" on front end (STUD-989)

change code-side "Not Graded" to "notgraded"
parent 78c85ea3
...@@ -312,7 +312,7 @@ class CourseGradingTest(CourseTestCase): ...@@ -312,7 +312,7 @@ class CourseGradingTest(CourseTestCase):
descriptor = get_modulestore(self.course.location).get_item(self.course.location) descriptor = get_modulestore(self.course.location).get_item(self.course.location)
section_grader_type = CourseGradingModel.get_section_grader_type(self.course_locator) section_grader_type = CourseGradingModel.get_section_grader_type(self.course_locator)
self.assertEqual('Not Graded', section_grader_type['graderType']) self.assertEqual('notgraded', section_grader_type['graderType'])
self.assertEqual(None, descriptor.format) self.assertEqual(None, descriptor.format)
self.assertEqual(False, descriptor.graded) self.assertEqual(False, descriptor.graded)
...@@ -325,12 +325,12 @@ class CourseGradingTest(CourseTestCase): ...@@ -325,12 +325,12 @@ class CourseGradingTest(CourseTestCase):
self.assertEqual('Homework', descriptor.format) self.assertEqual('Homework', descriptor.format)
self.assertEqual(True, descriptor.graded) self.assertEqual(True, descriptor.graded)
# Change the grader type back to Not Graded, which should also unmark the section as graded # Change the grader type back to notgraded, which should also unmark the section as graded
CourseGradingModel.update_section_grader_type(self.course, 'Not Graded') CourseGradingModel.update_section_grader_type(self.course, 'notgraded')
descriptor = get_modulestore(self.course.location).get_item(self.course.location) descriptor = get_modulestore(self.course.location).get_item(self.course.location)
section_grader_type = CourseGradingModel.get_section_grader_type(self.course_locator) section_grader_type = CourseGradingModel.get_section_grader_type(self.course_locator)
self.assertEqual('Not Graded', section_grader_type['graderType']) self.assertEqual('notgraded', section_grader_type['graderType'])
self.assertEqual(None, descriptor.format) self.assertEqual(None, descriptor.format)
self.assertEqual(False, descriptor.graded) self.assertEqual(False, descriptor.graded)
...@@ -406,10 +406,10 @@ class CourseGradingTest(CourseTestCase): ...@@ -406,10 +406,10 @@ class CourseGradingTest(CourseTestCase):
response = self.client.get_json(grade_type_url + '?fields=graderType') response = self.client.get_json(grade_type_url + '?fields=graderType')
self.assertEqual(json.loads(response.content).get('graderType'), u'Homework') self.assertEqual(json.loads(response.content).get('graderType'), u'Homework')
# and unset # and unset
response = self.client.ajax_post(grade_type_url, {'graderType': u'Not Graded'}) response = self.client.ajax_post(grade_type_url, {'graderType': u'notgraded'})
self.assertEqual(200, response.status_code) self.assertEqual(200, response.status_code)
response = self.client.get_json(grade_type_url + '?fields=graderType') response = self.client.get_json(grade_type_url + '?fields=graderType')
self.assertEqual(json.loads(response.content).get('graderType'), u'Not Graded') self.assertEqual(json.loads(response.content).get('graderType'), u'notgraded')
class CourseMetadataEditingTest(CourseTestCase): class CourseMetadataEditingTest(CourseTestCase):
......
...@@ -173,13 +173,13 @@ class CourseGradingModel(object): ...@@ -173,13 +173,13 @@ class CourseGradingModel(object):
old_location = loc_mapper().translate_locator_to_location(location) old_location = loc_mapper().translate_locator_to_location(location)
descriptor = get_modulestore(old_location).get_item(old_location) descriptor = get_modulestore(old_location).get_item(old_location)
return { return {
"graderType": descriptor.format if descriptor.format is not None else 'Not Graded', "graderType": descriptor.format if descriptor.format is not None else 'notgraded',
"location": unicode(location), "location": unicode(location),
} }
@staticmethod @staticmethod
def update_section_grader_type(descriptor, grader_type): def update_section_grader_type(descriptor, grader_type):
if grader_type is not None and grader_type != u"Not Graded": if grader_type is not None and grader_type != u'notgraded':
descriptor.format = grader_type descriptor.format = grader_type
descriptor.graded = True descriptor.graded = True
else: else:
......
define(["backbone", "underscore"], function(Backbone, _) { define(["backbone", "underscore"], function(Backbone, _) {
var AssignmentGrade = Backbone.Model.extend({ var AssignmentGrade = Backbone.Model.extend({
defaults : { defaults : {
graderType : null, // the type label (string). May be "Not Graded" which implies None. graderType : null, // the type label (string). May be "notgraded" which implies None.
locator : null // locator for the block locator : null // locator for the block
}, },
idAttribute: 'locator', idAttribute: 'locator',
......
define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grade", "js/views/feedback_notification"], define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grade", "js/views/feedback_notification"],
function(BaseView, _, gettext, AssignmentGrade, NotificationView) { function(BaseView, _, gettext, AssignmentGrade, NotificationView) {
var l10nNotGraded = gettext('Not Graded');
var OverviewAssignmentGrader = BaseView.extend({ var OverviewAssignmentGrader = BaseView.extend({
// instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> } // instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> }
events : { events : {
...@@ -18,7 +19,9 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad ...@@ -18,7 +19,9 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
'<% graders.each(function(option) { %>' + '<% graders.each(function(option) { %>' +
'<li><a <% if (option.get("type") == assignmentType) {%>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="#">' +
l10nNotGraded +
'</a></li>' +
'</ul>'); '</ul>');
this.assignmentGrade = new AssignmentGrade({ this.assignmentGrade = new AssignmentGrade({
locator : this.$el.closest('.id-holder').data('locator'), locator : this.$el.closest('.id-holder').data('locator'),
...@@ -36,9 +39,15 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad ...@@ -36,9 +39,15 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
this.render(); this.render();
}, },
render : function() { render : function() {
this.$el.html(this.template({ assignmentType : this.assignmentGrade.get('graderType'), graders : this.graders, var graderType = this.assignmentGrade.get('graderType');
hideSymbol : this.hideSymbol })); this.$el.html(this.template(
if (this.assignmentGrade.has('graderType') && this.assignmentGrade.get('graderType') != "Not Graded") { {
assignmentType : (graderType == 'notgraded') ? l10nNotGraded : graderType,
graders : this.graders,
hideSymbol : this.hideSymbol
}
));
if (this.assignmentGrade.has('graderType') && this.assignmentGrade.get('graderType') != "notgraded") {
this.$el.addClass('is-set'); this.$el.addClass('is-set');
} }
else { else {
...@@ -64,10 +73,10 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad ...@@ -64,10 +73,10 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
saving.show(); saving.show();
// 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 notgraded (NOTE, change template's if check for is-selected accordingly)
this.assignmentGrade.save( this.assignmentGrade.save(
'graderType', 'graderType',
$(e.target).text(), ($(e.target).hasClass('gradable-status-notgraded')) ? 'notgraded' : $(e.target).text(),
{success: function () { saving.hide(); }} {success: function () { saving.hide(); }}
); );
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<div class="row gradable"> <div class="row gradable">
<label>${_("Graded as:")}</label> <label>${_("Graded as:")}</label>
<div class="gradable-status" data-initial-status="${subsection.format if subsection.format is not None else _('Not Graded')}"> <div class="gradable-status" data-initial-status="${subsection.format if subsection.format is not None else 'notgraded'}">
</div> </div>
<div class="due-date-input row"> <div class="due-date-input row">
......
...@@ -228,7 +228,7 @@ require(["domReady!", "jquery", "js/models/location", "js/models/section", "js/v ...@@ -228,7 +228,7 @@ require(["domReady!", "jquery", "js/models/location", "js/models/section", "js/v
<ul class="actions-list"> <ul class="actions-list">
<li class="actions-item grades"> <li class="actions-item grades">
<div class="gradable-status" data-initial-status="${subsection.format if subsection.format is not None else _('Not Graded')}"></div> <div class="gradable-status" data-initial-status="${subsection.format if subsection.format is not None else 'notgraded'}"></div>
</li> </li>
<li class="actions-item delete"> <li class="actions-item delete">
<a href="#" data-tooltip="${_('Delete this subsection')}" class="action delete-subsection-button"><i class="icon-trash"></i> <span class="sr">${_("Delete subsection")}</span></a> <a href="#" data-tooltip="${_('Delete this subsection')}" class="action delete-subsection-button"><i class="icon-trash"></i> <span class="sr">${_("Delete subsection")}</span></a>
......
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