File indexing completed on 2024-04-21 03:50:59
0001 /* 0002 SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef TESTENTRY_H 0007 #define TESTENTRY_H 0008 0009 #include <functional> 0010 0011 #include <QFlags> 0012 0013 #include <KEduVocExpression> 0014 0015 class TestEntry 0016 { 0017 public: 0018 enum ErrorType { 0019 SpellingMistake = 0x01, /** < misspelled */ 0020 CapitalizationMistake = 0x02, /** < capitalization error (whAt) */ 0021 AccentMistake = 0x04, /** < an accent is missing or wrong (é) */ 0022 PunctuationMistake = 0x08, /** < punctuation mistake (doesnt) */ 0023 ArticleWrong = 0x10, /** < solution is correct with the article interchanged */ 0024 ArticleMissing = 0x20, /** < solution is correct with the article missing*/ 0025 FalseFriend = 0x40, /** < a false friend */ 0026 Synonym = 0x80, /** < a synonym (may be correct) */ 0027 Empty = 0x100, /** < empty answer string */ 0028 UnrelatedWord = 0x200, /** < a valid word but no connection to the solution */ 0029 Incomplete = 0x400, /** < the part that was entered is right, but not complete */ 0030 Correct = 0x800, /** < no error, solution was right */ 0031 Wrong = 0x1000 /** < some error, solution was somehow wrong check other bits */ 0032 }; 0033 0034 Q_DECLARE_FLAGS(ErrorTypes, ErrorType) 0035 0036 explicit TestEntry(KEduVocExpression *entry); 0037 0038 /// update the internal statistics for this practice with a right result 0039 void updateStatisticsRightAnswer(grade_t currentPreGrade, grade_t currentGrade); 0040 0041 /// update the internal statistics for this practice with a wrong result 0042 void updateStatisticsWrongAnswer(grade_t currentPreGrade, grade_t currentGrade); 0043 0044 /** 0045 check if the entry was finished and the practice backend 0046 may update the grades that will be saved to the file persistently 0047 @return whether the entry is done 0048 */ 0049 bool shouldChangeGrades(); 0050 0051 int answeredCorrectInSequence(); 0052 int statisticCount(); 0053 int statisticGoodCount(); 0054 int statisticBadCount(); 0055 bool correctAtFirstAttempt(); 0056 bool isUnseenQuestion() const; 0057 0058 /** 0059 * In conjugation mode, use this tense for the entry. 0060 */ 0061 QString conjugationTense() const; 0062 void setConjugationTense(const QString &tense); 0063 0064 /** 0065 * In conjugation mode, use these pronouns for the entry. 0066 */ 0067 QList<KEduVocWordFlags> conjugationPronouns() const; 0068 void setConjugationPronouns(const QList<KEduVocWordFlags> &flags); 0069 0070 void setLastErrors(ErrorTypes errorTypes); 0071 ErrorTypes lastErrors(); 0072 0073 void setLastPercentage(double percent); 0074 double lastPercentage(); 0075 0076 void addUserAnswer(const QString &answer) 0077 { 0078 if (!answer.isEmpty()) 0079 m_userAnswers.append(answer); 0080 } 0081 QStringList userAnswers() 0082 { 0083 return m_userAnswers; 0084 } 0085 0086 void setLanguageFrom(int from); 0087 void setLanguageTo(int to); 0088 int languageFrom() const; 0089 int languageTo() const; 0090 0091 KEduVocExpression *entry() const; 0092 0093 grade_t practiceModeDependentMinGrade() const; 0094 grade_t practiceModeDependentMinPreGrade() const; 0095 grade_t practiceModeDependentMaxGrade() const; 0096 grade_t practiceModeDependentMaxPreGrade() const; 0097 0098 private: 0099 grade_t practiceModeDependentGrade(std::function<grade_t(KEduVocText)> gradeFunc, std::function<grade_t(grade_t, grade_t)> minMaxFunc) const; 0100 0101 private: 0102 /// the entry itself 0103 KEduVocExpression *m_entry; 0104 0105 int m_languageFrom; // Index of the language this entry is from 0106 int m_languageTo; // Index of the language this entry is from 0107 0108 // These are for the current entry only, so that we can display 0109 // statistics about it after the training session is finished.. 0110 int m_statisticCount; 0111 int m_statisticGoodCount; 0112 int m_statisticBadCount; 0113 int m_answeredCorrectInSequence; 0114 bool m_correctAtFirstAttempt; 0115 bool m_shouldChangeGrades; // Set to true when grades should be changed after the practice 0116 bool m_isUnseenQuestion; // Is set to true for questions never seen before. 0117 0118 double m_lastPercentage; 0119 ErrorTypes m_lastError; 0120 0121 QStringList m_userAnswers; 0122 0123 //! Only affects conjugation training. 0124 QString m_conjugationTense; 0125 //! Only affects conjugation training. 0126 QList<KEduVocWordFlags> m_conjugationPronouns; 0127 }; 0128 0129 Q_DECLARE_OPERATORS_FOR_FLAGS(TestEntry::ErrorTypes) 0130 0131 #endif