Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
471e7d9229 | ||
|
|
b8c3bdc0b4 | ||
|
|
a450c846a6 | ||
|
|
fa774b0db2 | ||
|
|
98a56f9117 | ||
|
|
cbc4b8c59d | ||
|
|
69d266e018 | ||
|
|
4bc3ac1665 | ||
|
|
e0de9d70de | ||
|
|
493bab8163 | ||
|
|
25a2d82e82 | ||
|
|
0183677494 | ||
|
|
7ae9244896 | ||
|
|
15330cb41d | ||
|
|
166996d77a | ||
|
|
4943e0e902 | ||
|
|
1db6a8bfda | ||
|
|
57f43b256a | ||
|
|
23b2e8d682 | ||
|
|
6e1d62340f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ node_modules
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
lms/public/frontend
|
lms/public/frontend
|
||||||
lms/www/lms.html
|
lms/www/lms.html
|
||||||
|
frappe-ui
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "frappe-ui"]
|
||||||
|
path = frappe-ui
|
||||||
|
url = https://github.com/pateljannat/frappe-ui
|
||||||
Submodule frappe-ui updated: aa44431c18...a349ab070a
@@ -14,10 +14,10 @@
|
|||||||
"@editorjs/editorjs": "^2.29.0",
|
"@editorjs/editorjs": "^2.29.0",
|
||||||
"@editorjs/embed": "^2.7.0",
|
"@editorjs/embed": "^2.7.0",
|
||||||
"@editorjs/header": "^2.8.1",
|
"@editorjs/header": "^2.8.1",
|
||||||
"@editorjs/image": "^2.9.0",
|
|
||||||
"@editorjs/inline-code": "^1.5.0",
|
"@editorjs/inline-code": "^1.5.0",
|
||||||
"@editorjs/nested-list": "^1.4.2",
|
"@editorjs/nested-list": "^1.4.2",
|
||||||
"@editorjs/paragraph": "^2.11.3",
|
"@editorjs/paragraph": "^2.11.3",
|
||||||
|
"@editorjs/simple-image": "^1.6.0",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
"dayjs": "^1.11.6",
|
"dayjs": "^1.11.6",
|
||||||
"feather-icons": "^4.28.0",
|
"feather-icons": "^4.28.0",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
||||||
class="pt-1"
|
class="mt-4"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex items-center justify-between pr-2 cursor-pointer"
|
class="flex items-center justify-between pr-2 cursor-pointer"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="!isSidebarCollapsed"
|
v-if="!isSidebarCollapsed"
|
||||||
class="flex items-center text-sm font-medium text-gray-600"
|
class="flex items-center text-sm text-gray-600 my-1"
|
||||||
>
|
>
|
||||||
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
<span class="grid h-5 w-6 flex-shrink-0 place-items-center">
|
||||||
<ChevronRight
|
<ChevronRight
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<span class="ml-2">
|
<span class="ml-2">
|
||||||
{{ __('Web Pages') }}
|
{{ __('More') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Button v-if="isModerator" variant="ghost" @click="openPageModal()">
|
<Button v-if="isModerator" variant="ghost" @click="openPageModal()">
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full"
|
class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full"
|
||||||
style="min-height: 150px"
|
style="min-height: 150px"
|
||||||
>
|
>
|
||||||
|
<div class="text-xl font-semibold mb-2">
|
||||||
|
{{ batch.title }}
|
||||||
|
</div>
|
||||||
<Badge
|
<Badge
|
||||||
v-if="batch.seat_count && batch.seats_left > 0"
|
v-if="batch.seat_count && batch.seats_left > 0"
|
||||||
theme="green"
|
theme="green"
|
||||||
@@ -19,9 +22,6 @@
|
|||||||
>
|
>
|
||||||
{{ __('Sold Out') }}
|
{{ __('Sold Out') }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<div class="text-xl font-semibold mb-1">
|
|
||||||
{{ batch.title }}
|
|
||||||
</div>
|
|
||||||
<div class="short-introduction">
|
<div class="short-introduction">
|
||||||
{{ batch.description }}
|
{{ batch.description }}
|
||||||
</div>
|
</div>
|
||||||
@@ -29,23 +29,23 @@
|
|||||||
<div v-if="batch.amount" class="font-semibold text-lg">
|
<div v-if="batch.amount" class="font-semibold text-lg">
|
||||||
{{ batch.price }}
|
{{ batch.price }}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
|
||||||
<BookOpen class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
|
||||||
<span> {{ batch.courses.length }} {{ __('Courses') }} </span>
|
|
||||||
</div>
|
|
||||||
<DateRange
|
<DateRange
|
||||||
:startDate="batch.start_date"
|
:startDate="batch.start_date"
|
||||||
:endDate="batch.end_date"
|
:endDate="batch.end_date"
|
||||||
class="mb-3"
|
class="text-sm text-gray-700 mb-3"
|
||||||
/>
|
/>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center text-sm text-gray-700">
|
||||||
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||||
<span>
|
<span>
|
||||||
{{ formatTime(batch.start_time) }} - {{ formatTime(batch.end_time) }}
|
{{ formatTime(batch.start_time) }} - {{ formatTime(batch.end_time) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="batch.timezone" class="flex items-center">
|
<div
|
||||||
<Globe class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
v-if="batch.timezone"
|
||||||
|
class="flex items-center text-sm text-gray-700"
|
||||||
|
>
|
||||||
|
<Globe class="h-4 w-4 stroke-1.5 mr-2 text-gray-600" />
|
||||||
<span>
|
<span>
|
||||||
{{ batch.timezone }}
|
{{ batch.timezone }}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -2,28 +2,23 @@
|
|||||||
<div
|
<div
|
||||||
v-if="course.title"
|
v-if="course.title"
|
||||||
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
|
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
|
||||||
style="min-height: 320px"
|
style="min-height: 350px"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="course-image"
|
class="course-image"
|
||||||
:class="{ 'default-image': !course.image }"
|
:class="{ 'default-image': !course.image }"
|
||||||
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
|
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
|
||||||
>
|
>
|
||||||
<div class="flex relative top-4 left-4 w-fit flex-wrap">
|
<div
|
||||||
<Badge
|
class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
|
||||||
v-if="course.featured"
|
>
|
||||||
variant="subtle"
|
<Badge v-if="course.featured" variant="subtle" theme="green" size="md">
|
||||||
theme="green"
|
|
||||||
size="md"
|
|
||||||
class="mr-2"
|
|
||||||
>
|
|
||||||
{{ __('Featured') }}
|
{{ __('Featured') }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge
|
<Badge
|
||||||
variant="outline"
|
variant="outline"
|
||||||
theme="gray"
|
theme="gray"
|
||||||
size="md"
|
size="md"
|
||||||
class="mr-2"
|
|
||||||
v-for="tag in course.tags"
|
v-for="tag in course.tags"
|
||||||
>
|
>
|
||||||
{{ tag }}
|
{{ tag }}
|
||||||
|
|||||||
@@ -63,6 +63,15 @@
|
|||||||
{{ __('Start Learning') }}
|
{{ __('Start Learning') }}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
v-if="canGetCertificate"
|
||||||
|
@click="fetchCertificate()"
|
||||||
|
variant="subtle"
|
||||||
|
class="w-full mt-2"
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
{{ __('Get Certificate') }}
|
||||||
|
</Button>
|
||||||
<router-link
|
<router-link
|
||||||
v-if="user?.data?.is_moderator || is_instructor()"
|
v-if="user?.data?.is_moderator || is_instructor()"
|
||||||
:to="{
|
:to="{
|
||||||
@@ -136,7 +145,7 @@ function enrollStudent() {
|
|||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = `/login?redirect-to=${window.location.pathname}`
|
window.location.href = `/login?redirect-to=${window.location.pathname}`
|
||||||
}, 3000)
|
}, 2000)
|
||||||
} else {
|
} else {
|
||||||
const enrollStudentResource = createResource({
|
const enrollStudentResource = createResource({
|
||||||
url: 'lms.lms.doctype.lms_enrollment.lms_enrollment.create_membership',
|
url: 'lms.lms.doctype.lms_enrollment.lms_enrollment.create_membership',
|
||||||
@@ -174,4 +183,39 @@ const is_instructor = () => {
|
|||||||
})
|
})
|
||||||
return user_is_instructor
|
return user_is_instructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const canGetCertificate = computed(() => {
|
||||||
|
if (
|
||||||
|
props.course.data?.enable_certification &&
|
||||||
|
props.course.data?.membership?.progress == 100
|
||||||
|
) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
const certificate = createResource({
|
||||||
|
url: 'lms.lms.doctype.lms_certificate.lms_certificate.create_certificate',
|
||||||
|
makeParams(values) {
|
||||||
|
return {
|
||||||
|
course: values.course,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess(data) {
|
||||||
|
console.log(data)
|
||||||
|
window.open(
|
||||||
|
`/api/method/frappe.utils.print_format.download_pdf?doctype=LMS+Certificate&name=${
|
||||||
|
data.name
|
||||||
|
}&format=${encodeURIComponent(data.template)}`,
|
||||||
|
'_blank'
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const fetchCertificate = () => {
|
||||||
|
certificate.submit({
|
||||||
|
course: props.course.data?.name,
|
||||||
|
member: user.data?.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -130,11 +130,14 @@ function submitEvaluation(close) {
|
|||||||
close()
|
close()
|
||||||
},
|
},
|
||||||
onError(err) {
|
onError(err) {
|
||||||
|
let message = err.messages?.[0] || err
|
||||||
|
let unavailabilityMessage = message.includes('unavailable')
|
||||||
|
|
||||||
createToast({
|
createToast({
|
||||||
title: 'Error',
|
title: unavailabilityMessage ? 'Evaluator is Unavailable' : 'Error',
|
||||||
text: err.messages?.[0] || err,
|
text: message,
|
||||||
icon: 'x',
|
icon: unavailabilityMessage ? 'alert-circle' : 'x',
|
||||||
iconClasses: 'bg-red-600 text-white rounded-md p-px',
|
iconClasses: 'bg-yellow-600 text-white rounded-md p-px',
|
||||||
position: 'top-center',
|
position: 'top-center',
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
})
|
})
|
||||||
|
|||||||
147
frontend/src/components/Modals/Question.vue
Normal file
147
frontend/src/components/Modals/Question.vue
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog v-model="show" :options="dialogOptions">
|
||||||
|
<template #body-content>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs text-gray-600 mb-1">
|
||||||
|
{{ __('Question') }}
|
||||||
|
</label>
|
||||||
|
<TextEditor
|
||||||
|
:content="question.question"
|
||||||
|
@change="(val) => (question.question = val)"
|
||||||
|
:editable="true"
|
||||||
|
:fixedMenu="true"
|
||||||
|
editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<FormControl
|
||||||
|
:label="__('Type')"
|
||||||
|
v-model="question.type"
|
||||||
|
type="select"
|
||||||
|
:options="['Choices', 'User Input']"
|
||||||
|
class="pb-2"
|
||||||
|
/>
|
||||||
|
<div v-if="question.type == 'Choices'" class="divide-y">
|
||||||
|
<div v-for="n in 4" class="space-y-4 py-2">
|
||||||
|
<FormControl
|
||||||
|
:label="__('Option') + ' ' + n"
|
||||||
|
v-model="question[`option_${n}`]"
|
||||||
|
/>
|
||||||
|
<FormControl
|
||||||
|
:label="__('Explanation')"
|
||||||
|
v-model="question[`explanation_${n}`]"
|
||||||
|
/>
|
||||||
|
<FormControl
|
||||||
|
:label="__('Correct Answer')"
|
||||||
|
v-model="question[`correct_answer_${n}`]"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else v-for="n in 4" class="space-y-2">
|
||||||
|
<FormControl
|
||||||
|
:label="__('Possibility') + ' ' + n"
|
||||||
|
v-model="question[`possibility_${n}`]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
|
||||||
|
import { computed, onMounted, reactive, inject } from 'vue'
|
||||||
|
|
||||||
|
const show = defineModel()
|
||||||
|
const user = inject('$user')
|
||||||
|
const question = reactive({
|
||||||
|
question: '',
|
||||||
|
type: 'Choices',
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
populateFields()
|
||||||
|
console.log(props.questionName)
|
||||||
|
if (
|
||||||
|
props.questionName == 'new' &&
|
||||||
|
!user.data?.is_moderator &&
|
||||||
|
!user.data?.is_instructor
|
||||||
|
) {
|
||||||
|
router.push({ name: 'Courses' })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.courseName !== 'new') {
|
||||||
|
questionDoc.reload()
|
||||||
|
}
|
||||||
|
window.addEventListener('keydown', keyboardShortcut)
|
||||||
|
})
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: __('Add a Question'),
|
||||||
|
},
|
||||||
|
questionName: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const questionDoc = createResource({
|
||||||
|
url: 'frappe.client.get',
|
||||||
|
makeParams: (values) => {
|
||||||
|
return {
|
||||||
|
doctype: 'LMS Question',
|
||||||
|
name: props.questionName,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess(data) {
|
||||||
|
let counter = 1
|
||||||
|
Object.keys(data).forEach((key) => {
|
||||||
|
if (Object.hasOwn(question, key)) question[key] = data[key]
|
||||||
|
})
|
||||||
|
while (counter <= 4) {
|
||||||
|
question[`is_correct_${counter}`] = question[`is_correct_${counter}`]
|
||||||
|
? true
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const populateFields = () => {
|
||||||
|
let fields = ['option', 'correct_answer', 'explanation', 'possibility']
|
||||||
|
let counter = 1
|
||||||
|
fields.forEach((field) => {
|
||||||
|
while (counter <= 4) {
|
||||||
|
question[`${field}_${counter}`] = field === 'correct_answer' ? false : ''
|
||||||
|
counter++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyboardShortcut = (e) => {
|
||||||
|
if (
|
||||||
|
e.key === 's' &&
|
||||||
|
(e.ctrlKey || e.metaKey) &&
|
||||||
|
!e.target.classList.contains('ProseMirror')
|
||||||
|
) {
|
||||||
|
submitQuestion()
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogOptions = computed(() => {
|
||||||
|
return {
|
||||||
|
title: __(props.title),
|
||||||
|
size: 'xl',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: __('Submit'),
|
||||||
|
variant: 'solid',
|
||||||
|
onClick: (close) => {
|
||||||
|
submitQuestion(close)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="videoContainer" class="video-block group relative">
|
<div ref="videoContainer" class="video-block group relative">
|
||||||
<video @timeupdate="updateTime" @ended="videoEnded" class="rounded-lg">
|
<video
|
||||||
|
@timeupdate="updateTime"
|
||||||
|
@ended="videoEnded"
|
||||||
|
class="rounded-lg border border-gray-100"
|
||||||
|
>
|
||||||
<source :src="fileURL" :type="type" />
|
<source :src="fileURL" :type="type" />
|
||||||
</video>
|
</video>
|
||||||
<div
|
<div
|
||||||
class="flex items-center space-x-2 bg-gray-200 rounded-lg p-0.5 absolute bottom-3 w-[98%] left-0 right-0 mx-auto"
|
class="flex items-center space-x-2 bg-gray-200 rounded-md p-0.5 absolute bottom-3 w-[98%] left-0 right-0 mx-auto"
|
||||||
>
|
>
|
||||||
<Button variant="ghost">
|
<Button variant="ghost">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
|
|||||||
@@ -7,7 +7,15 @@
|
|||||||
class="h-7"
|
class="h-7"
|
||||||
:items="[{ label: __('All Batches'), route: { name: 'Batches' } }]"
|
:items="[{ label: __('All Batches'), route: { name: 'Batches' } }]"
|
||||||
/>
|
/>
|
||||||
<div class="flex">
|
<div class="flex space-x-2">
|
||||||
|
<div class="w-40">
|
||||||
|
<Select
|
||||||
|
v-if="categories.data?.length"
|
||||||
|
v-model="currentCategory"
|
||||||
|
:options="categories.data"
|
||||||
|
:placeholder="__('Filter')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<router-link
|
<router-link
|
||||||
v-if="user.data?.is_moderator"
|
v-if="user.data?.is_moderator"
|
||||||
:to="{
|
:to="{
|
||||||
@@ -33,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<Tabs
|
<Tabs
|
||||||
v-model="tabIndex"
|
v-model="tabIndex"
|
||||||
:tabs="tabs"
|
:tabs="makeTabs"
|
||||||
tablistClass="overflow-x-visible flex-wrap !gap-3 md:flex-nowrap"
|
tablistClass="overflow-x-visible flex-wrap !gap-3 md:flex-nowrap"
|
||||||
>
|
>
|
||||||
<template #tab="{ tab, selected }">
|
<template #tab="{ tab, selected }">
|
||||||
@@ -87,13 +95,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { createListResource, Breadcrumbs, Button, Tabs, Badge } from 'frappe-ui'
|
import {
|
||||||
|
createListResource,
|
||||||
|
createResource,
|
||||||
|
Breadcrumbs,
|
||||||
|
Button,
|
||||||
|
Tabs,
|
||||||
|
Badge,
|
||||||
|
Select,
|
||||||
|
} from 'frappe-ui'
|
||||||
import { Plus } from 'lucide-vue-next'
|
import { Plus } from 'lucide-vue-next'
|
||||||
import BatchCard from '@/components/BatchCard.vue'
|
import BatchCard from '@/components/BatchCard.vue'
|
||||||
import { inject, ref, computed } from 'vue'
|
import { inject, ref, computed, onMounted, watch } from 'vue'
|
||||||
import { updateDocumentTitle } from '@/utils'
|
import { updateDocumentTitle } from '@/utils'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
|
const currentCategory = ref(null)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
let queries = new URLSearchParams(location.search)
|
||||||
|
if (queries.has('category')) {
|
||||||
|
currentCategory.value = queries.get('category')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const batches = createListResource({
|
const batches = createListResource({
|
||||||
doctype: 'LMS Batch',
|
doctype: 'LMS Batch',
|
||||||
@@ -102,35 +126,76 @@ const batches = createListResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const tabIndex = ref(0)
|
const categories = createResource({
|
||||||
const tabs = [
|
url: 'lms.lms.api.get_categories',
|
||||||
{
|
makeParams() {
|
||||||
label: 'Upcoming',
|
return {
|
||||||
batches: computed(() => batches.data?.upcoming || []),
|
doctype: 'LMS Batch',
|
||||||
count: computed(() => batches.data?.upcoming?.length),
|
filters: {
|
||||||
|
published: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
]
|
cache: ['batchCategories'],
|
||||||
|
auto: true,
|
||||||
|
transform(data) {
|
||||||
|
data.unshift({
|
||||||
|
label: '',
|
||||||
|
value: null,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
if (user.data?.is_moderator) {
|
const tabIndex = ref(0)
|
||||||
|
let tabs
|
||||||
|
|
||||||
|
const makeTabs = computed(() => {
|
||||||
|
tabs = []
|
||||||
|
addToTabs('Upcoming')
|
||||||
|
|
||||||
|
if (user.data?.is_moderator) {
|
||||||
|
addToTabs('Archived')
|
||||||
|
addToTabs('Private')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.data) {
|
||||||
|
addToTabs('Enrolled')
|
||||||
|
}
|
||||||
|
|
||||||
|
return tabs
|
||||||
|
})
|
||||||
|
|
||||||
|
const getBatches = (type) => {
|
||||||
|
if (currentCategory.value && currentCategory.value != '') {
|
||||||
|
return batches.data[type].filter(
|
||||||
|
(batch) => batch.category == currentCategory.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return batches.data[type]
|
||||||
|
}
|
||||||
|
|
||||||
|
const addToTabs = (label) => {
|
||||||
|
let batches = getBatches(label.toLowerCase().split(' ').join('_'))
|
||||||
tabs.push({
|
tabs.push({
|
||||||
label: 'Archived',
|
label,
|
||||||
batches: computed(() => batches.data?.archived),
|
batches: computed(() => batches),
|
||||||
count: computed(() => batches.data?.archived?.length),
|
count: computed(() => batches.length),
|
||||||
})
|
|
||||||
tabs.push({
|
|
||||||
label: 'Private',
|
|
||||||
batches: computed(() => batches.data?.private),
|
|
||||||
count: computed(() => batches.data?.private?.length),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (user.data) {
|
|
||||||
tabs.push({
|
|
||||||
label: 'Enrolled',
|
|
||||||
batches: computed(() => batches.data?.enrolled),
|
|
||||||
count: computed(() => batches.data?.enrolled?.length),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => currentCategory.value,
|
||||||
|
() => {
|
||||||
|
let queries = new URLSearchParams(location.search)
|
||||||
|
if (currentCategory.value) {
|
||||||
|
queries.set('category', currentCategory.value)
|
||||||
|
} else {
|
||||||
|
queries.delete('category')
|
||||||
|
}
|
||||||
|
history.pushState(null, '', `${location.pathname}?${queries.toString()}`)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const pageMeta = computed(() => {
|
const pageMeta = computed(() => {
|
||||||
return {
|
return {
|
||||||
title: 'Batches',
|
title: 'Batches',
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5">
|
||||||
<div v-if="participants.data" v-for="participant in participants.data">
|
<div
|
||||||
|
v-if="participants.data?.length"
|
||||||
|
v-for="participant in participantsList"
|
||||||
|
>
|
||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
@@ -59,12 +62,7 @@ const searchQuery = ref('')
|
|||||||
const participants = createResource({
|
const participants = createResource({
|
||||||
url: 'lms.lms.api.get_certified_participants',
|
url: 'lms.lms.api.get_certified_participants',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
debounce: 300,
|
cache: 'certified-participants',
|
||||||
makeParams(values) {
|
|
||||||
return {
|
|
||||||
search_query: searchQuery.value,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -79,5 +77,16 @@ const pageMeta = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const participantsList = computed(() => {
|
||||||
|
if (searchQuery.value) {
|
||||||
|
return participants.data.filter((participant) => {
|
||||||
|
return participant.full_name
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchQuery.value.toLowerCase())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return participants.data
|
||||||
|
})
|
||||||
|
|
||||||
updateDocumentTitle(pageMeta)
|
updateDocumentTitle(pageMeta)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -134,29 +134,30 @@ let tabs
|
|||||||
|
|
||||||
const makeTabs = computed(() => {
|
const makeTabs = computed(() => {
|
||||||
tabs = []
|
tabs = []
|
||||||
addToTabs('Live', getCourses('live'))
|
addToTabs('Live')
|
||||||
addToTabs('New', getCourses('new'))
|
addToTabs('New')
|
||||||
addToTabs('Upcoming', getCourses('upcoming'))
|
addToTabs('Upcoming')
|
||||||
|
|
||||||
if (user.data) {
|
if (user.data) {
|
||||||
addToTabs('Enrolled', getCourses('enrolled'))
|
addToTabs('Enrolled')
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user.data.is_moderator ||
|
user.data.is_moderator ||
|
||||||
user.data.is_instructor ||
|
user.data.is_instructor ||
|
||||||
courses.data?.created?.length
|
courses.data?.created?.length
|
||||||
) {
|
) {
|
||||||
addToTabs('Created', getCourses('created'))
|
addToTabs('Created')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.data.is_moderator) {
|
if (user.data.is_moderator) {
|
||||||
addToTabs('Under Review', getCourses('under_review'))
|
addToTabs('Under Review')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tabs
|
return tabs
|
||||||
})
|
})
|
||||||
|
|
||||||
const addToTabs = (label, courses) => {
|
const addToTabs = (label) => {
|
||||||
|
let courses = getCourses(label.toLowerCase().split(' ').join('_'))
|
||||||
tabs.push({
|
tabs.push({
|
||||||
label,
|
label,
|
||||||
courses: computed(() => courses),
|
courses: computed(() => courses),
|
||||||
@@ -166,8 +167,12 @@ const addToTabs = (label, courses) => {
|
|||||||
|
|
||||||
const getCourses = (type) => {
|
const getCourses = (type) => {
|
||||||
if (searchQuery.value) {
|
if (searchQuery.value) {
|
||||||
return courses.data[type].filter((course) =>
|
let query = searchQuery.value.toLowerCase()
|
||||||
course.title.toLowerCase().includes(searchQuery.value.toLowerCase())
|
return courses.data[type].filter(
|
||||||
|
(course) =>
|
||||||
|
course.title.toLowerCase().includes(query) ||
|
||||||
|
course.short_introduction.toLowerCase().includes(query) ||
|
||||||
|
course.tags.filter((tag) => tag.toLowerCase().includes(query)).length
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return courses.data[type]
|
return courses.data[type]
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
<div class="text-lg font-semibold mt-5 mb-4">
|
<div class="text-lg font-semibold mt-5 mb-4">
|
||||||
{{ __('Settings') }}
|
{{ __('Settings') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 gap-10 mb-4">
|
<div class="grid grid-cols-3 gap-10 mb-4">
|
||||||
<div
|
<div
|
||||||
v-if="user.data?.is_moderator"
|
v-if="user.data?.is_moderator"
|
||||||
class="flex flex-col space-y-3"
|
class="flex flex-col space-y-3"
|
||||||
@@ -147,11 +147,18 @@
|
|||||||
v-model="course.featured"
|
v-model="course.featured"
|
||||||
:label="__('Featured')"
|
:label="__('Featured')"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col space-y-3">
|
||||||
<FormControl
|
<FormControl
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
v-model="course.disable_self_learning"
|
v-model="course.disable_self_learning"
|
||||||
:label="__('Disable Self Enrollment')"
|
:label="__('Disable Self Enrollment')"
|
||||||
/>
|
/>
|
||||||
|
<FormControl
|
||||||
|
type="checkbox"
|
||||||
|
v-model="course.enable_certification"
|
||||||
|
:label="__('Completion Certificate')"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -244,6 +251,7 @@ const course = reactive({
|
|||||||
featured: false,
|
featured: false,
|
||||||
upcoming: false,
|
upcoming: false,
|
||||||
disable_self_learning: false,
|
disable_self_learning: false,
|
||||||
|
enable_certification: false,
|
||||||
paid_course: false,
|
paid_course: false,
|
||||||
course_price: '',
|
course_price: '',
|
||||||
currency: '',
|
currency: '',
|
||||||
@@ -337,6 +345,7 @@ const courseResource = createResource({
|
|||||||
'disable_self_learning',
|
'disable_self_learning',
|
||||||
'paid_course',
|
'paid_course',
|
||||||
'featured',
|
'featured',
|
||||||
|
'enable_certification',
|
||||||
]
|
]
|
||||||
for (let idx in checkboxes) {
|
for (let idx in checkboxes) {
|
||||||
let key = checkboxes[idx]
|
let key = checkboxes[idx]
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<div
|
<div
|
||||||
v-show="openInstructorEditor"
|
v-show="openInstructorEditor"
|
||||||
id="instructor-notes"
|
id="instructor-notes"
|
||||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6 py-3"
|
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal py-3"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<div
|
<div
|
||||||
id="content"
|
id="content"
|
||||||
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6 py-3"
|
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal py-3"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -439,7 +439,8 @@ const pageMeta = computed(() => {
|
|||||||
updateDocumentTitle(pageMeta)
|
updateDocumentTitle(pageMeta)
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.embed-tool__caption {
|
.embed-tool__caption,
|
||||||
|
.cdx-simple-image__caption {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,17 @@
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<router-link
|
||||||
|
v-else
|
||||||
|
:to="{
|
||||||
|
name: 'CourseDetail',
|
||||||
|
params: { courseName: courseName },
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<Button>
|
||||||
|
{{ __('Back to Course') }}
|
||||||
|
</Button>
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -160,12 +171,12 @@
|
|||||||
{{ lesson.data.course_title }}
|
{{ lesson.data.course_title }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="user && lesson.data.membership" class="text-sm mt-3">
|
<div v-if="user && lesson.data.membership" class="text-sm mt-3">
|
||||||
{{ Math.ceil(lesson.data.membership.progress) }}% completed
|
{{ Math.ceil(lessonProgress) }}% {{ __('completed') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
v-if="user && lesson.data.membership"
|
v-if="user && lesson.data.membership"
|
||||||
:progress="lesson.data.membership.progress"
|
:progress="lessonProgress"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CourseOutline
|
<CourseOutline
|
||||||
@@ -179,7 +190,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { createResource, Breadcrumbs, Button } from 'frappe-ui'
|
import { createResource, Breadcrumbs, Button } from 'frappe-ui'
|
||||||
import { computed, watch, inject, ref } from 'vue'
|
import { computed, watch, inject, ref, onMounted, onBeforeUnmount } from 'vue'
|
||||||
import CourseOutline from '@/components/CourseOutline.vue'
|
import CourseOutline from '@/components/CourseOutline.vue'
|
||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
@@ -196,6 +207,9 @@ const route = useRoute()
|
|||||||
const allowDiscussions = ref(false)
|
const allowDiscussions = ref(false)
|
||||||
const editor = ref(null)
|
const editor = ref(null)
|
||||||
const instructorEditor = ref(null)
|
const instructorEditor = ref(null)
|
||||||
|
const lessonProgress = ref(0)
|
||||||
|
const timer = ref(0)
|
||||||
|
let timerInterval
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
courseName: {
|
courseName: {
|
||||||
@@ -212,6 +226,10 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
startTimer()
|
||||||
|
})
|
||||||
|
|
||||||
const lesson = createResource({
|
const lesson = createResource({
|
||||||
url: 'lms.lms.utils.get_lesson',
|
url: 'lms.lms.utils.get_lesson',
|
||||||
cache: ['lesson', props.courseName, props.chapterNumber, props.lessonNumber],
|
cache: ['lesson', props.courseName, props.chapterNumber, props.lessonNumber],
|
||||||
@@ -224,7 +242,7 @@ const lesson = createResource({
|
|||||||
},
|
},
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
markProgress(data)
|
lessonProgress.value = data.membership?.progress
|
||||||
if (data.content) editor.value = renderEditor('editor', data.content)
|
if (data.content) editor.value = renderEditor('editor', data.content)
|
||||||
if (data.instructor_content?.blocks?.length)
|
if (data.instructor_content?.blocks?.length)
|
||||||
instructorEditor.value = renderEditor(
|
instructorEditor.value = renderEditor(
|
||||||
@@ -256,8 +274,10 @@ const renderEditor = (holder, content) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const markProgress = (data) => {
|
const markProgress = () => {
|
||||||
if (user.data && !data.progress) progress.submit()
|
if (user.data && !lesson.data?.progress) {
|
||||||
|
progress.submit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const progress = createResource({
|
const progress = createResource({
|
||||||
@@ -268,6 +288,9 @@ const progress = createResource({
|
|||||||
course: props.courseName,
|
course: props.courseName,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onSuccess(data) {
|
||||||
|
lessonProgress.value = data
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const breadcrumbs = computed(() => {
|
const breadcrumbs = computed(() => {
|
||||||
@@ -304,10 +327,27 @@ watch(
|
|||||||
chapter: newChapterNumber,
|
chapter: newChapterNumber,
|
||||||
lesson: newLessonNumber,
|
lesson: newLessonNumber,
|
||||||
})
|
})
|
||||||
|
clearInterval(timerInterval)
|
||||||
|
timer.value = 0
|
||||||
|
startTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const startTimer = () => {
|
||||||
|
timerInterval = setInterval(() => {
|
||||||
|
timer.value++
|
||||||
|
if (timer.value == 30) {
|
||||||
|
clearInterval(timerInterval)
|
||||||
|
markProgress()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clearInterval(timerInterval)
|
||||||
|
})
|
||||||
|
|
||||||
const checkIfDiscussionsAllowed = () => {
|
const checkIfDiscussionsAllowed = () => {
|
||||||
let quizPresent = false
|
let quizPresent = false
|
||||||
JSON.parse(lesson.data?.content)?.blocks?.forEach((block) => {
|
JSON.parse(lesson.data?.content)?.blocks?.forEach((block) => {
|
||||||
|
|||||||
209
frontend/src/pages/QuizCreation.vue
Normal file
209
frontend/src/pages/QuizCreation.vue
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
<template>
|
||||||
|
<header
|
||||||
|
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
|
||||||
|
>
|
||||||
|
<Breadcrumbs :items="breadcrumbs" />
|
||||||
|
</header>
|
||||||
|
<div class="w-3/4 mx-auto py-5">
|
||||||
|
<!-- Details -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm font-semibold mb-4">
|
||||||
|
{{ __('Details') }}
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-5">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<FormControl v-model="quiz.title" :label="__('Title')" />
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.max_attempts"
|
||||||
|
:label="__('Maximun Attempts')"
|
||||||
|
/>
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.limit_questions_to"
|
||||||
|
:label="__('Limit Questions To')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<FormControl v-model="quiz.total_marks" :label="__('Total Marks')" />
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.passing_percentage"
|
||||||
|
:label="__('Passing Percentage')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Settings -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<div class="text-sm font-semibold mb-4">
|
||||||
|
{{ __('Settings') }}
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-3 gap-5 my-4">
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.show_answers"
|
||||||
|
type="checkbox"
|
||||||
|
:label="__('Show Answers')"
|
||||||
|
/>
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.show_submission_history"
|
||||||
|
type="checkbox"
|
||||||
|
:label="__('Show Submission History')"
|
||||||
|
/>
|
||||||
|
<FormControl
|
||||||
|
v-model="quiz.shuffle_questions"
|
||||||
|
type="checkbox"
|
||||||
|
:label="__('Shuffle Questions')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Questions -->
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<div class="text-sm font-semibold">
|
||||||
|
{{ __('Questions') }}
|
||||||
|
</div>
|
||||||
|
<Button @click="openQuestionModal()">
|
||||||
|
<template #prefix>
|
||||||
|
<Plus class="w-4 h-4" />
|
||||||
|
</template>
|
||||||
|
{{ __('New Question') }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<ListView
|
||||||
|
:columns="questionColumns"
|
||||||
|
:rows="quiz.questions"
|
||||||
|
row-key="name"
|
||||||
|
:options="{
|
||||||
|
showTooltip: false,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<ListHeader
|
||||||
|
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
|
||||||
|
>
|
||||||
|
<ListHeaderItem :item="item" v-for="item in questionColumns" />
|
||||||
|
</ListHeader>
|
||||||
|
<ListRows>
|
||||||
|
<ListRow
|
||||||
|
:row="row"
|
||||||
|
v-slot="{ idx, column, item }"
|
||||||
|
v-for="row in quiz.questions"
|
||||||
|
@click="openQuestionModal(row.question)"
|
||||||
|
>
|
||||||
|
<ListRowItem :item="item">
|
||||||
|
<div
|
||||||
|
v-if="column.key == 'question_detail'"
|
||||||
|
class="text-xs truncate"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</div>
|
||||||
|
<div v-else class="text-xs">
|
||||||
|
{{ item }}
|
||||||
|
</div>
|
||||||
|
</ListRowItem>
|
||||||
|
</ListRow>
|
||||||
|
</ListRows>
|
||||||
|
</ListView>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Question v-model="showQuestionModal" :questionName="currentQuestion" />
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
Breadcrumbs,
|
||||||
|
createDocumentResource,
|
||||||
|
FormControl,
|
||||||
|
ListView,
|
||||||
|
ListHeader,
|
||||||
|
ListHeaderItem,
|
||||||
|
ListRows,
|
||||||
|
ListRow,
|
||||||
|
ListRowItem,
|
||||||
|
Button,
|
||||||
|
} from 'frappe-ui'
|
||||||
|
import { computed, reactive, ref } from 'vue'
|
||||||
|
import { Plus } from 'lucide-vue-next'
|
||||||
|
import Question from '@/components/Modals/Question.vue'
|
||||||
|
|
||||||
|
const showQuestionModal = ref(false)
|
||||||
|
const currentQuestion = ref(null)
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
quizID: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const quiz = reactive({
|
||||||
|
title: '',
|
||||||
|
total_marks: '',
|
||||||
|
passing_percentage: '',
|
||||||
|
max_attempts: 0,
|
||||||
|
limit_questions_to: 0,
|
||||||
|
show_answers: true,
|
||||||
|
show_submission_history: false,
|
||||||
|
shuffle_questions: false,
|
||||||
|
questions: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
const quizDetails = createDocumentResource({
|
||||||
|
doctype: 'LMS Quiz',
|
||||||
|
name: props.quizID,
|
||||||
|
auto: true,
|
||||||
|
cache: ['quiz', props.quizID],
|
||||||
|
onSuccess(data) {
|
||||||
|
Object.keys(data).forEach((key) => {
|
||||||
|
if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
|
||||||
|
})
|
||||||
|
|
||||||
|
let checkboxes = [
|
||||||
|
'show_answers',
|
||||||
|
'show_submission_history',
|
||||||
|
'shuffle_questions',
|
||||||
|
]
|
||||||
|
for (let idx in checkboxes) {
|
||||||
|
let key = checkboxes[idx]
|
||||||
|
quiz[key] = quiz[key] ? true : false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const questionColumns = computed(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __('ID'),
|
||||||
|
key: 'question',
|
||||||
|
width: '25%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Question'),
|
||||||
|
key: __('question_detail'),
|
||||||
|
width: '60%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Marks'),
|
||||||
|
key: 'marks',
|
||||||
|
width: '10%',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const openQuestionModal = (question = null) => {
|
||||||
|
console.log('called')
|
||||||
|
console.log(question)
|
||||||
|
currentQuestion.value = question
|
||||||
|
showQuestionModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const breadcrumbs = computed(() => {
|
||||||
|
let crumbs = [
|
||||||
|
{
|
||||||
|
label: __('Quizzes'),
|
||||||
|
route: {
|
||||||
|
name: 'Quizzes',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
return crumbs
|
||||||
|
})
|
||||||
|
</script>
|
||||||
108
frontend/src/pages/Quizzes.vue
Normal file
108
frontend/src/pages/Quizzes.vue
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<template>
|
||||||
|
<header
|
||||||
|
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
|
||||||
|
>
|
||||||
|
<Breadcrumbs :items="breadcrumbs" />
|
||||||
|
<Button variant="solid">
|
||||||
|
<template #prefix>
|
||||||
|
<Plus class="w-4 h-4"/>
|
||||||
|
</template>
|
||||||
|
{{ __('New Quiz') }}
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
<div v-if="quizzes.data?.length" class="w-3/4 mx-auto py-5">
|
||||||
|
<ListView
|
||||||
|
:columns="quizColumns"
|
||||||
|
:rows="quizzes.data"
|
||||||
|
row-key="name"
|
||||||
|
:options="{ showTooltip: false, selectable: false }"
|
||||||
|
>
|
||||||
|
<ListHeader
|
||||||
|
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
|
||||||
|
>
|
||||||
|
<ListHeaderItem :item="item" v-for="item in quizColumns">
|
||||||
|
</ListHeaderItem>
|
||||||
|
</ListHeader>
|
||||||
|
<ListRows>
|
||||||
|
<router-link
|
||||||
|
v-for="row in quizzes.data"
|
||||||
|
:to="{
|
||||||
|
name: 'QuizCreation',
|
||||||
|
params: {
|
||||||
|
quizID: row.name,
|
||||||
|
},
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<ListRow :row="row" />
|
||||||
|
</router-link>
|
||||||
|
</ListRows>
|
||||||
|
</ListView>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import {
|
||||||
|
Breadcrumbs,
|
||||||
|
createListResource,
|
||||||
|
ListView,
|
||||||
|
ListRows,
|
||||||
|
ListRow,
|
||||||
|
ListHeader,
|
||||||
|
ListHeaderItem,
|
||||||
|
Button,
|
||||||
|
} from 'frappe-ui'
|
||||||
|
import { computed, inject } from 'vue'
|
||||||
|
import { Plus } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
const user = inject('$user')
|
||||||
|
|
||||||
|
const quizFilter = computed(() => {
|
||||||
|
if (user.data?.is_moderator) return {}
|
||||||
|
return {
|
||||||
|
owner: user.data?.name,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const quizzes = createListResource({
|
||||||
|
doctype: 'LMS Quiz',
|
||||||
|
filters: quizFilter,
|
||||||
|
fields: ['name', 'title', 'passing_percentage', 'total_marks'],
|
||||||
|
auto: true,
|
||||||
|
cache: ['quizzes', user.data?.name],
|
||||||
|
onSuccess(data) {
|
||||||
|
data.forEach((row) => {})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const quizColumns = computed(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __('Title'),
|
||||||
|
key: 'title',
|
||||||
|
width: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Total Marks'),
|
||||||
|
key: 'total_marks',
|
||||||
|
width: 1,
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __('Passing Percentage'),
|
||||||
|
key: 'passing_percentage',
|
||||||
|
width: 1,
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const breadcrumbs = computed(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: __('Quizzes'),
|
||||||
|
route: {
|
||||||
|
name: 'Quizzes',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -141,6 +141,17 @@ const routes = [
|
|||||||
component: () => import('@/pages/Badge.vue'),
|
component: () => import('@/pages/Badge.vue'),
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/quizzes',
|
||||||
|
name: 'Quizzes',
|
||||||
|
component: () => import('@/pages/Quizzes.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/quizzes/:quizID',
|
||||||
|
name: 'QuizCreation',
|
||||||
|
component: () => import('@/pages/QuizCreation.vue'),
|
||||||
|
props: true,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
let router = createRouter({
|
let router = createRouter({
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import router from '@/router'
|
|||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
export const sessionStore = defineStore('lms-session', () => {
|
export const sessionStore = defineStore('lms-session', () => {
|
||||||
let { userResource } = usersStore()
|
let { userResource, allUsers } = usersStore()
|
||||||
|
|
||||||
function sessionUser() {
|
function sessionUser() {
|
||||||
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
|
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
|
||||||
@@ -17,6 +17,9 @@ export const sessionStore = defineStore('lms-session', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user = ref(sessionUser())
|
let user = ref(sessionUser())
|
||||||
|
if (user) {
|
||||||
|
allUsers.reload()
|
||||||
|
}
|
||||||
const isLoggedIn = computed(() => !!user.value)
|
const isLoggedIn = computed(() => !!user.value)
|
||||||
|
|
||||||
const login = createResource({
|
const login = createResource({
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export const usersStore = defineStore('lms-users', () => {
|
|||||||
const allUsers = createResource({
|
const allUsers = createResource({
|
||||||
url: 'lms.lms.api.get_all_users',
|
url: 'lms.lms.api.get_all_users',
|
||||||
cache: ['allUsers'],
|
cache: ['allUsers'],
|
||||||
auto: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
|
|||||||
|
|
||||||
export default function translationPlugin(app) {
|
export default function translationPlugin(app) {
|
||||||
app.config.globalProperties.__ = translate
|
app.config.globalProperties.__ = translate
|
||||||
|
window.__ = translate
|
||||||
if (!window.translatedMessages) fetchTranslations()
|
if (!window.translatedMessages) fetchTranslations()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import InlineCode from '@editorjs/inline-code'
|
|||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
import dayjs from '@/utils/dayjs'
|
import dayjs from '@/utils/dayjs'
|
||||||
import Embed from '@editorjs/embed'
|
import Embed from '@editorjs/embed'
|
||||||
|
import SimpleImage from '@editorjs/simple-image'
|
||||||
|
|
||||||
export function createToast(options) {
|
export function createToast(options) {
|
||||||
toast({
|
toast({
|
||||||
@@ -79,15 +80,18 @@ export function getFileSize(file_size) {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showToast(title, text, icon) {
|
export function showToast(title, text, icon, iconClasses = null) {
|
||||||
|
if (!iconClasses) {
|
||||||
|
iconClasses =
|
||||||
|
icon == 'check'
|
||||||
|
? 'bg-green-600 text-white rounded-md p-px'
|
||||||
|
: 'bg-red-600 text-white rounded-md p-px'
|
||||||
|
}
|
||||||
createToast({
|
createToast({
|
||||||
title: title,
|
title: title,
|
||||||
text: htmlToText(text),
|
text: htmlToText(text),
|
||||||
icon: icon,
|
icon: icon,
|
||||||
iconClasses:
|
iconClasses: iconClasses,
|
||||||
icon == 'check'
|
|
||||||
? 'bg-green-600 text-white rounded-md p-px'
|
|
||||||
: 'bg-red-600 text-white rounded-md p-px',
|
|
||||||
position: icon == 'check' ? 'bottom-right' : 'top-center',
|
position: icon == 'check' ? 'bottom-right' : 'top-center',
|
||||||
timeout: 5,
|
timeout: 5,
|
||||||
})
|
})
|
||||||
@@ -133,6 +137,7 @@ export function getEditorTools() {
|
|||||||
header: Header,
|
header: Header,
|
||||||
quiz: Quiz,
|
quiz: Quiz,
|
||||||
upload: Upload,
|
upload: Upload,
|
||||||
|
image: SimpleImage,
|
||||||
paragraph: {
|
paragraph: {
|
||||||
class: Paragraph,
|
class: Paragraph,
|
||||||
inlineToolbar: true,
|
inlineToolbar: true,
|
||||||
@@ -164,10 +169,68 @@ export function getEditorTools() {
|
|||||||
inlineToolbar: false,
|
inlineToolbar: false,
|
||||||
config: {
|
config: {
|
||||||
services: {
|
services: {
|
||||||
youtube: true,
|
youtube: {
|
||||||
|
regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,
|
||||||
|
embedUrl:
|
||||||
|
'https://www.youtube.com/embed/<%= remote_id %>',
|
||||||
|
html: '<iframe style="width:100%; height: 30rem;" frameborder="0" allowfullscreen></iframe>',
|
||||||
|
height: 320,
|
||||||
|
width: 580,
|
||||||
|
id: ([id, params]) => {
|
||||||
|
if (!params && id) {
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramsMap = {
|
||||||
|
start: 'start',
|
||||||
|
end: 'end',
|
||||||
|
t: 'start',
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
time_continue: 'start',
|
||||||
|
list: 'list',
|
||||||
|
}
|
||||||
|
|
||||||
|
let newParams = params
|
||||||
|
.slice(1)
|
||||||
|
.split('&')
|
||||||
|
.map((param) => {
|
||||||
|
const [name, value] = param.split('=')
|
||||||
|
|
||||||
|
if (!id && name === 'v') {
|
||||||
|
id = value
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!paramsMap[name]) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
value === 'LL' ||
|
||||||
|
value.startsWith('RDMM') ||
|
||||||
|
value.startsWith('FL')
|
||||||
|
) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${paramsMap[name]}=${value}`
|
||||||
|
})
|
||||||
|
.filter((param) => !!param)
|
||||||
|
|
||||||
|
return id + '?' + newParams.join('&')
|
||||||
|
},
|
||||||
|
},
|
||||||
vimeo: true,
|
vimeo: true,
|
||||||
codepen: true,
|
codepen: true,
|
||||||
aparat: true,
|
aparat: {
|
||||||
|
regex: /(?:http[s]?:\/\/)?(?:www.)?aparat\.com\/v\/([^\/\?\&]+)\/?/,
|
||||||
|
embedUrl:
|
||||||
|
'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame',
|
||||||
|
html: '<iframe style="margin: 0 auto; width: 100%; height: 25rem;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
|
||||||
|
height: 300,
|
||||||
|
width: 600,
|
||||||
|
},
|
||||||
github: true,
|
github: true,
|
||||||
slides: {
|
slides: {
|
||||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
||||||
|
|||||||
@@ -68,13 +68,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@codexteam/icons" "^0.0.5"
|
"@codexteam/icons" "^0.0.5"
|
||||||
|
|
||||||
"@editorjs/image@^2.9.0":
|
|
||||||
version "2.9.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/@editorjs/image/-/image-2.9.0.tgz#0c83252d569a0dc3af14c3f7d16b6df033b9c37b"
|
|
||||||
integrity sha512-xItihKJFiWJ06SMtLWQZvzHv4LRPNAFZYaHAXesBFzXvWwUrtVaVMcNSf0eNnw3InrPO3Po1vZRRgpsT+Ya3Bg==
|
|
||||||
dependencies:
|
|
||||||
"@codexteam/icons" "^0.0.6"
|
|
||||||
|
|
||||||
"@editorjs/inline-code@^1.5.0":
|
"@editorjs/inline-code@^1.5.0":
|
||||||
version "1.5.0"
|
version "1.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426"
|
resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426"
|
||||||
@@ -96,6 +89,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@codexteam/icons" "^0.0.4"
|
"@codexteam/icons" "^0.0.4"
|
||||||
|
|
||||||
|
"@editorjs/simple-image@^1.6.0":
|
||||||
|
version "1.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@editorjs/simple-image/-/simple-image-1.6.0.tgz#711c3900e17845331d6667cf0fe91793a5557f84"
|
||||||
|
integrity sha512-WvdGfQPlozwZd3PXQrJnRXk6gEYbv1U2vRupYJ6lTd3/UsLInXYUX5jSFcnGB5ZMH3bd0JDZfcb4d4Sv1/1big==
|
||||||
|
dependencies:
|
||||||
|
"@codexteam/icons" "^0.0.6"
|
||||||
|
|
||||||
"@esbuild/aix-ppc64@0.20.2":
|
"@esbuild/aix-ppc64@0.20.2":
|
||||||
version "0.20.2"
|
version "0.20.2"
|
||||||
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz#a70f4ac11c6a1dfc18b8bbb13284155d933b9537"
|
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz#a70f4ac11c6a1dfc18b8bbb13284155d933b9537"
|
||||||
@@ -1875,8 +1875,16 @@ source-map-js@^1.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af"
|
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af"
|
||||||
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
|
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
|
||||||
|
|
||||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
|
"string-width-cjs@npm:string-width@^4.2.0":
|
||||||
name string-width-cjs
|
version "4.2.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
|
dependencies:
|
||||||
|
emoji-regex "^8.0.0"
|
||||||
|
is-fullwidth-code-point "^3.0.0"
|
||||||
|
strip-ansi "^6.0.1"
|
||||||
|
|
||||||
|
string-width@^4.1.0:
|
||||||
version "4.2.3"
|
version "4.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
@@ -1894,8 +1902,14 @@ string-width@^5.0.1, string-width@^5.1.2:
|
|||||||
emoji-regex "^9.2.2"
|
emoji-regex "^9.2.2"
|
||||||
strip-ansi "^7.0.1"
|
strip-ansi "^7.0.1"
|
||||||
|
|
||||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||||
name strip-ansi-cjs
|
version "6.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||||
|
dependencies:
|
||||||
|
ansi-regex "^5.0.1"
|
||||||
|
|
||||||
|
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||||
version "6.0.1"
|
version "6.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||||
|
|||||||
47
lms/hooks.py
47
lms/hooks.py
@@ -176,52 +176,7 @@ update_website_context = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
jinja = {
|
jinja = {
|
||||||
"methods": [
|
"methods": ["lms.lms.utils.get_signup_optin_checks"],
|
||||||
"lms.page_renderers.get_profile_url",
|
|
||||||
"lms.overrides.user.get_enrolled_courses",
|
|
||||||
"lms.overrides.user.get_course_membership",
|
|
||||||
"lms.overrides.user.get_authored_courses",
|
|
||||||
"lms.overrides.user.get_palette",
|
|
||||||
"lms.lms.utils.get_membership",
|
|
||||||
"lms.lms.utils.get_lessons",
|
|
||||||
"lms.lms.utils.get_tags",
|
|
||||||
"lms.lms.utils.get_instructors",
|
|
||||||
"lms.lms.utils.get_students",
|
|
||||||
"lms.lms.utils.get_average_rating",
|
|
||||||
"lms.lms.utils.is_certified",
|
|
||||||
"lms.lms.utils.get_lesson_index",
|
|
||||||
"lms.lms.utils.get_lesson_url",
|
|
||||||
"lms.lms.utils.get_chapters",
|
|
||||||
"lms.lms.utils.get_slugified_chapter_title",
|
|
||||||
"lms.lms.utils.get_progress",
|
|
||||||
"lms.lms.utils.render_html",
|
|
||||||
"lms.lms.utils.is_mentor",
|
|
||||||
"lms.lms.utils.is_cohort_staff",
|
|
||||||
"lms.lms.utils.get_mentors",
|
|
||||||
"lms.lms.utils.get_reviews",
|
|
||||||
"lms.lms.utils.is_eligible_to_review",
|
|
||||||
"lms.lms.utils.get_initial_members",
|
|
||||||
"lms.lms.utils.get_sorted_reviews",
|
|
||||||
"lms.lms.utils.is_instructor",
|
|
||||||
"lms.lms.utils.convert_number_to_character",
|
|
||||||
"lms.lms.utils.get_signup_optin_checks",
|
|
||||||
"lms.lms.utils.get_popular_courses",
|
|
||||||
"lms.lms.utils.format_amount",
|
|
||||||
"lms.lms.utils.first_lesson_exists",
|
|
||||||
"lms.lms.utils.get_courses_under_review",
|
|
||||||
"lms.lms.utils.has_course_instructor_role",
|
|
||||||
"lms.lms.utils.has_course_moderator_role",
|
|
||||||
"lms.lms.utils.get_certificates",
|
|
||||||
"lms.lms.utils.format_number",
|
|
||||||
"lms.lms.utils.get_lesson_count",
|
|
||||||
"lms.lms.utils.get_all_memberships",
|
|
||||||
"lms.lms.utils.get_filtered_membership",
|
|
||||||
"lms.lms.utils.show_start_learing_cta",
|
|
||||||
"lms.lms.utils.can_create_courses",
|
|
||||||
"lms.lms.utils.get_telemetry_boot_info",
|
|
||||||
"lms.lms.utils.is_onboarding_complete",
|
|
||||||
"lms.www.utils.is_student",
|
|
||||||
],
|
|
||||||
"filters": [],
|
"filters": [],
|
||||||
}
|
}
|
||||||
## Specify the additional tabs to be included in the user profile page.
|
## Specify the additional tabs to be included in the user profile page.
|
||||||
|
|||||||
@@ -330,13 +330,12 @@ def get_evaluator_details(evaluator):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_certified_participants(search_query=""):
|
def get_certified_participants():
|
||||||
LMSCertificate = DocType("LMS Certificate")
|
LMSCertificate = DocType("LMS Certificate")
|
||||||
participants = (
|
participants = (
|
||||||
frappe.qb.from_(LMSCertificate)
|
frappe.qb.from_(LMSCertificate)
|
||||||
.select(LMSCertificate.member)
|
.select(LMSCertificate.member)
|
||||||
.distinct()
|
.distinct()
|
||||||
.where(LMSCertificate.member_name.like(f"%{search_query}%"))
|
|
||||||
.where(LMSCertificate.published == 1)
|
.where(LMSCertificate.published == 1)
|
||||||
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
|
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
|
||||||
.run(as_dict=1)
|
.run(as_dict=1)
|
||||||
@@ -542,3 +541,21 @@ def update_index(lessons, chapter):
|
|||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Lesson Reference", {"lesson": row, "parent": chapter}, "idx", lessons.index(row) + 1
|
"Lesson Reference", {"lesson": row, "parent": chapter}, "idx", lessons.index(row) + 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def get_categories(doctype, filters):
|
||||||
|
categoryOptions = []
|
||||||
|
|
||||||
|
categories = frappe.get_all(
|
||||||
|
doctype,
|
||||||
|
filters,
|
||||||
|
pluck="category",
|
||||||
|
)
|
||||||
|
categories = list(set(categories))
|
||||||
|
|
||||||
|
for category in categories:
|
||||||
|
if category:
|
||||||
|
categoryOptions.append({"label": category, "value": category})
|
||||||
|
|
||||||
|
return categoryOptions
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ def save_progress(lesson, course):
|
|||||||
"LMS Enrollment", {"course": course, "member": frappe.session.user}
|
"LMS Enrollment", {"course": course, "member": frappe.session.user}
|
||||||
)
|
)
|
||||||
if not membership:
|
if not membership:
|
||||||
return 0
|
return
|
||||||
|
|
||||||
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ def save_progress(lesson, course):
|
|||||||
if frappe.db.exists(
|
if frappe.db.exists(
|
||||||
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
|
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
|
||||||
):
|
):
|
||||||
return 0
|
return
|
||||||
|
|
||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
@@ -116,9 +116,12 @@ def save_progress(lesson, course):
|
|||||||
).save(ignore_permissions=True)
|
).save(ignore_permissions=True)
|
||||||
|
|
||||||
progress = get_course_progress(course)
|
progress = get_course_progress(course)
|
||||||
frappe.db.set_value("LMS Enrollment", membership, "progress", progress)
|
# Had to get doc, as on_change doesn't trigger when you use set_value. The trigger is necesary for badge to get assigned.
|
||||||
enrollment = frappe.get_doc("LMS Enrollment", membership)
|
enrollment = frappe.get_doc("LMS Enrollment", membership)
|
||||||
|
enrollment.progress = progress
|
||||||
|
enrollment.save()
|
||||||
enrollment.run_method("on_change")
|
enrollment.run_method("on_change")
|
||||||
|
|
||||||
return progress
|
return progress
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,6 @@
|
|||||||
"label": "Comments"
|
"label": "Comments"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "course.evaluator",
|
|
||||||
"fieldname": "evaluator",
|
"fieldname": "evaluator",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Evaluator",
|
"label": "Evaluator",
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
"fieldname": "start_date",
|
"fieldname": "start_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Start Date",
|
"label": "Start Date",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -127,6 +128,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "start_time",
|
"fieldname": "start_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Start Time",
|
"label": "Start Time",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -165,6 +167,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "category",
|
"fieldname": "category",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Category",
|
"label": "Category",
|
||||||
"options": "LMS Category"
|
"options": "LMS Category"
|
||||||
},
|
},
|
||||||
@@ -325,7 +328,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-06-24 16:24:45.536453",
|
"modified": "2024-07-18 18:06:37.229885",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class LMSBatch(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
|
"title": self.title,
|
||||||
"student_name": student.student_name,
|
"student_name": student.student_name,
|
||||||
"start_time": self.start_time,
|
"start_time": self.start_time,
|
||||||
"start_date": self.start_date,
|
"start_date": self.start_date,
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
"course_title",
|
"course_title",
|
||||||
"member",
|
"member",
|
||||||
"member_name",
|
"member_name",
|
||||||
"column_break_3",
|
"column_break_vwbn",
|
||||||
"template",
|
|
||||||
"issue_date",
|
"issue_date",
|
||||||
|
"template",
|
||||||
|
"published",
|
||||||
|
"section_break_scyf",
|
||||||
"expiry_date",
|
"expiry_date",
|
||||||
"batch_name",
|
"column_break_slaw",
|
||||||
"published"
|
"batch_name"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -25,10 +27,6 @@
|
|||||||
"label": "Issue Date",
|
"label": "Issue Date",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "column_break_3",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@@ -85,11 +83,23 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Course Title",
|
"label": "Course Title",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_vwbn",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_scyf",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_slaw",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-06-21 18:14:30.491841",
|
"modified": "2024-07-16 15:29:19.708888",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate",
|
"name": "LMS Certificate",
|
||||||
@@ -120,13 +130,15 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"create": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "LMS Student",
|
"role": "LMS Student",
|
||||||
"share": 1
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ class LMSCertificate(Document):
|
|||||||
def has_website_permission(doc, ptype, user, verbose=False):
|
def has_website_permission(doc, ptype, user, verbose=False):
|
||||||
if ptype in ["read", "print"]:
|
if ptype in ["read", "print"]:
|
||||||
return True
|
return True
|
||||||
|
if doc.member == user and ptype == "create":
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -81,7 +83,9 @@ def create_certificate(course):
|
|||||||
certificate = is_certified(course)
|
certificate = is_certified(course)
|
||||||
|
|
||||||
if certificate:
|
if certificate:
|
||||||
return certificate
|
return frappe.db.get_value(
|
||||||
|
"LMS Certificate", certificate, ["name", "course", "template"], as_dict=True
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
expires_after_yrs = int(frappe.db.get_value("LMS Course", course, "expiry"))
|
expires_after_yrs = int(frappe.db.get_value("LMS Course", course, "expiry"))
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
"fieldtype": "Rating",
|
"fieldtype": "Rating",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Rating",
|
"label": "Rating",
|
||||||
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
|
"mandatory_depends_on": "eval:doc.status == 'Pass'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "summary",
|
"fieldname": "summary",
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-04-15 11:22:43.189908",
|
"modified": "2024-07-16 14:06:11.977666",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate Evaluation",
|
"name": "LMS Certificate Evaluation",
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class LMSCertificateRequest(Document):
|
|||||||
self.validate_if_existing_requests()
|
self.validate_if_existing_requests()
|
||||||
self.validate_evaluation_end_date()
|
self.validate_evaluation_end_date()
|
||||||
|
|
||||||
|
def after_insert(self):
|
||||||
|
self.send_notification()
|
||||||
|
|
||||||
def set_evaluator(self):
|
def set_evaluator(self):
|
||||||
if not self.evaluator:
|
if not self.evaluator:
|
||||||
self.evaluator = get_evaluator(self.course, self.batch_name)
|
self.evaluator = get_evaluator(self.course, self.batch_name)
|
||||||
@@ -42,7 +45,7 @@ class LMSCertificateRequest(Document):
|
|||||||
):
|
):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Evaluator is unavailable from {0} to {1}. Please select a date after {1}"
|
"The evaluator of this course is unavailable from {0} to {1}. Please select a date after {1}"
|
||||||
).format(
|
).format(
|
||||||
format_date(unavailable.unavailable_from, "medium"),
|
format_date(unavailable.unavailable_from, "medium"),
|
||||||
format_date(unavailable.unavailable_to, "medium"),
|
format_date(unavailable.unavailable_to, "medium"),
|
||||||
@@ -107,6 +110,35 @@ class LMSCertificateRequest(Document):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def send_notification(self):
|
||||||
|
outgoing_email_account = frappe.get_cached_value(
|
||||||
|
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
|
||||||
|
)
|
||||||
|
if outgoing_email_account or frappe.conf.get("mail_login"):
|
||||||
|
subject = _("Your evaluation slot has been booked")
|
||||||
|
template = "certificate_request_notification"
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"course": frappe.db.get_value("LMS Course", self.course, "title"),
|
||||||
|
"timezone": frappe.db.get_value("LMS Batch", self.batch_name, "timezone")
|
||||||
|
if self.batch_name
|
||||||
|
else "",
|
||||||
|
"date": format_date(self.date, "medium"),
|
||||||
|
"member_name": self.member_name,
|
||||||
|
"start_time": format_time(self.start_time, "short"),
|
||||||
|
"evaluator": frappe.db.get_value("User", self.evaluator, "full_name"),
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.sendmail(
|
||||||
|
recipients=[self.member],
|
||||||
|
cc=[self.evaluator],
|
||||||
|
subject=subject,
|
||||||
|
template=template,
|
||||||
|
args=args,
|
||||||
|
header=[subject, "green"],
|
||||||
|
retry=3,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def schedule_evals():
|
def schedule_evals():
|
||||||
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
||||||
|
|||||||
@@ -30,23 +30,23 @@
|
|||||||
"disable_self_learning",
|
"disable_self_learning",
|
||||||
"section_break_18",
|
"section_break_18",
|
||||||
"short_introduction",
|
"short_introduction",
|
||||||
|
"column_break_viqw",
|
||||||
"description",
|
"description",
|
||||||
|
"section_break_gglp",
|
||||||
"chapters",
|
"chapters",
|
||||||
"related_courses",
|
"related_courses",
|
||||||
|
"pricing_tab",
|
||||||
"pricing_section",
|
"pricing_section",
|
||||||
"paid_course",
|
"paid_course",
|
||||||
"column_break_acoj",
|
"column_break_acoj",
|
||||||
"course_price",
|
"course_price",
|
||||||
"currency",
|
"currency",
|
||||||
"amount_usd",
|
"amount_usd",
|
||||||
|
"certification_tab",
|
||||||
"certification_section",
|
"certification_section",
|
||||||
"enable_certification",
|
"enable_certification",
|
||||||
"expiry",
|
|
||||||
"max_attempts",
|
|
||||||
"column_break_rxww",
|
"column_break_rxww",
|
||||||
"grant_certificate_after",
|
"expiry"
|
||||||
"evaluator",
|
|
||||||
"duration"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -129,8 +129,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "certification_section",
|
"fieldname": "certification_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break"
|
||||||
"label": "Certification"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
@@ -170,25 +169,9 @@
|
|||||||
"fieldname": "column_break_10",
|
"fieldname": "column_break_10",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"depends_on": "enable_certification",
|
|
||||||
"fieldname": "grant_certificate_after",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Grant Certificate After",
|
|
||||||
"options": "Completion\nEvaluation"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
|
||||||
"fieldname": "evaluator",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Evaluator",
|
|
||||||
"mandatory_depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
|
||||||
"options": "Course Evaluator"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "pricing_section",
|
"fieldname": "pricing_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break"
|
||||||
"label": "Pricing"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "paid_course",
|
"depends_on": "paid_course",
|
||||||
@@ -198,20 +181,6 @@
|
|||||||
"mandatory_depends_on": "paid_course",
|
"mandatory_depends_on": "paid_course",
|
||||||
"options": "Currency"
|
"options": "Currency"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"default": "1",
|
|
||||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
|
||||||
"fieldname": "max_attempts",
|
|
||||||
"fieldtype": "Int",
|
|
||||||
"label": "Max Attempts for Evaluations"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
|
|
||||||
"fieldname": "duration",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"label": "Duration for Attempts",
|
|
||||||
"options": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "paid_course",
|
"fieldname": "paid_course",
|
||||||
@@ -250,6 +219,24 @@
|
|||||||
"fieldname": "featured",
|
"fieldname": "featured",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Featured"
|
"label": "Featured"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_viqw",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_gglp",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "pricing_tab",
|
||||||
|
"fieldtype": "Tab Break",
|
||||||
|
"label": "Pricing"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "certification_tab",
|
||||||
|
"fieldtype": "Tab Break",
|
||||||
|
"label": "Certification"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_published_field": "published",
|
"is_published_field": "published",
|
||||||
@@ -276,7 +263,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"make_attachments_public": 1,
|
"make_attachments_public": 1,
|
||||||
"modified": "2024-06-24 17:44:45.903164",
|
"modified": "2024-07-12 13:54:40.474097",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Course",
|
"name": "LMS Course",
|
||||||
|
|||||||
@@ -195,7 +195,8 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-05-24 16:12:26.331351",
|
"make_attachments_public": 1,
|
||||||
|
"modified": "2024-08-01 12:53:22.540990",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Question",
|
"name": "LMS Question",
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
"default": "1",
|
"default": "1",
|
||||||
"fieldname": "show_answers",
|
"fieldname": "show_answers",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Show Answers"
|
"label": "Show Answers"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -98,6 +99,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "passing_percentage",
|
"fieldname": "passing_percentage",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Passing Percentage",
|
"label": "Passing Percentage",
|
||||||
"non_negative": 1,
|
"non_negative": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
@@ -110,6 +113,7 @@
|
|||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "total_marks",
|
"fieldname": "total_marks",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Total Marks",
|
"label": "Total Marks",
|
||||||
"non_negative": 1,
|
"non_negative": 1,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@@ -133,7 +137,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-06-27 22:03:48.576489",
|
"modified": "2024-07-19 18:21:26.681501",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Quiz",
|
"name": "LMS Quiz",
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"question",
|
"question",
|
||||||
"marks"
|
"column_break_qcpo",
|
||||||
|
"marks",
|
||||||
|
"section_break_huup",
|
||||||
|
"question_detail"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -25,12 +28,28 @@
|
|||||||
"label": "Marks",
|
"label": "Marks",
|
||||||
"non_negative": 1,
|
"non_negative": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "question.question",
|
||||||
|
"fieldname": "question_detail",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Question Detail",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_qcpo",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_huup",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-10-16 19:51:03.893144",
|
"modified": "2024-07-29 15:10:09.662715",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Quiz Question",
|
"name": "LMS Quiz Question",
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
|
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
|
||||||
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short"), timezone) }}</p>
|
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, "medium"), frappe.utils.format_time(doc.start_time, "short"), timezone) }}</p>
|
||||||
<p> {{ _("Your evaluator is {0}").format(evaluator_name) }}
|
<p> {{ _("Your evaluator is {0}").format(evaluator_name) }} </p>
|
||||||
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Notification",
|
"doctype": "Notification",
|
||||||
"document_type": "LMS Certificate Request",
|
"document_type": "LMS Certificate Request",
|
||||||
"enabled": 1,
|
"enabled": 0,
|
||||||
"event": "New",
|
"event": "New",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }}\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }} </p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
||||||
"message_type": "HTML",
|
"message_type": "HTML",
|
||||||
"modified": "2024-07-10 15:51:03.429317",
|
"modified": "2024-08-01 12:17:40.647724",
|
||||||
"modified_by": "sayali@erpnext.com",
|
"modified_by": "jannat@frappe.io",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Certificate Request Creation",
|
"name": "Certificate Request Creation",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import getdate
|
from .utils import slugify
|
||||||
|
|
||||||
from lms.lms.doctype.lms_course.test_lms_course import new_course, new_user
|
|
||||||
|
|
||||||
from .utils import get_evaluation_details, slugify
|
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(unittest.TestCase):
|
class TestUtils(unittest.TestCase):
|
||||||
@@ -20,58 +16,3 @@ class TestUtils(unittest.TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
slugify("Hello World", ["hello-world", "hello-world-2"]), "hello-world-3"
|
slugify("Hello World", ["hello-world", "hello-world-2"]), "hello-world-3"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_evaluation_details(self):
|
|
||||||
user = new_user("Eval", "eval@test.com")
|
|
||||||
|
|
||||||
course = new_course(
|
|
||||||
"Test Evaluation Details",
|
|
||||||
{
|
|
||||||
"enable_certification": 1,
|
|
||||||
"grant_certificate_after": "Evaluation",
|
|
||||||
"evaluator": "evaluator@example.com",
|
|
||||||
"max_attempts": 3,
|
|
||||||
"duration": 2,
|
|
||||||
"instructors": [{"instructor": user.name}],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
# Two evaluations failed within max attempts. Check eligibility for a third evaluation
|
|
||||||
create_evaluation(user.name, course.name, getdate("21-03-2022"), 0.4, "Fail")
|
|
||||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
|
||||||
details = get_evaluation_details(course.name, user.name)
|
|
||||||
self.assertTrue(details.eligible)
|
|
||||||
|
|
||||||
# Three evaluations failed within max attempts. Check eligibility for a forth evaluation
|
|
||||||
create_evaluation(user.name, course.name, getdate("21-03-2022"), 0.4, "Fail")
|
|
||||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
|
||||||
create_evaluation(user.name, course.name, getdate("16-04-2022"), 0.4, "Fail")
|
|
||||||
details = get_evaluation_details(course.name, user.name)
|
|
||||||
self.assertFalse(details.eligible)
|
|
||||||
|
|
||||||
# Three evaluations failed within max attempts. Check eligibility for a forth evaluation. Different Dates
|
|
||||||
create_evaluation(user.name, course.name, getdate("01-03-2022"), 0.4, "Fail")
|
|
||||||
create_evaluation(user.name, course.name, getdate("12-04-2022"), 0.4, "Fail")
|
|
||||||
create_evaluation(user.name, course.name, getdate("16-04-2022"), 0.4, "Fail")
|
|
||||||
details = get_evaluation_details(course.name, user.name)
|
|
||||||
self.assertFalse(details.eligible)
|
|
||||||
|
|
||||||
frappe.db.delete("LMS Certificate Evaluation", {"course": course.name})
|
|
||||||
frappe.db.delete("LMS Course", course.name)
|
|
||||||
frappe.db.delete("User", user.name)
|
|
||||||
|
|
||||||
|
|
||||||
def create_evaluation(user, course, date, rating, status):
|
|
||||||
evaluation = frappe.get_doc(
|
|
||||||
{
|
|
||||||
"doctype": "LMS Certificate Evaluation",
|
|
||||||
"member": user,
|
|
||||||
"course": course,
|
|
||||||
"date": date,
|
|
||||||
"start_time": "12:00:00",
|
|
||||||
"end_time": "13:00:00",
|
|
||||||
"rating": rating,
|
|
||||||
"status": status,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
evaluation.save()
|
|
||||||
|
|||||||
@@ -452,45 +452,6 @@ def get_popular_courses():
|
|||||||
return course_membership[:3]
|
return course_membership[:3]
|
||||||
|
|
||||||
|
|
||||||
def get_evaluation_details(course, member=None):
|
|
||||||
info = frappe.db.get_value(
|
|
||||||
"LMS Course",
|
|
||||||
course,
|
|
||||||
["grant_certificate_after", "max_attempts", "duration"],
|
|
||||||
as_dict=True,
|
|
||||||
)
|
|
||||||
request = frappe.db.get_value(
|
|
||||||
"LMS Certificate Request",
|
|
||||||
{
|
|
||||||
"course": course,
|
|
||||||
"member": member or frappe.session.user,
|
|
||||||
"date": [">=", getdate()],
|
|
||||||
},
|
|
||||||
["date", "start_time", "end_time"],
|
|
||||||
as_dict=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
no_of_attempts = frappe.db.count(
|
|
||||||
"LMS Certificate Evaluation",
|
|
||||||
{
|
|
||||||
"course": course,
|
|
||||||
"member": member or frappe.session.user,
|
|
||||||
"status": ["!=", "Pass"],
|
|
||||||
"creation": [">=", add_months(getdate(), -abs(cint(info.duration)))],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return frappe._dict(
|
|
||||||
{
|
|
||||||
"eligible": info.grant_certificate_after == "Evaluation"
|
|
||||||
and not request
|
|
||||||
and no_of_attempts < info.max_attempts,
|
|
||||||
"request": request,
|
|
||||||
"no_of_attempts": no_of_attempts,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def format_amount(amount, currency):
|
def format_amount(amount, currency):
|
||||||
amount_reduced = amount / 1000
|
amount_reduced = amount / 1000
|
||||||
if amount_reduced < 1:
|
if amount_reduced < 1:
|
||||||
@@ -612,14 +573,6 @@ def get_courses_under_review():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_certificates(member=None):
|
|
||||||
return frappe.get_all(
|
|
||||||
"LMS Certificate",
|
|
||||||
{"member": member or frappe.session.user},
|
|
||||||
["course", "member", "issue_date", "expiry_date", "name"],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def validate_image(path):
|
def validate_image(path):
|
||||||
if path and "/private" in path:
|
if path and "/private" in path:
|
||||||
file = frappe.get_doc("File", {"file_url": path})
|
file = frappe.get_doc("File", {"file_url": path})
|
||||||
@@ -944,19 +897,13 @@ def has_graded_assessment(submission):
|
|||||||
return False if status == "Not Graded" else True
|
return False if status == "Not Graded" else True
|
||||||
|
|
||||||
|
|
||||||
def get_evaluator(course, batch=None):
|
def get_evaluator(course, batch):
|
||||||
evaluator = None
|
evaluator = None
|
||||||
|
evaluator = frappe.db.get_value(
|
||||||
if batch:
|
"Batch Course",
|
||||||
evaluator = frappe.db.get_value(
|
{"parent": batch, "course": course},
|
||||||
"Batch Course",
|
"evaluator",
|
||||||
{"parent": batch, "course": course},
|
)
|
||||||
"evaluator",
|
|
||||||
)
|
|
||||||
|
|
||||||
if not evaluator:
|
|
||||||
evaluator = frappe.db.get_value("LMS Course", course, "evaluator")
|
|
||||||
|
|
||||||
return evaluator
|
return evaluator
|
||||||
|
|
||||||
|
|
||||||
@@ -1285,6 +1232,7 @@ def get_course_details(course):
|
|||||||
"course_price",
|
"course_price",
|
||||||
"currency",
|
"currency",
|
||||||
"amount_usd",
|
"amount_usd",
|
||||||
|
"enable_certification",
|
||||||
],
|
],
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
@@ -1508,6 +1456,7 @@ def get_batch_details(batch):
|
|||||||
"evaluation_end_date",
|
"evaluation_end_date",
|
||||||
"allow_self_enrollment",
|
"allow_self_enrollment",
|
||||||
"timezone",
|
"timezone",
|
||||||
|
"category",
|
||||||
],
|
],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,10 +8,11 @@
|
|||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
<b>
|
<b>
|
||||||
{{ _("Important Details:") }}
|
{{ title }}
|
||||||
</b>
|
</b>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<b>{{ _("Batch Start Date:") }}</b> {{ frappe.utils.format_date(start_date, "medium") }}
|
<b>{{ _("Batch Start Date:") }}</b> {{ frappe.utils.format_date(start_date, "medium") }}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<p> {{ _("Hey {0}").format(member_name) }} </p>
|
||||||
|
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, date, start_time, timezone) }}</p>
|
||||||
|
<p> {{ _("Your evaluator is {0}").format(evaluator) }} </p>
|
||||||
|
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "frappe_lms",
|
"name": "frappe_lms",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Easy to use, open-source, Learning Management System",
|
"description": "Easy to use, open-source, Learning Management System",
|
||||||
"workspaces1": [
|
"workspaces": [
|
||||||
"frappe-ui",
|
"frappe-ui",
|
||||||
"frontend"
|
"frontend"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user