diff --git a/kolibri/plugins/coach/assets/src/composables/useFetchContentNode.js b/kolibri/plugins/coach/assets/src/composables/useFetchContentNode.js new file mode 100644 index 0000000000..7fb06d46dd --- /dev/null +++ b/kolibri/plugins/coach/assets/src/composables/useFetchContentNode.js @@ -0,0 +1,33 @@ +import { ref } from 'vue'; +import ContentNodeResource from 'kolibri-common/apiResources/ContentNodeResource'; + +export default function useFetchContentNode(contentId) { + const contentNode = ref({}); + const ancestors = ref([]); + const questions = ref([]); + + const fetchContentNode = () => { + ContentNodeResource.fetchModel({ + id: contentId, + getParams: { no_available_filtering: true }, + }).then(node => { + contentNode.value = node; + + if (node.ancestors.length) { + ancestors.value = node.ancestors; + } + + if (node.assessmentmetadata) { + questions.value = node.assessmentmetadata.assessment_item_ids; + } + }); + }; + + fetchContentNode(); + + return { + ancestors, + contentNode, + questions, + }; +} diff --git a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js index fb764a328a..40c481b928 100644 --- a/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js +++ b/kolibri/plugins/coach/assets/src/routes/lessonsRoutes.js @@ -155,6 +155,17 @@ export default [ path: 'channels', component: SelectFromChannels, }, + { + name: PageNames.LESSON_PREVIEW_RESOURCE, + path: 'preview-selected-resources', + component: PreviewSelectedResources, + props: toRoute => { + const contentId = toRoute.query.contentId; + return { + contentId, + }; + }, + }, ], }, { @@ -162,11 +173,6 @@ export default [ path: 'preview-resources/', component: ManageSelectedLessonResources, }, - { - name: PageNames.LESSON_PREVIEW_RESOURCE, - path: 'preview-resources/:nodeId', - component: PreviewSelectedResources, - }, ], }, { diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/UpdatedResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/UpdatedResourceSelection.vue index 96ae5f451a..f803da605b 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/UpdatedResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/UpdatedResourceSelection.vue @@ -125,12 +125,20 @@ }, methods: { contentLink(content) { - const { name, params, query } = this.$route; + const { params, query } = this.$route; if (!content.is_leaf) { return this.topicsLink(content.id); } - // Just return the current route; router-link will handle the no-op from here - return { name, params, query }; + return { + name: PageNames.LESSON_PREVIEW_RESOURCE, + params: { + ...params, + }, + query: { + contentId: content.id, + ...query, + }, + }; }, topicsLink(topicId) { const { name, params, query } = this.$route; diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewContent.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewContent.vue new file mode 100644 index 0000000000..19aa442c98 --- /dev/null +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewContent.vue @@ -0,0 +1,252 @@ + + + + + + + diff --git a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue index ab66b490d4..b96dbd43cc 100644 --- a/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue +++ b/kolibri/plugins/coach/assets/src/views/lessons/LessonSummaryPage/sidePanels/PreviewSelectedResources.vue @@ -7,7 +7,19 @@ @closePanel="() => $router.go(-1)" @shouldFocusFirstEl="() => null" > -

PreviewSelectedResources

+ + @@ -15,12 +27,82 @@