Commit 4023d756 by Joe Blaylock

Tim-346: Addressing PR feedback

parent 0b5d6bda
...@@ -3,7 +3,6 @@ import os.path ...@@ -3,7 +3,6 @@ import os.path
from ddt import ddt, file_data from ddt import ddt, file_data
from django.test import TestCase from django.test import TestCase
from rest_framework.serializers import ValidationError
from openassessment.assessment.models import Criterion, CriterionOption, Rubric, AssessmentFeedback from openassessment.assessment.models import Criterion, CriterionOption, Rubric, AssessmentFeedback
from openassessment.assessment.serializers import ( from openassessment.assessment.serializers import (
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
<div class="step__actions"> <div class="step__actions">
<div class="message message--inline message--error message--error-server"> <div class="message message--inline message--error message--error-server">
<h3 class="message__title">We could not submit your assessment</h3> <h3 class="message__title">We could not submit your assessment</h3>
<div class="message__content"></div>
</div> </div>
<ul class="list list--actions"> <ul class="list list--actions">
......
...@@ -30,6 +30,19 @@ describe("OpenAssessment.Server", function() { ...@@ -30,6 +30,19 @@ describe("OpenAssessment.Server", function() {
); );
}; };
var getHugeTestString = function() {
var testStringSize = server.maxInputSize + 1;
var testString = '';
for (i = 0; i < (testStringSize); i++) { testString += 'x'; }
return testString;
}
var getHugeStringError = function() {
// return a string that can be used with .toContain()
// "Response text is too large. Please reduce the size of your response and try to submit again.";
return "text is too large"
}
beforeEach(function() { beforeEach(function() {
// Create the server // Create the server
// Since the runtime is a stub implementation that ignores the element passed to it, // Since the runtime is a stub implementation that ignores the element passed to it,
...@@ -194,17 +207,15 @@ describe("OpenAssessment.Server", function() { ...@@ -194,17 +207,15 @@ describe("OpenAssessment.Server", function() {
it("confirms that very long submissions fail with an error without ajax", function() { it("confirms that very long submissions fail with an error without ajax", function() {
var receivedErrorCode = ""; var receivedErrorCode = "";
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var testString = getHugeTestString();
var test_string_size = server.get_max_input_size() + 1; server.submit(testString).fail(
for (i = 0; i < (test_string_size); i++) { test_string += 'x'; }
server.submit(test_string).fail(
function(errorCode, errorMsg) { function(errorCode, errorMsg) {
receivedErrorCode = errorCode; receivedErrorCode = errorCode;
receivedErrorMsg = errorMsg; receivedErrorMsg = errorMsg;
} }
); );
expect(receivedErrorCode).toEqual("submit"); expect(receivedErrorCode).toEqual("submit");
expect(receivedErrorMsg).toEqual("Response text is too large. Please reduce the size of your response and try to submit again."); expect(receivedErrorMsg).toContain(getHugeStringError());
}); });
it("informs the caller of an server error when sending a submission", function() { it("informs the caller of an server error when sending a submission", function() {
...@@ -225,13 +236,11 @@ describe("OpenAssessment.Server", function() { ...@@ -225,13 +236,11 @@ describe("OpenAssessment.Server", function() {
it("confirms that very long saves fail with an error without ajax", function() { it("confirms that very long saves fail with an error without ajax", function() {
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var testString = getHugeTestString();
var test_string_size = server.get_max_input_size() + 1; server.save(testString).fail(
for (i = 0; i < (test_string_size); i++) { test_string += 'x'; }
server.save(test_string).fail(
function(errorMsg) { receivedErrorMsg = errorMsg; } function(errorMsg) { receivedErrorMsg = errorMsg; }
); );
expect(receivedErrorMsg).toEqual("Response text is too large. Please reduce the size of your response and try to submit again."); expect(receivedErrorMsg).toContain(getHugeStringError());
}); });
it("informs the caller of an AJAX error when sending a submission", function() { it("informs the caller of an AJAX error when sending a submission", function() {
...@@ -295,15 +304,13 @@ describe("OpenAssessment.Server", function() { ...@@ -295,15 +304,13 @@ describe("OpenAssessment.Server", function() {
it("confirms that very long peer assessments fail with an error without ajax", function() { it("confirms that very long peer assessments fail with an error without ajax", function() {
var options = {clarity: "Very clear", precision: "Somewhat precise"}; var options = {clarity: "Very clear", precision: "Somewhat precise"};
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var testString = getHugeTestString();
var test_string_size = server.get_max_input_size() + 1; server.peerAssess("abc1234", options, testString).fail(
for (i = 0; i < (test_string_size); i++) { test_string += 'x'; }
server.peerAssess("abc1234", options, test_string).fail(
function(errorMsg) { function(errorMsg) {
receivedErrorMsg = errorMsg; receivedErrorMsg = errorMsg;
} }
); );
expect(receivedErrorMsg).toEqual("Response text is too large. Please reduce the size of your response and try to submit again."); expect(receivedErrorMsg).toContain(getHugeStringError());
}); });
it("informs the caller of a server error when sending a peer assessment", function() { it("informs the caller of a server error when sending a peer assessment", function() {
...@@ -356,15 +363,13 @@ describe("OpenAssessment.Server", function() { ...@@ -356,15 +363,13 @@ describe("OpenAssessment.Server", function() {
it("confirms that very long assessment feedback fails with an error without ajax", function() { it("confirms that very long assessment feedback fails with an error without ajax", function() {
var options = ["Option 1", "Option 2"]; var options = ["Option 1", "Option 2"];
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var testString = getHugeTestString();
var test_string_size = server.get_max_input_size() + 1; server.submitFeedbackOnAssessment(testString, options).fail(
for (i = 0; i < (test_string_size); i++) { test_string += 'x'; }
server.submitFeedbackOnAssessment(test_string, options).fail(
function(errorMsg) { function(errorMsg) {
receivedErrorMsg = errorMsg; receivedErrorMsg = errorMsg;
} }
); );
expect(receivedErrorMsg).toEqual("Response text is too large. Please reduce the size of your response and try to submit again."); expect(receivedErrorMsg).toContain(getHugeStringError());
}); });
it("informs the caller of an AJAX error when sending feedback on submission", function() { it("informs the caller of an AJAX error when sending feedback on submission", function() {
......
...@@ -40,9 +40,7 @@ OpenAssessment.Server.prototype = { ...@@ -40,9 +40,7 @@ OpenAssessment.Server.prototype = {
/* /*
* Get maximum size of input * Get maximum size of input
*/ */
get_max_input_size: function() { maxInputSize: 1024 * 64, /* 64KB should be enough for anybody, right? ;^P */
return 1024 * 64; /* 64KB should be enough for anybody, right? ;^P */
},
/** /**
Render the XBlock. Render the XBlock.
...@@ -119,7 +117,7 @@ OpenAssessment.Server.prototype = { ...@@ -119,7 +117,7 @@ OpenAssessment.Server.prototype = {
**/ **/
submit: function(submission) { submit: function(submission) {
var url = this.url('submit'); var url = this.url('submit');
if (submission.length > this.get_max_input_size()) { if (submission.length > this.maxInputSize) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["submit", "Response text is too large. Please reduce the size of your response and try to submit again."]); defer.rejectWith(this, ["submit", "Response text is too large. Please reduce the size of your response and try to submit again."]);
}).promise(); }).promise();
...@@ -159,7 +157,7 @@ OpenAssessment.Server.prototype = { ...@@ -159,7 +157,7 @@ OpenAssessment.Server.prototype = {
**/ **/
save: function(submission) { save: function(submission) {
var url = this.url('save_submission'); var url = this.url('save_submission');
if (submission.length > this.get_max_input_size()) { if (submission.length > this.maxInputSize) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]); defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]);
}).promise(); }).promise();
...@@ -199,7 +197,7 @@ OpenAssessment.Server.prototype = { ...@@ -199,7 +197,7 @@ OpenAssessment.Server.prototype = {
*/ */
submitFeedbackOnAssessment: function(text, options) { submitFeedbackOnAssessment: function(text, options) {
var url = this.url('submit_feedback'); var url = this.url('submit_feedback');
if (text.length > this.get_max_input_size()) { if (text.length > this.maxInputSize) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]); defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]);
}).promise(); }).promise();
...@@ -243,7 +241,7 @@ OpenAssessment.Server.prototype = { ...@@ -243,7 +241,7 @@ OpenAssessment.Server.prototype = {
**/ **/
peerAssess: function(submissionId, optionsSelected, feedback) { peerAssess: function(submissionId, optionsSelected, feedback) {
var url = this.url('peer_assess'); var url = this.url('peer_assess');
if (feedback.length > this.get_max_input_size()) { if (feedback.length > this.maxInputSize) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]); defer.rejectWith(this, ["Response text is too large. Please reduce the size of your response and try to submit again."]);
}).promise(); }).promise();
......
...@@ -28,7 +28,7 @@ SECOND_STUDENT_ITEM = dict( ...@@ -28,7 +28,7 @@ SECOND_STUDENT_ITEM = dict(
ANSWER_ONE = u"this is my answer!" ANSWER_ONE = u"this is my answer!"
ANSWER_TWO = u"this is my other answer!" ANSWER_TWO = u"this is my other answer!"
ANSWER_THREE = u'' + 'c' * (Submission.MAXSIZE+1) ANSWER_THREE = u'' + 'c' * (Submission.MAXSIZE + 1)
@ddt @ddt
......
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