Skip to content

Commit

Permalink
transfers fetching execrises to contentnode composable
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanOXDi committed Feb 11, 2025
1 parent 1ca1517 commit 36157e7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ref, getCurrentInstance } from 'vue';
import { ref, getCurrentInstance, computed } from 'vue';
import ContentNodeResource from 'kolibri-common/apiResources/ContentNodeResource';
import { exerciseToQuestionArray } from '../utils/selectQuestions';

export default function useFetchContentNode(contentId) {
const contentNode = ref({});
Expand Down Expand Up @@ -30,12 +31,15 @@ export default function useFetchContentNode(contentId) {
});
};

const exerciseQuestions = computed(() => exerciseToQuestionArray(contentNode.value));

fetchContentNode();

return {
loading,
ancestors,
contentNode,
questions,
exerciseQuestions,
};
}
15 changes: 0 additions & 15 deletions kolibri/plugins/coach/assets/src/composables/useFetchExercise.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="questions-accordion-header">
<div>
<KCheckbox
v-if="isCheckBoxVisible"
v-if="isSelectable"
ref="selectAllCheckbox"
class="select-all-box"
:label="selectAllLabel$()"
Expand Down Expand Up @@ -59,28 +59,27 @@
}"
>
<template #leading-actions>
<div v-if="isCheckBoxVisible">
<DragHandle>
<div>
<DragSortWidget
:moveUpText="upLabel$"
:moveDownText="downLabel$"
:noDrag="true"
:isFirst="index === 0"
:isLast="index === questions.length - 1"
@moveUp="() => handleKeyboardDragUp(index)"
@moveDown="() => handleKeyboardDragDown(index)"
/>
</div>
</DragHandle>
<KCheckbox
class="accordion-item-checkbox"
:checked="selectedQuestions.includes(question.item)"
@change="
(value, $event) => handleQuestionCheckboxChange(question.item, value, $event)
"
/>
</div>
<DragHandle v-if="isSelectable">
<div>
<DragSortWidget
:moveUpText="upLabel$"
:moveDownText="downLabel$"
:noDrag="true"
:isFirst="index === 0"
:isLast="index === questions.length - 1"
@moveUp="() => handleKeyboardDragUp(index)"
@moveDown="() => handleKeyboardDragDown(index)"
/>
</div>
</DragHandle>
<KCheckbox
v-if="isSelectable"
class="accordion-item-checkbox"
:checked="selectedQuestions.includes(question.item)"
@change="
(value, $event) => handleQuestionCheckboxChange(question.item, value, $event)
"
/>
</template>
<template #content>
<div
Expand Down Expand Up @@ -171,7 +170,8 @@
},
selectedQuestions: {
type: Array,
required: true,
required: false,
default: () => [],
},
selectAllIsChecked: {
type: Boolean,
Expand All @@ -181,7 +181,7 @@
type: Boolean,
required: false,
},
isCheckBoxVisible: {
isSelectable: {
type: Boolean,
required: false,
default: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>

<div>
<QuestionsAccordion
:questions="questions"
:getQuestionContent="() => contentNode"
:isSelectable="false"
/>
</div>

</template>


<script>
import QuestionsAccordion from '../../../../../../common/QuestionsAccordion.vue';
export default {
name: 'PreviewExercise',
components: {
QuestionsAccordion,
},
props: {
contentNode: {
type: Object,
required: true,
},
questions: {
type: Array,
required: true,
},
},
};
</script>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
</KLabeledIcon>
</h2>

<PreviewSelectedExercise
<PreviewExercise
v-if="isExercise"
:contentNode="contentNode"
:questions="exerciseQuestions"
/>

<PreviewContent
Expand All @@ -75,13 +76,13 @@
import { PageNames } from '../../../../../../../constants/index';
import ResourceSelectionBreadcrumbs from '../../../../../LessonResourceSelectionPage/SearchTools/ResourceSelectionBreadcrumbs.vue';
import PreviewContent from './PreviewContent';
import PreviewSelectedExercise from './PreviewSelectedExercise.vue';
import PreviewExercise from './PreviewExercise.vue';
export default {
name: 'PreviewSelectedResources',
components: {
PreviewContent,
PreviewSelectedExercise,
PreviewExercise,
ResourceSelectionBreadcrumbs,
LearningActivityIcon,
},
Expand All @@ -91,7 +92,9 @@
const instance = getCurrentInstance();
const { addText$, addedIndicator$ } = searchAndFilterStrings;
const { contentNode, ancestors, questions, loading } = useFetchContentNode(props.contentId);
const { contentNode, ancestors, questions, loading, exerciseQuestions } = useFetchContentNode(
props.contentId,
);
const { manageLessonResourcesTitle$ } = coachStrings;
props.setTitle(manageLessonResourcesTitle$());
Expand All @@ -111,6 +114,7 @@
ancestors,
questions,
loading,
exerciseQuestions,
routeBack,
// eslint-disable-next-line vue/no-unused-properties
previousRoute,
Expand Down

0 comments on commit 36157e7

Please sign in to comment.