Commit 4023d756 by Joe Blaylock

Tim-346: Addressing PR feedback

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