Commit 6aaad83a by Alexander Kryklia

finished interface change

parent 17f11cef
...@@ -202,8 +202,8 @@ class DragAndDrop(object): ...@@ -202,8 +202,8 @@ class DragAndDrop(object):
def populate(self, correct_answer, user_answer): def populate(self, correct_answer, user_answer):
""" """ """ """
# convert from dict format to list format # convert from dict format to list format
tmp = []
if isinstance(correct_answer, dict): if isinstance(correct_answer, dict):
tmp = []
for key, value in correct_answer.items(): for key, value in correct_answer.items():
tmp_dict = {'draggables': [], 'targets': [], 'rule': 'exact'} tmp_dict = {'draggables': [], 'targets': [], 'rule': 'exact'}
tmp_dict['draggables'].append(key) tmp_dict['draggables'].append(key)
...@@ -222,9 +222,7 @@ class DragAndDrop(object): ...@@ -222,9 +222,7 @@ class DragAndDrop(object):
# and positions must reflect order in group # and positions must reflect order in group
for i in xrange(0, len(correct_answer)): for i in xrange(0, len(correct_answer)):
groupname = str(i) groupname = str(i)
self.correct_groups = OrderedDict()
self.correct_groups[groupname] = correct_answer[i]['draggables'] self.correct_groups[groupname] = correct_answer[i]['draggables']
self.correct_positions = OrderedDict()
self.correct_positions[groupname] = {correct_answer[i]['rule']: correct_answer[i]['targets']} self.correct_positions[groupname] = {correct_answer[i]['rule']: correct_answer[i]['targets']}
self.user_groups[groupname] = [] self.user_groups[groupname] = []
self.user_positions[groupname] = {'user': []} self.user_positions[groupname] = {'user': []}
...@@ -258,6 +256,8 @@ def grade(user_input, correct_answer): ...@@ -258,6 +256,8 @@ def grade(user_input, correct_answer):
else: else:
{'1': '[10, 10]', 'name_with_icon': '[[10, 10], 20]'} {'1': '[10, 10]', 'name_with_icon': '[[10, 10], 20]'}
Support 2 interfaces""" Support 2 interfaces"""
# import ipdb; ipdb.set_trace()
dnd = DragAndDrop() dnd = DragAndDrop()
# import ipdb; ipdb.set_trace()
dnd.populate(correct_answer=correct_answer, user_answer=user_input) dnd.populate(correct_answer=correct_answer, user_answer=user_input)
return dnd.grade() return dnd.grade()
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