show credit eligibility requirements in studio
ECOM-1591
This commit is contained in:
@@ -2,7 +2,7 @@ define([
|
||||
'jquery', 'js/models/settings/course_details', 'js/views/settings/main'
|
||||
], function($, CourseDetailsModel, MainView) {
|
||||
'use strict';
|
||||
return function (detailsUrl) {
|
||||
return function (detailsUrl, showMinGradeWarning) {
|
||||
var model;
|
||||
// highlighting labels when fields are focused in
|
||||
$('form :input')
|
||||
@@ -19,7 +19,8 @@ define([
|
||||
success: function(model) {
|
||||
var editor = new MainView({
|
||||
el: $('.settings-details'),
|
||||
model: model
|
||||
model: model,
|
||||
showMinGradeWarning: showMinGradeWarning
|
||||
});
|
||||
editor.render();
|
||||
},
|
||||
|
||||
@@ -5,7 +5,8 @@ var CourseGradingPolicy = Backbone.Model.extend({
|
||||
defaults : {
|
||||
graders : null, // CourseGraderCollection
|
||||
grade_cutoffs : null, // CourseGradeCutoff model
|
||||
grace_period : null // either null or { hours: n, minutes: m, ...}
|
||||
grace_period : null, // either null or { hours: n, minutes: m, ...}
|
||||
minimum_grade_credit : null // either null or percentage
|
||||
},
|
||||
parse: function(attributes) {
|
||||
if (attributes['graders']) {
|
||||
@@ -28,6 +29,11 @@ var CourseGradingPolicy = Backbone.Model.extend({
|
||||
minutes: 0
|
||||
}
|
||||
}
|
||||
// If minimum_grade_credit is unset or equal to 0 on the server,
|
||||
// it's received as 0
|
||||
if (attributes.minimum_grade_credit === null) {
|
||||
attributes.minimum_grade_credit = 0;
|
||||
}
|
||||
return attributes;
|
||||
},
|
||||
gracePeriodToDate : function() {
|
||||
@@ -55,6 +61,13 @@ var CourseGradingPolicy = Backbone.Model.extend({
|
||||
minutes: parseInt(pieces[1], 10)
|
||||
}
|
||||
},
|
||||
parseMinimumGradeCredit : function(minimum_grade_credit) {
|
||||
// get the value of minimum grade credit value in percentage
|
||||
if (isNaN(minimum_grade_credit)) {
|
||||
return 0;
|
||||
}
|
||||
return parseInt(minimum_grade_credit);
|
||||
},
|
||||
validate : function(attrs) {
|
||||
if(_.has(attrs, 'grace_period')) {
|
||||
if(attrs['grace_period'] === null) {
|
||||
@@ -63,6 +76,18 @@ var CourseGradingPolicy = Backbone.Model.extend({
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_.has(attrs, 'minimum_grade_credit')) {
|
||||
var minimum_grade_cutoff = _.values(attrs.grade_cutoffs).pop();
|
||||
if(isNaN(attrs.minimum_grade_credit) || attrs.minimum_grade_credit === null || attrs.minimum_grade_credit < minimum_grade_cutoff) {
|
||||
return {
|
||||
'minimum_grade_credit': interpolate(
|
||||
gettext('Not able to set passing grade to less than %(minimum_grade_cutoff)s%.'),
|
||||
{minimum_grade_cutoff: minimum_grade_cutoff * 100},
|
||||
true
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ var GradingView = ValidatingView.extend({
|
||||
this.clearValidationErrors();
|
||||
|
||||
this.renderGracePeriod();
|
||||
this.renderMinimumGradeCredit();
|
||||
|
||||
// Create and render the grading type subs
|
||||
var self = this;
|
||||
@@ -86,7 +87,8 @@ var GradingView = ValidatingView.extend({
|
||||
this.model.get('graders').push({});
|
||||
},
|
||||
fieldToSelectorMap : {
|
||||
'grace_period' : 'course-grading-graceperiod'
|
||||
'grace_period' : 'course-grading-graceperiod',
|
||||
'minimum_grade_credit' : 'course-minimum_grade_credit'
|
||||
},
|
||||
renderGracePeriod: function() {
|
||||
var format = function(time) {
|
||||
@@ -97,11 +99,23 @@ var GradingView = ValidatingView.extend({
|
||||
format(grace_period.hours) + ':' + format(grace_period.minutes)
|
||||
);
|
||||
},
|
||||
renderMinimumGradeCredit: function() {
|
||||
var minimum_grade_credit = this.model.get('minimum_grade_credit');
|
||||
this.$el.find('#course-minimum_grade_credit').val(
|
||||
parseFloat(minimum_grade_credit) * 100 + '%'
|
||||
);
|
||||
},
|
||||
setGracePeriod : function(event) {
|
||||
this.clearValidationErrors();
|
||||
var newVal = this.model.parseGracePeriod($(event.currentTarget).val());
|
||||
this.model.set('grace_period', newVal, {validate: true});
|
||||
},
|
||||
setMinimumGradeCredit : function(event) {
|
||||
this.clearValidationErrors();
|
||||
// get field value in float
|
||||
var newVal = this.model.parseMinimumGradeCredit($(event.currentTarget).val()) / 100;
|
||||
this.model.set('minimum_grade_credit', newVal, {validate: true});
|
||||
},
|
||||
updateModel : function(event) {
|
||||
if (!this.selectorToField[event.currentTarget.id]) return;
|
||||
|
||||
@@ -110,6 +124,10 @@ var GradingView = ValidatingView.extend({
|
||||
this.setGracePeriod(event);
|
||||
break;
|
||||
|
||||
case 'minimum_grade_credit':
|
||||
this.setMinimumGradeCredit(event);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.setField(event);
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
define(["js/views/validation", "codemirror", "underscore", "jquery", "jquery.ui", "js/utils/date_utils", "js/models/uploads",
|
||||
"js/views/uploads", "js/utils/change_on_enter", "js/views/license", "js/models/license", "jquery.timepicker", "date"],
|
||||
"js/views/uploads", "js/utils/change_on_enter", "js/views/license", "js/models/license",
|
||||
"js/views/feedback_notification", "jquery.timepicker", "date"],
|
||||
function(ValidatingView, CodeMirror, _, $, ui, DateUtils, FileUploadModel,
|
||||
FileUploadDialog, TriggerChangeEventOnEnter, LicenseView, LicenseModel) {
|
||||
FileUploadDialog, TriggerChangeEventOnEnter, LicenseView, LicenseModel, NotificationView) {
|
||||
|
||||
var DetailsView = ValidatingView.extend({
|
||||
// Model class is CMS.Models.Settings.CourseDetails
|
||||
@@ -21,7 +22,8 @@ var DetailsView = ValidatingView.extend({
|
||||
'click .action-upload-image': "uploadImage"
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
initialize : function(options) {
|
||||
options = options || {};
|
||||
this.fileAnchorTemplate = _.template('<a href="<%= fullpath %>"> <i class="icon fa fa-file"></i><%= filename %></a>');
|
||||
// fill in fields
|
||||
this.$el.find("#course-language").val(this.model.get('language'));
|
||||
@@ -49,6 +51,14 @@ var DetailsView = ValidatingView.extend({
|
||||
showPreview: true
|
||||
});
|
||||
this.listenTo(this.licenseModel, 'change', this.handleLicenseChange);
|
||||
|
||||
if (options.showMinGradeWarning || false) {
|
||||
new NotificationView.Warning({
|
||||
title: gettext("Credit Eligibility Requirements"),
|
||||
message: gettext("Minimum passing grade for credit is not set."),
|
||||
closeIcon: true
|
||||
}).show();
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
||||
@@ -326,6 +326,24 @@
|
||||
width: flex-grid(5, 9);
|
||||
}
|
||||
|
||||
// Credit eligibility requirements
|
||||
#credit-minimum-passing-grade {
|
||||
float: left;
|
||||
width: flex-grid(3, 9);
|
||||
margin-right: flex-gutter();
|
||||
}
|
||||
|
||||
#credit-proctoring-requirements {
|
||||
float: left;
|
||||
width: flex-grid(3, 9);
|
||||
margin-right: flex-gutter();
|
||||
}
|
||||
|
||||
#credit-reverification-requirements {
|
||||
float: left;
|
||||
width: flex-grid(3, 9);
|
||||
}
|
||||
|
||||
// course link note
|
||||
.note-promotion-courseURL {
|
||||
box-shadow: 0 2px 1px $shadow-l1;
|
||||
@@ -731,6 +749,11 @@
|
||||
#field-course-grading-graceperiod {
|
||||
width: flex-grid(3, 9);
|
||||
}
|
||||
|
||||
#field-course-minimum_grade_credit {
|
||||
width: flex-grid(4, 9);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&.assignment-types {
|
||||
@@ -985,4 +1008,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user