fix to work with unicode answers

This commit is contained in:
Frédéric Péters 2011-11-27 15:01:42 +01:00
parent a8f2bd1025
commit 2e089c894e
1 changed files with 4 additions and 1 deletions

View File

@ -63,8 +63,11 @@ class EffectiveQuizForm(form.Form):
question_title = question_lines[0]
question_answers = [x[2:] for x in question_lines[1:]]
self.good_answers['q%s' % (i+1)] = [x[2:] for x in question_lines[1:] if x.startswith('o')]
terms = [SimpleVocabulary.createTerm(x, x.encode('ascii', 'ignore'), x)
for x in question_answers]
question_vocabulary = SimpleVocabulary(terms)
question_field = schema.Choice(title=question_title,
values=question_answers,
vocabulary=question_vocabulary,
required=False)
question_field.__name__ = 'q%s' % (i+1)
question_field.widgetFactory = RadioFieldWidget