Exemple #1
0
    def displayQuestion(self, Question):
        # display question from object we've parsed
        # Add one due to index 0
        print(self.currentQuestion)
        num = self.currentQuestion + 1
        self.checkBoxFlag.setText("Question {} of {}".format(
            num, len(self.test)))
        # if graded display color

        self.textBrowserQuestion.setText(Question.question)
        self.checkBoxAnswer1.setText(Question.AnswerSetAt(0))
        self.checkBoxAnswer2.setText(Question.AnswerSetAt(1))
        self.checkBoxAnswer3.setText(Question.AnswerSetAt(2))
        self.checkBoxAnswer4.setText(Question.AnswerSetAt(3))
        self.textBoxNotes.setPlainText(Question.Explain())
        self.answerLabel.setText(Question.ShowAnswer())

        # if user has not been graded (userCorrect None) then set to black
        if (Question.GotCorrect() is None):
            self.checkBoxAnswer1.setStyleSheet("color: black")
            self.checkBoxAnswer2.setStyleSheet("color: black")
            self.checkBoxAnswer3.setStyleSheet("color: black")
            self.checkBoxAnswer4.setStyleSheet("color: black")
            self.checkBoxFlag.setChecked(Question.IsFlagged())
            self.checkBoxAnswer1.setChecked(Question.LoadAnswer(0))
            self.checkBoxAnswer2.setChecked(Question.LoadAnswer(1))
            self.checkBoxAnswer3.setChecked(Question.LoadAnswer(2))
            self.checkBoxAnswer4.setChecked(Question.LoadAnswer(3))
        # if already graded previously, then display the answer
        elif (Question.GotCorrect() is not None):
            self.displayGradedAnswers(Question)

        # Always hide the solutions box whenever we load a question
        self.answerOpened = False
        self.notesOpened = False
        self.answerLabel.hide()
        self.textBoxNotes.hide()
        self.pushButtonEditNotes.hide()
        self.pushButtonSaveNotes.hide()
        self.pushButtonCancelNotes.hide()

        #if first question disable next button
        if (num is 1):
            self.pushButtonBack.setEnabled(False)
        elif (num is self.total_questions - 1):
            self.pushButtonNext.setEnabled(False)
            self.pushButtonNext.hide()
            self.pushButtonFinish.setEnabled(True)
            self.pushButtonFinish.show()
        else:
            self.pushButtonNext.setEnabled(True)
            self.pushButtonNext.show()
            self.pushButtonFinish.hide()
            self.pushButtonBack.setEnabled(True)
            self.pushButtonNext.setText("Next")
        self.displayedQuestion = self.test[self.currentQuestion]