Commit b7be0402 by Alexander Kryklia

updated case when no rule is processed

parent aaf54c56
...@@ -142,28 +142,22 @@ class DragAndDrop(object): ...@@ -142,28 +142,22 @@ class DragAndDrop(object):
# from now self.correct_groups and self.user_groups are equal if # from now self.correct_groups and self.user_groups are equal if
# order is ignored # order is ignored
# Checks in every group that user positions of every element are equal # Next check in every group that user positions of every element are equal
# with correct positions for every rule # with correct positions for every rule
# for group in self.correct_groups: # 'denied' rule
# if not self.compare_positions(self.correct_positions[group].get(
# 'denied', []), self.user_positions[group]['user'], flag='denied'):
# return False
passed_rules = dict() passed_rules = dict()
for rule in ('exact', 'anyof'): for rule in ('exact', 'anyof'):
passed_rules[rule] = True passed_rules[rule] = 0
for groupname in self.correct_groups: for groupname in self.correct_groups:
if self.correct_positions[groupname].get(rule, []): if self.correct_positions[groupname].get(rule, []):
if not self.compare_positions( if not self.compare_positions(
self.correct_positions[groupname][rule], self.correct_positions[groupname][rule],
self.user_positions[groupname]['user'], flag=rule): self.user_positions[groupname]['user'], flag=rule):
return False return False
else: passed_rules[rule] += 1
passed_rules[rule] = False
# if all passed rules are false # if no rule was executed for all groups
if not reduce(lambda x, y: x or y, passed_rules): if sum(passed_rules.values()) == 0:
return False return False
return True return True
...@@ -201,7 +195,7 @@ class DragAndDrop(object): ...@@ -201,7 +195,7 @@ 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 answer format to list format
if isinstance(correct_answer, dict): if isinstance(correct_answer, dict):
tmp = [] tmp = []
for key, value in correct_answer.items(): for key, value in correct_answer.items():
......
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