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
|
||||
lms/public/frontend
|
||||
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/embed": "^2.7.0",
|
||||
"@editorjs/header": "^2.8.1",
|
||||
"@editorjs/image": "^2.9.0",
|
||||
"@editorjs/inline-code": "^1.5.0",
|
||||
"@editorjs/nested-list": "^1.4.2",
|
||||
"@editorjs/paragraph": "^2.11.3",
|
||||
"@editorjs/simple-image": "^1.6.0",
|
||||
"chart.js": "^4.4.1",
|
||||
"dayjs": "^1.11.6",
|
||||
"feather-icons": "^4.28.0",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div
|
||||
v-if="sidebarSettings.data?.web_pages?.length || isModerator"
|
||||
class="pt-1"
|
||||
class="mt-4"
|
||||
>
|
||||
<div
|
||||
class="flex items-center justify-between pr-2 cursor-pointer"
|
||||
@@ -27,7 +27,7 @@
|
||||
>
|
||||
<div
|
||||
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">
|
||||
<ChevronRight
|
||||
@@ -36,7 +36,7 @@
|
||||
/>
|
||||
</span>
|
||||
<span class="ml-2">
|
||||
{{ __('Web Pages') }}
|
||||
{{ __('More') }}
|
||||
</span>
|
||||
</div>
|
||||
<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"
|
||||
style="min-height: 150px"
|
||||
>
|
||||
<div class="text-xl font-semibold mb-2">
|
||||
{{ batch.title }}
|
||||
</div>
|
||||
<Badge
|
||||
v-if="batch.seat_count && batch.seats_left > 0"
|
||||
theme="green"
|
||||
@@ -19,9 +22,6 @@
|
||||
>
|
||||
{{ __('Sold Out') }}
|
||||
</Badge>
|
||||
<div class="text-xl font-semibold mb-1">
|
||||
{{ batch.title }}
|
||||
</div>
|
||||
<div class="short-introduction">
|
||||
{{ batch.description }}
|
||||
</div>
|
||||
@@ -29,23 +29,23 @@
|
||||
<div v-if="batch.amount" class="font-semibold text-lg">
|
||||
{{ batch.price }}
|
||||
</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
|
||||
:startDate="batch.start_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" />
|
||||
<span>
|
||||
{{ formatTime(batch.start_time) }} - {{ formatTime(batch.end_time) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="batch.timezone" class="flex items-center">
|
||||
<Globe class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
|
||||
<div
|
||||
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>
|
||||
{{ batch.timezone }}
|
||||
</span>
|
||||
|
||||
@@ -2,28 +2,23 @@
|
||||
<div
|
||||
v-if="course.title"
|
||||
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
|
||||
style="min-height: 320px"
|
||||
style="min-height: 350px"
|
||||
>
|
||||
<div
|
||||
class="course-image"
|
||||
:class="{ 'default-image': !course.image }"
|
||||
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
|
||||
>
|
||||
<div class="flex relative top-4 left-4 w-fit flex-wrap">
|
||||
<Badge
|
||||
v-if="course.featured"
|
||||
variant="subtle"
|
||||
theme="green"
|
||||
size="md"
|
||||
class="mr-2"
|
||||
>
|
||||
<div
|
||||
class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
|
||||
>
|
||||
<Badge v-if="course.featured" variant="subtle" theme="green" size="md">
|
||||
{{ __('Featured') }}
|
||||
</Badge>
|
||||
<Badge
|
||||
variant="outline"
|
||||
theme="gray"
|
||||
size="md"
|
||||
class="mr-2"
|
||||
v-for="tag in course.tags"
|
||||
>
|
||||
{{ tag }}
|
||||
|
||||
@@ -63,6 +63,15 @@
|
||||
{{ __('Start Learning') }}
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
v-if="canGetCertificate"
|
||||
@click="fetchCertificate()"
|
||||
variant="subtle"
|
||||
class="w-full mt-2"
|
||||
size="md"
|
||||
>
|
||||
{{ __('Get Certificate') }}
|
||||
</Button>
|
||||
<router-link
|
||||
v-if="user?.data?.is_moderator || is_instructor()"
|
||||
:to="{
|
||||
@@ -136,7 +145,7 @@ function enrollStudent() {
|
||||
})
|
||||
setTimeout(() => {
|
||||
window.location.href = `/login?redirect-to=${window.location.pathname}`
|
||||
}, 3000)
|
||||
}, 2000)
|
||||
} else {
|
||||
const enrollStudentResource = createResource({
|
||||
url: 'lms.lms.doctype.lms_enrollment.lms_enrollment.create_membership',
|
||||
@@ -174,4 +183,39 @@ const 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>
|
||||
|
||||
@@ -130,11 +130,14 @@ function submitEvaluation(close) {
|
||||
close()
|
||||
},
|
||||
onError(err) {
|
||||
let message = err.messages?.[0] || err
|
||||
let unavailabilityMessage = message.includes('unavailable')
|
||||
|
||||
createToast({
|
||||
title: 'Error',
|
||||
text: err.messages?.[0] || err,
|
||||
icon: 'x',
|
||||
iconClasses: 'bg-red-600 text-white rounded-md p-px',
|
||||
title: unavailabilityMessage ? 'Evaluator is Unavailable' : 'Error',
|
||||
text: message,
|
||||
icon: unavailabilityMessage ? 'alert-circle' : 'x',
|
||||
iconClasses: 'bg-yellow-600 text-white rounded-md p-px',
|
||||
position: 'top-center',
|
||||
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>
|
||||
<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" />
|
||||
</video>
|
||||
<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">
|
||||
<template #icon>
|
||||
|
||||
@@ -7,7 +7,15 @@
|
||||
class="h-7"
|
||||
: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
|
||||
v-if="user.data?.is_moderator"
|
||||
:to="{
|
||||
@@ -33,7 +41,7 @@
|
||||
</div>
|
||||
<Tabs
|
||||
v-model="tabIndex"
|
||||
:tabs="tabs"
|
||||
:tabs="makeTabs"
|
||||
tablistClass="overflow-x-visible flex-wrap !gap-3 md:flex-nowrap"
|
||||
>
|
||||
<template #tab="{ tab, selected }">
|
||||
@@ -87,13 +95,29 @@
|
||||
</div>
|
||||
</template>
|
||||
<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 BatchCard from '@/components/BatchCard.vue'
|
||||
import { inject, ref, computed } from 'vue'
|
||||
import { inject, ref, computed, onMounted, watch } from 'vue'
|
||||
import { updateDocumentTitle } from '@/utils'
|
||||
|
||||
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({
|
||||
doctype: 'LMS Batch',
|
||||
@@ -102,35 +126,76 @@ const batches = createListResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const tabIndex = ref(0)
|
||||
const tabs = [
|
||||
{
|
||||
label: 'Upcoming',
|
||||
batches: computed(() => batches.data?.upcoming || []),
|
||||
count: computed(() => batches.data?.upcoming?.length),
|
||||
const categories = createResource({
|
||||
url: 'lms.lms.api.get_categories',
|
||||
makeParams() {
|
||||
return {
|
||||
doctype: 'LMS Batch',
|
||||
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({
|
||||
label: 'Archived',
|
||||
batches: computed(() => batches.data?.archived),
|
||||
count: computed(() => batches.data?.archived?.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),
|
||||
label,
|
||||
batches: computed(() => batches),
|
||||
count: computed(() => batches.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(() => {
|
||||
return {
|
||||
title: 'Batches',
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
</header>
|
||||
|
||||
<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
|
||||
:to="{
|
||||
name: 'Profile',
|
||||
@@ -59,12 +62,7 @@ const searchQuery = ref('')
|
||||
const participants = createResource({
|
||||
url: 'lms.lms.api.get_certified_participants',
|
||||
method: 'GET',
|
||||
debounce: 300,
|
||||
makeParams(values) {
|
||||
return {
|
||||
search_query: searchQuery.value,
|
||||
}
|
||||
},
|
||||
cache: 'certified-participants',
|
||||
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)
|
||||
</script>
|
||||
|
||||
@@ -134,29 +134,30 @@ let tabs
|
||||
|
||||
const makeTabs = computed(() => {
|
||||
tabs = []
|
||||
addToTabs('Live', getCourses('live'))
|
||||
addToTabs('New', getCourses('new'))
|
||||
addToTabs('Upcoming', getCourses('upcoming'))
|
||||
addToTabs('Live')
|
||||
addToTabs('New')
|
||||
addToTabs('Upcoming')
|
||||
|
||||
if (user.data) {
|
||||
addToTabs('Enrolled', getCourses('enrolled'))
|
||||
addToTabs('Enrolled')
|
||||
|
||||
if (
|
||||
user.data.is_moderator ||
|
||||
user.data.is_instructor ||
|
||||
courses.data?.created?.length
|
||||
) {
|
||||
addToTabs('Created', getCourses('created'))
|
||||
addToTabs('Created')
|
||||
}
|
||||
|
||||
if (user.data.is_moderator) {
|
||||
addToTabs('Under Review', getCourses('under_review'))
|
||||
addToTabs('Under Review')
|
||||
}
|
||||
}
|
||||
return tabs
|
||||
})
|
||||
|
||||
const addToTabs = (label, courses) => {
|
||||
const addToTabs = (label) => {
|
||||
let courses = getCourses(label.toLowerCase().split(' ').join('_'))
|
||||
tabs.push({
|
||||
label,
|
||||
courses: computed(() => courses),
|
||||
@@ -166,8 +167,12 @@ const addToTabs = (label, courses) => {
|
||||
|
||||
const getCourses = (type) => {
|
||||
if (searchQuery.value) {
|
||||
return courses.data[type].filter((course) =>
|
||||
course.title.toLowerCase().includes(searchQuery.value.toLowerCase())
|
||||
let query = 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]
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<div class="text-lg font-semibold mt-5 mb-4">
|
||||
{{ __('Settings') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-10 mb-4">
|
||||
<div class="grid grid-cols-3 gap-10 mb-4">
|
||||
<div
|
||||
v-if="user.data?.is_moderator"
|
||||
class="flex flex-col space-y-3"
|
||||
@@ -147,11 +147,18 @@
|
||||
v-model="course.featured"
|
||||
:label="__('Featured')"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col space-y-3">
|
||||
<FormControl
|
||||
type="checkbox"
|
||||
v-model="course.disable_self_learning"
|
||||
:label="__('Disable Self Enrollment')"
|
||||
/>
|
||||
<FormControl
|
||||
type="checkbox"
|
||||
v-model="course.enable_certification"
|
||||
:label="__('Completion Certificate')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -244,6 +251,7 @@ const course = reactive({
|
||||
featured: false,
|
||||
upcoming: false,
|
||||
disable_self_learning: false,
|
||||
enable_certification: false,
|
||||
paid_course: false,
|
||||
course_price: '',
|
||||
currency: '',
|
||||
@@ -337,6 +345,7 @@ const courseResource = createResource({
|
||||
'disable_self_learning',
|
||||
'paid_course',
|
||||
'featured',
|
||||
'enable_certification',
|
||||
]
|
||||
for (let idx in checkboxes) {
|
||||
let key = checkboxes[idx]
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div
|
||||
v-show="openInstructorEditor"
|
||||
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>
|
||||
@@ -54,7 +54,7 @@
|
||||
</label>
|
||||
<div
|
||||
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>
|
||||
@@ -439,7 +439,8 @@ const pageMeta = computed(() => {
|
||||
updateDocumentTitle(pageMeta)
|
||||
</script>
|
||||
<style>
|
||||
.embed-tool__caption {
|
||||
.embed-tool__caption,
|
||||
.cdx-simple-image__caption {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,17 @@
|
||||
</span>
|
||||
</Button>
|
||||
</router-link>
|
||||
<router-link
|
||||
v-else
|
||||
:to="{
|
||||
name: 'CourseDetail',
|
||||
params: { courseName: courseName },
|
||||
}"
|
||||
>
|
||||
<Button>
|
||||
{{ __('Back to Course') }}
|
||||
</Button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -160,12 +171,12 @@
|
||||
{{ lesson.data.course_title }}
|
||||
</div>
|
||||
<div v-if="user && lesson.data.membership" class="text-sm mt-3">
|
||||
{{ Math.ceil(lesson.data.membership.progress) }}% completed
|
||||
{{ Math.ceil(lessonProgress) }}% {{ __('completed') }}
|
||||
</div>
|
||||
|
||||
<ProgressBar
|
||||
v-if="user && lesson.data.membership"
|
||||
:progress="lesson.data.membership.progress"
|
||||
:progress="lessonProgress"
|
||||
/>
|
||||
</div>
|
||||
<CourseOutline
|
||||
@@ -179,7 +190,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
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 UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
@@ -196,6 +207,9 @@ const route = useRoute()
|
||||
const allowDiscussions = ref(false)
|
||||
const editor = ref(null)
|
||||
const instructorEditor = ref(null)
|
||||
const lessonProgress = ref(0)
|
||||
const timer = ref(0)
|
||||
let timerInterval
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -212,6 +226,10 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
startTimer()
|
||||
})
|
||||
|
||||
const lesson = createResource({
|
||||
url: 'lms.lms.utils.get_lesson',
|
||||
cache: ['lesson', props.courseName, props.chapterNumber, props.lessonNumber],
|
||||
@@ -224,7 +242,7 @@ const lesson = createResource({
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
markProgress(data)
|
||||
lessonProgress.value = data.membership?.progress
|
||||
if (data.content) editor.value = renderEditor('editor', data.content)
|
||||
if (data.instructor_content?.blocks?.length)
|
||||
instructorEditor.value = renderEditor(
|
||||
@@ -256,8 +274,10 @@ const renderEditor = (holder, content) => {
|
||||
})
|
||||
}
|
||||
|
||||
const markProgress = (data) => {
|
||||
if (user.data && !data.progress) progress.submit()
|
||||
const markProgress = () => {
|
||||
if (user.data && !lesson.data?.progress) {
|
||||
progress.submit()
|
||||
}
|
||||
}
|
||||
|
||||
const progress = createResource({
|
||||
@@ -268,6 +288,9 @@ const progress = createResource({
|
||||
course: props.courseName,
|
||||
}
|
||||
},
|
||||
onSuccess(data) {
|
||||
lessonProgress.value = data
|
||||
},
|
||||
})
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
@@ -304,10 +327,27 @@ watch(
|
||||
chapter: newChapterNumber,
|
||||
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 = () => {
|
||||
let quizPresent = false
|
||||
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'),
|
||||
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({
|
||||
|
||||
@@ -5,7 +5,7 @@ import router from '@/router'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
export const sessionStore = defineStore('lms-session', () => {
|
||||
let { userResource } = usersStore()
|
||||
let { userResource, allUsers } = usersStore()
|
||||
|
||||
function sessionUser() {
|
||||
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
|
||||
@@ -17,6 +17,9 @@ export const sessionStore = defineStore('lms-session', () => {
|
||||
}
|
||||
|
||||
let user = ref(sessionUser())
|
||||
if (user) {
|
||||
allUsers.reload()
|
||||
}
|
||||
const isLoggedIn = computed(() => !!user.value)
|
||||
|
||||
const login = createResource({
|
||||
|
||||
@@ -15,7 +15,6 @@ export const usersStore = defineStore('lms-users', () => {
|
||||
const allUsers = createResource({
|
||||
url: 'lms.lms.api.get_all_users',
|
||||
cache: ['allUsers'],
|
||||
auto: true,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
|
||||
|
||||
export default function translationPlugin(app) {
|
||||
app.config.globalProperties.__ = translate
|
||||
window.__ = translate
|
||||
if (!window.translatedMessages) fetchTranslations()
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import InlineCode from '@editorjs/inline-code'
|
||||
import { watch } from 'vue'
|
||||
import dayjs from '@/utils/dayjs'
|
||||
import Embed from '@editorjs/embed'
|
||||
import SimpleImage from '@editorjs/simple-image'
|
||||
|
||||
export function createToast(options) {
|
||||
toast({
|
||||
@@ -79,15 +80,18 @@ export function getFileSize(file_size) {
|
||||
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({
|
||||
title: title,
|
||||
text: htmlToText(text),
|
||||
icon: icon,
|
||||
iconClasses:
|
||||
icon == 'check'
|
||||
? 'bg-green-600 text-white rounded-md p-px'
|
||||
: 'bg-red-600 text-white rounded-md p-px',
|
||||
iconClasses: iconClasses,
|
||||
position: icon == 'check' ? 'bottom-right' : 'top-center',
|
||||
timeout: 5,
|
||||
})
|
||||
@@ -133,6 +137,7 @@ export function getEditorTools() {
|
||||
header: Header,
|
||||
quiz: Quiz,
|
||||
upload: Upload,
|
||||
image: SimpleImage,
|
||||
paragraph: {
|
||||
class: Paragraph,
|
||||
inlineToolbar: true,
|
||||
@@ -164,10 +169,68 @@ export function getEditorTools() {
|
||||
inlineToolbar: false,
|
||||
config: {
|
||||
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,
|
||||
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,
|
||||
slides: {
|
||||
regex: /https:\/\/docs\.google\.com\/presentation\/d\/e\/([A-Za-z0-9_-]+)\/pub/,
|
||||
|
||||
@@ -68,13 +68,6 @@
|
||||
dependencies:
|
||||
"@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":
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426"
|
||||
@@ -96,6 +89,13 @@
|
||||
dependencies:
|
||||
"@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":
|
||||
version "0.20.2"
|
||||
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"
|
||||
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
|
||||
name string-width-cjs
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
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"
|
||||
strip-ansi "^7.0.1"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
name strip-ansi-cjs
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
|
||||
47
lms/hooks.py
47
lms/hooks.py
@@ -176,52 +176,7 @@ update_website_context = [
|
||||
]
|
||||
|
||||
jinja = {
|
||||
"methods": [
|
||||
"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",
|
||||
],
|
||||
"methods": ["lms.lms.utils.get_signup_optin_checks"],
|
||||
"filters": [],
|
||||
}
|
||||
## 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)
|
||||
def get_certified_participants(search_query=""):
|
||||
def get_certified_participants():
|
||||
LMSCertificate = DocType("LMS Certificate")
|
||||
participants = (
|
||||
frappe.qb.from_(LMSCertificate)
|
||||
.select(LMSCertificate.member)
|
||||
.distinct()
|
||||
.where(LMSCertificate.member_name.like(f"%{search_query}%"))
|
||||
.where(LMSCertificate.published == 1)
|
||||
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
|
||||
.run(as_dict=1)
|
||||
@@ -542,3 +541,21 @@ def update_index(lessons, chapter):
|
||||
frappe.db.set_value(
|
||||
"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}
|
||||
)
|
||||
if not membership:
|
||||
return 0
|
||||
return
|
||||
|
||||
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
||||
|
||||
@@ -104,7 +104,7 @@ def save_progress(lesson, course):
|
||||
if frappe.db.exists(
|
||||
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
|
||||
):
|
||||
return 0
|
||||
return
|
||||
|
||||
frappe.get_doc(
|
||||
{
|
||||
@@ -116,9 +116,12 @@ def save_progress(lesson, course):
|
||||
).save(ignore_permissions=True)
|
||||
|
||||
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.progress = progress
|
||||
enrollment.save()
|
||||
enrollment.run_method("on_change")
|
||||
|
||||
return progress
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
"label": "Comments"
|
||||
},
|
||||
{
|
||||
"fetch_from": "course.evaluator",
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
"fieldname": "start_date",
|
||||
"fieldtype": "Date",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Start Date",
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -127,6 +128,7 @@
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
"fieldtype": "Time",
|
||||
"in_list_view": 1,
|
||||
"label": "Start Time",
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -165,6 +167,7 @@
|
||||
{
|
||||
"fieldname": "category",
|
||||
"fieldtype": "Link",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Category",
|
||||
"options": "LMS Category"
|
||||
},
|
||||
@@ -325,7 +328,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-24 16:24:45.536453",
|
||||
"modified": "2024-07-18 18:06:37.229885",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
|
||||
@@ -96,6 +96,7 @@ class LMSBatch(Document):
|
||||
)
|
||||
|
||||
args = {
|
||||
"title": self.title,
|
||||
"student_name": student.student_name,
|
||||
"start_time": self.start_time,
|
||||
"start_date": self.start_date,
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
"course_title",
|
||||
"member",
|
||||
"member_name",
|
||||
"column_break_3",
|
||||
"template",
|
||||
"column_break_vwbn",
|
||||
"issue_date",
|
||||
"template",
|
||||
"published",
|
||||
"section_break_scyf",
|
||||
"expiry_date",
|
||||
"batch_name",
|
||||
"published"
|
||||
"column_break_slaw",
|
||||
"batch_name"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -25,10 +27,6 @@
|
||||
"label": "Issue Date",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
@@ -85,11 +83,23 @@
|
||||
"fieldtype": "Data",
|
||||
"label": "Course Title",
|
||||
"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,
|
||||
"links": [],
|
||||
"modified": "2024-06-21 18:14:30.491841",
|
||||
"modified": "2024-07-16 15:29:19.708888",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate",
|
||||
@@ -120,13 +130,15 @@
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"share": 1
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
|
||||
@@ -73,6 +73,8 @@ class LMSCertificate(Document):
|
||||
def has_website_permission(doc, ptype, user, verbose=False):
|
||||
if ptype in ["read", "print"]:
|
||||
return True
|
||||
if doc.member == user and ptype == "create":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -81,7 +83,9 @@ def create_certificate(course):
|
||||
certificate = is_certified(course)
|
||||
|
||||
if certificate:
|
||||
return certificate
|
||||
return frappe.db.get_value(
|
||||
"LMS Certificate", certificate, ["name", "course", "template"], as_dict=True
|
||||
)
|
||||
|
||||
else:
|
||||
expires_after_yrs = int(frappe.db.get_value("LMS Course", course, "expiry"))
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
"fieldtype": "Rating",
|
||||
"in_list_view": 1,
|
||||
"label": "Rating",
|
||||
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
|
||||
"mandatory_depends_on": "eval:doc.status == 'Pass'"
|
||||
},
|
||||
{
|
||||
"fieldname": "summary",
|
||||
@@ -107,7 +107,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-04-15 11:22:43.189908",
|
||||
"modified": "2024-07-16 14:06:11.977666",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Evaluation",
|
||||
|
||||
@@ -26,6 +26,9 @@ class LMSCertificateRequest(Document):
|
||||
self.validate_if_existing_requests()
|
||||
self.validate_evaluation_end_date()
|
||||
|
||||
def after_insert(self):
|
||||
self.send_notification()
|
||||
|
||||
def set_evaluator(self):
|
||||
if not self.evaluator:
|
||||
self.evaluator = get_evaluator(self.course, self.batch_name)
|
||||
@@ -42,7 +45,7 @@ class LMSCertificateRequest(Document):
|
||||
):
|
||||
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_date(unavailable.unavailable_from, "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():
|
||||
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
||||
|
||||
@@ -30,23 +30,23 @@
|
||||
"disable_self_learning",
|
||||
"section_break_18",
|
||||
"short_introduction",
|
||||
"column_break_viqw",
|
||||
"description",
|
||||
"section_break_gglp",
|
||||
"chapters",
|
||||
"related_courses",
|
||||
"pricing_tab",
|
||||
"pricing_section",
|
||||
"paid_course",
|
||||
"column_break_acoj",
|
||||
"course_price",
|
||||
"currency",
|
||||
"amount_usd",
|
||||
"certification_tab",
|
||||
"certification_section",
|
||||
"enable_certification",
|
||||
"expiry",
|
||||
"max_attempts",
|
||||
"column_break_rxww",
|
||||
"grant_certificate_after",
|
||||
"evaluator",
|
||||
"duration"
|
||||
"expiry"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -129,8 +129,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "certification_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Certification"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -170,25 +169,9 @@
|
||||
"fieldname": "column_break_10",
|
||||
"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",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Pricing"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "paid_course",
|
||||
@@ -198,20 +181,6 @@
|
||||
"mandatory_depends_on": "paid_course",
|
||||
"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",
|
||||
"fieldname": "paid_course",
|
||||
@@ -250,6 +219,24 @@
|
||||
"fieldname": "featured",
|
||||
"fieldtype": "Check",
|
||||
"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",
|
||||
@@ -276,7 +263,7 @@
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2024-06-24 17:44:45.903164",
|
||||
"modified": "2024-07-12 13:54:40.474097",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
@@ -195,7 +195,8 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-05-24 16:12:26.331351",
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2024-08-01 12:53:22.540990",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Question",
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
"default": "1",
|
||||
"fieldname": "show_answers",
|
||||
"fieldtype": "Check",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Show Answers"
|
||||
},
|
||||
{
|
||||
@@ -98,6 +99,8 @@
|
||||
{
|
||||
"fieldname": "passing_percentage",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Passing Percentage",
|
||||
"non_negative": 1,
|
||||
"reqd": 1
|
||||
@@ -110,6 +113,7 @@
|
||||
"default": "0",
|
||||
"fieldname": "total_marks",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"label": "Total Marks",
|
||||
"non_negative": 1,
|
||||
"read_only": 1,
|
||||
@@ -133,7 +137,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-06-27 22:03:48.576489",
|
||||
"modified": "2024-07-19 18:21:26.681501",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz",
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"question",
|
||||
"marks"
|
||||
"column_break_qcpo",
|
||||
"marks",
|
||||
"section_break_huup",
|
||||
"question_detail"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -25,12 +28,28 @@
|
||||
"label": "Marks",
|
||||
"non_negative": 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,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-10-16 19:51:03.893144",
|
||||
"modified": "2024-07-29 15:10:09.662715",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz Question",
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
<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 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>
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "Notification",
|
||||
"document_type": "LMS Certificate Request",
|
||||
"enabled": 1,
|
||||
"enabled": 0,
|
||||
"event": "New",
|
||||
"idx": 0,
|
||||
"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",
|
||||
"modified": "2024-07-10 15:51:03.429317",
|
||||
"modified_by": "sayali@erpnext.com",
|
||||
"modified": "2024-08-01 12:17:40.647724",
|
||||
"modified_by": "jannat@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "Certificate Request Creation",
|
||||
"owner": "Administrator",
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.utils import getdate
|
||||
|
||||
from lms.lms.doctype.lms_course.test_lms_course import new_course, new_user
|
||||
|
||||
from .utils import get_evaluation_details, slugify
|
||||
from .utils import slugify
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
@@ -20,58 +16,3 @@ class TestUtils(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
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]
|
||||
|
||||
|
||||
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):
|
||||
amount_reduced = amount / 1000
|
||||
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):
|
||||
if path and "/private" in 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
|
||||
|
||||
|
||||
def get_evaluator(course, batch=None):
|
||||
def get_evaluator(course, batch):
|
||||
evaluator = None
|
||||
|
||||
if batch:
|
||||
evaluator = frappe.db.get_value(
|
||||
"Batch Course",
|
||||
{"parent": batch, "course": course},
|
||||
"evaluator",
|
||||
)
|
||||
|
||||
if not evaluator:
|
||||
evaluator = frappe.db.get_value("LMS Course", course, "evaluator")
|
||||
|
||||
evaluator = frappe.db.get_value(
|
||||
"Batch Course",
|
||||
{"parent": batch, "course": course},
|
||||
"evaluator",
|
||||
)
|
||||
return evaluator
|
||||
|
||||
|
||||
@@ -1285,6 +1232,7 @@ def get_course_details(course):
|
||||
"course_price",
|
||||
"currency",
|
||||
"amount_usd",
|
||||
"enable_certification",
|
||||
],
|
||||
as_dict=1,
|
||||
)
|
||||
@@ -1508,6 +1456,7 @@ def get_batch_details(batch):
|
||||
"evaluation_end_date",
|
||||
"allow_self_enrollment",
|
||||
"timezone",
|
||||
"category",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
<br>
|
||||
<p>
|
||||
<b>
|
||||
{{ _("Important Details:") }}
|
||||
{{ title }}
|
||||
</b>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>{{ _("Batch Start Date:") }}</b> {{ frappe.utils.format_date(start_date, "medium") }}
|
||||
</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",
|
||||
"version": "1.0.0",
|
||||
"description": "Easy to use, open-source, Learning Management System",
|
||||
"workspaces1": [
|
||||
"workspaces": [
|
||||
"frappe-ui",
|
||||
"frontend"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user