You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
424 lines
11 KiB
424 lines
11 KiB
![]()
4 years ago
|
<template>
|
||
![]()
3 years ago
|
<div
|
||
![]()
3 years ago
|
v-if="isCourseLoading"
|
||
|
class="flex flex-col gap-4"
|
||
|
>
|
||
|
<div class="flex gap-4 items-center">
|
||
|
<Skeleton
|
||
![]()
2 years ago
|
class="mr-auto"
|
||
![]()
3 years ago
|
height="2.5rem"
|
||
|
width="12rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
![]()
2 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
3 years ago
|
height="2.5rem"
|
||
|
width="8rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
![]()
2 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
3 years ago
|
height="2.5rem"
|
||
|
width="3rem"
|
||
|
/>
|
||
|
</div>
|
||
|
|
||
|
<Skeleton
|
||
|
height="16rem"
|
||
|
/>
|
||
|
|
||
|
<div class="flex items-center gap-6">
|
||
|
<Skeleton
|
||
|
height="1.5rem"
|
||
|
width="6rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
class="ml-auto"
|
||
![]()
3 years ago
|
height="1.5rem"
|
||
|
width="6rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
class="aspect-square"
|
||
![]()
3 years ago
|
height="1.5rem"
|
||
|
width="6rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
class="aspect-square"
|
||
![]()
3 years ago
|
height="1.5rem"
|
||
|
width="6rem"
|
||
|
/>
|
||
|
<Skeleton
|
||
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
class="aspect-square"
|
||
![]()
3 years ago
|
height="1.5rem"
|
||
|
width="6rem"
|
||
|
/>
|
||
|
</div>
|
||
|
|
||
|
<hr class="mt-0 mb-4">
|
||
|
|
||
|
<div class="grid gap-y-12 sm:gap-x-5 md:gap-x-16 md:gap-y-12 justify-between grid-cols-course-tools">
|
||
|
<Skeleton
|
||
|
v-for="v in 30"
|
||
|
:key="v"
|
||
![]()
2 years ago
|
class="aspect-square"
|
||
![]()
3 years ago
|
height="auto"
|
||
|
width="7.5rem"
|
||
|
/>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div
|
||
|
v-else
|
||
![]()
3 years ago
|
class="flex flex-col gap-4"
|
||
|
>
|
||
|
<div class="flex gap-4 items-center">
|
||
![]()
3 years ago
|
<h2
|
||
|
class="mr-auto"
|
||
|
>
|
||
![]()
4 years ago
|
{{ course.title }}
|
||
![]()
3 years ago
|
<small v-if="session">
|
||
![]()
4 years ago
|
({{ session.name }})
|
||
![]()
3 years ago
|
</small>
|
||
|
</h2>
|
||
|
|
||
![]()
2 years ago
|
<BaseButton
|
||
![]()
3 years ago
|
v-if="course && isCurrentTeacher"
|
||
![]()
2 years ago
|
type="black"
|
||
![]()
3 years ago
|
:label="t('See as student')"
|
||
![]()
2 years ago
|
icon="eye"
|
||
![]()
3 years ago
|
/>
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
<BaseButton
|
||
|
v-if="showUpdateIntroductionButton"
|
||
|
type="black"
|
||
|
:label="t('Edit introduction')"
|
||
|
icon="pencil"
|
||
|
@click="updateIntro(intro)"
|
||
|
/>
|
||
|
|
||
|
<BaseButton
|
||
![]()
3 years ago
|
v-if="course && isCurrentTeacher"
|
||
![]()
2 years ago
|
type="black"
|
||
|
popup-identifier="course-tmenu"
|
||
|
icon="cog"
|
||
|
only-icon
|
||
![]()
3 years ago
|
@click="toggleCourseTMenu"
|
||
|
/>
|
||
|
|
||
![]()
2 years ago
|
<BaseMenu
|
||
![]()
3 years ago
|
id="course-tmenu"
|
||
|
ref="courseTMenu"
|
||
|
:model="courseItems"
|
||
|
/>
|
||
![]()
4 years ago
|
</div>
|
||
![]()
4 years ago
|
|
||
![]()
3 years ago
|
<div
|
||
|
v-if="isCurrentTeacher"
|
||
![]()
4 years ago
|
>
|
||
![]()
3 years ago
|
<div
|
||
|
v-if="intro"
|
||
|
class="flex flex-col gap-4"
|
||
|
>
|
||
|
<div v-html="intro.introText" />
|
||
|
|
||
![]()
2 years ago
|
<BaseButton
|
||
![]()
3 years ago
|
v-if="createInSession && introTool"
|
||
![]()
2 years ago
|
:label="t('Course introduction')"
|
||
![]()
2 years ago
|
class="ml-auto"
|
||
|
type="primary"
|
||
|
icon="plus"
|
||
![]()
3 years ago
|
@click="addIntro(course, introTool)"
|
||
|
/>
|
||
![]()
4 years ago
|
</div>
|
||
![]()
3 years ago
|
<EmptyState
|
||
|
v-else-if="introTool"
|
||
|
:detail="t('Add a course introduction to display to your students.')"
|
||
![]()
2 years ago
|
:summary="t('You don\'t have any course content yet.')"
|
||
![]()
3 years ago
|
icon="mdi mdi-book-open-page-variant"
|
||
![]()
3 years ago
|
>
|
||
![]()
2 years ago
|
<BaseButton
|
||
![]()
2 years ago
|
:label="t('Course introduction')"
|
||
![]()
2 years ago
|
class="mt-4"
|
||
|
type="primary"
|
||
|
icon="plus"
|
||
![]()
3 years ago
|
@click="addIntro(course, introTool)"
|
||
![]()
3 years ago
|
/>
|
||
![]()
3 years ago
|
</EmptyState>
|
||
![]()
4 years ago
|
</div>
|
||
![]()
3 years ago
|
<div
|
||
|
v-else-if="intro"
|
||
|
v-html="intro.introText"
|
||
|
/>
|
||
![]()
4 years ago
|
|
||
![]()
3 years ago
|
<div class="flex items-center gap-6">
|
||
|
<h6 v-t="'Tools'" />
|
||
|
<Button
|
||
![]()
3 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
:disabled="isSorting || isCustomizing"
|
||
![]()
3 years ago
|
:label="t('Show all')"
|
||
|
class="p-button-text p-button-plain p-button-sm ml-auto"
|
||
![]()
2 years ago
|
icon="mdi mdi-eye"
|
||
![]()
3 years ago
|
@click="onClickShowAll"
|
||
![]()
3 years ago
|
/>
|
||
|
<Button
|
||
![]()
3 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
2 years ago
|
:disabled="isSorting || isCustomizing"
|
||
![]()
3 years ago
|
:label="t('Hide all')"
|
||
|
class="p-button-text p-button-plain p-button-sm"
|
||
![]()
2 years ago
|
icon="mdi mdi-eye-off"
|
||
![]()
3 years ago
|
@click="onClickHideAll"
|
||
![]()
3 years ago
|
/>
|
||
|
<ToggleButton
|
||
![]()
3 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
3 years ago
|
v-model="isSorting"
|
||
![]()
2 years ago
|
:disabled="isCustomizing"
|
||
![]()
3 years ago
|
:off-label="t('Sort')"
|
||
![]()
2 years ago
|
:on-label="t('Sort')"
|
||
![]()
3 years ago
|
class="p-button-text p-button-plain p-button-sm"
|
||
![]()
2 years ago
|
off-icon="mdi mdi-swap-vertical"
|
||
|
on-icon="mdi mdi-swap-vertical"
|
||
![]()
3 years ago
|
/>
|
||
|
<ToggleButton
|
||
![]()
3 years ago
|
v-if="isCurrentTeacher"
|
||
![]()
3 years ago
|
v-model="isCustomizing"
|
||
![]()
2 years ago
|
:disabled="isSorting"
|
||
![]()
3 years ago
|
:off-label="t('Customize')"
|
||
![]()
2 years ago
|
:on-label="t('Customize')"
|
||
![]()
3 years ago
|
class="p-button-text p-button-plain p-button-sm"
|
||
![]()
2 years ago
|
off-icon="mdi mdi-format-paint"
|
||
|
on-icon="mdi mdi-format-paint"
|
||
![]()
3 years ago
|
/>
|
||
|
</div>
|
||
![]()
3 years ago
|
<hr class="mt-0 mb-4">
|
||
|
|
||
![]()
3 years ago
|
<div class="grid gap-y-12 sm:gap-x-5 md:gap-x-16 md:gap-y-12 grid-cols-course-tools">
|
||
![]()
4 years ago
|
<CourseToolList
|
||
![]()
3 years ago
|
v-for="(tool, index) in tools.authoring"
|
||
|
:key="index"
|
||
![]()
3 years ago
|
:change-visibility="changeVisibility"
|
||
|
:course="course"
|
||
|
:go-to-course-tool="goToCourseTool"
|
||
|
:go-to-setting-course-tool="goToSettingCourseTool"
|
||
|
:tool="tool"
|
||
![]()
4 years ago
|
/>
|
||
![]()
4 years ago
|
|
||
|
<CourseToolList
|
||
![]()
3 years ago
|
v-for="(tool, index) in tools.interaction"
|
||
|
:key="index"
|
||
![]()
3 years ago
|
:change-visibility="changeVisibility"
|
||
|
:course="course"
|
||
|
:go-to-course-tool="goToCourseTool"
|
||
|
:go-to-setting-course-tool="goToSettingCourseTool"
|
||
|
:tool="tool"
|
||
![]()
4 years ago
|
/>
|
||
|
|
||
![]()
4 years ago
|
<CourseToolList
|
||
![]()
3 years ago
|
v-for="(tool, index) in tools.plugin"
|
||
|
:key="index"
|
||
![]()
3 years ago
|
:change-visibility="changeVisibility"
|
||
|
:course="course"
|
||
|
:go-to-course-tool="goToCourseTool"
|
||
|
:go-to-setting-course-tool="goToSettingCourseTool"
|
||
|
:tool="tool"
|
||
![]()
4 years ago
|
/>
|
||
|
|
||
![]()
4 years ago
|
<ShortCutList
|
||
![]()
3 years ago
|
v-for="(shortcut, index) in shortcuts"
|
||
|
:key="index"
|
||
![]()
3 years ago
|
:change-visibility="changeVisibility"
|
||
|
:go-to-short-cut="goToShortCut"
|
||
|
:shortcut="shortcut"
|
||
![]()
4 years ago
|
/>
|
||
![]()
4 years ago
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
![]()
3 years ago
|
<script setup>
|
||
![]()
2 years ago
|
import { computed, provide, ref } from "vue";
|
||
|
import { useStore } from "vuex";
|
||
|
import { useRoute, useRouter } from "vue-router";
|
||
|
import { useI18n } from "vue-i18n";
|
||
|
import axios from "axios";
|
||
|
import { ENTRYPOINT } from "../../config/entrypoint";
|
||
|
import Button from "primevue/button";
|
||
|
import ToggleButton from "primevue/togglebutton";
|
||
|
import CourseToolList from "../../components/course/CourseToolList.vue";
|
||
|
import ShortCutList from "../../components/course/ShortCutList.vue";
|
||
|
import translateHtml from "../../../js/translatehtml.js";
|
||
|
import EmptyState from "../../components/EmptyState";
|
||
|
import Skeleton from "primevue/skeleton";
|
||
![]()
2 years ago
|
import BaseButton from "../../components/basecomponents/BaseButton.vue";
|
||
|
import BaseMenu from "../../components/basecomponents/BaseMenu.vue";
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
const route = useRoute();
|
||
|
const store = useStore();
|
||
|
const router = useRouter();
|
||
|
const { t } = useI18n();
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
const course = ref(null);
|
||
|
const session = ref(null);
|
||
|
const tools = ref({});
|
||
![]()
3 years ago
|
const shortcuts = ref([]);
|
||
|
const intro = ref(null);
|
||
|
const introTool = ref(null);
|
||
|
const createInSession = ref(false);
|
||
|
|
||
|
let courseId = route.params.id;
|
||
|
let sessionId = route.query.sid ?? 0;
|
||
|
|
||
![]()
3 years ago
|
const isCourseLoading = ref(true);
|
||
|
|
||
![]()
2 years ago
|
const showUpdateIntroductionButton = computed(() => {
|
||
|
return course.value && isCurrentTeacher.value && intro.value && !(createInSession.value && introTool.value)
|
||
|
})
|
||
![]()
2 years ago
|
const isCurrentTeacher = computed(() => store.getters["security/isCurrentTeacher"]);
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
const isSorting = ref(false);
|
||
|
const isCustomizing = ref(false);
|
||
|
|
||
![]()
2 years ago
|
provide("isSorting", isSorting);
|
||
|
provide("isCustomizing", isCustomizing);
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
// Remove the course session state.
|
||
![]()
2 years ago
|
store.dispatch("session/cleanSession");
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
const courseItems = ref([]);
|
||
|
|
||
|
axios
|
||
|
.get(ENTRYPOINT + `../course/${courseId}/home.json?sid=${sessionId}`)
|
||
![]()
2 years ago
|
.then(({ data }) => {
|
||
![]()
3 years ago
|
course.value = data.course;
|
||
|
session.value = data.session;
|
||
|
tools.value = data.tools;
|
||
|
shortcuts.value = data.shortcuts;
|
||
|
|
||
|
if (tools.value.admin) {
|
||
|
courseItems.value = tools.value.admin.map(tool => ({
|
||
|
label: tool.tool.nameToShow,
|
||
|
url: goToCourseTool(course, tool)
|
||
|
}));
|
||
|
}
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
getIntro();
|
||
![]()
3 years ago
|
|
||
|
isCourseLoading.value = false;
|
||
![]()
3 years ago
|
})
|
||
|
.catch(error => console.log(error));
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
const courseTMenu = ref(null);
|
||
![]()
3 years ago
|
|
||
|
const toggleCourseTMenu = event => {
|
||
|
courseTMenu.value.toggle(event);
|
||
![]()
2 years ago
|
};
|
||
![]()
3 years ago
|
|
||
![]()
2 years ago
|
async function getIntro() {
|
||
![]()
3 years ago
|
// Searching for the CTool called 'course_homepage'.
|
||
![]()
2 years ago
|
let currentIntroTool = course.value.tools.find(element => element.name === "course_homepage");
|
||
![]()
3 years ago
|
|
||
![]()
3 years ago
|
if (!introTool.value) {
|
||
![]()
3 years ago
|
introTool.value = currentIntroTool;
|
||
|
|
||
![]()
3 years ago
|
if (sessionId) {
|
||
|
createInSession.value = true;
|
||
|
}
|
||
|
|
||
![]()
3 years ago
|
// Search CToolIntro for this
|
||
|
const filter = {
|
||
|
courseTool: currentIntroTool.iid,
|
||
|
cid: courseId,
|
||
![]()
2 years ago
|
sid: sessionId
|
||
![]()
3 years ago
|
};
|
||
|
|
||
![]()
3 years ago
|
try {
|
||
![]()
2 years ago
|
const response = await store.dispatch("ctoolintro/findAll", filter);
|
||
![]()
3 years ago
|
if (response) {
|
||
|
if (sessionId) {
|
||
|
createInSession.value = false;
|
||
![]()
4 years ago
|
}
|
||
![]()
3 years ago
|
// first item
|
||
|
intro.value = response[0];
|
||
|
translateHtml();
|
||
|
}
|
||
|
} catch (e) {
|
||
|
console.error(e);
|
||
|
}
|
||
![]()
3 years ago
|
}
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
function addIntro(course, introTool) {
|
||
![]()
3 years ago
|
return router.push({
|
||
![]()
2 years ago
|
name: "ToolIntroCreate",
|
||
|
params: { "courseTool": introTool.iid },
|
||
![]()
3 years ago
|
query: {
|
||
![]()
2 years ago
|
"cid": courseId,
|
||
|
"sid": sessionId,
|
||
|
"parentResourceNodeId": course.resourceNode.id
|
||
![]()
4 years ago
|
}
|
||
![]()
3 years ago
|
});
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
function updateIntro(intro) {
|
||
![]()
3 years ago
|
return router.push({
|
||
![]()
2 years ago
|
name: "ToolIntroUpdate",
|
||
|
params: { "id": intro["@id"] },
|
||
![]()
3 years ago
|
query: {
|
||
![]()
2 years ago
|
"cid": courseId,
|
||
|
"sid": sessionId,
|
||
|
"id": intro["@id"]
|
||
![]()
4 years ago
|
}
|
||
![]()
3 years ago
|
});
|
||
|
}
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
function goToSettingCourseTool(course, tool) {
|
||
|
return "/course/" + courseId + "/settings/" + tool.tool.name + "?sid=" + sessionId;
|
||
![]()
3 years ago
|
}
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
function goToCourseTool(course, tool) {
|
||
|
return "/course/" + courseId + "/tool/" + tool.tool.name + "?sid=" + sessionId;
|
||
![]()
3 years ago
|
}
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
function goToShortCut(shortcut) {
|
||
|
const url = new URLSearchParams("?");
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
url.append("cid", courseId);
|
||
|
url.append("sid", sessionId);
|
||
![]()
4 years ago
|
|
||
![]()
2 years ago
|
return shortcut.url + "?" + url;
|
||
![]()
3 years ago
|
}
|
||
![]()
4 years ago
|
|
||
![]()
3 years ago
|
const setToolVisibility = (tool, visibility) => {
|
||
|
tool.ctool.resourceNode.resourceLinks[0].visibility = visibility;
|
||
|
};
|
||
|
|
||
![]()
2 years ago
|
function changeVisibility(course, tool) {
|
||
|
axios.post(ENTRYPOINT + "../r/course_tool/links/" + tool.ctool.resourceNode.id + "/change_visibility")
|
||
![]()
3 years ago
|
.then(response => setToolVisibility(tool, response.data.visibility))
|
||
|
.catch(error => console.log(error));
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
function onClickShowAll() {
|
||
![]()
3 years ago
|
axios.post(ENTRYPOINT + `../r/course_tool/links/change_visibility/show?cid=${courseId}&sid=${sessionId}`)
|
||
|
.then(() => {
|
||
![]()
2 years ago
|
tools.value.authoring.forEach(tool => setToolVisibility(tool, 2));
|
||
![]()
3 years ago
|
|
||
![]()
2 years ago
|
tools.value.interaction.forEach(tool => setToolVisibility(tool, 2));
|
||
![]()
3 years ago
|
|
||
![]()
2 years ago
|
tools.value.plugin.forEach(tool => setToolVisibility(tool, 2));
|
||
![]()
3 years ago
|
})
|
||
|
.catch(error => console.log(error));
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
function onClickHideAll() {
|
||
![]()
3 years ago
|
axios.post(ENTRYPOINT + `../r/course_tool/links/change_visibility/hide?cid=${courseId}&sid=${sessionId}`)
|
||
|
.then(() => {
|
||
![]()
2 years ago
|
tools.value.authoring.forEach(tool => setToolVisibility(tool, 0));
|
||
![]()
3 years ago
|
|
||
![]()
2 years ago
|
tools.value.interaction.forEach(tool => setToolVisibility(tool, 0));
|
||
![]()
3 years ago
|
|
||
![]()
2 years ago
|
tools.value.plugin.forEach(tool => setToolVisibility(tool, 0));
|
||
![]()
3 years ago
|
})
|
||
|
.catch(error => console.log(error));
|
||
![]()
3 years ago
|
}
|
||
![]()
4 years ago
|
</script>
|