Commit b2ddc4a2 authored by Hartmut Riesenbeck's avatar Hartmut Riesenbeck

Fix wrong displayed grade/pregrade in practise mode

The grade/pregrade display at the upper right corner of the practice
dialog fails for conjugation, gender of nouns and comparsion sessions.
The grades of the base entry were shown instead of the congugation
resp. article or comparsion ones.

BUG: 368749
REVIEW: 128901
parent f10872cf
......@@ -128,3 +128,21 @@ void ComparisonBackendMode::updateGrades()
updateGrade(super, superlativeCorrect, m_current->statisticBadCount() == 0);
translation->setSuperlativeForm(super);
}
grade_t ComparisonBackendMode::currentPreGradeForEntry() const
{
KEduVocTranslation *translation = m_current->entry()->translation(m_current->languageTo());
if (translation) {
return qMin(translation->comparativeForm().preGrade(), translation->superlativeForm().preGrade());
}
return KV_NORM_GRADE;
}
grade_t ComparisonBackendMode::currentGradeForEntry() const
{
KEduVocTranslation *translation = m_current->entry()->translation(m_current->languageTo());
if (translation) {
return qMin(translation->comparativeForm().grade(), translation->superlativeForm().grade());
}
return KV_NORM_GRADE;
}
......@@ -30,6 +30,8 @@ public:
QObject *parent, Practice::SessionManagerBase* sessionManager, KEduVocDocument* doc);
virtual bool setTestEntry(TestEntry* current);
virtual grade_t currentPreGradeForEntry() const;
virtual grade_t currentGradeForEntry() const;
void checkAnswer();
......
......@@ -117,29 +117,19 @@ void ConjugationBackendMode::checkAnswer()
grade_t ConjugationBackendMode::currentPreGradeForEntry() const
{
Q_ASSERT(m_current != 0);
KEduVocTranslation* trans = m_current->entry()->translation(m_current->languageTo());
KEduVocConjugation conj = trans->getConjugation(m_current->conjugationTense());
QList<KEduVocWordFlags> keys = conj.keys();
grade_t min_grade = KV_MAX_GRADE;
foreach(KEduVocWordFlags key, keys) {
min_grade = qMin(conj.conjugation(key).preGrade(), min_grade);
grade_t min_preGrade = KV_MAX_GRADE;
foreach(KEduVocWordFlags key, m_pronounFlags) {
min_preGrade = qMin(m_conjugation.conjugation(key).preGrade(), min_preGrade);
}
return min_grade;
return min_preGrade;
}
grade_t ConjugationBackendMode::currentGradeForEntry() const
{
Q_ASSERT(m_current != 0);
KEduVocTranslation* trans = m_current->entry()->translation(m_current->languageTo());
KEduVocConjugation conj = trans->getConjugation(m_current->conjugationTense());
QList<KEduVocWordFlags> keys = conj.keys();
grade_t min_grade = KV_MAX_GRADE;
foreach(KEduVocWordFlags key, keys) {
min_grade = qMin(conj.conjugation(key).grade(), min_grade);
foreach(KEduVocWordFlags key, m_pronounFlags) {
min_grade = qMin(m_conjugation.conjugation(key).grade(), min_grade);
}
return min_grade;
......
......@@ -129,3 +129,22 @@ void GenderBackendMode::updateGrades()
m_current->entry()->translation(m_current->languageTo())->setArticle(articleGrade);
}
grade_t GenderBackendMode::currentPreGradeForEntry() const
{
KEduVocTranslation *translation = m_current->entry()->translation(m_current->languageTo());
if (translation) {
return translation->article().preGrade();
}
return KV_NORM_GRADE;
}
grade_t GenderBackendMode::currentGradeForEntry() const
{
KEduVocTranslation *translation = m_current->entry()->translation(m_current->languageTo());
if (translation) {
return translation->article().grade();
}
return KV_NORM_GRADE;
}
......@@ -33,6 +33,9 @@ public:
/** Start practicing a new word */
virtual bool setTestEntry(TestEntry* current);
virtual grade_t currentPreGradeForEntry() const;
virtual grade_t currentGradeForEntry() const;
protected:
virtual void prepareChoices(TestEntry* current);
virtual void updateGrades();
......
......@@ -196,8 +196,8 @@ void PracticeStateMachine::updateFrontend()
m_frontend->setFeedbackState(AbstractFrontend::QuestionState);
m_frontend->setResultState(AbstractFrontend::QuestionState);
m_frontend->setLessonName(m_current->entry()->lesson()->name());
m_frontend->showGrade(m_current->entry()->translation(m_current->languageTo())->preGrade(),
m_current->entry()->translation(m_current->languageTo())->grade());
grade_t grade = m_mode->currentGradeForEntry();
m_frontend->showGrade(m_mode->currentPreGradeForEntry(), grade);
// show the word that is currently practiced in the progress bar
m_frontend->setFinishedWordsTotalWords(
......@@ -212,7 +212,6 @@ void PracticeStateMachine::updateFrontend()
? m_frontend->learningLangFont()
: m_frontend->knownLangFont());
grade_t grade = m_mode->currentGradeForEntry();
grade_t goodGrade = qMax(grade, grade_t(KV_LEV1_GRADE)); // if the word hasn't been practiced yet, use grade 1 as a base
if (m_current->statisticBadCount() == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment