Commit c2f6aceb by Joe Blaylock

Merge pull request #244 from edx/jrbl/381-self_assessment_errors_invisible

Fix TIM-381: Invisible Self Assessment errors
parents 0757dbb7 d8f21988
......@@ -86,4 +86,17 @@ describe("OpenAssessment.BaseView", function() {
});
});
it("Displays error messages from self assessment to the user", function() {
var testError = 'Test failure contacting server message';
loadSubviews(function() {
/* stub our selfAssess to fail */
spyOn(server, 'selfAssess').andCallFake(function(submissionId, optionsSelected) {
return $.Deferred(function(defer) { defer.rejectWith(server, [testError]); }).promise();
});
view.selfAssess();
expect(server.selfAssess).toHaveBeenCalled();
expect(view.getStepActionsErrorMessage()).toContain(testError);
});
});
});
......@@ -250,6 +250,13 @@ describe("OpenAssessment.Server", function() {
expect(receivedMsg).toEqual('Could not contact server.');
});
it("informs the caller of an AJAX error when sending a self assessment", function() {
stubAjax(false, null);
var receivedMsg = null;
server.selfAssess("Test").fail(function(errorMsg) { receivedMsg = errorMsg; });
expect(receivedMsg).toEqual('Could not contact server.');
});
it("informs the caller of a server error when sending a submission", function() {
stubAjax(true, {'success': false, 'msg': 'test error'});
var receivedMsg = null;
......
......@@ -302,12 +302,17 @@ OpenAssessment.BaseView.prototype = {
If null, hide the error message (with one exception: loading errors are never hidden once displayed)
**/
toggleActionError: function(type, msg) {
var element = this.element;
var container = null;
if (type == 'save') { container = '.response__submission__actions'; }
else if (type == 'submit') { container = '.step__actions'; }
else if (type == 'peer') { container = '.step__actions'; }
else if (type == 'self') { container = '.self-assessment__actions'; }
else if (type == 'feedback_assess') { container = '.submission__feedback__actions'; }
if (type == 'save') {
container = '.response__submission__actions';
}
else if (type == 'submit' || type == 'peer' || type == 'self') {
container = '.step__actions';
}
else if (type == 'feedback_assess') {
container = '.submission__feedback__actions';
}
// If we don't have anywhere to put the message, just log it to the console
if (container === null) {
......@@ -317,10 +322,10 @@ OpenAssessment.BaseView.prototype = {
else {
// Insert the error message
var msgHtml = (msg === null) ? "" : msg;
$(container + " .message__content").html('<p>' + msgHtml + '</p>');
$(container + " .message__content", element).html('<p>' + msgHtml + '</p>');
// Toggle the error class
$(container).toggleClass('has--error', msg !== null);
$(container, element).toggleClass('has--error', msg !== null);
}
},
......@@ -335,6 +340,20 @@ OpenAssessment.BaseView.prototype = {
$(container).toggleClass('has--error', true);
$(container + ' .step__status__value i').removeClass().addClass('ico icon-warning-sign');
$(container + ' .step__status__value .copy').html('Unable to Load');
},
/**
* Get the contents of the Step Actions error message box, for unit test validation.
*
* Step Actions are the UX-level parts of the student interaction flow -
* Submission, Peer Assessment, and Self Assessment. Since steps are mutually
* exclusive, only one error box should be rendered on screen at a time.
*
* Returns:
* One HTML string
*/
getStepActionsErrorMessage: function() {
return $('.step__actions .message__content').html();
}
};
......
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