Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement manual questions selection workflow #13091

Merged
2 changes: 1 addition & 1 deletion kolibri/plugins/coach/assets/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class CoachToolsModule extends KolibriApp {
PageNames.QUIZ_SELECT_RESOURCES_LANDING_SETTINGS,
PageNames.QUIZ_SECTION_ORDER,
PageNames.QUIZ_BOOK_MARKED_RESOURCES,
PageNames.QUIZ_PREVIEW_SELECTED_QUESTIONS,
PageNames.QUIZ_LEARNER_REPORT,
PageNames.LESSON_SUMMARY,
PageNames.LESSON_SUMMARY_BETTER,
Expand All @@ -86,7 +87,6 @@ class CoachToolsModule extends KolibriApp {
PageNames.LESSON_SELECT_RESOURCES_SEARCH_RESULTS,
PageNames.LESSON_SELECT_RESOURCES_BOOKMARKS,
PageNames.LESSON_SELECT_RESOURCES_TOPIC_TREE,
PageNames.LESSON_PREVIEW_SELECTED_QUESTIONS,
];
// If we're navigating to the same page for a quiz summary page, don't set loading
if (
Expand Down
2 changes: 1 addition & 1 deletion kolibri/plugins/coach/assets/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const PageNames = {
QUIZ_SELECT_RESOURCES: 'QUIZ_SELECT_RESOURCES',
QUIZ_PREVIEW_RESOURCE: 'QUIZ_PREVIEW_RESOURCE',
QUIZ_PREVIEW_SELECTED_RESOURCES: 'QUIZ_PREVIEW_SELECTED_RESOURCES',
QUIZ_PREVIEW_SELECTED_QUESTIONS: 'QUIZ_PREVIEW_SELECTED_QUESTIONS',
QUIZ_SELECT_RESOURCES_INDEX: 'QUIZ_SELECT_RESOURCES_INDEX',
QUIZ_SELECT_RESOURCES_SEARCH: 'QUIZ_SELECT_RESOURCES_SEARCH',
QUIZ_SELECT_RESOURCES_BOOKMARKS: 'QUIZ_SELECT_RESOURCES_BOOKMARKS',
Expand Down Expand Up @@ -52,7 +53,6 @@ export const PageNames = {
LESSON_SELECT_RESOURCES_TOPIC_TREE: 'LESSON_SELECT_RESOURCES_TOPIC_TREE',
LESSON_SELECT_RESOURCES_SEARCH_RESULTS: 'LESSON_SELECT_RESOURCES_SEARCH_RESULTS',
LESSON_PREVIEW_SELECTED_RESOURCES: 'LESSON_PREVIEW_SELECTED_RESOURCES',
LESSON_PREVIEW_SELECTED_QUESTIONS: 'LESSON_PREVIEW_SELECTED_QUESTIONS',
LESSON_PREVIEW_RESOURCE: 'LESSON_PREVIEW_RESOURCE',
LESSON_LEARNER_REPORT: 'LESSON_LEARNER_REPORT',
LESSON_RESOURCE_LEARNERS_REPORT: 'LESSON_RESOURCE_LEARNERS_REPORT',
Expand Down
6 changes: 6 additions & 0 deletions kolibri/plugins/coach/assets/src/routes/examRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SelectionIndex from '../views/common/resourceSelection/subPages/Selection
import SelectFromChannels from '../views/common/resourceSelection/subPages/SelectFromTopicTree.vue';
import SelectFromBookmarks from '../views/common/resourceSelection/subPages/SelectFromBookmarks.vue';
import ManageSelectedResources from '../views/common/resourceSelection/subPages/ManageSelectedResources.vue';
import ManageSelectedQuestions from '../views/quizzes/CreateExamPage/sidePanels/QuizResourceSelection/subPages/ManageSelectedQuestions.vue';
import PreviewSelectedResources from '../views/common/resourceSelection/subPages/PreviewSelectedResources/index.vue';
import {
generateQuestionDetailHandler,
Expand Down Expand Up @@ -114,6 +115,11 @@ export default [
path: 'preview-resources',
component: ManageSelectedResources,
},
{
name: PageNames.QUIZ_PREVIEW_SELECTED_QUESTIONS,
path: 'preview-questions',
component: ManageSelectedQuestions,
},
{
name: PageNames.QUIZ_SELECT_RESOURCES_SETTINGS,
path: 'settings',
Expand Down
6 changes: 0 additions & 6 deletions kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import PreviewSelectedResources from '../views/common/resourceSelection/subPages
import LessonResourceSelection from '../views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/index.vue';
import SearchFilters from '../views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/subPages/SearchFilters.vue';
import SelectFromSearchResults from '../views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/subPages/SelectFromSearchResults.vue';
import ManageSelectedQuestions from '../views/lessons/LessonSummaryPage/sidePanels/LessonResourceSelection/subPages/ManageSelectedQuestions.vue';
import { classIdParamRequiredGuard, RouteSegments } from './utils';

const {
Expand Down Expand Up @@ -184,11 +183,6 @@ export default [
};
},
},
{
name: PageNames.LESSON_PREVIEW_SELECTED_QUESTIONS,
path: 'preview-questions',
component: ManageSelectedQuestions,
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
//Map the string of questionids to actual question object
const question = this.exerciseQuestions.find(q => q.item === questionItem);
if (value) {
this.$emit('selectQuestions', [question]);
this.$emit('selectQuestions', [question], this.contentNode);
} else {
this.$emit('deselectQuestions', [question]);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
</span>
<KRouterLink
v-else-if="
workingResourcePool.length > 0 &&
!settings.isChoosingManually &&
workingResourcePool.length > 0 &&
$route.name !== PageNames.QUIZ_PREVIEW_SELECTED_RESOURCES
"
:to="{ name: PageNames.QUIZ_PREVIEW_SELECTED_RESOURCES }"
Expand All @@ -102,6 +103,20 @@
})
}}
</KRouterLink>
<KRouterLink
v-else-if="
settings.isChoosingManually &&
workingQuestions.length > 0 &&
$route.name !== PageNames.QUIZ_PREVIEW_SELECTED_QUESTIONS
"
:to="{ name: PageNames.QUIZ_PREVIEW_SELECTED_QUESTIONS }"
>
{{
numberOfSelectedQuestions$({
count: workingQuestions.length,
})
}}
</KRouterLink>
</div>
<div class="save-button-wrapper">
<KButton
Expand Down Expand Up @@ -245,8 +260,11 @@
* @affects workingQuestions -- Updates it with the given questions and is ensured to have
* a list of unique questions to avoid unnecessary duplication
*/
function addToWorkingQuestions(questions) {
function addToWorkingQuestions(questions, resource) {
workingQuestions.value = uniqWith([...workingQuestions.value, ...questions], isEqual);
if (!workingResourcePool.value.find(r => r.id === resource.id)) {
addToWorkingResourcePool([resource]);
}
}

/**
Expand All @@ -257,6 +275,10 @@
workingQuestions.value = workingQuestions.value.filter(
obj => !questions.some(r => r.item === obj.item),
);
const resourcesToRemove = workingResourcePool.value.filter(
r => !workingQuestions.value.some(q => q.exercise_id === r.id),
);
removeFromWorkingResourcePool(resourcesToRemove);
}

const { annotateTopicsWithDescendantCounts } = useQuizResources();
Expand Down Expand Up @@ -377,7 +399,7 @@
return maximumResourcesSelectedWarning$();
});

const { numberOfSelectedResources$ } = searchAndFilterStrings;
const { numberOfSelectedResources$, numberOfSelectedQuestions$ } = searchAndFilterStrings;

return {
title,
Expand Down Expand Up @@ -420,6 +442,7 @@
selectQuiz$,
addNumberOfQuestions$,
numberOfSelectedResources$,
numberOfSelectedQuestions$,
};
},
beforeRouteLeave(_, __, next) {
Expand Down
Loading
Loading