/** - checks, if the user solved the task correctly - emits signals if task was solved correctly or wrong */ void ExerciseCompare::showResult() { QPalette pal; SignButtonState result; if (m_firstRatio < m_secondRatio) result = lessThen; else if (m_firstRatio > m_secondRatio) result = greaterThen; else result = equalTo; // disable sign button m_minorButton->setEnabled(false); m_moreButton->setEnabled(false); m_equalButton->setEnabled(false); if (m_signButtonState == result) { // emit the signal for correct signalExerciseSolvedCorrect(); /* yes, the user entered the correct result */ m_resultWidget->setResult(1); } else { // emit the signal for wrong signalExerciseSolvedWrong(); /* no, the user entered the wrong result */ m_resultWidget->setResult(2); } /* if (entered_result == result) */ return; }
/** - checks, if the user solved the task correctly - emits signals if task was solved correctly or wrong */ void ExerciseFactorize::showResult() { QString tmp_str, tmp_str2; /* to build a string for a label */ QPalette pal; QColorGroup cg; uint uint_result = 0; // change the tooltip of the check button QToolTip::add(m_checkButton, i18n("Click on this button to get to the next task.")); // disable prime factor buttons m_factor2Button->setEnabled(false); m_factor3Button->setEnabled(false); m_factor5Button->setEnabled(false); m_factor7Button->setEnabled(false); m_factor11Button->setEnabled(false); m_factor13Button->setEnabled(false); m_factor17Button->setEnabled(false); m_factor19Button->setEnabled(false); // disable factor removal button as well m_removeLastFactorButton->setEnabled(false); // show the result m_factorsWidget->setFactors(m_factorsResult); m_factorsWidget->show(); // now calculate the product of the prime factors entered by the user for (uint tmp_uint = 0; tmp_uint < m_factorsEntered.count(); tmp_uint++) { if (tmp_uint == 0) { uint_result = m_factorsEntered[0]; } else { uint_result *= m_factorsEntered[tmp_uint]; } } if (uint_result == m_taskNumber) { // emit the signal for correct signalExerciseSolvedCorrect(); /* yes, the user entered the correct result */ result_label->setText(i18n("CORRECT")); pal = result_label->palette(); /* set green font color */ cg = pal.active(); cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0)); pal.setActive(cg); cg = pal.inactive(); cg.setColor(QColorGroup::Foreground, QColor(6, 179, 0)); pal.setInactive(cg); result_label->setPalette(pal); } else { // emit the signal for wrong signalExerciseSolvedWrong(); /* no, the user entered the wrong result */ result_label->setText(i18n("WRONG")); pal = result_label->palette(); /* set red font color */ cg = pal.active(); cg.setColor(QColorGroup::Foreground, QColor(red)); pal.setActive(cg); cg = pal.inactive(); cg.setColor(QColorGroup::Foreground, QColor(red)); pal.setInactive(cg); result_label->setPalette(pal); } /* if (entered_result == result) */ result_label->show(); /* show the result at the end of the task */ return; }