aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Riesenbeck <hartmut.riesenbeck@gmx.de>2016-10-30 19:14:10 (GMT)
committerHartmut Riesenbeck <hartmut.riesenbeck@gmx.de>2016-10-30 19:24:58 (GMT)
commitb2ddc4a2bf4147ad5c435d4199e1cfc8f4176aba (patch)
tree409e62205eac97dd93cd751c964202be6a21d148
parentf10872cfa5642f2b8279720b85d79039bdb100a7 (diff)
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
-rw-r--r--src/practice/comparisonbackendmode.cpp18
-rw-r--r--src/practice/comparisonbackendmode.h2
-rw-r--r--src/practice/conjugationbackendmode.cpp22
-rw-r--r--src/practice/genderbackendmode.cpp19
-rw-r--r--src/practice/genderbackendmode.h3
-rw-r--r--src/practice/practicestatemachine.cpp5
6 files changed, 50 insertions, 19 deletions
diff --git a/src/practice/comparisonbackendmode.cpp b/src/practice/comparisonbackendmode.cpp
index 2dcfe12..3e73653 100644
--- a/src/practice/comparisonbackendmode.cpp
+++ b/src/practice/comparisonbackendmode.cpp
@@ -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;
+}
diff --git a/src/practice/comparisonbackendmode.h b/src/practice/comparisonbackendmode.h
index f99dc3a..85cad82 100644
--- a/src/practice/comparisonbackendmode.h
+++ b/src/practice/comparisonbackendmode.h
@@ -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();
diff --git a/src/practice/conjugationbackendmode.cpp b/src/practice/conjugationbackendmode.cpp
index 7e05584..dd6f9a3 100644
--- a/src/practice/conjugationbackendmode.cpp
+++ b/src/practice/conjugationbackendmode.cpp
@@ -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;
diff --git a/src/practice/genderbackendmode.cpp b/src/practice/genderbackendmode.cpp
index 724e4c4..96d4a2a 100644
--- a/src/practice/genderbackendmode.cpp
+++ b/src/practice/genderbackendmode.cpp
@@ -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;
+}
+
diff --git a/src/practice/genderbackendmode.h b/src/practice/genderbackendmode.h
index 676e39c..64eed49 100644
--- a/src/practice/genderbackendmode.h
+++ b/src/practice/genderbackendmode.h
@@ -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();
diff --git a/src/practice/practicestatemachine.cpp b/src/practice/practicestatemachine.cpp
index bc03ffe..994d9c1 100644
--- a/src/practice/practicestatemachine.cpp
+++ b/src/practice/practicestatemachine.cpp
@@ -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) {