Commit 7915014f by Joe Blaylock

Merge pull request #256 from edx/jrbl/435-no_whitespace_submissions

TIM-435: Prevent whitespace-only submissions
parents 86c20003 958060a0
......@@ -65,6 +65,13 @@ describe("OpenAssessment.ResponseView", function() {
expect(view.saveEnabled()).toBe(false);
expect(view.saveStatus()).toContain('Unsaved draft');
// Response is whitespace --> save/submit buttons disabled
view.response(' \n \n ');
view.responseChanged();
expect(view.submitEnabled()).toBe(false);
expect(view.saveEnabled()).toBe(false);
expect(view.saveStatus()).toContain('Unsaved draft');
// Response is not blank --> submit button enabled
view.response('Test response');
view.responseChanged();
......
......@@ -170,12 +170,12 @@ OpenAssessment.ResponseView.prototype = {
**/
responseChanged: function() {
// Enable the save/submit button only for non-blank responses
var currentResponse = this.response();
var currentResponse = $.trim(this.response());
var isBlank = (currentResponse !== '');
this.submitEnabled(isBlank);
// Update the save button and status only if the response has changed
if (this.savedResponse !== currentResponse) {
if ($.trim(this.savedResponse) !== currentResponse) {
this.saveEnabled(isBlank);
this.saveStatus('Unsaved draft');
}
......
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