chore: identify user persona
This commit is contained in:
@@ -24,7 +24,7 @@ const router = useRouter()
|
|||||||
const noSidebar = ref(false)
|
const noSidebar = ref(false)
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (to.query.fromLesson) {
|
if (to.query.fromLesson || to.path === '/persona') {
|
||||||
noSidebar.value = true
|
noSidebar.value = true
|
||||||
} else {
|
} else {
|
||||||
noSidebar.value = false
|
noSidebar.value = false
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex items-center"
|
class="flex items-center mt-4"
|
||||||
:class="
|
:class="
|
||||||
sidebarStore.isSidebarCollapsed ? 'flex-col space-y-3' : 'flex-row'
|
sidebarStore.isSidebarCollapsed ? 'flex-col space-y-3' : 'flex-row'
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
import {
|
import {
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Button,
|
Button,
|
||||||
|
call,
|
||||||
createListResource,
|
createListResource,
|
||||||
FormControl,
|
FormControl,
|
||||||
Select,
|
Select,
|
||||||
@@ -107,6 +108,7 @@ import { BookOpen, Plus } from 'lucide-vue-next'
|
|||||||
import { sessionStore } from '@/stores/session'
|
import { sessionStore } from '@/stores/session'
|
||||||
import { canCreateCourse } from '@/utils'
|
import { canCreateCourse } from '@/utils'
|
||||||
import CourseCard from '@/components/CourseCard.vue'
|
import CourseCard from '@/components/CourseCard.vue'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const dayjs = inject('$dayjs')
|
const dayjs = inject('$dayjs')
|
||||||
@@ -121,6 +123,7 @@ const currentTab = ref('Live')
|
|||||||
const { brand } = sessionStore()
|
const { brand } = sessionStore()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
identifyUserPersona()
|
||||||
setFiltersFromQuery()
|
setFiltersFromQuery()
|
||||||
updateCourses()
|
updateCourses()
|
||||||
categories.value = [
|
categories.value = [
|
||||||
@@ -145,16 +148,34 @@ const courses = createListResource({
|
|||||||
pageLength: pageLength.value,
|
pageLength: pageLength.value,
|
||||||
start: start.value,
|
start: start.value,
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
let allCategories = data.map((course) => course.category)
|
setCategories(data)
|
||||||
allCategories = allCategories.filter(
|
|
||||||
(category, index) => allCategories.indexOf(category) === index && category
|
|
||||||
)
|
|
||||||
if (categories.value.length <= allCategories.length) {
|
|
||||||
updateCategories(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 = () => {
|
const updateCourses = () => {
|
||||||
updateFilters()
|
updateFilters()
|
||||||
courses.update({
|
courses.update({
|
||||||
|
|||||||
176
frontend/src/pages/PersonaForm.vue
Normal file
176
frontend/src/pages/PersonaForm.vue
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex h-screen overflow-hidden sm:bg-gray-50">
|
||||||
|
<div class="relative z-10 mx-auto py-8 sm:w-max sm:py-32">
|
||||||
|
<div class="mx-auto flex items-center justify-center space-x-2">
|
||||||
|
<LMSLogo class="size-7" />
|
||||||
|
<span
|
||||||
|
class="select-none text-xl font-semibold tracking-tight text-gray-900"
|
||||||
|
>
|
||||||
|
Learning
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="mx-auto space-y-5 w-full h-fit bg-white px-4 py-8 sm:mt-6 sm:w-96 sm:rounded-lg sm:px-8 sm:shadow-xl"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm text-gray-700 mb-2">
|
||||||
|
{{ __('1. What best describes your role?') }}
|
||||||
|
</div>
|
||||||
|
<FormControl
|
||||||
|
v-model="persona.role"
|
||||||
|
type="select"
|
||||||
|
:options="roleOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm text-gray-700 mb-2">
|
||||||
|
{{ __('2. How many students are you planning to teach?') }}
|
||||||
|
</div>
|
||||||
|
<FormControl
|
||||||
|
v-model="persona.noOfStudents"
|
||||||
|
type="select"
|
||||||
|
:options="noOfStudentsOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm text-gray-700 mb-2">
|
||||||
|
{{ __('3. What is your main use case for Frappe Learning?') }}
|
||||||
|
</div>
|
||||||
|
<FormControl
|
||||||
|
v-model="persona.useCase"
|
||||||
|
type="select"
|
||||||
|
:options="useCaseOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div class="text-sm text-gray-700 mb-2">
|
||||||
|
{{ __('4. Are you currently using any Frappe products?') }}
|
||||||
|
</div>
|
||||||
|
<FormControl
|
||||||
|
v-model="persona.frappeProducts"
|
||||||
|
type="select"
|
||||||
|
:options="frappeProductsOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex w-full">
|
||||||
|
<Button variant="solid" class="mx-auto" @click="submitPersona()">
|
||||||
|
{{ __('Submit and Continue') }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import LMSLogo from '@/components/Icons/LMSLogo.vue'
|
||||||
|
import { Button, call, FormControl, usePageMeta } from 'frappe-ui'
|
||||||
|
import { computed, inject, reactive } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { sessionStore } from '@/stores/session'
|
||||||
|
|
||||||
|
const user = inject('$user')
|
||||||
|
const router = useRouter()
|
||||||
|
const { brand } = sessionStore()
|
||||||
|
|
||||||
|
const persona = reactive({
|
||||||
|
role: null,
|
||||||
|
noOfStudents: null,
|
||||||
|
useCase: null,
|
||||||
|
frappeProducts: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
const submitPersona = () => {
|
||||||
|
call('lms.lms.api.capture_user_persona', {
|
||||||
|
site: user.data?.sitename,
|
||||||
|
role: persona.role,
|
||||||
|
no_of_students: persona.noOfStudents,
|
||||||
|
use_case: persona.useCase,
|
||||||
|
frappe_products: persona.frappeProducts,
|
||||||
|
}).then(() => {
|
||||||
|
router.push({
|
||||||
|
name: 'Courses',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleOptions = computed(() => {
|
||||||
|
const options = [
|
||||||
|
'Trainer / Instructor',
|
||||||
|
'Freelancer / Consultant',
|
||||||
|
'HR / L&D Professional',
|
||||||
|
'School / University Admin',
|
||||||
|
'Software Developer',
|
||||||
|
'Community Manager',
|
||||||
|
'Business Owner / Team Lead',
|
||||||
|
'Other',
|
||||||
|
]
|
||||||
|
|
||||||
|
return options.map((option) => ({
|
||||||
|
label: option,
|
||||||
|
value: option,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const noOfStudentsOptions = computed(() => {
|
||||||
|
const options = [
|
||||||
|
'Less than 50',
|
||||||
|
'50-200',
|
||||||
|
'200-1000',
|
||||||
|
'1000+',
|
||||||
|
'Not sure yet',
|
||||||
|
]
|
||||||
|
|
||||||
|
return options.map((option) => ({
|
||||||
|
label: option,
|
||||||
|
value: option,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const useCaseOptions = computed(() => {
|
||||||
|
const options = [
|
||||||
|
'Teaching students in a school/university',
|
||||||
|
'Training employees in my company',
|
||||||
|
'Onboarding and educating my users/community',
|
||||||
|
'Selling courses and earning income',
|
||||||
|
'Other',
|
||||||
|
]
|
||||||
|
|
||||||
|
return options.map((option) => ({
|
||||||
|
label: option,
|
||||||
|
value: option,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const frappeProductsOptions = computed(() => {
|
||||||
|
const options = [
|
||||||
|
'Frappe Framework',
|
||||||
|
'ERPNext / Frappe HR',
|
||||||
|
'Frappe CRM / Helpdesk',
|
||||||
|
'Custom Frappe App',
|
||||||
|
'Other',
|
||||||
|
'Not using any Frappe product',
|
||||||
|
]
|
||||||
|
|
||||||
|
return options.map((option) => ({
|
||||||
|
label: option,
|
||||||
|
value: option,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
usePageMeta(() => {
|
||||||
|
return {
|
||||||
|
title: 'Persona',
|
||||||
|
icon: brand.favicon,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -210,6 +210,11 @@ const routes = [
|
|||||||
name: 'AssignmentSubmissionList',
|
name: 'AssignmentSubmissionList',
|
||||||
component: () => import('@/pages/AssignmentSubmissionList.vue'),
|
component: () => import('@/pages/AssignmentSubmissionList.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/persona',
|
||||||
|
name: 'PersonaForm',
|
||||||
|
component: () => import('@/pages/PersonaForm.vue'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
let router = createRouter({
|
let router = createRouter({
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export default defineConfig({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
allowedHosts: ['fs', 'bs'],
|
allowedHosts: ['fs', 'persona'],
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import requests
|
||||||
import frappe
|
import frappe
|
||||||
import zipfile
|
import zipfile
|
||||||
import os
|
import os
|
||||||
@@ -1389,3 +1390,21 @@ def add_an_evaluator(email):
|
|||||||
evaluator.insert()
|
evaluator.insert()
|
||||||
|
|
||||||
return evaluator
|
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",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user