|
|
@ -101,6 +101,13 @@ const router = createRouter({ |
|
|
|
beforeEnter: async (to) => { |
|
|
|
beforeEnter: async (to) => { |
|
|
|
const courseId = to.params.id |
|
|
|
const courseId = to.params.id |
|
|
|
const sessionId = to.query?.sid |
|
|
|
const sessionId = to.query?.sid |
|
|
|
|
|
|
|
const autoLaunchKey = `course_autolaunch_${courseId}` |
|
|
|
|
|
|
|
const hasAutoLaunched = sessionStorage.getItem(autoLaunchKey) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hasAutoLaunched === "true") { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const check = await courseService.checkLegal(courseId, sessionId) |
|
|
|
const check = await courseService.checkLegal(courseId, sessionId) |
|
|
|
if (check.redirect) { |
|
|
|
if (check.redirect) { |
|
|
@ -125,6 +132,7 @@ const router = createRouter({ |
|
|
|
// Document auto-launch
|
|
|
|
// Document auto-launch
|
|
|
|
const documentAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_document_auto_launch"), 10) || 0 |
|
|
|
const documentAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_document_auto_launch"), 10) || 0 |
|
|
|
if (documentAutoLaunch === 1 && course.resourceNode?.id) { |
|
|
|
if (documentAutoLaunch === 1 && course.resourceNode?.id) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/resources/document/${course.resourceNode.id}/?cid=${courseId}` |
|
|
|
window.location.href = `/resources/document/${course.resourceNode.id}/?cid=${courseId}` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
@ -136,12 +144,14 @@ const router = createRouter({ |
|
|
|
if (isExerciseAutoLaunchEnabled) { |
|
|
|
if (isExerciseAutoLaunchEnabled) { |
|
|
|
const exerciseAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_exercise_auto_launch"), 10) || 0 |
|
|
|
const exerciseAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_exercise_auto_launch"), 10) || 0 |
|
|
|
if (exerciseAutoLaunch === 2) { |
|
|
|
if (exerciseAutoLaunch === 2) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/main/exercise/exercise.php?cid=${courseId}` |
|
|
|
window.location.href = `/main/exercise/exercise.php?cid=${courseId}` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
|
} else if (exerciseAutoLaunch === 1) { |
|
|
|
} else if (exerciseAutoLaunch === 1) { |
|
|
|
const exerciseId = await courseService.getAutoLaunchExerciseId(courseId, sessionId) |
|
|
|
const exerciseId = await courseService.getAutoLaunchExerciseId(courseId, sessionId) |
|
|
|
if (exerciseId) { |
|
|
|
if (exerciseId) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}` |
|
|
|
window.location.href = `/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
@ -152,12 +162,14 @@ const router = createRouter({ |
|
|
|
// Learning path auto-launch
|
|
|
|
// Learning path auto-launch
|
|
|
|
const lpAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_lp_auto_launch"), 10) || 0 |
|
|
|
const lpAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_lp_auto_launch"), 10) || 0 |
|
|
|
if (lpAutoLaunch === 2) { |
|
|
|
if (lpAutoLaunch === 2) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/main/lp/lp_controller.php?cid=${courseId}` |
|
|
|
window.location.href = `/main/lp/lp_controller.php?cid=${courseId}` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
|
} else if (lpAutoLaunch === 1) { |
|
|
|
} else if (lpAutoLaunch === 1) { |
|
|
|
const lpId = await courseService.getAutoLaunchLPId(courseId, sessionId) |
|
|
|
const lpId = await courseService.getAutoLaunchLPId(courseId, sessionId) |
|
|
|
if (lpId) { |
|
|
|
if (lpId) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/main/lp/lp_controller.php?lp_id=${lpId}&cid=${courseId}&action=view&isStudentView=true` |
|
|
|
window.location.href = `/main/lp/lp_controller.php?lp_id=${lpId}&cid=${courseId}&action=view&isStudentView=true` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
@ -167,6 +179,7 @@ const router = createRouter({ |
|
|
|
// Forum auto-launch
|
|
|
|
// Forum auto-launch
|
|
|
|
const forumAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_forum_auto_launch"), 10) || 0 |
|
|
|
const forumAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_forum_auto_launch"), 10) || 0 |
|
|
|
if (forumAutoLaunch === 1) { |
|
|
|
if (forumAutoLaunch === 1) { |
|
|
|
|
|
|
|
sessionStorage.setItem(autoLaunchKey, "true") |
|
|
|
window.location.href = `/main/forum/index.php?cid=${courseId}` |
|
|
|
window.location.href = `/main/forum/index.php?cid=${courseId}` |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
+ (sessionId ? `&sid=${sessionId}` : '') |
|
|
|
return false |
|
|
|
return false |
|
|
@ -244,6 +257,10 @@ const router = createRouter({ |
|
|
|
router.beforeEach(async (to, from, next) => { |
|
|
|
router.beforeEach(async (to, from, next) => { |
|
|
|
const securityStore = useSecurityStore() |
|
|
|
const securityStore = useSecurityStore() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!securityStore.isAuthenticated) { |
|
|
|
|
|
|
|
sessionStorage.clear() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (to.matched.some((record) => record.meta.requiresAuth)) { |
|
|
|
if (to.matched.some((record) => record.meta.requiresAuth)) { |
|
|
|
if (!securityStore.isLoading) { |
|
|
|
if (!securityStore.isLoading) { |
|
|
|
await securityStore.checkSession() |
|
|
|
await securityStore.checkSession() |
|
|
@ -252,6 +269,7 @@ router.beforeEach(async (to, from, next) => { |
|
|
|
if (securityStore.isAuthenticated) { |
|
|
|
if (securityStore.isAuthenticated) { |
|
|
|
next() |
|
|
|
next() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
sessionStorage.clear() |
|
|
|
next({ |
|
|
|
next({ |
|
|
|
path: "/login", |
|
|
|
path: "/login", |
|
|
|
query: { redirect: to.fullPath }, |
|
|
|
query: { redirect: to.fullPath }, |
|
|
|