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

Register learning goals on demand

Fixes crash when switching to newly installed course.
parent bfa52d01
......@@ -277,6 +277,9 @@ void ProfileManager::recordProgress(Learner *learner,
QHash<QString, int> ProfileManager::progressValues(Learner *learner, LearningGoal *goal,
const QString &container) const
{
if (!learner || !goal) {
return QHash<QString, int>();
}
return d->m_storage.readProgressValues(learner, goal, container);
}
......
......@@ -180,17 +180,6 @@ bool ResourceManager::modified() const
return false;
}
void ResourceManager::registerLearningGoals(LearnerProfile::ProfileManager *profileManger)
{
foreach (LanguageResource *languageResource, languageResources()) {
profileManger->registerGoal(
LearnerProfile::LearningGoal::Language,
languageResource->language()->id(),
languageResource->language()->i18nTitle()
);
}
}
void ResourceManager::addLanguage(const QUrl &languageFile)
{
if (m_loadedResources.contains(languageFile.toLocalFile())) {
......
......@@ -78,14 +78,6 @@ public:
*/
bool modified() const;
/**
* Register loaded languages as learning goals in profile manager.
*
* TODO this should not be done by explicit call, but by putting data at shared data storage
* for profile manager
*/
void registerLearningGoals(LearnerProfile::ProfileManager *profileManger);
/**
* \return \c true if a repository is used, else \c false
*/
......
......@@ -82,6 +82,13 @@ void TrainingSession::setCourse(Course *course)
// lazy loading of training data
LearnerProfile::LearningGoal * goal = m_profileManager->goal(
LearnerProfile::LearningGoal::Language, m_course->id());
if (!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()
......
......@@ -67,7 +67,6 @@ MainWindow::MainWindow()
qFatal("No language resources found, cannot start application.");
}
m_resourceManager->loadCourseResources();
m_resourceManager->registerLearningGoals(m_profileManager);
m_trainingSession->setProfileManager(m_profileManager);
// create menu
......
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