From ff0f21614ebf77f57d16d3de01acb0eeab25bd7f Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 26 Dec 2012 15:57:48 +0200 Subject: [PATCH] started tests and add graders to capa_problem --- common/lib/capa/capa/capa_problem.py | 5 ++++- common/lib/capa/capa/graders/tests.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 2eaa0e4286..96a334ef97 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -34,6 +34,8 @@ import chem import chem.chemcalc import chem.chemtools import chem.miller +import graders +import graders.draganddrop import calc from correctmap import CorrectMap @@ -69,7 +71,8 @@ global_context = {'random': random, 'eia': eia, 'chemcalc': chem.chemcalc, 'chemtools': chem.chemtools, - 'miller': chem.miller} + 'miller': chem.miller, + 'draganddrop': graders.draganddrop} # These should be removed from HTML output, including all subelements html_problem_semantics = ["codeparam", "responseparam", "answer", "script", "hintgroup", "openendedparam","openendedrubric"] diff --git a/common/lib/capa/capa/graders/tests.py b/common/lib/capa/capa/graders/tests.py index 1e0da9411e..be37c49679 100644 --- a/common/lib/capa/capa/graders/tests.py +++ b/common/lib/capa/capa/graders/tests.py @@ -5,9 +5,16 @@ import draganddrop class Test_DragAndDrop(unittest.TestCase): - def test_1(self): - user_input = '{"laice": "bcc", "points": [["0.00", "1.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}' - correct_answer = {} + def test_targets_true(self): + user_input = '{"use_targets": "true", "draggables": \ + ["1": "t1", "name_with_icon": "t2"]}' + correct_answer = {'1': 't1', 'name_with_icon': 't2'} + self.assertTrue(draganddrop.grade(user_input, correct_answer)) + + def test_targets_true(self): + user_input = '{"use_targets": "true", "draggables": \ + ["1": "t1", "name_with_icon": "t2"]}' + correct_answer = {'1': 't1', 'name_with_icon': 't2'} self.assertTrue(draganddrop.grade(user_input, correct_answer))