Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

void ExercisePercentage::showResult (  ) [private]
  • checks, if the user solved the task correctly
    • emits signals if task was solved correctly or wrong

Definition at line 324 of file exercisepercentage.cpp.

References ratio::setDenominator(), ratio::setNumerator(), ResultWidget::setResult(), signalExerciseSolvedCorrect(), and signalExerciseSolvedWrong().

{
    QString tmp_str; /* to build a string for a label */
    QPalette pal;
    int tmp_result;
    ratio entered_result;
    ratio correct_result;

    // change the tooltip of the check button
    m_checkButton->setToolTip (i18n ("Click on this button to get to the next question."));

    answer_edit->setEnabled (false);
    m_skipButton->setEnabled (false);

    //an empty answer field will be interpreted as 0
    if (answer_edit->text().isEmpty() == true)
        answer_edit->setText ("0");


    tmp_result = answer_edit->text().toInt();
    entered_result.setNumerator (tmp_result, false);
    entered_result.setDenominator (1, false);
    correct_result.setNumerator (m_resultPercentage.toInt());
    correct_result.setDenominator (1, false);
    if (tmp_result == m_resultPercentage.toInt()) {
        // emit the signal for correct
        signalExerciseSolvedCorrect();
        /* yes, the user entered the correct result */
        m_resultWidget->setResult (entered_result, 1);
    } else {
        // emit the signal for incorrect
        signalExerciseSolvedWrong();
        /* no, the user entered the wrong result */
        m_resultWidget->setResult (correct_result, 0);
    }

    return;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index