Ignore:
Timestamp:
09/18/07 15:11:43 (12 years ago)
Author:
pjotr
Message:

Done some stuff for the multiple choice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r2033 r2034  
    173173        for i in range(1,len(exercise_body)): 
    174174            if exercise_body[i][1] == 'multiple_choices': 
    175                 # XXX Do some stuff 
     175                answered_right = [] 
     176                answered_wrong = [] 
     177                question_text = exercise_body[i][0][0] 
     178                correct_answers = exercise_body[i][0][1] 
     179                all_answers = exercise_body[i][0][1] + exercise_body[i][0][2] 
     180                for a in all_answers: 
     181                    answer_value = REQUEST.get('bodyText_'+str(i)+'_'+str(a)) 
     182                    if answer_value == 'checked' and a in correct_answers: 
     183                        answered_right.append(a) 
     184                    elif answer_value == 'checked' and a not in correct_answers: 
     185                        answered_wrong.append(a) 
     186                message += "\n\n\n%s\n\nAnswered right: %s out of %s.\nRight answers given: %s. Wrong answers given: %s." % (question_text, len(answered_right), len(all_answers), ','.join(answered_right), ','.join(answered_wrong)) 
    176187            elif exercise_body[i][1] == 'fill_in_the_blanks': 
    177188                # XXX Do some stuff 
    178189            elif exercise_body[i][1] == 'open_ended': 
    179190                question_text = exercise_body[i][0] 
    180                 students_answer = REQUEST.get('bodyText_'+i) 
    181                 message += "\n\n\n %s \n\n %s" % (question_text, students_answer) 
     191                students_answer = REQUEST.get('bodyText_'+str(i)) 
     192                message += "\n\n\n%s\n\n%s" % (question_text, students_answer) 
    182193        message += "\n\n\nBest regards,\nLeMill" 
    183194         
Note: See TracChangeset for help on using the changeset viewer.