def __init__(self, quiz_header=None, quiz_data_builder=None, 
         score_filer=None):
     if quiz_header == None:
         Quiz_Header.__init__(self, 'no_file.drill')
     else:
         Quiz_Header.__init__(self, quiz_header.file_path, 
                 quiz_header.quiz_type, quiz_header.question_topic, 
                 quiz_header.data_name, quiz_header.all_subquizzes)
     if quiz_data_builder == None:
         Quiz_Data.__init__(self)
     else:
         Quiz_Data.__init__(self, quiz_data_builder)
     if score_filer == None:
         self.score_filer = Score_Filer(self.file_path)
     else:
         self.score_filer = score_filer
     self.quiz = Weighted_Quiz(self.quiz_list, 
             self.score_filer.question_score)
     self.quiz.next()
 def __init__(self, quiz_header=None, quiz_data_builder=None, 
         score_filer=None):
     if quiz_header == None:
         Quiz_Header.__init__(self, 'no_file.drill')
     else:
         Quiz_Header.__init__(self, quiz_header.file_path, 
                 quiz_header.quiz_type, quiz_header.question_topic, 
                 quiz_header.data_name, quiz_header.all_subquizzes)
     if quiz_data_builder == None:
         Quiz_Data.__init__(self)
     else:
         Quiz_Data.__init__(self, quiz_data_builder)
     if score_filer == None:
         self.score_filer = Score_Filer(self.file_path)
     else:
         self.score_filer = score_filer
     self.quiz = Weighted_Quiz(self.quiz_list, 
             self.score_filer.question_score)
class Quiz_Filer(Quiz_Data, Quiz_Header):
    """
    Contains the parts of a quiz, that are not tested. A kind of "meta-data" as
    well as loading and saving.

    Note that the quiz-words are saved in a treestore.
    """

    def __init__(self, quiz_header=None, quiz_data_builder=None, 
            score_filer=None):
        if quiz_header == None:
            Quiz_Header.__init__(self, 'no_file.drill')
        else:
            Quiz_Header.__init__(self, quiz_header.file_path, 
                    quiz_header.quiz_type, quiz_header.question_topic, 
                    quiz_header.data_name, quiz_header.all_subquizzes)
        if quiz_data_builder == None:
            Quiz_Data.__init__(self)
        else:
            Quiz_Data.__init__(self, quiz_data_builder)
        if score_filer == None:
            self.score_filer = Score_Filer(self.file_path)
        else:
            self.score_filer = score_filer
        self.quiz = Weighted_Quiz(self.quiz_list, 
                self.score_filer.question_score)

    def set_question_direction(self, question, answer=None):
        """
        Sets which column of the quiz contains the questions and which the 
        answers.

        Note: If either of the question or answer columns was not used before
          the .drill-file will be read again. (TODO)
        """
        if answer == None:
            answer = 1 - question
        if question == self.quiz.ask_from and answer == self.quiz.answer_to:
            return
        elif question == self.quiz.answer_to and answer == self.quiz.ask_from:
            self.quiz.set_question_direction(question)
        else:
            # TODO: Needed once quizzes can have more question/answer pairs
            print "Error: Not implemented yet!"
            print self.quiz.ask_from, self.quiz.answer_to
            print question, answer

    def write_score_file(self, score_file=None):
        """
        Saves the score_file to disk (if the quiz is "Weighted" otherwise it
        just passes). Optionally a file name can be given to save it somewhere
        else.
        """
        if isinstance(self.quiz, Weighted_Quiz):
            self.score_filer.write_score_file(score_file)

    def toggle_questions(self, treestore_path, toggle_to=None):
        """
        Given a row from the treestore it switches if it is being asked or not.
        If toggle_to is passed it is switched to the value of toggle_to.
        """
        toggle_to, toggled_quizzes = super(Quiz_Filer, self).toggle_questions(
                treestore_path, toggle_to)
        if toggle_to:
            self.quiz.add_quizzes(toggled_quizzes)
        else:
            self.quiz.remove_quizzes(toggled_quizzes)
        return toggle_to, toggled_quizzes
class Quiz_Filer(Quiz_Data, Quiz_Header):
    """
    Contains the parts of a quiz, that are not tested. A kind of "meta-data" as
    well as loading and saving.

    Note that the quiz-words are saved in a treestore.
    """

    def __init__(self, quiz_header=None, quiz_data_builder=None, 
            score_filer=None):
        if quiz_header == None:
            Quiz_Header.__init__(self, 'no_file.drill')
        else:
            Quiz_Header.__init__(self, quiz_header.file_path, 
                    quiz_header.quiz_type, quiz_header.question_topic, 
                    quiz_header.data_name, quiz_header.all_subquizzes)
        if quiz_data_builder == None:
            Quiz_Data.__init__(self)
        else:
            Quiz_Data.__init__(self, quiz_data_builder)
        if score_filer == None:
            self.score_filer = Score_Filer(self.file_path)
        else:
            self.score_filer = score_filer
        self.quiz = Weighted_Quiz(self.quiz_list, 
                self.score_filer.question_score)
        self.quiz.next()

    def set_question_direction(self, question, answer):
        """
        Sets which column of the quiz contains the questions and which the 
        answers.

        Note: If either of the question or answer columns was not used before
          the .drill-file will be read again. (TODO)
        """
        if question == self.quiz.ask_from and answer == self.quiz.answer_to:
            return
        elif question == self.quiz.answer_to and answer == self.quiz.ask_from:
            self.quiz.set_question_direction(question)
        else:
            # TODO: Needed once quizzes can have more question/answer pairs
            print "Error: Not implemented yet!"

    def write_score_file(self, score_file=None):
        """
        Saves the score_file to disk (if the quiz is "Weighted" otherwise it
        just passes). Optionally a file name can be given to save it somewhere
        else.
        """
        if isinstance(self.quiz, Weighted_Quiz):
            self.score_filer.write_score_file(score_file)

    def toggle_questions(self, treestore_path, toggle_to=None):
        """
        Given a row from the treestore it switches if it is being asked or not.
        If toggle_to is passed it is switched to the value of toggle_to.
        """
        toggle_to, toggled_quizzes = super(Quiz_Filer, self).toggle_questions(
                treestore_path, toggle_to)
        if toggle_to:
            self.quiz.add_quizzes(toggled_quizzes)
        else:
            self.quiz.remove_quizzes(toggled_quizzes)
        return toggle_to, toggled_quizzes