Commit 808b3feb by Andy Armstrong

Merge pull request #741 from edx/andya/add-jshint

Run JSHint as part of the build
parents 4b3f6d66 d2322a7d
......@@ -22,10 +22,10 @@
"nonbsp" : true, // Warns about "non-breaking whitespace" characters.
"nonew" : false, // Prohibits the use of constructor functions for side-effects.
"plusplus" : false, // Prohibits the use of unary increment and decrement operators.
"quotmark" : "single", // Enforces the consistency of quotation marks used throughout your code. It accepts three values: true, "single", and "double".
"quotmark" : false, // Enforces the consistency of quotation marks used throughout your code. It accepts three values: true, "single", and "double".
"undef" : true, // Prohibits the use of explicitly undeclared variables.
"unused" : true, // Warns when you define and never use your variables.
"strict" : true, // Requires all functions to run in ECMAScript 5's strict mode.
"strict" : false, // Requires all functions to run in ECMAScript 5's strict mode.
"trailing" : true, // Makes it an error to leave a trailing whitespace in your code.
"maxlen" : 120, // Lets you set the maximum length of a line.
//"maxparams" : 4, // Lets you set the max number of formal parameters allowed per function.
......@@ -141,6 +141,17 @@
"readFixtures",
"setFixtures",
"appendSetFixtures",
"spyOnEvent"
"spyOnEvent",
// MathJax
"MathJax",
// Miscellaneous
"Logger",
"gettext",
"ngettext",
// ORA-specific globals
"OpenAssessment"
]
}
\ No newline at end of file
}
......@@ -46,8 +46,17 @@ install-dev:
install: install-wheels install-python install-js install-nltk-data install-test install-dev javascript
test:
quality:
jshint openassessment/xblock/static/js/src -c .jshintrc --verbose
test: quality
./scripts/test.sh
test-js:
./scripts/test-js.sh
test-js-debug:
./scripts/js-debugger.sh
sass:
./scripts/sass.sh
......@@ -108,16 +108,16 @@ OpenAssessment.BaseView.prototype = {
toggleActionError: function(type, msg) {
var element = this.element;
var container = null;
if (type == 'save') {
if (type === 'save') {
container = '.response__submission__actions';
}
else if (type == 'submit' || type == 'peer' || type == 'self' || type == 'student-training') {
else if (type === 'submit' || type === 'peer' || type === 'self' || type === 'student-training') {
container = '.step__actions';
}
else if (type == 'feedback_assess') {
else if (type === 'feedback_assess') {
container = '.submission__feedback__actions';
}
else if (type == 'upload') {
else if (type === 'upload') {
container = '#upload__error';
}
......@@ -150,6 +150,7 @@ OpenAssessment.BaseView.prototype = {
};
/* XBlock JavaScript entry point for OpenAssessmentXBlock. */
/* jshint unused:false */
function OpenAssessmentBlock(runtime, element) {
/**
Render views within the base view on page load.
......
......@@ -26,7 +26,7 @@ OpenAssessment.FileUploader = function() {
processData: false,
contentType: file.type,
}).done(
function(data, textStatus, jqXHR) {
function() {
// Log an analytics event
Logger.log(
"openassessment.upload_file",
......@@ -41,7 +41,7 @@ OpenAssessment.FileUploader = function() {
defer.resolve();
}
).fail(
function(data, textStatus, jqXHR) {
function(data, textStatus) {
defer.rejectWith(this, [textStatus]);
}
);
......
......@@ -98,7 +98,7 @@ OpenAssessment.GradeView.prototype = {
if (typeof options === 'undefined') {
return $.map(
$('.feedback__overall__value:checked', view.element),
function(element, index) { return $(element).val(); }
function(element) { return $(element).val(); }
);
} else {
// Uncheck all the options
......@@ -136,7 +136,7 @@ OpenAssessment.GradeView.prototype = {
boolean
**/
isHidden: function(sel) {
return sel.hasClass('is--hidden') && sel.attr('aria-hidden') == 'true';
return sel.hasClass('is--hidden') && sel.attr('aria-hidden') === 'true';
},
/**
......@@ -199,7 +199,7 @@ OpenAssessment.GradeView.prototype = {
}
else {
if (newState == 'open') {
if (newState === 'open') {
containerSel.toggleClass('is--transitioning', false);
containerSel.toggleClass('is--submitting', false);
containerSel.toggleClass('is--submitted', false);
......@@ -210,7 +210,7 @@ OpenAssessment.GradeView.prototype = {
this.setHidden(messageSel, true);
}
else if (newState == 'submitting') {
else if (newState === 'submitting') {
containerSel.toggleClass('is--transitioning', true);
containerSel.toggleClass('is--submitting', true);
containerSel.toggleClass('is--submitted', false);
......@@ -221,7 +221,7 @@ OpenAssessment.GradeView.prototype = {
this.setHidden(messageSel, true);
}
else if (newState == 'submitted') {
else if (newState === 'submitted') {
containerSel.toggleClass('is--transitioning', false);
containerSel.toggleClass('is--submitting', false);
containerSel.toggleClass('is--submitted', true);
......
......@@ -32,4 +32,4 @@ OpenAssessment.MessageView.prototype = {
baseView.showLoadError('message', errMsg);
});
}
}
\ No newline at end of file
};
......@@ -31,7 +31,7 @@ OpenAssessment.PeerView.prototype = {
view.server.renderLatex($('#openassessment__peer-assessment', view.element));
view.installHandlers(false);
}
).fail(function(errMsg) {
).fail(function() {
view.baseView.showLoadError('peer-assessment');
});
// Called to update Messagview with info on whether or not it was able to grab a submission
......@@ -55,7 +55,7 @@ OpenAssessment.PeerView.prototype = {
view.server.renderLatex($('#openassessment__peer-assessment', view.element));
view.installHandlers(true);
}
).fail(function(errMsg) {
).fail(function() {
view.baseView.showLoadError('peer-assessment');
view.continueAssessmentEnabled(true);
});
......@@ -208,7 +208,5 @@ OpenAssessment.PeerView.prototype = {
view.baseView.toggleActionError('peer', errMsg);
view.peerSubmitEnabled(true);
});
},
}
};
......@@ -48,7 +48,7 @@ OpenAssessment.ResponseView.prototype = {
view.installHandlers();
view.setAutoSaveEnabled(true);
}
).fail(function(errMsg) {
).fail(function() {
view.baseView.showLoadError('response');
});
},
......@@ -65,7 +65,7 @@ OpenAssessment.ResponseView.prototype = {
// Install change handler for textarea (to enable submission button)
this.savedResponse = this.response();
var handleChange = function(eventData) { view.handleResponseChanged(); };
var handleChange = function() { view.handleResponseChanged(); };
sel.find('.submission__answer__part__text__value').on('change keyup drop paste', handleChange);
var handlePrepareUpload = function(eventData) { view.prepareUpload(eventData.target.files); };
......@@ -248,6 +248,7 @@ OpenAssessment.ResponseView.prototype = {
if (enabled) {
window.onbeforeunload = function() {
// Keep this on one big line to avoid gettext bug: http://stackoverflow.com/a/24579117
/* jshint maxlen:300 */
return gettext("If you leave this page without saving or submitting your response, you'll lose any work you've done on the response.");
};
}
......@@ -274,9 +275,9 @@ OpenAssessment.ResponseView.prototype = {
return $.trim($(this).val());
}).get();
} else {
sel.map(function(index, element) {
sel.map(function(index) {
$(this).val(texts[index]);
})
});
}
},
......@@ -287,7 +288,7 @@ OpenAssessment.ResponseView.prototype = {
**/
responseChanged: function() {
var savedResponse = this.savedResponse;
return this.response().some(function(element, index, array) {
return this.response().some(function(element, index) {
return element !== savedResponse[index];
});
......@@ -320,8 +321,8 @@ OpenAssessment.ResponseView.prototype = {
**/
handleResponseChanged: function() {
// Enable the save/submit button only for non-blank responses
var isNotBlank = !this.response().every(function(element, index, array) {
return $.trim(element) == '';
var isNotBlank = !this.response().every(function(element) {
return $.trim(element) === '';
});
this.submitEnabled(isNotBlank);
......@@ -363,12 +364,12 @@ OpenAssessment.ResponseView.prototype = {
// ... but update the UI based on what the user may have entered
// since hitting the save button.
var currentResponse = view.response();
var currentResponseIsEmpty = currentResponse.every(function(element, index, array) {
return element == '';
var currentResponseIsEmpty = currentResponse.every(function(element) {
return element === '';
});
view.submitEnabled(!currentResponseIsEmpty);
var currentResponseEqualsSaved = currentResponse.every(function(element, index, array) {
var currentResponseEqualsSaved = currentResponse.every(function(element, index) {
return element === savedResponse[index];
});
if (currentResponseEqualsSaved) {
......@@ -418,7 +419,7 @@ OpenAssessment.ResponseView.prototype = {
// If the error is "multiple submissions", then we should move to the next
// step. Otherwise, the user will be stuck on the current step with no
// way to continue.
if (errCode == 'ENOMULTI') { view.moveToNextStep(); }
if (errCode === 'ENOMULTI') { view.moveToNextStep(); }
else {
// If there is an error message, display it
if (errMsg) { baseView.toggleActionError('submit', errMsg); }
......@@ -451,6 +452,7 @@ OpenAssessment.ResponseView.prototype = {
**/
confirmSubmission: function() {
// Keep this on one big line to avoid gettext bug: http://stackoverflow.com/a/24579117
/* jshint maxlen:300 */
var msg = gettext("You're about to submit your response for this assignment. After you submit this response, you can't change it or submit a new response.");
// TODO -- UI for confirmation dialog instead of JS confirm
return $.Deferred(function(defer) {
......@@ -477,7 +479,7 @@ OpenAssessment.ResponseView.prototype = {
this.baseView.toggleActionError(
'upload', gettext("File size must be 5MB or less.")
);
} else if (this.imageType.substring(0,6) != 'image/') {
} else if (this.imageType.substring(0,6) !== 'image/') {
this.baseView.toggleActionError(
'upload', gettext("File must be an image.")
);
......
......@@ -105,7 +105,7 @@ OpenAssessment.Rubric.prototype = {
// Check the selected options
$(selector, this.element).each(function(index, sel) {
if (optionsSelected.hasOwnProperty(sel.name)) {
if (sel.value == optionsSelected[sel.name]) {
if (sel.value === optionsSelected[sel.name]) {
$(sel).prop('checked', true);
}
}
......@@ -153,7 +153,7 @@ OpenAssessment.Rubric.prototype = {
}
});
return (numChecked == numAvailable && completedRequiredComments);
return (numChecked === numAvailable && completedRequiredComments);
},
/**
......
......@@ -31,7 +31,7 @@ OpenAssessment.SelfView.prototype = {
view.server.renderLatex($('#openassessment__self-assessment', view.element));
view.installHandlers();
}
).fail(function(errMsg) {
).fail(function() {
view.showLoadError('self-assessment');
});
},
......
......@@ -35,7 +35,7 @@ OpenAssessment.StaffInfoView.prototype = {
view.server.renderLatex($('#openassessment__staff-info', view.element));
view.installHandlers();
}
).fail(function(errMsg) {
).fail(function() {
view.baseView.showLoadError('staff_info');
});
}
......@@ -56,7 +56,7 @@ OpenAssessment.StaffInfoView.prototype = {
$('#openassessment__student-info', view.element).replaceWith(html);
// Install key handler for new staff grade Save button.
var selCancelSub = $('#openassessment__staff-info__cancel__submission', this.element);
var selCancelSub = $('#openassessment__staff-info__cancel__submission', view.element);
selCancelSub.on('click', '#submit_cancel_submission', function (eventObject) {
eventObject.preventDefault();
view.cancelSubmission($(this).data('submission-uuid'));
......@@ -64,11 +64,12 @@ OpenAssessment.StaffInfoView.prototype = {
);
// Install change handler for textarea (to enable cancel submission button)
var handleChange = function(eventData) { view.handleCommentChanged(); };
selCancelSub.find('#staff-info__cancel-submission__comments').on('change keyup drop paste', handleChange);
var handleChange = function() { view.handleCommentChanged(); };
selCancelSub.find('#staff-info__cancel-submission__comments')
.on('change keyup drop paste', handleChange);
}
).fail(function(errMsg) {
).fail(function() {
view.showLoadError('student_info');
});
},
......@@ -130,10 +131,10 @@ OpenAssessment.StaffInfoView.prototype = {
var view = this;
this.server.scheduleTraining().done(
function(msg) {
$('#schedule_training_message', this.element).text(msg)
$('#schedule_training_message', view.element).text(msg);
}
).fail(function(errMsg) {
$('#schedule_training_message', this.element).text(errMsg)
$('#schedule_training_message', view.element).text(errMsg);
});
},
......@@ -147,10 +148,10 @@ OpenAssessment.StaffInfoView.prototype = {
var view = this;
this.server.rescheduleUnfinishedTasks().done(
function(msg) {
$('#reschedule_unfinished_tasks_message', this.element).text(msg)
$('#reschedule_unfinished_tasks_message', view.element).text(msg);
}
).fail(function(errMsg) {
$('#reschedule_unfinished_tasks_message', this.element).text(errMsg)
$('#reschedule_unfinished_tasks_message', view.element).text(errMsg);
});
},
......
......@@ -31,7 +31,7 @@ OpenAssessment.StudentTrainingView.prototype = {
view.server.renderLatex($('#openassessment__student-training', view.element));
view.installHandlers();
}
).fail(function(errMsg) {
).fail(function() {
view.baseView.showLoadError('student-training');
});
},
......@@ -85,8 +85,8 @@ OpenAssessment.StudentTrainingView.prototype = {
var baseView = this.baseView;
this.server.trainingAssess(options).done(
function(corrections) {
var incorrect = $("#openassessment__student-training--incorrect", this.element);
var instructions = $("#openassessment__student-training--instructions", this.element);
var incorrect = $("#openassessment__student-training--incorrect", view.element);
var instructions = $("#openassessment__student-training--instructions", view.element);
if (!view.rubric.showCorrections(corrections)) {
view.load();
......
......@@ -4,7 +4,7 @@ Encapsulate interactions with OpenAssessment XBlock handlers.
// Since the server is included by both LMS and Studio views,
// skip loading it the second time.
if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
if (typeof OpenAssessment.Server === "undefined" || !OpenAssessment.Server) {
/**
Interface for server-side XBlock handlers.
......@@ -56,7 +56,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
)
**/
render: function(component) {
var that = this;
var view = this;
var url = this.url('render_' + component);
return $.Deferred(function(defer) {
$.ajax({
......@@ -64,9 +64,9 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
type: "POST",
dataType: "html"
}).done(function(data) {
defer.resolveWith(this, [data]);
}).fail(function(data) {
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
defer.resolveWith(view, [data]);
}).fail(function() {
defer.rejectWith(view, [gettext('This section could not be loaded.')]);
});
}).promise();
},
......@@ -108,9 +108,9 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
dataType: "html",
data: {continue_grading: true}
}).done(function(data) {
defer.resolveWith(this, [data]);
}).fail(function(data) {
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
defer.resolveWith(view, [data]);
}).fail(function() {
defer.rejectWith(view, [gettext('This section could not be loaded.')]);
});
}).promise();
},
......@@ -128,7 +128,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
data: {student_username: student_username}
}).done(function(data) {
defer.resolveWith(this, [data]);
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext('This section could not be loaded.')]);
});
}).promise();
......@@ -164,7 +164,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
var errorMsg = data[2];
defer.rejectWith(this, [errorNum, errorMsg]);
}
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, ["AJAX", gettext("This response could not be submitted.")]);
});
}).promise();
......@@ -191,7 +191,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
}).done(function(data) {
if (data.success) { defer.resolve(); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext("This response could not be saved.")]);
});
}).promise();
......@@ -228,7 +228,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
if (data.success) { defer.resolve(); }
else { defer.rejectWith(this, [data.msg]); }
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('This feedback could not be submitted.')]);
});
}).promise();
......@@ -275,7 +275,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
}).promise();
......@@ -319,7 +319,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
});
......@@ -360,7 +360,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
});
......@@ -394,7 +394,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('This assessment could not be submitted.')]);
});
});
......@@ -418,7 +418,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('One or more rescheduling tasks failed.')]);
});
});
......@@ -467,7 +467,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
}).done(function(data) {
if (data.success) { defer.resolve(); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext('This problem could not be saved.')]);
});
}).promise();
......@@ -497,7 +497,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
}).done(function(data) {
if (data.success) { defer.resolveWith(this, [data.is_released]); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext("The server could not be contacted.")]);
});
}).promise();
......@@ -519,11 +519,14 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
var url = this.url('upload_url');
return $.Deferred(function(defer) {
$.ajax({
type: "POST", url: url, data: JSON.stringify({contentType: contentType}), contentType: jsonContentType
type: "POST",
url: url,
data: JSON.stringify({contentType: contentType}),
contentType: jsonContentType
}).done(function(data) {
if (data.success) { defer.resolve(data.url); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext('Could not retrieve upload url.')]);
});
}).promise();
......@@ -544,7 +547,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
}).done(function(data) {
if (data.success) { defer.resolve(data.url); }
else { defer.rejectWith(this, [data.msg]); }
}).fail(function(data) {
}).fail(function() {
defer.rejectWith(this, [gettext('Could not retrieve download url.')]);
});
}).promise();
......@@ -572,7 +575,7 @@ if (typeof OpenAssessment.Server == "undefined" || !OpenAssessment.Server) {
defer.rejectWith(this, [data.msg]);
}
}
).fail(function(data) {
).fail(function() {
defer.rejectWith(this, [gettext('The submission could not be removed from the grading pool.')]);
});
}).promise();
......
......@@ -8,9 +8,11 @@ an object!
/* Namespace for open assessment */
/* jshint ignore:start */
if (typeof OpenAssessment == "undefined" || !OpenAssessment) {
OpenAssessment = {};
}
/* jshint ignore:end */
// Stub gettext if the runtime doesn't provide it
......@@ -27,14 +29,14 @@ if (typeof window.ngetgext === 'undefined') {
} else {
return singular_text;
}
}
};
}
// Stub event logging if the runtime doesn't provide it
if (typeof window.Logger === 'undefined') {
window.Logger = {
log: function(event_type, data, kwargs) {}
log: function() {}
};
}
......@@ -43,8 +45,8 @@ if (typeof window.Logger === 'undefined') {
if (typeof window.MathJax === 'undefined') {
window.MathJax = {
Hub: {
Typeset: function(data){},
Queue: function(list){}
Typeset: function() {},
Queue: function() {}
}
};
}
\ No newline at end of file
......@@ -58,21 +58,21 @@ Kwargs:
notifier (OpenAssessment.Notifier): Used to send notifications of updates to container items.
**/
OpenAssessment.Container = function(containerItem, kwargs) {
OpenAssessment.Container = function(ContainerItem, kwargs) {
this.containerElement = kwargs.containerElement;
this.templateElement = kwargs.templateElement;
this.addButtonElement = kwargs.addButtonElement;
this.removeButtonClass = kwargs.removeButtonClass;
this.containerItemClass = kwargs.containerItemClass;
this.notifier = kwargs.notifier;
this.addRemoveEnabled = (typeof kwargs.addRemoveEnabled == 'undefined') || kwargs.addRemoveEnabled;
this.addRemoveEnabled = (typeof kwargs.addRemoveEnabled === 'undefined') || kwargs.addRemoveEnabled;
// Since every container item should be instantiated with
// the notifier we were given, create a helper method
// that does this automatically.
var container = this;
this.createContainerItem = function(element) {
return new containerItem(element, container.notifier);
return new ContainerItem(element, container.notifier);
};
};
......
......@@ -613,7 +613,7 @@ OpenAssessment.RubricCriterion.prototype = {
OpenAssessment.TrainingExample = function(element){
this.element = element;
this.criteria = $(".openassessment_training_example_criterion_option", this.element);
this.answer = $('.openassessment_training_example_essay_part textarea', this.element)
this.answer = $('.openassessment_training_example_essay_part textarea', this.element);
};
OpenAssessment.TrainingExample.prototype = {
......
......@@ -273,11 +273,12 @@ OpenAssessment.StudioView.prototype = {
/* XBlock entry point for Studio view */
/* jshint unused:false */
function OpenAssessmentEditor(runtime, element) {
/**
Initialize the editing interface on page load.
**/
var server = new OpenAssessment.Server(runtime, element);
var view = new OpenAssessment.StudioView(runtime, element, server);
new OpenAssessment.StudioView(runtime, element, server);
}
......@@ -136,7 +136,7 @@ OpenAssessment.ToggleControl.prototype = {
Returns:
OpenAssessment.ToggleControl
**/
install: function(checkboxSelector) {
install: function() {
this.checkbox.change(
this, function(event) {
var control = event.data;
......
......@@ -12,9 +12,9 @@ OpenAssessment.StudentTrainingListener.prototype = {
/**
Add a answer part in the training examples when a prompt is added.
*/
promptAdd: function(data) {
promptAdd: function() {
var view = this.element;
var essay_part = $("#openassessment_training_example_part_template")
$("#openassessment_training_example_part_template")
.children().first()
.clone()
.removeAttr('id')
......@@ -93,6 +93,7 @@ OpenAssessment.StudentTrainingListener.prototype = {
});
if (criterionAdded) {
/* jshint maxlen:300 */
this.displayAlertMsg(
gettext("Criterion Added"),
gettext("You've added a criterion. You'll need to select an option for the criterion in the Student Training step. To do this, click the Settings tab.")
......@@ -133,13 +134,14 @@ OpenAssessment.StudentTrainingListener.prototype = {
// If all options have been removed from the Criterion, remove
// the criterion entirely.
if ($("option", criterionOption).length == 1) {
if ($("option", criterionOption).length === 1) {
handler.removeAllOptions(data);
invalidated = false;
}
});
if (invalidated) {
/* jshint maxlen:300 */
this.displayAlertMsg(
gettext("Option Deleted"),
gettext("You've deleted an option. The system has removed that option from its criterion in the sample responses in the Student Training step. You may have to select a new option for the criterion.")
......@@ -148,7 +150,10 @@ OpenAssessment.StudentTrainingListener.prototype = {
},
_optionSel: function(criterionName) {
return $('.openassessment_training_example_criterion_option[data-criterion="' + criterionName + '"]', this.element);
return $(
'.openassessment_training_example_criterion_option[data-criterion="' + criterionName + '"]',
this.element
);
},
/**
......@@ -165,13 +170,14 @@ OpenAssessment.StudentTrainingListener.prototype = {
var changed = false;
$('.openassessment_training_example_criterion', this.element).each(function() {
var criterion = this;
if ($(criterion).data('criterion') == data.criterionName) {
if ($(criterion).data('criterion') === data.criterionName) {
$(criterion).remove();
changed = true;
}
});
if (changed) {
/* jshint maxlen:300 */
this.displayAlertMsg(
gettext("Option Deleted"),
gettext("You've deleted all the options for this criterion. The system has removed the criterion from the sample responses in the Student Training step.")
......@@ -199,6 +205,7 @@ OpenAssessment.StudentTrainingListener.prototype = {
);
if (changed) {
/* jshint maxlen:300 */
this.displayAlertMsg(
gettext("Criterion Deleted"),
gettext("You've deleted a criterion. The system has removed the criterion from the sample responses in the Student Training step.")
......@@ -369,14 +376,14 @@ OpenAssessment.AssessmentToggleListener = function() {
};
OpenAssessment.AssessmentToggleListener.prototype = {
toggleOff: function(data) {
toggleOff: function() {
this.alert.setMessage(
gettext("Warning"),
gettext("Changes to steps that are not selected as part of the assignment will not be saved.")
).show();
},
toggleOn: function(data) {
toggleOn: function() {
this.alert.hide();
}
};
......@@ -11,7 +11,7 @@ Returns:
OpenAssessment.EditPromptsView = function(element, notifier) {
this.element = element;
this.editorElement = $(this.element).closest("#openassessment-editor");
this.addRemoveEnabled = !(this.editorElement.attr('data-is-released') === 'true');
this.addRemoveEnabled = this.editorElement.attr('data-is-released') !== 'true';
this.promptsContainer = new OpenAssessment.Container(
OpenAssessment.Prompt, {
......
......@@ -65,7 +65,7 @@ OpenAssessment.EditSettingsView.prototype = {
.sortable('refresh').sortable('refreshPositions');
},
// On stop, we redisplay the divs to their original state
stop: function(event, ui){
stop: function() {
$('.openassessment_assessment_module_editor', view.element).show();
},
snap: true,
......@@ -134,10 +134,10 @@ OpenAssessment.EditSettingsView.prototype = {
imageSubmissionEnabled: function(isEnabled) {
var sel = $("#openassessment_submission_image_editor", this.settingsElement);
if (isEnabled !== undefined) {
if (isEnabled) { sel.val(1); }
else { sel.val(0); }
if (isEnabled) { sel.val("1"); }
else { sel.val("0"); }
}
return (sel.val() == 1);
return sel.val() === "1";
},
/**
......@@ -154,10 +154,10 @@ OpenAssessment.EditSettingsView.prototype = {
if (isEnabled) {
sel.val(1);
} else {
sel.val(0)
sel.val(0);
}
}
return (sel.val() == 1);
return sel.val() === 1;
},
/**
Get or set the number of scores to show in the leaderboard.
......@@ -212,7 +212,7 @@ OpenAssessment.EditSettingsView.prototype = {
var asmntView = view.assessmentViews[$(this).attr('id')];
if (asmntView.isEnabled()) {
var description = asmntView.description();
description["name"] = asmntView.name;
description.name = asmntView.name;
assessmentDescList.push(description);
}
}
......
......@@ -9,7 +9,8 @@
"karma-jasmine": "0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"karma-spec-reporter": "^0.0.20",
"uglify-js": "2.3.6"
"uglify-js": "2.3.6",
"jshint": "2.8.0"
},
"scripts": {
"test": "./node_modules/karma/bin/karma start --reporters spec,coverage"
......
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