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

change code-side "Not Graded" to "notgraded"
This commit is contained in:
Adam Palay
2014-01-15 16:02:57 -05:00
parent 78c85ea3b2
commit e07c80e1e8
6 changed files with 26 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
define(["backbone", "underscore"], function(Backbone, _) {
var AssignmentGrade = Backbone.Model.extend({
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
},
idAttribute: 'locator',

View File

@@ -1,5 +1,6 @@
define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grade", "js/views/feedback_notification"],
function(BaseView, _, gettext, AssignmentGrade, NotificationView) {
var l10nNotGraded = gettext('Not Graded');
var OverviewAssignmentGrader = BaseView.extend({
// instantiate w/ { graders : CourseGraderCollection, el : <the gradable-status div> }
events : {
@@ -18,7 +19,9 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
'<% graders.each(function(option) { %>' +
'<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>');
this.assignmentGrade = new AssignmentGrade({
locator : this.$el.closest('.id-holder').data('locator'),
@@ -36,9 +39,15 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
this.render();
},
render : function() {
this.$el.html(this.template({ assignmentType : this.assignmentGrade.get('graderType'), graders : this.graders,
hideSymbol : this.hideSymbol }));
if (this.assignmentGrade.has('graderType') && this.assignmentGrade.get('graderType') != "Not Graded") {
var graderType = this.assignmentGrade.get('graderType');
this.$el.html(this.template(
{
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');
}
else {
@@ -64,10 +73,10 @@ define(["js/views/baseview", "underscore", "gettext", "js/models/assignment_grad
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
// 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(
'graderType',
$(e.target).text(),
($(e.target).hasClass('gradable-status-notgraded')) ? 'notgraded' : $(e.target).text(),
{success: function () { saving.hide(); }}
);