diff --git a/frontend/src/App.vue b/frontend/src/App.vue index d890f55a..c79397af 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -24,7 +24,7 @@ const router = useRouter() const noSidebar = ref(false) router.beforeEach((to, from, next) => { - if (to.query.fromLesson) { + if (to.query.fromLesson || to.path === '/persona') { noSidebar.value = true } else { noSidebar.value = false diff --git a/frontend/src/components/AppSidebar.vue b/frontend/src/components/AppSidebar.vue index 50c4f318..0dcc59f0 100644 --- a/frontend/src/components/AppSidebar.vue +++ b/frontend/src/components/AppSidebar.vue @@ -76,7 +76,7 @@ />
{ + identifyUserPersona() setFiltersFromQuery() updateCourses() categories.value = [ @@ -145,16 +148,34 @@ const courses = createListResource({ pageLength: pageLength.value, start: start.value, onSuccess(data) { - let allCategories = data.map((course) => course.category) - allCategories = allCategories.filter( - (category, index) => allCategories.indexOf(category) === index && category - ) - if (categories.value.length <= allCategories.length) { - updateCategories(data) - } + setCategories(data) }, }) +const setCategories = (data) => { + let allCategories = data.map((course) => course.category) + allCategories = allCategories.filter( + (category, index) => allCategories.indexOf(category) === index && category + ) + if (categories.value.length <= allCategories.length) { + updateCategories(data) + } +} + +const identifyUserPersona = () => { + if (user.data?.is_system_manager) { + call('frappe.client.get_count', { + doctype: 'LMS Course', + }).then((data) => { + if (!data) { + router.push({ + name: 'PersonaForm', + }) + } + }) + } +} + const updateCourses = () => { updateFilters() courses.update({ diff --git a/frontend/src/pages/PersonaForm.vue b/frontend/src/pages/PersonaForm.vue new file mode 100644 index 00000000..c2300d4d --- /dev/null +++ b/frontend/src/pages/PersonaForm.vue @@ -0,0 +1,176 @@ + + diff --git a/frontend/src/router.js b/frontend/src/router.js index 7eba6f7a..fb04cc7d 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -210,6 +210,11 @@ const routes = [ name: 'AssignmentSubmissionList', component: () => import('@/pages/AssignmentSubmissionList.vue'), }, + { + path: '/persona', + name: 'PersonaForm', + component: () => import('@/pages/PersonaForm.vue'), + }, ] let router = createRouter({ diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 4be6085e..16881bc4 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -25,7 +25,7 @@ export default defineConfig({ }), ], server: { - allowedHosts: ['fs', 'bs'], + allowedHosts: ['fs', 'persona'], }, resolve: { alias: { diff --git a/lms/lms/api.py b/lms/lms/api.py index cc8f7df0..229e9281 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -2,6 +2,7 @@ """ import json +import requests import frappe import zipfile import os @@ -1389,3 +1390,21 @@ def add_an_evaluator(email): evaluator.insert() return evaluator + + +@frappe.whitelist() +def capture_user_persona(site, role, number_of_students, use_case, frappe_products): + requests.post( + "https://school.frappe.io/api/method/capture_persona", + json={ + "site": site, + "role": role, + "number_of_students": number_of_students, + "use_case": use_case, + "frappe_products": frappe_products, + }, + headers={ + "Authorization": f"token {frappe.local.conf.frappe_token}", + "Content-Type": "application/json", + }, + )