Commit c85101e1 by Will Daly

All tests passing

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