Commit ead5b179 by Joe Blaylock

Updating size limitations to be more reasonable

Javascript validation keeps inputs < 64KB, the python API allows up to
100KB.
parent d1ec220f
...@@ -237,7 +237,7 @@ class Assessment(models.Model): ...@@ -237,7 +237,7 @@ class Assessment(models.Model):
objects that map to each :class:`Criterion` in the :class:`Rubric` we're objects that map to each :class:`Criterion` in the :class:`Rubric` we're
assessing against. assessing against.
""" """
MAXSIZE = 1024*1024 MAXSIZE = 1024 * 100 # 100KB
submission_uuid = models.CharField(max_length=128, db_index=True) submission_uuid = models.CharField(max_length=128, db_index=True)
rubric = models.ForeignKey(Rubric) rubric = models.ForeignKey(Rubric)
...@@ -431,7 +431,7 @@ class AssessmentFeedback(models.Model): ...@@ -431,7 +431,7 @@ class AssessmentFeedback(models.Model):
as well as zero or more feedback options as well as zero or more feedback options
("Please select the statements below that reflect what you think of this peer grading experience") ("Please select the statements below that reflect what you think of this peer grading experience")
""" """
MAXSIZE = 1024*1024 MAXSIZE = 1024*100 # 100KB
submission_uuid = models.CharField(max_length=128, unique=True, db_index=True) submission_uuid = models.CharField(max_length=128, unique=True, db_index=True)
assessments = models.ManyToManyField(Assessment, related_name='assessment_feedback', default=None) assessments = models.ManyToManyField(Assessment, related_name='assessment_feedback', default=None)
......
...@@ -195,7 +195,8 @@ describe("OpenAssessment.Server", function() { ...@@ -195,7 +195,8 @@ describe("OpenAssessment.Server", function() {
var receivedErrorCode = ""; var receivedErrorCode = "";
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var test_string = '';
for (i = 0; i < (1024 * 1024 + 1); i++) { test_string += 'x'; } 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( server.submit(test_string).fail(
function(errorCode, errorMsg) { function(errorCode, errorMsg) {
receivedErrorCode = errorCode; receivedErrorCode = errorCode;
...@@ -225,7 +226,8 @@ describe("OpenAssessment.Server", function() { ...@@ -225,7 +226,8 @@ 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 test_string = '';
for (i = 0; i < (1024 * 1024 + 1); i++) { test_string += 'x'; } 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( server.save(test_string).fail(
function(errorMsg) { receivedErrorMsg = errorMsg; } function(errorMsg) { receivedErrorMsg = errorMsg; }
); );
...@@ -294,7 +296,8 @@ describe("OpenAssessment.Server", function() { ...@@ -294,7 +296,8 @@ describe("OpenAssessment.Server", 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 test_string = '';
for (i = 0; i < (1024 * 1024 + 1); i++) { test_string += 'x'; } 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( server.peerAssess("abc1234", options, test_string).fail(
function(errorMsg) { function(errorMsg) {
receivedErrorMsg = errorMsg; receivedErrorMsg = errorMsg;
...@@ -354,7 +357,8 @@ describe("OpenAssessment.Server", function() { ...@@ -354,7 +357,8 @@ describe("OpenAssessment.Server", function() {
var options = ["Option 1", "Option 2"]; var options = ["Option 1", "Option 2"];
var receivedErrorMsg = ""; var receivedErrorMsg = "";
var test_string = ''; var test_string = '';
for (i = 0; i < (1024 * 1024 + 1); i++) { test_string += 'x'; } 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( server.submitFeedbackOnAssessment(test_string, options).fail(
function(errorMsg) { function(errorMsg) {
receivedErrorMsg = errorMsg; receivedErrorMsg = errorMsg;
......
...@@ -37,6 +37,13 @@ OpenAssessment.Server.prototype = { ...@@ -37,6 +37,13 @@ OpenAssessment.Server.prototype = {
return this.runtime.handlerUrl(this.element, handler); return this.runtime.handlerUrl(this.element, handler);
}, },
/*
* Get maximum size of input
*/
get_max_input_size: function() {
return 1024 * 64; /* 64KB should be enough for anybody, right? ;^P */
},
/** /**
Render the XBlock. Render the XBlock.
...@@ -112,7 +119,7 @@ OpenAssessment.Server.prototype = { ...@@ -112,7 +119,7 @@ OpenAssessment.Server.prototype = {
**/ **/
submit: function(submission) { submit: function(submission) {
var url = this.url('submit'); var url = this.url('submit');
if (submission.length > 1024*256) { if (submission.length > this.get_max_input_size()) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["submit", "Text input too large."]); defer.rejectWith(this, ["submit", "Text input too large."]);
}).promise(); }).promise();
...@@ -152,7 +159,7 @@ OpenAssessment.Server.prototype = { ...@@ -152,7 +159,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 > 1024*256) { if (submission.length > this.get_max_input_size()) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Text input too large."]); defer.rejectWith(this, ["Text input too large."]);
}).promise(); }).promise();
...@@ -192,7 +199,7 @@ OpenAssessment.Server.prototype = { ...@@ -192,7 +199,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 > 1024*256) { if (text.length > this.get_max_input_size()) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Text input too large."]); defer.rejectWith(this, ["Text input too large."]);
}).promise(); }).promise();
...@@ -236,7 +243,7 @@ OpenAssessment.Server.prototype = { ...@@ -236,7 +243,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 > 1024*256) { if (feedback.length > this.get_max_input_size()) {
return $.Deferred(function(defer) { return $.Deferred(function(defer) {
defer.rejectWith(this, ["Text input too large."]); defer.rejectWith(this, ["Text input too large."]);
}).promise(); }).promise();
......
...@@ -70,7 +70,7 @@ class Submission(models.Model): ...@@ -70,7 +70,7 @@ class Submission(models.Model):
because it makes caching trivial. because it makes caching trivial.
""" """
MAXSIZE = 1024*1024 # Used by validators to cap maximum answer size MAXSIZE = 1024*100 # 100KB
uuid = UUIDField(version=1, db_index=True) uuid = UUIDField(version=1, db_index=True)
......
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