Changeset 2436


Ignore:
Timestamp:
06/25/08 16:19:48 (11 years ago)
Author:
anonymous
Message:

References #1758, forgot the main thing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r2434 r2436  
    211211                # Use mchoice_body as a holder to construct the htm for the question -> then append it to the general holder 
    212212                mchoice_body = u'' 
     213                mchoice_array = [] 
    213214                correct_answers = chapter_text[1] 
    214215                answers_total = correct_answers + chapter_text[2] 
    215216                for a in range(len(correct_answers)): 
    216217                    answer_value = REQUEST.get('exercise_%s_checkbox_%s' % (i,a),'') 
     218                    # Need a number to get the order right 
     219                    answer_number = REQUEST.get('exercise_%s_hiddencheck_%s' % (i,a),'') 
    217220                    if answer_value: 
    218                         mchoice_body += multiple_choices_repl % ('correct_mc', '0', i, a, i, a, 'checked="checked"', correct_answers[a]) 
    219                     else: 
    220                         mchoice_body += multiple_choices_repl % ('incorrect_mc', '0', i, a, i, a, '', correct_answers[a]) 
     221                        mchoice_array.append((answer_number,multiple_choices_repl % ('correct_mc', answer_number, i, a, i, a, 'checked="checked"', to_unicode(correct_answers[a])))) 
     222                    else: 
     223                        mchoice_array.append((answer_number,multiple_choices_repl % ('incorrect_mc', answer_number, i, a, i, a, '', to_unicode(correct_answers[a])))) 
    221224                for a in range(len(correct_answers),len(answers_total)): 
    222225                    answer_value = REQUEST.get('exercise_%s_checkbox_%s' % (i,a),'') 
     226                    # Need a number to get the order right 
     227                    answer_number = REQUEST.get('exercise_%s_hiddencheck_%s' % (i,a),'') 
    223228                    if answer_value: 
    224                         mchoice_body += multiple_choices_repl % ('incorrect_mc', '0', i, a, i, a, 'checked="checked"', answers_total[a]) 
    225                     else: 
    226                         mchoice_body += multiple_choices_repl % ('correct_mc', '0', i, a, i, a, '', answers_total[a]) 
     229                        mchoice_array.append((answer_number,multiple_choices_repl % ('incorrect_mc', answer_number, i, a, i, a, 'checked="checked"', to_unicode(answers_total[a])))) 
     230                    else: 
     231                        mchoice_array.append((answer_number,multiple_choices_repl % ('correct_mc', answer_number, i, a, i, a, '', to_unicode(answers_total[a])))) 
     232                # Structuring the array, appending elements to the text placeholder 
     233                mchoice_array.sort(cmp=lambda t1,t2: cmp(t1[0],t2[0])) 
     234                for mc in mchoice_array: 
     235                    mchoice_body += mc[1] 
    227236                # Add the html result to the general holder 
    228                 feedbody += u"""<p>%s</p> <p>%s</p>""" % (chapter_text[0], mchoice_body) 
     237                feedbody += u"""<p>%s</p> <p>%s</p>""" % (to_unicode(chapter_text[0]), mchoice_body) 
    229238            elif chapter_type == 'fill_in_the_blanks': 
    230239                correct_answer_dict = self.get_values_from_fitbs(i) 
Note: See TracChangeset for help on using the changeset viewer.