|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import { createRouter, createWebHistory } from "vue-router" |
|
|
|
|
import {createRouter, createWebHistory} from "vue-router" |
|
|
|
|
import adminRoutes from "./admin" |
|
|
|
|
import courseRoutes from "./course" |
|
|
|
|
import accountRoutes from "./account" |
|
|
|
@ -20,8 +20,7 @@ import documents from "./documents" |
|
|
|
|
import assignments from "./assignments" |
|
|
|
|
import links from "./links" |
|
|
|
|
import glossary from "./glossary" |
|
|
|
|
import { useSecurityStore } from "../store/securityStore" |
|
|
|
|
import securityService from "../services/securityService" |
|
|
|
|
import {useSecurityStore} from "../store/securityStore" |
|
|
|
|
import MyCourseList from "../views/user/courses/List.vue" |
|
|
|
|
import MySessionList from "../views/user/sessions/SessionsCurrent.vue" |
|
|
|
|
import MySessionListPast from "../views/user/sessions/SessionsPast.vue" |
|
|
|
@ -38,12 +37,14 @@ import Login from "../pages/Login.vue" |
|
|
|
|
import Faq from "../pages/Faq.vue" |
|
|
|
|
import Demo from "../pages/Demo.vue" |
|
|
|
|
|
|
|
|
|
import { useCidReqStore } from "../store/cidReq" |
|
|
|
|
import {useCidReqStore} from "../store/cidReq" |
|
|
|
|
import courseService from "../services/courseService" |
|
|
|
|
|
|
|
|
|
import catalogueCourses from "./cataloguecourses" |
|
|
|
|
import catalogueSessions from "./cataloguesessions" |
|
|
|
|
import { customVueTemplateEnabled } from "../config/env" |
|
|
|
|
import {customVueTemplateEnabled} from "../config/env" |
|
|
|
|
import {useCourseSettings} from "../store/courseSettingStore"; |
|
|
|
|
import {checkIsAllowedToEdit} from "../composables/userPermissions"; |
|
|
|
|
|
|
|
|
|
const router = createRouter({ |
|
|
|
|
history: createWebHistory(), |
|
|
|
@ -97,13 +98,42 @@ const router = createRouter({ |
|
|
|
|
name: "CourseHome", |
|
|
|
|
component: CourseHome, |
|
|
|
|
beforeEnter: async (to) => { |
|
|
|
|
const check = await courseService.checkLegal(to.params.id, to.query?.sid) |
|
|
|
|
|
|
|
|
|
if (check.redirect) { |
|
|
|
|
window.location.href = check.url |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
const courseId = to.params.id |
|
|
|
|
const sessionId = to.query?.sid |
|
|
|
|
try { |
|
|
|
|
const check = await courseService.checkLegal(courseId, sessionId) |
|
|
|
|
if (check.redirect) { |
|
|
|
|
window.location.href = check.url |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const course = await courseService.getCourseDetails(courseId) |
|
|
|
|
if (!course) { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const isAllowedToEdit = await checkIsAllowedToEdit(true, true, true) |
|
|
|
|
if (isAllowedToEdit) { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const courseSettingsStore = useCourseSettings() |
|
|
|
|
await courseSettingsStore.loadCourseSettings(courseId, sessionId) |
|
|
|
|
const documentAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_document_auto_launch"), 10) || 0 |
|
|
|
|
if (documentAutoLaunch === 1 && course.resourceNode?.id) { |
|
|
|
|
window.location.href = `/resources/document/${course.resourceNode.id}/?cid=${courseId}` |
|
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
|
return false |
|
|
|
|
} else { |
|
|
|
|
console.log("Document auto launch is disabled or resourceNode ID is missing.") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("Error during CourseHome route guard:", error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|