diff --git a/edx_sga/static/js/src/edx_sga.js b/edx_sga/static/js/src/edx_sga.js
index 8eb7aff3..e41890cb 100644
--- a/edx_sga/static/js/src/edx_sga.js
+++ b/edx_sga/static/js/src/edx_sga.js
@@ -4,9 +4,13 @@ function StaffGradedAssignmentXBlock(runtime, element) {
var uploadUrl = runtime.handlerUrl(element, 'upload_assignment');
var downloadUrl = runtime.handlerUrl(element, 'download_assignment');
var annotatedUrl = runtime.handlerUrl(element, 'download_annotated');
- var getStaffGradingUrl = runtime.handlerUrl(element, 'get_staff_grading_data');
+ var getStaffGradingUrl = runtime.handlerUrl(
+ element, 'get_staff_grading_data'
+ );
var staffDownloadUrl = runtime.handlerUrl(element, 'staff_download');
- var staffAnnotatedUrl = runtime.handlerUrl(element, 'staff_download_annotated');
+ var staffAnnotatedUrl = runtime.handlerUrl(
+ element, 'staff_download_annotated'
+ );
var staffUploadUrl = runtime.handlerUrl(element, 'staff_upload_annotated');
var enterGradeUrl = runtime.handlerUrl(element, 'enter_grade');
var removeGradeUrl = runtime.handlerUrl(element, 'remove_grade');
@@ -17,28 +21,29 @@ function StaffGradedAssignmentXBlock(runtime, element) {
// Add download urls to template context
state.downloadUrl = downloadUrl;
state.annotatedUrl = annotatedUrl;
- state.error = state.error ? state.error : false;
+ state.error = state.error || false;
// Render template
- var content = $(element).find("#sga-content").html(template(state));
+ var content = $(element).find('#sga-content').html(template(state));
// Set up file upload
- $(content).find(".fileupload").fileupload({
+ $(content).find('.fileupload').fileupload({
url: uploadUrl,
add: function(e, data) {
- var do_upload = $(content).find(".upload").html('');
- $(content).find('p.error').html("");
+ var do_upload = $(content).find('.upload').html('');
+ $(content).find('p.error').html('');
$('')
.text('Upload ' + data.files[0].name)
.appendTo(do_upload)
.click(function() {
- do_upload.text("Uploading...");
+ do_upload.text('Uploading...');
var block = $(element).find(".sga-block");
var data_max_size = block.attr("data-max-size");
var size = data.files[0].size;
if (!_.isUndefined(size)) {
- if (size >= data_max_size) { //if file size is larger max file size define in env(django)
- state.error = "The file you are trying to upload is too large.";
+ //if file size is larger max file size define in env(django)
+ if (size >= data_max_size) {
+ state.error = 'The file you are trying to upload is too large.';
render(state);
return;
}
@@ -48,62 +53,60 @@ function StaffGradedAssignmentXBlock(runtime, element) {
},
progressall: function(e, data) {
var percent = parseInt(data.loaded / data.total * 100, 10);
- $(content).find(".upload").text(
- "Uploading... " + percent + "%");
+ $(content).find('.upload').text(
+ 'Uploading... ' + percent + '%');
},
fail: function(e, data) {
/**
- * Nginx and other sanely implemented servers return a
- * "413 Request entity too large" status code if an
+ * Nginx and other sanely implemented servers return a
+ * "413 Request entity too large" status code if an
* upload exceeds its limit. See the 'done' handler for
* the not sane way that Django handles the same thing.
*/
- if (data.jqXHR.status == 413) {
+ if (data.jqXHR.status === 413) {
/* I guess we have no way of knowing what the limit is
* here, so no good way to inform the user of what the
* limit is.
*/
- state.error = "The file you are trying to upload is too large."
- }
- else {
+ state.error = 'The file you are trying to upload is too large.';
+ } else {
// Suitably vague
- state.error = "There was an error uploading your file.";
+ state.error = 'There was an error uploading your file.';
// Dump some information to the console to help someone
// debug.
- console.log("There was an error with file upload.");
- console.log("event: ", e);
- console.log("data: ", data);
+ console.log('There was an error with file upload.');
+ console.log('event: ', e);
+ console.log('data: ', data);
}
render(state);
},
- done: function(e, data) {
+ done: function(e, data) {
/* When you try to upload a file that exceeds Django's size
* limit for file uploads, Django helpfully returns a 200 OK
* response with a JSON payload of the form:
- *
+ *
* {'success': 'Grade must be a number.");
- }
- else if (score != parseInt(score)) {
- form.find(".error").html(" Grade must be an integer.");
- }
- else if (score < 0) {
- form.find(".error").html(" Grade must be positive.");
- }
- else if (score > max_score) {
- form.find(".error").html(" Maximum score is " + max_score);
- }
- else {
+ form.find('.error').html(' Grade must be a number.');
+ } else if (score !== parseInt(score)) {
+ form.find('.error').html(' Grade must be an integer.');
+ } else if (score < 0) {
+ form.find('.error').html(' Grade must be positive.');
+ } else if (score > max_score) {
+ form.find('.error').html(' Maximum score is ' + max_score);
+ } else {
// No errors
$.post(enterGradeUrl, form.serialize())
.success(renderStaffGrading);
}
});
- form.find("#remove-grade").on("click", function() {
- var url = removeGradeUrl + "?module_id=" +
- row.data("module_id") + "&student_id=" +
- row.data("student_id");
+ form.find('#remove-grade').on('click', function() {
+ var url = removeGradeUrl + '?module_id=' +
+ row.data('module_id') + '&student_id=' +
+ row.data('student_id');
$.get(url).success(renderStaffGrading);
});
- form.find("#enter-grade-cancel").on("click", function() {
+ form.find('#enter-grade-cancel').on('click', function() {
/* We're kind of stretching the limits of leanModal, here,
* by nesting modals one on top of the other. One side effect
* is that when the enter grade modal is closed, it hides
* the overlay for itself and for the staff grading modal,
* so the overlay is no longer present to click on to close
* the staff grading modal. Since leanModal uses a fade out
- * time of 200ms to hide the overlay, our work around is to
+ * time of 200ms to hide the overlay, our work around is to
* wait 225ms and then just "click" the 'Grade Submissions'
- * button again. It would also probably be pretty
+ * button again. It would also probably be pretty
* straightforward to submit a patch to leanModal so that it
* would work properly with nested modals.
*
* See: https://github.com/mitodl/edx-sga/issues/13
*/
setTimeout(function() {
- $("#grade-submissions-button").click();
+ $('#grade-submissions-button').click();
}, 225);
});
}
$(function($) { // onLoad
- var block = $(element).find(".sga-block");
- var state = block.attr("data-state");
+ var block = $(element).find('.sga-block');
+ var state = block.attr('data-state');
render(JSON.parse(state));
- var is_staff = block.attr("data-staff") == "True";
+ var is_staff = block.attr('data-staff') == 'True';
if (is_staff) {
gradingTemplate = _.template(
- $(element).find("#sga-grading-tmpl").text());
- block.find("#grade-submissions-button")
+ $(element).find('#sga-grading-tmpl').text());
+ block.find('#grade-submissions-button')
.leanModal()
- .on("click", function() {
+ .on('click', function() {
$.ajax({
url: getStaffGradingUrl,
success: renderStaffGrading
});
});
- block.find("#staff-debug-info-button")
+ block.find('#staff-debug-info-button')
.leanModal();
}
});
}
- if (require === undefined) {
- /**
+ function loadjs(url) {
+ $('