Commit b372d703 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Reactivate lazy loading of course entity

parent 4068974c
......@@ -60,32 +60,32 @@ void TrainingSession::setCourse(Course *course)
return;
}
m_course = course;
// if (m_course && m_course->unitList().count() > 0) {
// setUnit(m_course->unitList().first());
// }
// // lazy loading of training data
// LearnerProfile::LearningGoal * goal = m_profileManager->goal(
// LearnerProfile::LearningGoal::Language, m_course->id());
// if (!goal) {
// goal = m_profileManager->registerGoal(
// LearnerProfile::LearningGoal::Language,
// course->language()->id(),
// course->language()->i18nTitle()
// );
// }
// auto data = m_profileManager->progressValues(m_profileManager->activeProfile(),
// goal,
// m_course->id()
// );
// Q_FOREACH(Unit *unit, m_course->unitList()) {
// Q_FOREACH(Phrase *phrase, unit->phraseList()) {
// auto iter = data.find(phrase->id());
// if (iter != data.end()) {
// phrase->setProgress(iter.value());
// }
// }
// }
if (m_course && m_course->unitList().count() > 0) {
setUnit(m_course->unitList().first());
}
// lazy loading of training data
LearnerProfile::LearningGoal * goal = m_profileManager->goal(
LearnerProfile::LearningGoal::Language, m_course->id());
if (!goal) {
goal = m_profileManager->registerGoal(
LearnerProfile::LearningGoal::Language,
course->language()->id(),
course->language()->i18nTitle()
);
}
auto data = m_profileManager->progressValues(m_profileManager->activeProfile(),
goal,
m_course->id()
);
Q_FOREACH(Unit *unit, m_course->unitList()) {
Q_FOREACH(Phrase *phrase, unit->phraseList()) {
auto iter = data.find(phrase->id());
if (iter != data.end()) {
phrase->setProgress(iter.value());
}
}
}
emit courseChanged();
}
......
......@@ -54,8 +54,6 @@ public:
void setCourse(Course *course);
Unit * unit() const;
void setUnit(Unit *unit);
PhonemeGroup * phonemeGroup() const;
void setPhonemeGroup(PhonemeGroup *phonemeGroup);
Phrase::Type phraseType() const;
void setPhraseType(Phrase::Type type);
Phrase * phrase() const;
......
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