From 684be2382ec17d6c6c63c030e4c314cb768ecc8f Mon Sep 17 00:00:00 2001 From: SaadYousaf Date: Mon, 8 Jun 2020 08:25:50 +0500 Subject: [PATCH] PROD-1284 --- .../models/settings/course_grading_policy.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/cms/static/js/models/settings/course_grading_policy.js b/cms/static/js/models/settings/course_grading_policy.js index 5b2e7003d8..f954e5bf03 100644 --- a/cms/static/js/models/settings/course_grading_policy.js +++ b/cms/static/js/models/settings/course_grading_policy.js @@ -1,6 +1,7 @@ /* globals _ */ -define(['backbone', 'js/models/location', 'js/collections/course_grader'], - function(Backbone, Location, CourseGraderCollection) { +define(['backbone', 'js/models/location', 'js/collections/course_grader', 'edx-ui-toolkit/js/utils/string-utils'], + function(Backbone, Location, CourseGraderCollection, StringUtils) { + 'use strict'; var CourseGradingPolicy = Backbone.Model.extend({ defaults: { graders: null, // CourseGraderCollection @@ -37,9 +38,15 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'], }, gracePeriodToDate: function() { var newDate = new Date(); - if (this.has('grace_period') && this.get('grace_period').hours) { newDate.setHours(this.get('grace_period').hours); } else newDate.setHours(0); - if (this.has('grace_period') && this.get('grace_period').minutes) { newDate.setMinutes(this.get('grace_period').minutes); } else newDate.setMinutes(0); - if (this.has('grace_period') && this.get('grace_period').seconds) { newDate.setSeconds(this.get('grace_period').seconds); } else newDate.setSeconds(0); + if (this.has('grace_period') && this.get('grace_period').hours) { + newDate.setHours(this.get('grace_period').hours); + } else newDate.setHours(0); + if (this.has('grace_period') && this.get('grace_period').minutes) { + newDate.setMinutes(this.get('grace_period').minutes); + } else newDate.setMinutes(0); + if (this.has('grace_period') && this.get('grace_period').seconds) { + newDate.setSeconds(this.get('grace_period').seconds); + } else newDate.setSeconds(0); return newDate; }, @@ -62,6 +69,7 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'], return parseInt(minimum_grade_credit); }, validate: function(attrs) { + var minimumGradeCutoff; if (_.has(attrs, 'grace_period')) { if (attrs.grace_period === null) { return { @@ -71,12 +79,13 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader'], } if (this.get('is_credit_course') && _.has(attrs, 'minimum_grade_credit')) { // Getting minimum grade cutoff value - var minimum_grade_cutoff = _.min(_.values(attrs.grade_cutoffs)); - if (isNaN(attrs.minimum_grade_credit) || attrs.minimum_grade_credit === null || attrs.minimum_grade_credit < minimum_grade_cutoff) { + minimumGradeCutoff = _.min(_.values(attrs.grade_cutoffs)); + if (isNaN(attrs.minimum_grade_credit) || attrs.minimum_grade_credit === null || + attrs.minimum_grade_credit < minimumGradeCutoff) { return { - minimum_grade_credit: interpolate( + minimum_grade_credit: StringUtils.interpolate( gettext('Not able to set passing grade to less than %(minimum_grade_cutoff)s%.'), - {minimum_grade_cutoff: minimum_grade_cutoff * 100}, + {minimum_grade_cutoff: minimumGradeCutoff * 100}, true ) };