mirror of
https://github.com/frappe/lms.git
synced 2026-04-19 22:52:29 +03:00
Merge pull request #2168 from raizasafeel/fix/persona
fix(persona): redirection route and skip button
This commit is contained in:
@@ -187,26 +187,6 @@ const setCategories = (data) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isPersonaCaptured = async () => {
|
||||
let persona = await call('frappe.client.get_single_value', {
|
||||
doctype: 'LMS Settings',
|
||||
field: 'persona_captured',
|
||||
})
|
||||
return persona
|
||||
}
|
||||
|
||||
const identifyUserPersona = async () => {
|
||||
if (user.data?.is_system_manager && !user.data?.developer_mode) {
|
||||
let personaCaptured = await isPersonaCaptured()
|
||||
if (personaCaptured) return
|
||||
if (!courseCount.value) {
|
||||
router.push({
|
||||
name: 'PersonaForm',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getCourseCount = () => {
|
||||
if (!user.data) return
|
||||
if (!user.data.is_moderator) return
|
||||
@@ -214,7 +194,6 @@ const getCourseCount = () => {
|
||||
doctype: 'LMS Course',
|
||||
}).then((data) => {
|
||||
courseCount.value = data
|
||||
identifyUserPersona()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,14 @@
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { call, createResource, usePageMeta } from 'frappe-ui'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { useRouter } from 'vue-router'
|
||||
import StudentHome from '@/pages/Home/StudentHome.vue'
|
||||
import AdminHome from '@/pages/Home/AdminHome.vue'
|
||||
import Streak from '@/pages/Home/Streak.vue'
|
||||
|
||||
const user = inject<any>('$user')
|
||||
const { brand } = sessionStore()
|
||||
const router = useRouter()
|
||||
const evalCount = ref(0)
|
||||
const currentTab = ref<'student' | 'instructor'>('student')
|
||||
const showStreakModal = ref(false)
|
||||
@@ -71,7 +73,29 @@ const isAdmin = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const isPersonaCaptured = async () => {
|
||||
let persona = await call('frappe.client.get_single_value', {
|
||||
doctype: 'LMS Settings',
|
||||
field: 'persona_captured',
|
||||
})
|
||||
return persona
|
||||
}
|
||||
|
||||
const identifyUserPersona = async () => {
|
||||
if (user.data?.is_system_manager && !user.data?.developer_mode) {
|
||||
let personaCaptured = await isPersonaCaptured()
|
||||
if (personaCaptured) return
|
||||
let courseCount = await call('frappe.client.get_count', {
|
||||
doctype: 'LMS Course',
|
||||
})
|
||||
if (!courseCount) {
|
||||
router.push({ name: 'PersonaForm' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
identifyUserPersona()
|
||||
if (isAdmin.value) {
|
||||
currentTab.value = 'instructor'
|
||||
} else {
|
||||
|
||||
@@ -79,7 +79,7 @@ const submitPersona = () => {
|
||||
responses: JSON.stringify(responses),
|
||||
}).then(() => {
|
||||
router.push({
|
||||
name: 'Courses',
|
||||
name: 'Home',
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -87,12 +87,12 @@ const submitPersona = () => {
|
||||
const skipPersonaForm = () => {
|
||||
call('frappe.client.set_value', {
|
||||
doctype: 'LMS Settings',
|
||||
name: null,
|
||||
name: 'LMS Settings',
|
||||
fieldname: 'persona_captured',
|
||||
value: 1,
|
||||
}).then(() => {
|
||||
router.push({
|
||||
name: 'Courses',
|
||||
name: 'Home',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user