Commit 4d880db1 by RobertMarks

Updated behavior for split_answer_dict, get_score, and check_student_inputs (responsetypes.py)

parent 46ae2f9c
...@@ -460,10 +460,10 @@ class JSInput(InputTypeBase): ...@@ -460,10 +460,10 @@ class JSInput(InputTypeBase):
DO NOT USE! HAS NOT BEEN TESTED BEYOND 700X PROBLEMS, AND MAY CHANGE IN DO NOT USE! HAS NOT BEEN TESTED BEYOND 700X PROBLEMS, AND MAY CHANGE IN
BACKWARDS-INCOMPATIBLE WAYS. BACKWARDS-INCOMPATIBLE WAYS.
Inputtype for general javascript inputs. Intended to be used with Inputtype for general javascript inputs. Intended to be used with
customresponse. customresponse.
Loads in a sandboxed iframe to help prevent css and js conflicts between Loads in a sandboxed iframe to help prevent css and js conflicts between
frame and top-level window. frame and top-level window.
iframe sandbox whitelist: iframe sandbox whitelist:
- allow-scripts - allow-scripts
- allow-popups - allow-popups
...@@ -474,9 +474,9 @@ class JSInput(InputTypeBase): ...@@ -474,9 +474,9 @@ class JSInput(InputTypeBase):
window elements. window elements.
Example: Example:
<jsinput html_file="/static/test.html" <jsinput html_file="/static/test.html"
gradefn="grade" gradefn="grade"
height="500" height="500"
width="400"/> width="400"/>
See the documentation in the /doc/public folder for more information. See the documentation in the /doc/public folder for more information.
...@@ -500,7 +500,7 @@ class JSInput(InputTypeBase): ...@@ -500,7 +500,7 @@ class JSInput(InputTypeBase):
Attribute('width', "400"), # iframe width Attribute('width', "400"), # iframe width
Attribute('height', "300")] # iframe height Attribute('height', "300")] # iframe height
def _extra_context(self): def _extra_context(self):
context = { context = {
...@@ -510,11 +510,12 @@ class JSInput(InputTypeBase): ...@@ -510,11 +510,12 @@ class JSInput(InputTypeBase):
return context return context
registry.register(JSInput) registry.register(JSInput)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
class TextLine(InputTypeBase): class TextLine(InputTypeBase):
""" """
A text line input. Can do math preview if "math"="1" is specified. A text line input. Can do math preview if "math"="1" is specified.
...@@ -1373,8 +1374,6 @@ registry.register(AnnotationInput) ...@@ -1373,8 +1374,6 @@ registry.register(AnnotationInput)
class ChoiceTextGroup(InputTypeBase): class ChoiceTextGroup(InputTypeBase):
""" """
Groups of radiobutton/checkboxes with text inputs. Groups of radiobutton/checkboxes with text inputs.
Allows for a "not enough information" option to be added
to problems with numerical answers.
Examples: Examples:
RadioButton problem RadioButton problem
......
...@@ -2256,7 +2256,6 @@ class ChoiceTextResponse(LoncapaResponse): ...@@ -2256,7 +2256,6 @@ class ChoiceTextResponse(LoncapaResponse):
binary_choices, numtolerance_inputs = self._split_answers_dict(answer_dict) binary_choices, numtolerance_inputs = self._split_answers_dict(answer_dict)
# Check the binary choices first. # Check the binary choices first.
choices_correct = self._check_student_choices(binary_choices) choices_correct = self._check_student_choices(binary_choices)
inputs_correct = True
inputs_correct = self._check_student_inputs(numtolerance_inputs) inputs_correct = self._check_student_inputs(numtolerance_inputs)
# Only return correct if the student got both the binary # Only return correct if the student got both the binary
# and numtolerance_inputs are correct # and numtolerance_inputs are correct
...@@ -2376,7 +2375,6 @@ class ChoiceTextResponse(LoncapaResponse): ...@@ -2376,7 +2375,6 @@ class ChoiceTextResponse(LoncapaResponse):
Returns True if and only if all student inputs are correct. Returns True if and only if all student inputs are correct.
""" """
inputs_correct = True inputs_correct = True
for answer_name, answer_value in numtolerance_inputs.iteritems(): for answer_name, answer_value in numtolerance_inputs.iteritems():
# If `self.corrrect_inputs` does not contain an entry for # If `self.corrrect_inputs` does not contain an entry for
......
...@@ -857,15 +857,15 @@ class ChoiceTextResponseXMLFactory(ResponseXMLFactory): ...@@ -857,15 +857,15 @@ class ChoiceTextResponseXMLFactory(ResponseXMLFactory):
choice_element.set("correct", correct) choice_element.set("correct", correct)
choice_element.text = text choice_element.text = text
for inp in inputs: for inp in inputs:
# Add all of the inputs as children of this element # Add all of the inputs as children of this choice
choice_element.append(inp) choice_element.append(inp)
return choice_element return choice_element
def _create_numtolerance_input_element(self, params): def _create_numtolerance_input_element(self, params):
""" """
Creates a <numtolerance_input/> element with optionally Creates a <numtolerance_input/> or <decoy_input/> element with
specified tolerance and answer. optionally specified tolerance and answer.
""" """
answer = params['answer'] if 'answer' in params else None answer = params['answer'] if 'answer' in params else None
# If there is not an answer specified, Then create a <decoy_input/> # If there is not an answer specified, Then create a <decoy_input/>
......
...@@ -820,10 +820,11 @@ class CapaModule(CapaFields, XModule): ...@@ -820,10 +820,11 @@ class CapaModule(CapaFields, XModule):
elif is_dict_key: elif is_dict_key:
try: try:
val = json.loads(data[key]) val = json.loads(data[key])
# If the submission wasn't deserializable, raise an error.
except(KeyError, ValueError): except(KeyError, ValueError):
# Send this information along to be reported by raise ValueError(
# The grading method u"Invalid submission: {val} for {key}".format(val=data[key], key=key)
val = {"error": "error"} )
else: else:
val = data[key] val = data[key]
......
...@@ -388,8 +388,9 @@ def assert_choicetext_values(problem_type, choices, expected_values): ...@@ -388,8 +388,9 @@ def assert_choicetext_values(problem_type, choices, expected_values):
Asserts that only the given choices are checked, and given Asserts that only the given choices are checked, and given
text fields have a desired value text fields have a desired value
""" """
# Names of the radio buttons or checkboxes
all_choices = ['choiceinput_0bc', 'choiceinput_1bc'] all_choices = ['choiceinput_0bc', 'choiceinput_1bc']
# Names of the numtolerance_inputs
all_inputs = [ all_inputs = [
"choiceinput_0_numtolerance_input_0", "choiceinput_0_numtolerance_input_0",
"choiceinput_1_numtolerance_input_0" "choiceinput_1_numtolerance_input_0"
......
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