Ignore:
Timestamp:
09/14/07 10:38:40 (12 years ago)
Author:
pjotr
Message:

Added getAllAnswers method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ExerciseMaterial.py

    r2018 r2019  
    9494        return REQUEST.RESPONSE.redirect(self.absolute_url()+'/edit') 
    9595 
     96    def getAllAnswers(self, chapter): 
     97        """ Will return the list of the shuffled combined correct and incorrect answers """ 
     98        # Chapter should have the structure: [question,correct_list,incorrect_list] 
     99        all_answers = chapter[1] + chapter[2] 
     100        extended_answers = [] 
     101        for i, answer in enumerate(all_answers): 
     102            ext_answer = () 
     103            ext_answer.append(answer) 
     104            ext_answer.append(i) 
     105            extended_answers.append(ext_answer) 
     106        import random 
     107        random.shuffle(extended_answers) 
     108        return extended_answers 
     109 
    96110registerType(ExerciseMaterial, PROJECTNAME) 
Note: See TracChangeset for help on using the changeset viewer.