Assigning buckets to items in answer description for a question of type "przyporzadkuj"
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 13 Nov 2013 15:59:28 +0000 (16:59 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 15 Jan 2014 10:18:59 +0000 (11:18 +0100)
wtem/models.py

index 4038485..51515fe 100644 (file)
@@ -97,7 +97,12 @@ class Submission(models.Model):
                 toret = 0
                 for bucket_id, items in answer.items():
                     for item_id in items:
-                        if int(item_id) in exercise['answer'].get(bucket_id, []):
+                        is_corect = False
+                        if exercise.get('answer_mode', None) == 'possible_buckets_for_item':
+                            is_correct = int(bucket_id) in exercise['answer'].get(item_id)
+                        else:
+                            is_correct = int(item_id) in exercise['answer'].get(bucket_id, [])
+                        if is_correct:
                             toret += exercise['points_per_hit']
                 return toret
             if t == 'edumed_wybor':