+ def question_data(i):
+ field = 'pyt%s' % i
+ choices = fields[field].choices
+ score = contact.body[field]
+ chosen_idx = get_idx(choices, score)
+ correct_idx = get_idx(choices, 2)
+ return {
+ 'score': score,
+ 'chosen_idx': chosen_idx,
+ 'correct_idx': correct_idx,
+ 'chosen': 'abc'[chosen_idx],
+ 'correct': 'abc'[correct_idx],
+ 'label': fields[field].label,
+ 'comment': mark_safe(markdown.convert(cls.ANSWER_COMMENTS[i-1][chosen_idx])),
+ 'answers': [(text, a_score == score, a_score == 2) for a_score, text in choices],
+ }
+ question_count = 20
+ questions = [question_data(i) for i in xrange(1, question_count + 1)]
+ points = sum(question['score'] for question in questions)
+ return {'questions': questions, 'points': points/2., 'total': question_count}
+
+
+class CollegiumMlodychTestForm(CollegiumTestForm):
+ def __init__(self, *args, **kwargs):
+ super(CollegiumMlodychTestForm, self).__init__(*args, **kwargs)
+ self.label_suffix = ''
+
+ result_page = True
+ form_tag = 'collegium-mlodych-test'
+ form_title = u'Test wiedzy w zakresie edukacji medialnej i cyfrowej'
+ submit_label = u'Wyślij'
+
+ contact = forms.EmailField(label=u'Adres e-mail, na który przyślemy informację o wynikach')
+
+ @classmethod
+ def results(cls, contact):
+ fields = cls().fields
+