Commit c85101e1 by Will Daly

All tests passing

parent f66e07ac
......@@ -219,9 +219,6 @@ describe("OpenAssessment.StudioView", function() {
// Also expect that an error is displayed
expect(server.receivedData).toBe(null);
expect(view.validationAlert.isVisible()).toBe(true);
expect(runtime.notify).toHaveBeenCalledWith(
"error", {msg: "The problem could not be saved."}
);
// Expect that individual fields were highlighted
expect(view.validationErrors()).toContain(
......@@ -230,6 +227,7 @@ describe("OpenAssessment.StudioView", function() {
// Fix the error and try to save again
view.settingsView.submissionStart("2014-04-01", "00:00");
view.save();
// Expect that the validation errors were cleared
// and that data was successfully sent to the server.
......
......@@ -124,20 +124,32 @@ OpenAssessment.StudioView.prototype = {
save: function () {
var view = this;
this.saveTabState();
// Check whether the problem has been released; if not,
// warn the user and allow them to cancel.
this.server.checkReleased().done(
function (isReleased) {
if (isReleased) {
view.confirmPostReleaseUpdate($.proxy(view.updateEditorContext, view));
}
else {
view.updateEditorContext();
// Perform client-side validation
// TODO -- more explanation
this.validationAlert.hide();
this.clearValidationErrors();
if (!this.validate()) {
this.validationAlert.setMessage(
gettext("Validation errors! [TODO Sylvia please help!]")
).show();
}
else {
// Check whether the problem has been released; if not,
// warn the user and allow them to cancel.
this.server.checkReleased().done(
function (isReleased) {
if (isReleased) {
view.confirmPostReleaseUpdate($.proxy(view.updateEditorContext, view));
}
else {
view.updateEditorContext();
}
}
}
).fail(function (errMsg) {
view.showError(errMsg);
});
).fail(function (errMsg) {
view.showError(errMsg);
});
}
},
/**
......
......@@ -28,32 +28,44 @@ OpenAssessment.ValidationAlert.prototype = {
},
/**
Hides the alert.
*/
Hides the alert.
Returns:
TODO
*/
hide: function() {
this.element.addClass('is--hidden');
this.rubricContentElement.removeClass('openassessment_alert_shown');
return this;
},
/**
Displays the alert.
*/
Displays the alert.
Returns:
TODO
*/
show : function() {
this.element.removeClass('is--hidden');
this.rubricContentElement.addClass('openassessment_alert_shown');
return this;
},
/**
Sets the message of the alert.
How will this work with internationalization?
Sets the message of the alert.
How will this work with internationalization?
Args:
newTitle (str): the new title that the message will have
newMessage (str): the new text that the message's body will contain
Args:
newTitle (str): the new title that the message will have
newMessage (str): the new text that the message's body will contain
*/
Returns:
TODO
*/
setMessage: function(newTitle, newMessage) {
this.title.text(newTitle);
this.message.text(newMessage);
return this;
},
/**
......
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