Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion frontend/src/components/Members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ import { ref, watch, reactive, inject } from 'vue'
import { RefreshCw, Plus, X } from 'lucide-vue-next'
import { useOnboarding } from 'frappe-ui/frappe'

interface User {
data: {
email: string
name: string
enabled: boolean
user_image: string
full_name: string
user_type: ['System User', 'Website User']
username: string
is_moderator: boolean
is_system_manager: boolean
is_evaluator: boolean
is_instructor: boolean
is_fc_site: boolean
}
}

const router = useRouter()
const show = defineModel('show')
const search = ref('')
Expand All @@ -126,6 +143,7 @@ const memberList = ref([])
const hasNextPage = ref(false)
const showForm = ref(false)
const dayjs = inject('$dayjs')
const user = inject<User | null>('$user')
const { updateOnboardingStep } = useOnboarding('learning')

const member = reactive({
Expand Down Expand Up @@ -187,7 +205,9 @@ const newMember = createResource({
auto: false,
onSuccess(data) {
show.value = false
updateOnboardingStep('invite_students')

if (user?.data?.is_system_manager) updateOnboardingStep('invite_students')

router.push({
name: 'Profile',
params: {
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/Modals/BatchCourseModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</template>
<script setup>
import { Dialog, createResource } from 'frappe-ui'
import { ref } from 'vue'
import { ref, inject } from 'vue'
import Link from '@/components/Controls/Link.vue'
import { showToast } from '@/utils'
import { useOnboarding } from 'frappe-ui/frappe'
Expand All @@ -41,6 +41,7 @@ import { useSettings } from '@/stores/settings'
const show = defineModel()
const course = ref(null)
const evaluator = ref(null)
const user = inject('$user')
const courses = defineModel('courses')
const { updateOnboardingStep } = useOnboarding('learning')
const settingsStore = useSettings()
Expand Down Expand Up @@ -73,9 +74,11 @@ const addCourse = (close) => {
{},
{
onSuccess() {
courses.value.reload()
updateOnboardingStep('add_batch_course')
if (user.data?.is_system_manager)
updateOnboardingStep('add_batch_course')

close()
courses.value.reload()
course.value = null
evaluator.value = null
},
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/Modals/ChapterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ import {
FormControl,
Switch,
} from 'frappe-ui'
import { reactive, watch } from 'vue'
import { reactive, watch, inject } from 'vue'
import { showToast, getFileSize } from '@/utils/'
import { capture } from '@/telemetry'
import { FileText, X } from 'lucide-vue-next'
import { useOnboarding } from 'frappe-ui/frappe'

const show = defineModel()
const outline = defineModel('outline')
const user = inject('$user')
const { updateOnboardingStep } = useOnboarding('learning')

const props = defineProps({
Expand Down Expand Up @@ -139,8 +140,10 @@ const addChapter = async (close) => {
return validateChapter()
},
onSuccess: (data) => {
if (user.data?.is_system_manager)
updateOnboardingStep('create_first_chapter')

capture('chapter_created')
updateOnboardingStep('create_first_chapter')
chapterReference.submit(
{ name: data.name },
{
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/Modals/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
</template>
<script setup>
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
import { computed, watch, reactive, ref } from 'vue'
import { computed, watch, reactive, ref, inject } from 'vue'
import Link from '@/components/Controls/Link.vue'
import { showToast } from '@/utils'
import { useOnboarding } from 'frappe-ui/frappe'
Expand All @@ -115,6 +115,7 @@ const show = defineModel()
const quiz = defineModel('quiz')
const questionType = ref(null)
const editMode = ref(false)
const user = inject('$user')
const { updateOnboardingStep } = useOnboarding('learning')

const existingQuestion = reactive({
Expand Down Expand Up @@ -262,8 +263,10 @@ const addQuestionRow = (question, close) => {
},
{
onSuccess() {
if (user.data?.is_system_manager)
updateOnboardingStep('create_first_quiz')

show.value = false
updateOnboardingStep('create_first_quiz')
showToast(__('Success'), __('Question added successfully'), 'check')
quiz.value.reload()
close()
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/Modals/StudentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
</template>
<script setup>
import { Dialog, createResource } from 'frappe-ui'
import { ref } from 'vue'
import { ref, inject } from 'vue'
import Link from '@/components/Controls/Link.vue'
import { showToast } from '@/utils'
import { useOnboarding } from 'frappe-ui/frappe'

const students = defineModel('reloadStudents')
const student = ref()
const user = inject('$user')
const { updateOnboardingStep } = useOnboarding('learning')
const show = defineModel()

Expand Down Expand Up @@ -61,9 +62,11 @@ const addStudent = (close) => {
{},
{
onSuccess() {
if (user.data?.is_system_manager)
updateOnboardingStep('add_batch_student')

students.value.reload()
student.value = null
updateOnboardingStep('add_batch_student')
close()
},
onError(err) {
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/pages/BatchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,13 @@ const createNewBatch = () => {
{},
{
onSuccess(data) {
if (user.data?.is_system_manager) {
updateOnboardingStep('create_first_batch', true, false, () => {
localStorage.setItem('firstBatch', data.name)
})
}

capture('batch_created')
updateOnboardingStep('create_first_batch', true, false, () => {
localStorage.setItem('firstBatch', data.name)
})
router.push({
name: 'BatchDetail',
params: {
Expand Down
21 changes: 10 additions & 11 deletions frontend/src/pages/CourseForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
<div class="grid md:grid-cols-[70%,30%] h-full">
<div>
<header
class="sticky top-0 z-10 group flex flex-col md:flex-row md:items-center justify-between border-b bg-surface-white px-3 py-2.5 sm:px-5"
class="sticky top-0 z-10 flex flex-col md:flex-row md:items-center justify-between border-b bg-surface-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs class="h-7" :items="breadcrumbs" />
<div class="flex items-center mt-3 md:mt-0">
<Button
v-if="courseResource.data?.name"
@click="trashCourse()"
class="invisible group-hover:visible"
>
<Button v-if="courseResource.data?.name" @click="trashCourse()">
<template #icon>
<Trash2 class="w-4 h-4 stroke-1.5" />
</template>
Expand Down Expand Up @@ -265,7 +261,7 @@ import {
watch,
getCurrentInstance,
} from 'vue'
import { showToast, updateDocumentTitle } from '@/utils'
import { showToast } from '@/utils'
import { Image, Trash2, X } from 'lucide-vue-next'
import { useRouter } from 'vue-router'
import { capture } from '@/telemetry'
Expand Down Expand Up @@ -404,7 +400,7 @@ const courseResource = createResource({
'paid_course',
'featured',
'enable_certification',
'paid_certifiate',
'paid_certificate',
]
for (let idx in checkboxes) {
let key = checkboxes[idx]
Expand Down Expand Up @@ -447,11 +443,14 @@ const submitCourse = () => {
} else {
courseCreationResource.submit(course, {
onSuccess(data) {
if (user.data?.is_system_manager) {
updateOnboardingStep('create_first_course', true, false, () => {
localStorage.setItem('firstCourse', data.name)
})
}

capture('course_created')
showToast('Success', 'Course created successfully', 'check')
updateOnboardingStep('create_first_course', true, false, () => {
localStorage.setItem('firstCourse', data.name)
})
router.push({
name: 'CourseForm',
params: { courseName: data.name },
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/Courses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
<Breadcrumbs :items="breadcrumbs" />
<router-link
v-if="user.data?.is_moderator"
v-if="canCreateCourse()"
:to="{
name: 'CourseForm',
params: { courseName: 'new' },
Expand Down Expand Up @@ -105,6 +105,7 @@ import {
import { computed, inject, onMounted, ref, watch } from 'vue'
import { BookOpen, Plus } from 'lucide-vue-next'
import { sessionStore } from '@/stores/session'
import { canCreateCourse } from '@/utils'
import CourseCard from '@/components/CourseCard.vue'

const user = inject('$user')
Expand Down
26 changes: 18 additions & 8 deletions frontend/src/pages/Jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</router-link>
</header>
<div>
<div class="p-5">
<div v-if="jobs.data?.length" class="p-5">
<div
class="flex flex-col lg:flex-row space-y-4 lg:space-y-0 lg:items-center justify-between mb-5"
>
Expand Down Expand Up @@ -58,10 +58,7 @@
</div>
</div>

<div
v-if="jobs.data?.length"
class="grid grid-cols-1 lg:grid-cols-3 gap-5"
>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-5">
<router-link
v-for="job in jobs.data"
:to="{
Expand All @@ -73,8 +70,21 @@
<JobCard :job="job" />
</router-link>
</div>
<div v-else class="text-ink-gray-7 italic p-5 w-fit mx-auto">
{{ __('No jobs posted') }}
</div>
<div
v-else
class="flex flex-col items-center justify-center text-sm text-ink-gray-5 mt-48"
>
<Laptop class="size-10 mx-auto stroke-1 text-ink-gray-4" />
<div class="text-lg font-medium mb-1">
{{ __('No jobs found') }}
</div>
<div class="leading-5 w-2/5 text-center">
{{
__(
'There are no jobs available at the moment. Open a job opportunity or check here again later.'
)
}}
</div>
</div>
</div>
Expand All @@ -88,7 +98,7 @@ import {
FormControl,
usePageMeta,
} from 'frappe-ui'
import { Plus, Search } from 'lucide-vue-next'
import { Laptop, Plus, Search } from 'lucide-vue-next'
import { sessionStore } from '../stores/session'
import { inject, computed, ref, onMounted } from 'vue'
import JobCard from '@/components/JobCard.vue'
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/LessonForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,10 @@ const createNewLesson = () => {
{ lesson: data.name },
{
onSuccess() {
if (user.data?.is_system_manager)
updateOnboardingStep('create_first_lesson')

capture('lesson_created')
updateOnboardingStep('create_first_lesson')
showToast('Success', 'Lesson created successfully', 'check')
lessonDetails.reload()
},
Expand Down
18 changes: 3 additions & 15 deletions frontend/src/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ export const useSettings = defineStore('settings', () => {
const activeTab = ref(null)

const learningPaths = createResource({
url: 'frappe.client.get_single_value',
makeParams(values) {
return {
doctype: 'LMS Settings',
field: 'enable_learning_paths',
}
},
auto: isLoggedIn ? true : false,
cache: ['learningPaths'],
url: 'lms.lms.api.is_learning_path_enabled',
auto: true,
cache: ['learningPath'],
})

const allowGuestAccess = createResource({
Expand All @@ -26,12 +20,6 @@ export const useSettings = defineStore('settings', () => {
cache: ['allowGuestAccess'],
})

/* const onboardingDetails = createResource({
url: 'lms.lms.utils.is_onboarding_complete',
auto: isLoggedIn ? true : false,
cache: ['onboardingDetails'],
}) */

return {
isSettingsOpen,
activeTab,
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import dayjs from '@/utils/dayjs'
import Embed from '@editorjs/embed'
import SimpleImage from '@editorjs/simple-image'
import Table from '@editorjs/table'
import { usersStore } from '../stores/user'

export function createToast(options) {
toast({
Expand Down Expand Up @@ -567,3 +568,8 @@ export const escapeHTML = (text) => {
(char) => escape_html_mapping[char] || char
)
}

export const canCreateCourse = () => {
const { userResource } = usersStore()
return userResource.data?.is_instructor || userResource.data?.is_moderator
}
2 changes: 1 addition & 1 deletion frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
}),
],
server: {
allowedHosts: ['fs', 'onb1'],
allowedHosts: ['fs', 'onb2'],
},
resolve: {
alias: {
Expand Down
5 changes: 5 additions & 0 deletions lms/lms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,11 @@ def is_guest_allowed():
return frappe.get_cached_value("LMS Settings", None, "allow_guest_access")


@frappe.whitelist(allow_guest=True)
def is_learning_path_enabled():
return frappe.get_cached_value("LMS Settings", None, "enable_learning_paths")


@frappe.whitelist()
def cancel_evaluation(evaluation):
evaluation = frappe._dict(evaluation)
Expand Down
Loading