diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index c797170a56..10a0130a6e 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1848,8 +1848,7 @@ class AnnotationResponse(LoncapaResponse): Checking of annotation responses. The response contains both a comment (student commentary) and an option (student tag). - Only the tag is currently graded. Answers may be incorrect, partially correct, or correct - and are scored accordingly. + Only the tag is currently graded. Answers may be incorrect, partially correct, or correct. ''' response_tag = 'annotationresponse' allowed_inputfields = ['annotationinput'] diff --git a/common/lib/capa/capa/tests/test_files/annotationresponse.xml b/common/lib/capa/capa/tests/test_files/annotationresponse.xml new file mode 100644 index 0000000000..86af0bb789 --- /dev/null +++ b/common/lib/capa/capa/tests/test_files/annotationresponse.xml @@ -0,0 +1,17 @@ + + + + the title + the text + the comment + Type a commentary below: + Select one or more tags: + + + + + + + + Instructor text here... + diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py index daf09b4136..8a0c953d33 100644 --- a/common/lib/capa/capa/tests/test_responsetypes.py +++ b/common/lib/capa/capa/tests/test_responsetypes.py @@ -428,4 +428,16 @@ class JavascriptResponseTest(unittest.TestCase): self.assertEquals(test_lcp.grade_answers(correct_answers).get_correctness('1_2_1'), 'correct') class AnnotationResponseTest(unittest.TestCase): - pass \ No newline at end of file + + def test_grade(self): + annotationresponse_file = os.path.dirname(__file__) + "/test_files/annotationresponse.xml" + test_lcp = lcp.LoncapaProblem(open(annotationresponse_file).read(), '1', system=test_system) + answers_for = { + 'correct': {'1_2_1': json.dumps({'options':[0]})}, + 'incorrect': {'1_2_1': json.dumps({'options':[1]})}, + 'partially-correct': {'1_2_1': json.dumps({'options':[2]})} + } + + for expected_correctness in answers_for.keys(): + actual_correctness = test_lcp.grade_answers(answers_for[expected_correctness]).get_correctness('1_2_1') + self.assertEquals(expected_correctness, actual_correctness) \ No newline at end of file