Rename composable to useCourseData

This commit is contained in:
Daniel Egger 2023-10-14 16:06:16 +02:00
parent 00357ad4f3
commit 0c40bb9341
21 changed files with 45 additions and 45 deletions

View File

@ -2,7 +2,7 @@
import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue"; import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue";
import { calculateCircleSectorData } from "@/pages/learningPath/learningPathPage/utils"; import { calculateCircleSectorData } from "@/pages/learningPath/learningPathPage/utils";
import { computed } from "vue"; import { computed } from "vue";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
export type DiagramType = "horizontal" | "horizontalSmall" | "singleSmall"; export type DiagramType = "horizontal" | "horizontalSmall" | "singleSmall";
@ -20,7 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
userId: undefined, userId: undefined,
}); });
const lpQueryResult = useLearningPathWithCompletion( const lpQueryResult = useCourseDataWithCompletion(
props.courseSlug, props.courseSlug,
props.userId, props.userId,
props.courseSessionId props.courseSessionId

View File

@ -146,7 +146,7 @@ export function flatCircles(learningPath: LearningPathType) {
return learningPath.topics.flatMap((t) => t.circles); return learningPath.topics.flatMap((t) => t.circles);
} }
export function useLearningPath(courseSlug: string) { export function useCourseData(courseSlug: string) {
const learningPath = ref<LearningPathType | undefined>(undefined); const learningPath = ref<LearningPathType | undefined>(undefined);
const actionCompetences = ref<ActionCompetence[]>([]); const actionCompetences = ref<ActionCompetence[]>([]);
const course = ref<Course | undefined>(undefined); const course = ref<Course | undefined>(undefined);
@ -278,7 +278,7 @@ export function useLearningPath(courseSlug: string) {
}; };
} }
export function useLearningPathWithCompletion( export function useCourseDataWithCompletion(
courseSlug?: string, courseSlug?: string,
userId?: string, userId?: string,
courseSessionId?: string courseSessionId?: string
@ -293,7 +293,7 @@ export function useLearningPathWithCompletion(
courseSessionId = useCurrentCourseSession().value.id; courseSessionId = useCurrentCourseSession().value.id;
} }
const courseResult = useLearningPath(courseSlug); const courseResult = useCourseData(courseSlug);
const completionStore = useCompletionStore(); const completionStore = useCompletionStore();
const nextLearningContent = ref<LearningContentWithCompletion | undefined>(undefined); const nextLearningContent = ref<LearningContentWithCompletion | undefined>(undefined);
const loaded = ref(false); const loaded = ref(false);

View File

@ -5,7 +5,7 @@ import { useTranslation } from "i18next-vue";
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue"; import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
import type { DueDate } from "@/types"; import type { DueDate } from "@/types";
import DueDatesList from "@/components/dueDates/DueDatesList.vue"; import DueDatesList from "@/components/dueDates/DueDatesList.vue";
import { useLearningPath } from "@/composables"; import { useCourseData } from "@/composables";
const { t } = useTranslation(); const { t } = useTranslation();
@ -61,7 +61,7 @@ const selectedCircle = ref<Item>(circles.value[0]);
async function loadCircleValues() { async function loadCircleValues() {
if (selectedCourse.value) { if (selectedCourse.value) {
const learningPathQuery = useLearningPath(selectedCourse.value.slug); const learningPathQuery = useCourseData(selectedCourse.value.slug);
await learningPathQuery.resultPromise; await learningPathQuery.resultPromise;
circles.value = [ circles.value = [
initialItemCircle, initialItemCircle,

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { import {
useCourseSessionDetailQuery, useCourseSessionDetailQuery,
useLearningPathWithCompletion, useCourseDataWithCompletion,
} from "@/composables"; } from "@/composables";
import { useCockpitStore } from "@/stores/cockpit"; import { useCockpitStore } from "@/stores/cockpit";
import * as log from "loglevel"; import * as log from "loglevel";
@ -28,7 +28,7 @@ onMounted(async () => {
courseSessionDetailResult.findCurrentUser() courseSessionDetailResult.findCurrentUser()
); );
const userDataPromises = courseSessionDetailResult.filterMembers().map((m) => { const userDataPromises = courseSessionDetailResult.filterMembers().map((m) => {
const completionData = useLearningPathWithCompletion(props.courseSlug, m.id); const completionData = useCourseDataWithCompletion(props.courseSlug, m.id);
return completionData.resultPromise; return completionData.resultPromise;
}); });
await Promise.all(userDataPromises); await Promise.all(userDataPromises);

View File

@ -6,7 +6,7 @@ import CompetenceDetail from "@/pages/competence/ActionCompetenceDetail.vue";
import LearningPathPathView from "@/pages/learningPath/learningPathPage/LearningPathPathView.vue"; import LearningPathPathView from "@/pages/learningPath/learningPathPage/LearningPathPathView.vue";
import { import {
useCourseSessionDetailQuery, useCourseSessionDetailQuery,
useLearningPathWithCompletion, useCourseDataWithCompletion,
} from "@/composables"; } from "@/composables";
const props = defineProps<{ const props = defineProps<{
@ -16,7 +16,7 @@ const props = defineProps<{
log.debug("CockpitUserProfilePage created", props.userId); log.debug("CockpitUserProfilePage created", props.userId);
const courseCompletionData = useLearningPathWithCompletion( const courseCompletionData = useCourseDataWithCompletion(
props.courseSlug, props.courseSlug,
props.userId props.userId
); );
@ -25,7 +25,7 @@ onMounted(async () => {
log.debug("CockpitUserProfilePage mounted"); log.debug("CockpitUserProfilePage mounted");
}); });
const lpQueryResult = useLearningPathWithCompletion(props.courseSlug, props.userId); const lpQueryResult = useCourseDataWithCompletion(props.courseSlug, props.userId);
const learningPath = computed(() => { const learningPath = computed(() => {
return lpQueryResult.learningPath.value; return lpQueryResult.learningPath.value;

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useCurrentCourseSession, useLearningPath } from "@/composables"; import { useCurrentCourseSession, useCourseData } from "@/composables";
import AssignmentDetails from "@/pages/cockpit/assignmentsPage/AssignmentDetails.vue"; import AssignmentDetails from "@/pages/cockpit/assignmentsPage/AssignmentDetails.vue";
import * as log from "loglevel"; import * as log from "loglevel";
import { computed, onMounted } from "vue"; import { computed, onMounted } from "vue";
@ -18,7 +18,7 @@ onMounted(async () => {
log.debug("AssignmentsPage mounted"); log.debug("AssignmentsPage mounted");
}); });
const lpQueryResult = useLearningPath(props.courseSlug); const lpQueryResult = useCourseData(props.courseSlug);
const learningContentAssignment = computed(() => { const learningContentAssignment = computed(() => {
return lpQueryResult.findLearningContent(props.assignmentId); return lpQueryResult.findLearningContent(props.assignmentId);

View File

@ -13,7 +13,7 @@ import FeedbackSubmissionProgress from "@/pages/cockpit/cockpitPage/FeedbackSubm
import { learningContentTypeData } from "@/utils/typeMaps"; import { learningContentTypeData } from "@/utils/typeMaps";
import { import {
useCourseSessionDetailQuery, useCourseSessionDetailQuery,
useLearningPathWithCompletion, useCourseDataWithCompletion,
} from "@/composables"; } from "@/composables";
import { circleFlatLearningContents } from "@/services/circle"; import { circleFlatLearningContents } from "@/services/circle";
@ -39,7 +39,7 @@ const courseSessionDetailResult = useCourseSessionDetailQuery();
const { t } = useTranslation(); const { t } = useTranslation();
const lpQueryResult = useLearningPathWithCompletion(); const lpQueryResult = useCourseDataWithCompletion();
const submittables = computed(() => { const submittables = computed(() => {
if (!lpQueryResult.circles.value?.length) { if (!lpQueryResult.circles.value?.length) {

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
import { computed } from "vue"; import { computed } from "vue";
import { calcPerformanceCriteriaStatusCount } from "@/services/competence"; import { calcPerformanceCriteriaStatusCount } from "@/services/competence";
@ -9,7 +9,7 @@ const props = defineProps<{
circleId?: string; circleId?: string;
}>(); }>();
const courseData = useLearningPathWithCompletion(props.courseSlug, props.userId); const courseData = useCourseDataWithCompletion(props.courseSlug, props.userId);
const circleStatusCount = computed(() => { const circleStatusCount = computed(() => {
if (props.circleId) { if (props.circleId) {

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useCurrentCourseSession, useLearningPath } from "@/composables"; import { useCurrentCourseSession, useCourseData } from "@/composables";
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue"; import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
import { useCockpitStore } from "@/stores/cockpit"; import { useCockpitStore } from "@/stores/cockpit";
import ItModal from "@/components/ui/ItModal.vue"; import ItModal from "@/components/ui/ItModal.vue";
@ -20,7 +20,7 @@ import DocumentListItem from "@/components/circle/DocumentListItem.vue";
const cockpitStore = useCockpitStore(); const cockpitStore = useCockpitStore();
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const courseSessionsStore = useCourseSessionsStore(); const courseSessionsStore = useCourseSessionsStore();
const courseData = useLearningPath(courseSession.value?.course.slug); const courseData = useCourseData(courseSession.value?.course.slug);
const { t } = useTranslation(); const { t } = useTranslation();

View File

@ -2,7 +2,7 @@
import CompetenceDetail from "@/pages/competence/ActionCompetenceDetail.vue"; import CompetenceDetail from "@/pages/competence/ActionCompetenceDetail.vue";
import * as log from "loglevel"; import * as log from "loglevel";
import { ref } from "vue"; import { ref } from "vue";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
log.debug("CompetenceListPage created"); log.debug("CompetenceListPage created");
@ -10,7 +10,7 @@ const props = defineProps<{
courseSlug: string; courseSlug: string;
}>(); }>();
const courseData = useLearningPathWithCompletion(props.courseSlug); const courseData = useCourseDataWithCompletion(props.courseSlug);
const isOpenAll = ref(false); const isOpenAll = ref(false);

View File

@ -4,7 +4,7 @@ import { COMPETENCE_NAVI_CERTIFICATE_QUERY } from "@/graphql/queries";
import { useQuery } from "@urql/vue"; import { useQuery } from "@urql/vue";
import { computed } from "vue"; import { computed } from "vue";
import type { CompetenceCertificate } from "@/types"; import type { CompetenceCertificate } from "@/types";
import { useCurrentCourseSession, useLearningPathWithCompletion } from "@/composables"; import { useCurrentCourseSession, useCourseDataWithCompletion } from "@/composables";
import { import {
assignmentsMaxEvaluationPoints, assignmentsMaxEvaluationPoints,
assignmentsUserPoints, assignmentsUserPoints,
@ -20,7 +20,7 @@ const props = defineProps<{
log.debug("CompetenceIndexPage setup", props); log.debug("CompetenceIndexPage setup", props);
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const courseData = useLearningPathWithCompletion(props.courseSlug); const courseData = useCourseDataWithCompletion(props.courseSlug);
const certificatesQuery = useQuery({ const certificatesQuery = useQuery({
query: COMPETENCE_NAVI_CERTIFICATE_QUERY, query: COMPETENCE_NAVI_CERTIFICATE_QUERY,

View File

@ -2,7 +2,7 @@
import * as log from "loglevel"; import * as log from "loglevel";
import { computed } from "vue"; import { computed } from "vue";
import _ from "lodash"; import _ from "lodash";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
const props = defineProps<{ const props = defineProps<{
courseSlug: string; courseSlug: string;
@ -10,7 +10,7 @@ const props = defineProps<{
log.debug("PerformanceCriteriaPage created", props); log.debug("PerformanceCriteriaPage created", props);
const courseCompletionData = useLearningPathWithCompletion(props.courseSlug); const courseCompletionData = useCourseDataWithCompletion(props.courseSlug);
const uniqueLearningUnits = computed(() => { const uniqueLearningUnits = computed(() => {
// FIXME: this complex calculation can go away, // FIXME: this complex calculation can go away,

View File

@ -8,7 +8,7 @@ import CircleOverview from "./CircleOverview.vue";
import DocumentSection from "./DocumentSection.vue"; import DocumentSection from "./DocumentSection.vue";
import { import {
useCourseSessionDetailQuery, useCourseSessionDetailQuery,
useLearningPathWithCompletion, useCourseDataWithCompletion,
} from "@/composables"; } from "@/composables";
import { stringifyParse } from "@/utils/utils"; import { stringifyParse } from "@/utils/utils";
import { useCircleStore } from "@/stores/circle"; import { useCircleStore } from "@/stores/circle";
@ -32,7 +32,7 @@ const props = withDefaults(defineProps<Props>(), {
log.debug("CirclePage created", stringifyParse(props)); log.debug("CirclePage created", stringifyParse(props));
const lpQueryResult = useLearningPathWithCompletion( const lpQueryResult = useCourseDataWithCompletion(
props.courseSlug, props.courseSlug,
props.profileUser?.user_id props.profileUser?.user_id
); );

View File

@ -24,7 +24,7 @@ import {
circleFlatLearningContents, circleFlatLearningContents,
someFinishedInLearningSequence, someFinishedInLearningSequence,
} from "@/services/circle"; } from "@/services/circle";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
import { findLastIndex } from "lodash"; import { findLastIndex } from "lodash";
type Props = { type Props = {
@ -40,7 +40,7 @@ const props = withDefaults(defineProps<Props>(), {
const circleStore = useCircleStore(); const circleStore = useCircleStore();
const lpQueryResult = useLearningPathWithCompletion(props.courseSlug); const lpQueryResult = useCourseDataWithCompletion(props.courseSlug);
function toggleCompleted(learningContent: LearningContentWithCompletion) { function toggleCompleted(learningContent: LearningContentWithCompletion) {
let completionStatus: CourseCompletionStatus = "SUCCESS"; let completionStatus: CourseCompletionStatus = "SUCCESS";

View File

@ -2,7 +2,7 @@
import LearningContentParent from "@/pages/learningPath/learningContentPage/LearningContentParent.vue"; import LearningContentParent from "@/pages/learningPath/learningContentPage/LearningContentParent.vue";
import * as log from "loglevel"; import * as log from "loglevel";
import { computed, getCurrentInstance, onUpdated } from "vue"; import { computed, getCurrentInstance, onUpdated } from "vue";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
import { stringifyParse } from "@/utils/utils"; import { stringifyParse } from "@/utils/utils";
const props = defineProps<{ const props = defineProps<{
@ -13,7 +13,7 @@ const props = defineProps<{
log.debug("LearningContentView created", stringifyParse(props)); log.debug("LearningContentView created", stringifyParse(props));
const courseData = useLearningPathWithCompletion(props.courseSlug); const courseData = useCourseDataWithCompletion(props.courseSlug);
const learningContent = computed(() => const learningContent = computed(() =>
courseData.findLearningContent(props.contentSlug, props.circleSlug) courseData.findLearningContent(props.contentSlug, props.circleSlug)
); );

View File

@ -22,7 +22,7 @@ import RichTextBlock from "./blocks/RichTextBlock.vue";
import VideoBlock from "./blocks/VideoBlock.vue"; import VideoBlock from "./blocks/VideoBlock.vue";
import { getPreviousRoute } from "@/router/history"; import { getPreviousRoute } from "@/router/history";
import { stringifyParse } from "@/utils/utils"; import { stringifyParse } from "@/utils/utils";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
import { useCircleStore } from "@/stores/circle"; import { useCircleStore } from "@/stores/circle";
const props = defineProps<{ const props = defineProps<{
@ -32,7 +32,7 @@ const props = defineProps<{
log.debug("LearningContentParent setup", stringifyParse(props)); log.debug("LearningContentParent setup", stringifyParse(props));
const courseCompletionData = useLearningPathWithCompletion(); const courseCompletionData = useCourseDataWithCompletion();
const circleStore = useCircleStore(); const circleStore = useCircleStore();
const previousRoute = getPreviousRoute(); const previousRoute = getPreviousRoute();

View File

@ -6,7 +6,7 @@ import ItSuccessAlert from "@/components/ui/ItSuccessAlert.vue";
import { import {
useCourseSessionDetailQuery, useCourseSessionDetailQuery,
useCurrentCourseSession, useCurrentCourseSession,
useLearningPath, useCourseData,
} from "@/composables"; } from "@/composables";
import { bustItGetCache } from "@/fetchHelpers"; import { bustItGetCache } from "@/fetchHelpers";
import { UPSERT_ASSIGNMENT_COMPLETION_MUTATION } from "@/graphql/mutations"; import { UPSERT_ASSIGNMENT_COMPLETION_MUTATION } from "@/graphql/mutations";
@ -34,7 +34,7 @@ const emit = defineEmits<{
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const courseSessionDetailResult = useCourseSessionDetailQuery(); const courseSessionDetailResult = useCourseSessionDetailQuery();
const courseData = useLearningPath(courseSession.value.course.slug); const courseData = useCourseData(courseSession.value.course.slug);
const { t } = useTranslation(); const { t } = useTranslation();
@ -142,7 +142,7 @@ const onSubmit = async () => {
data-cy="confirm-submit-person" data-cy="confirm-submit-person"
@toggle="state.confirmPerson = !state.confirmPerson" @toggle="state.confirmPerson = !state.confirmPerson"
></ItCheckbox> ></ItCheckbox>
<div class="flex flex-row items-center pb-6 pl-[49px]" v-if="circleExpert"> <div v-if="circleExpert" class="flex flex-row items-center pb-6 pl-[49px]">
<img <img
alt="Notification icon" alt="Notification icon"
class="mr-2 h-[45px] min-w-[45px] rounded-full" class="mr-2 h-[45px] min-w-[45px] rounded-full"

View File

@ -8,7 +8,7 @@ import type { ViewType } from "@/pages/learningPath/learningPathPage/LearningPat
import LearningPathViewSwitch from "@/pages/learningPath/learningPathPage/LearningPathViewSwitch.vue"; import LearningPathViewSwitch from "@/pages/learningPath/learningPathPage/LearningPathViewSwitch.vue";
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"; import { breakpointsTailwind, useBreakpoints } from "@vueuse/core";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
import { someFinishedInLearningSequence } from "@/services/circle"; import { someFinishedInLearningSequence } from "@/services/circle";
const props = defineProps<{ const props = defineProps<{
@ -23,7 +23,7 @@ const selectedView = ref<ViewType>(
(window.localStorage.getItem("learningPathView") as ViewType) || "path" (window.localStorage.getItem("learningPathView") as ViewType) || "path"
); );
const lpQueryResult = useLearningPathWithCompletion(props.courseSlug); const lpQueryResult = useCourseDataWithCompletion(props.courseSlug);
const learningPath = computed(() => lpQueryResult.learningPath.value); const learningPath = computed(() => lpQueryResult.learningPath.value);
const course = computed(() => lpQueryResult.course.value); const course = computed(() => lpQueryResult.course.value);

View File

@ -3,7 +3,7 @@ import { useCircleStore } from "@/stores/circle";
import type { CircleType, LearningUnit } from "@/types"; import type { CircleType, LearningUnit } from "@/types";
import * as log from "loglevel"; import * as log from "loglevel";
import { useCurrentCourseSession, useLearningPathWithCompletion } from "@/composables"; import { useCurrentCourseSession, useCourseDataWithCompletion } from "@/composables";
import LearningContentContainer from "@/pages/learningPath/learningContentPage/LearningContentContainer.vue"; import LearningContentContainer from "@/pages/learningPath/learningContentPage/LearningContentContainer.vue";
import LearningContentMultiLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentMultiLayout.vue"; import LearningContentMultiLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentMultiLayout.vue";
import eventBus from "@/utils/eventBus"; import eventBus from "@/utils/eventBus";
@ -16,7 +16,7 @@ log.debug("LearningContent.vue setup");
const circleStore = useCircleStore(); const circleStore = useCircleStore();
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
const courseCompletionData = useLearningPathWithCompletion(); const courseCompletionData = useCourseDataWithCompletion();
const questionIndex = useRouteQuery("step", "0", { transform: Number, mode: "push" }); const questionIndex = useRouteQuery("step", "0", { transform: Number, mode: "push" });
const previousRoute = getPreviousRoute(); const previousRoute = getPreviousRoute();

View File

@ -3,7 +3,7 @@ import * as log from "loglevel";
import SelfEvaluation from "@/pages/learningPath/selfEvaluationPage/SelfEvaluation.vue"; import SelfEvaluation from "@/pages/learningPath/selfEvaluationPage/SelfEvaluation.vue";
import { computed } from "vue"; import { computed } from "vue";
import { useLearningPathWithCompletion } from "@/composables"; import { useCourseDataWithCompletion } from "@/composables";
log.debug("LearningUnitSelfEvaluationView created"); log.debug("LearningUnitSelfEvaluationView created");
@ -13,7 +13,7 @@ const props = defineProps<{
learningUnitSlug: string; learningUnitSlug: string;
}>(); }>();
const courseData = useLearningPathWithCompletion(props.courseSlug); const courseData = useCourseDataWithCompletion(props.courseSlug);
const learningUnit = computed(() => const learningUnit = computed(() =>
courseData.findLearningUnit(props.learningUnitSlug, props.circleSlug) courseData.findLearningUnit(props.learningUnitSlug, props.circleSlug)
); );

View File

@ -1,4 +1,4 @@
import { useLearningPath } from "@/composables"; import { useCourseData } from "@/composables";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import type { CircleLight, CourseSessionUser, ExpertSessionUser } from "@/types"; import type { CircleLight, CourseSessionUser, ExpertSessionUser } from "@/types";
import log from "loglevel"; import log from "loglevel";
@ -59,7 +59,7 @@ async function courseCircles(
const userStore = useUserStore(); const userStore = useUserStore();
// Return all circles from learning path for admin users // Return all circles from learning path for admin users
if (userStore.is_superuser) { if (userStore.is_superuser) {
const lpQueryResult = useLearningPath(courseSlug); const lpQueryResult = useCourseData(courseSlug);
await lpQueryResult.resultPromise; await lpQueryResult.resultPromise;
return (lpQueryResult.circles.value ?? []).map((c) => { return (lpQueryResult.circles.value ?? []).map((c) => {