Skip to content

Commit

Permalink
Minor: Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Nov 27, 2024
1 parent 45498fe commit 0abb3e1
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions assets/vue/router/index.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -37,15 +37,15 @@ 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 {useCourseSettings} from "../store/courseSettingStore"
import {checkIsAllowedToEdit, useUserSessionSubscription} from "../composables/userPermissions"
import {usePlatformConfig} from "../store/platformConfig"
import { customVueTemplateEnabled } from "../config/env"
import { useCourseSettings } from "../store/courseSettingStore"
import { checkIsAllowedToEdit, useUserSessionSubscription } from "../composables/userPermissions"
import { usePlatformConfig } from "../store/platformConfig"

const router = createRouter({
history: createWebHistory(),
Expand Down Expand Up @@ -133,27 +133,29 @@ const router = createRouter({
const documentAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_document_auto_launch"), 10) || 0
if (documentAutoLaunch === 1 && course.resourceNode?.id) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/resources/document/${course.resourceNode.id}/?cid=${courseId}`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href =
`/resources/document/${course.resourceNode.id}/?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "")
return false
}

// Exercise auto-launch
const platformConfigStore = usePlatformConfig()
const isExerciseAutoLaunchEnabled = "true" === platformConfigStore.getSetting("exercise.allow_exercise_auto_launch")
const isExerciseAutoLaunchEnabled =
"true" === platformConfigStore.getSetting("exercise.allow_exercise_auto_launch")
if (isExerciseAutoLaunchEnabled) {
const exerciseAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_exercise_auto_launch"), 10) || 0
if (exerciseAutoLaunch === 2) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/main/exercise/exercise.php?cid=${courseId}`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href =
`/main/exercise/exercise.php?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "")
return false
} else if (exerciseAutoLaunch === 1) {
const exerciseId = await courseService.getAutoLaunchExerciseId(courseId, sessionId)
if (exerciseId) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href =
`/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}` +
(sessionId ? `&sid=${sessionId}` : "")
return false
}
}
Expand All @@ -163,15 +165,15 @@ const router = createRouter({
const lpAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_lp_auto_launch"), 10) || 0
if (lpAutoLaunch === 2) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/main/lp/lp_controller.php?cid=${courseId}`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href = `/main/lp/lp_controller.php?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "")
return false
} else if (lpAutoLaunch === 1) {
const lpId = await courseService.getAutoLaunchLPId(courseId, sessionId)
if (lpId) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/main/lp/lp_controller.php?lp_id=${lpId}&cid=${courseId}&action=view&isStudentView=true`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href =
`/main/lp/lp_controller.php?lp_id=${lpId}&cid=${courseId}&action=view&isStudentView=true` +
(sessionId ? `&sid=${sessionId}` : "")
return false
}
}
Expand All @@ -180,11 +182,9 @@ const router = createRouter({
const forumAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_forum_auto_launch"), 10) || 0
if (forumAutoLaunch === 1) {
sessionStorage.setItem(autoLaunchKey, "true")
window.location.href = `/main/forum/index.php?cid=${courseId}`
+ (sessionId ? `&sid=${sessionId}` : '')
window.location.href = `/main/forum/index.php?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "")
return false
}

} catch (error) {
console.error("Error during CourseHome route guard:", error)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ router.beforeEach(async (to, from, next) => {

if (!cid) {
for (const key in sessionStorage) {
if (key.startsWith('course_autolaunch_')) {
if (key.startsWith("course_autolaunch_")) {
sessionStorage.removeItem(key)
}
}
Expand Down

0 comments on commit 0abb3e1

Please sign in to comment.