78
78
//=======================================================================================
80
80
class ProblemSpace;
83
#define lmNUM_GROUPS 16 //number of groups to classify questions
82
#define k_num_boxes 16 //number of boxes to classify questions
87
//---------------------------------------------------------------------------------------
88
// Question: A question for an exercise
89
Question(ApplicationScope& appScope, long nSpaceID, long nSetID,
92
Question(ApplicationScope& appScope, long nSpaceID, long nDeckID,
90
93
long nParam0 = 0L, long nParam1 = 0L,
91
94
long nParam2 = 0L, long nParam3 = 0L, long nParam4 = 0L,
92
int nGroup = 0, int nAskedTotal = 0, int nSuccessTotal = 0,
95
int nBox = 0, int nAskedTotal = 0, int nSuccessTotal = 0,
93
96
int nRepetitions = 0,
94
97
wxTimeSpan tsLastAsked = wxTimeSpan::Days(-36500), //never asked (100 years)
95
98
long nDaysRepIntv = (wxTimeSpan::Day()).GetDays() //1 day
99
102
inline void SetIndex(int nIndex) { m_nIndex = nIndex; }
100
103
inline int GetIndex() { return m_nIndex; }
101
inline int GetGroup() { return m_nGroup; }
104
inline int get_box_index() { return m_nBox; }
102
105
inline int GetRepetitions() { return m_nRepetitions; }
103
106
long GetParam(int nNumParam);
104
107
void SaveQuestion(int nSpaceID);
105
static bool LoadQuestions(wxSQLite3Database* pDB, long nSetID, ProblemSpace* pPS);
108
static bool LoadQuestions(wxSQLite3Database* pDB, long nDeckID, ProblemSpace* pPS);
107
110
void UpdateAsked(ProblemSpace* pPS);
108
111
void UpdateSuccess(ProblemSpace* pPS, bool fSuccess);
142
145
//creation / save
143
bool LoadSet(wxString& sSetName);
146
bool load_deck(wxString& sDeckName);
144
147
void SaveAndClear();
145
148
void NewSpace(wxString& sSpaceName, int nRepetitionsThreshold, int nNumMandatoryParams);
146
void StartNewSet(wxString& sSetName);
147
inline void EndOfNewSet() { m_sets.push_back(m_nSetID); }
149
void start_new_deck(wxString& sDeckName);
150
inline void end_of_new_deck() { m_decks.push_back(m_nDeckID); }
150
153
inline int GetSpaceSize() { return m_questions.size(); }
151
inline int GetGroup(int iQ) { return m_questions[iQ]->GetGroup(); }
154
inline int get_box_index(int iQ) { return m_questions[iQ]->get_box_index(); }
152
155
inline int RepetitionsThreshold() { return m_nRepetitions; }
153
156
inline wxDateTime GetCreationDate() { return m_tmCreation; }
154
157
inline wxTimeSpan GetTotalRespTime() { return m_tsTotalRespTime; }
164
167
long nParam3 = 0L, long nParam4 = 0L);
165
168
Question* AddQuestion(long nParam0 = 0L, long nParam1 = 0L, long nParam2 = 0L,
166
169
long nParam3 = 0L, long nParam4 = 0L,
167
int nGroup = 0, int nAskedTotal = 0, int nSuccessTotal = 0,
170
int nBox = 0, int nAskedTotal = 0, int nSuccessTotal = 0,
168
171
int nRepetitions = 0,
169
172
wxTimeSpan tsLastAsked = wxTimeSpan::Days(-36500), //never asked (100 years)
170
173
long nDaysRepIntv = (wxTimeSpan::Day()).GetDays() //1 day
180
long GetSetID(long nSpaceID, wxString& sSetName);
181
bool IsSetLoaded(long nSetID);
183
long get_deck_id(long nSpaceID, wxString& sDeckName);
184
bool is_deck_loaded(long nDeckID);
182
185
void LoadSpace(wxString& sSpaceName, int nRepetitionsThreshold, int nNumMandatoryParams);
185
188
ApplicationScope& m_appScope;
186
189
std::vector<Question*> m_questions;
187
std::list<long> m_sets; //setIDs of loaded sets
190
std::list<long> m_decks; //DecksIDs of loaded decks
189
192
//information to save
190
193
wxString m_sSpaceName; //name for this problem space
191
194
wxString m_sUser; //user name
192
195
long m_nSpaceID; //ID for this space
193
wxString m_sSetName; //name for current set (last loaded set)
194
long m_nSetID; //ID for current set
195
long m_nSetQIndex; //index for question to add to current set
196
wxString m_sDeckName; //name for current set (last loaded set)
197
long m_nDeckID; //ID for current set
198
long m_nQIndexForDeck; //index for question to add to current deck
196
199
wxDateTime m_tmCreation; //creation date
197
200
wxDateTime m_tmLastUsed; //last date when this problem space was used
198
201
int m_nRepetitions; //num of repetitions to promote a question
226
230
inline void NewSpace(wxString& sSpaceName, int nRepetitionsThreshold, int nNumMandatoryParams)
227
231
{ m_ProblemSpace.NewSpace(sSpaceName, nRepetitionsThreshold, nNumMandatoryParams); }
229
virtual bool LoadSet(wxString& sSetName);
230
inline void StartNewSet(wxString& sSetName) { m_ProblemSpace.StartNewSet(sSetName); }
231
inline void EndOfNewSet() { m_ProblemSpace.EndOfNewSet(); }
232
virtual void AddQuestionToSet(long nParam0=0L, long nParam1=0L, long nParam2=0L,
233
long nParam3=0L, long nParam4=0L);
233
virtual bool load_deck(wxString& sDeckName);
234
inline void start_new_deck(wxString& sDeckName) { m_ProblemSpace.start_new_deck(sDeckName); }
235
inline void end_of_new_deck() { m_ProblemSpace.end_of_new_deck(); }
236
virtual void add_question_to_deck(long nParam0=0L, long nParam1=0L, long nParam2=0L,
237
long nParam3=0L, long nParam4=0L);
234
238
virtual bool IsQuestionParamMandatory(int nNumParam);
235
239
virtual long GetQuestionParam(int iQ, int nNumParam);
238
242
ProblemSpace m_ProblemSpace;
239
ExerciseCtrol* m_pOwnerExercise;
242
245
//---------------------------------------------------------------------------------------
279
283
class LeitnerManager : public ProblemManager
282
LeitnerManager(ApplicationScope& appScope, ExerciseCtrol* pOwnerExercise,
286
LeitnerManager(ApplicationScope& appScope, bool fLearningMode);
284
287
~LeitnerManager();
286
289
//implementation of virtual methods
290
bool more_questions();
287
291
int ChooseQuestion();
288
292
void UpdateQuestion(int iQ, bool fSuccess, wxTimeSpan tsResponse);
289
293
void OnProblemSpaceChanged();
291
295
//specific for this class
292
wxTimeSpan GetRepetitionInterval(int nGroup);
296
wxTimeSpan get_repetition_interval(int nBox);
293
297
inline bool IsLearningMode() { return m_fLearningMode; }
298
void change_to_practise_mode();
295
300
//statistics for learning mode
299
float GetGlobalProgress();
300
float GetSessionProgress();
301
wxTimeSpan GetEstimatedSessionTime();
302
const wxString GetProgressReport();
304
float get_global_progress();
305
float get_session_progress();
306
float get_short_term_progress();
307
float get_medium_term_progress();
308
float get_long_term_progress();
309
wxTimeSpan get_estimated_session_time();
310
const wxString get_progress_report();
311
void compute_achievement_indicators();
304
313
//statistics for practise mode
305
314
inline int GetRight() { return m_nRight; }
306
315
inline int GetWrong() { return m_nWrong; }
307
316
void ResetPractiseCounters();
311
void UpdateProblemSpace();
312
void UpdateProblemSpaceForLearning();
313
void UpdateProblemSpaceForPractising();
314
int ChooseQuestionForLearning();
315
int ChooseQuestionForPractising();
316
void UpdateQuestionForLearning(int iQ, bool fSuccess, wxTimeSpan tsResponse);
317
void UpdateQuestionForPractising(int iQ, bool fSuccess, wxTimeSpan tsResponse);
319
void update_problem_space();
320
void update_problem_space_for_learning();
321
void update_problem_space_for_practising();
322
int choose_question_for_learning();
323
int choose_question_for_practising();
324
void update_question_for_learning(int iQ, bool fSuccess, wxTimeSpan tsResponse);
325
void update_question_for_practising(int iQ, bool fSuccess, wxTimeSpan tsResponse);
326
void remove_current_question();
319
bool m_fLearningMode; //true: learning mode, false: practise mode
320
bool m_fThereWhereQuestions; //to control change to Practise mode
328
bool m_fLearningMode; //true: learning mode, false: practise mode
329
bool m_fThereWhereQuestions; //to control change to Practise mode
322
331
//for learning mode
324
std::vector<int> m_set0; //questions scheduled for today
325
std::vector<int>::iterator m_it0; //points to next question to ask
332
std::vector<int> m_set0; //questions scheduled for today
333
int m_iQ; //index pointing to currently asked question or -1 if none
334
std::vector<int>::iterator m_it0; //iterator pointing to next question to ask
335
static double m_w[k_num_boxes]; //weighting factors
327
337
//for practise mode
329
std::vector<int> m_group[lmNUM_GROUPS]; //questions, splitted by group
330
double m_range[lmNUM_GROUPS]; //probability range for each group. -1.0 means 'do not use'
338
std::vector<int> m_box[k_num_boxes]; //questions, by box
339
double m_range[k_num_boxes]; //probability range for each box. -1.0 means 'do not use'
341
//statistics for learning mode
333
342
int m_nUnlearned;
336
int m_NumQuestions[lmNUM_GROUPS]; //num questions per group
345
int m_NumQuestions[k_num_boxes]; //num questions per box
346
double m_short, m_medium, m_long; //achievement indicators
338
//counters for right and wrong answers (practise mode)
348
//statistics for practise mode