Commit f11afb76 by Alan Boudreault

strip the answer when validating the min_characters

parent c47fed9b
......@@ -52,7 +52,7 @@ class AnswerBlock(LightChild):
default_from = String(help="If specified, the name of the answer to get the default value from",
default=None, scope=Scope.content)
min_characters = Integer(help="Minimum number of characters allowed for the answer",
scope=Scope.content)
default=0, scope=Scope.content)
@lazy
def student_input(self):
......@@ -110,7 +110,7 @@ class AnswerBlock(LightChild):
def completed(self):
answer_length_ok = self.student_input
if self.min_characters > 0:
answer_length_ok = len(self.student_input) >= self.min_characters
answer_length_ok = len(self.student_input.strip()) >= self.min_characters
return bool(self.read_only or answer_length_ok)
......
......@@ -43,8 +43,10 @@ class MRQBlock(QuestionnaireAbstractBlock):
An XBlock used to ask multiple-response questions
"""
student_choices = List(help="Last submissions by the student", default=[], scope=Scope.user_state)
max_attempts = Integer(help="Number of max attempts for this questions", scope=Scope.content)
num_attempts = Integer(help="Number of attempts a user has answered for this questions", scope=Scope.user_state)
max_attempts = Integer(help="Number of max attempts for this questions", default=0,
scope=Scope.content)
num_attempts = Integer(help="Number of attempts a user has answered for this questions",
default=0, scope=Scope.user_state)
# TODO REMOVE THIS, ONLY NEEDED FOR LIGHTCHILDREN
@classmethod
......
......@@ -2,7 +2,8 @@ function AnswerBlock(runtime, element) {
return {
submit: function() {
var input = $(':input', element),
answer_length = input.val().length,
input_value = input.val().replace(/^\s+|\s+$/gm,''),
answer_length = input_value.length,
data = input.data();
if (_.isNumber(data.min_characters) &&
......
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