feat: add assignment type count warning (#32068)

* feat: add assignment type count warning

* style: quality
This commit is contained in:
Jansen Kantor
2023-04-14 12:26:29 -04:00
committed by GitHub
parent e973266b2f
commit de047cd6f9
8 changed files with 137 additions and 10 deletions

View File

@@ -2,7 +2,7 @@ define([
'jquery', 'js/views/settings/grading', 'js/models/settings/course_grading_policy'
], function($, GradingView, CourseGradingPolicyModel) {
'use strict';
return function(courseDetails, gradingUrl) {
return function(courseDetails, gradingUrl, courseAssignmentLists) {
var model, editor;
$('form :input')
@@ -17,7 +17,8 @@ define([
model.urlRoot = gradingUrl;
editor = new GradingView({
el: $('.settings-grading'),
model: model
model: model,
courseAssignmentLists: courseAssignmentLists
});
editor.render();
};

View File

@@ -7,7 +7,9 @@ define(['backbone', 'js/models/location', 'js/collections/course_grader', 'edx-u
graders: null, // CourseGraderCollection
grade_cutoffs: null, // CourseGradeCutoff model
grace_period: null, // either null or { hours: n, minutes: m, ...}
minimum_grade_credit: null // either null or percentage
minimum_grade_credit: null, // either null or percentage
assignment_count_info: [], // Object with keys mapping assignment type names to a list of
//assignment display names
},
parse: function(attributes) {
if (attributes.graders) {

View File

@@ -24,7 +24,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
'focus :input': 'inputFocus',
'blur :input': 'inputUnfocus'
},
initialize: function() {
initialize: function(options) {
// load template for grading view
var self = this;
this.template = HtmlUtils.template(
@@ -40,6 +40,7 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
this.model.get('graders').on('reset', this.render, this);
this.model.get('graders').on('add', this.render, this);
this.selectorToField = _.invert(this.fieldToSelectorMap);
this.courseAssignmentLists = options.courseAssignmentLists;
this.render();
},
@@ -73,10 +74,26 @@ function(ValidatingView, _, $, ui, GraderView, StringUtils, HtmlUtils) {
},
this);
gradeCollection.each(function(gradeModel) {
HtmlUtils.append(gradelist, self.template({model: gradeModel}));
var graderType = gradeModel.get('type');
var graderTypeAssignmentList = self.courseAssignmentLists[graderType]
if (graderTypeAssignmentList === undefined) {
graderTypeAssignmentList = [];
}
HtmlUtils.append(
gradelist,
self.template({
model: gradeModel,
assignmentList: graderTypeAssignmentList
})
);
var newEle = gradelist.children().last();
var newView = new GraderView({el: newEle,
model: gradeModel, collection: gradeCollection});
var newView = new GraderView({
el: newEle,
model: gradeModel,
collection: gradeCollection,
courseAssignmentCountInfo: self.courseAssignmentCountInfo,
});
// Listen in order to rerender when the 'cancel' button is
// pressed
self.listenTo(newView, 'revert', _.bind(self.render, self));