mirror of
https://github.com/frappe/lms.git
synced 2026-04-19 22:52:29 +03:00
Merge pull request #2174 from frappe/develop
chore: merge `develop` into `main-hotfix`
This commit is contained in:
1
.github/helper/install.sh
vendored
1
.github/helper/install.sh
vendored
@@ -11,6 +11,7 @@ cd ./frappe-bench || exit
|
||||
bench -v setup requirements
|
||||
|
||||
echo "Setting Up LMS App..."
|
||||
bench get-app "https://github.com/frappe/payments"
|
||||
bench get-app lms "${GITHUB_WORKSPACE}"
|
||||
|
||||
echo "Setting Up Sites & Database..."
|
||||
|
||||
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -62,6 +62,9 @@ jobs:
|
||||
mkdir -p ~/bench-cache
|
||||
(cd && tar czf ~/bench-cache/bench.tgz frappe-bench)
|
||||
fi
|
||||
- name: add payments app to bench
|
||||
working-directory: /home/runner/frappe-bench
|
||||
run: bench get-app https://github.com/frappe/payments
|
||||
- name: add lms app to bench
|
||||
working-directory: /home/runner/frappe-bench
|
||||
run: bench get-app lms $GITHUB_WORKSPACE
|
||||
|
||||
@@ -104,16 +104,18 @@ describe("Course Creation", () => {
|
||||
cy.closeOnboardingModal();
|
||||
|
||||
cy.url().should("include", "/lms/courses");
|
||||
cy.get(".grid a:first").within(() => {
|
||||
cy.get("div").contains("Test Course");
|
||||
cy.get("div").contains(
|
||||
"Test Course Short Introduction to test the UI"
|
||||
);
|
||||
cy.get(".bg-cover")
|
||||
.invoke("css", "background-image")
|
||||
.should("include", "/files/profile");
|
||||
});
|
||||
cy.get(".grid a:first").click();
|
||||
cy.get("div")
|
||||
.contains("Test Course")
|
||||
.closest("a")
|
||||
.within(() => {
|
||||
cy.get("div").contains(
|
||||
"Test Course Short Introduction to test the UI"
|
||||
);
|
||||
cy.get(".bg-cover")
|
||||
.invoke("css", "background-image")
|
||||
.should("include", "/files/profile");
|
||||
});
|
||||
cy.get("div").contains("Test Course").closest("a").click();
|
||||
cy.url().should("include", "/lms/courses/test-course");
|
||||
cy.get("div").contains("Test Course");
|
||||
cy.get("div").contains("Test Course Short Introduction to test the UI");
|
||||
@@ -142,7 +144,6 @@ describe("Course Creation", () => {
|
||||
);
|
||||
|
||||
// Add Discussion
|
||||
cy.get("span").contains("Community").click();
|
||||
cy.button("New Question").click();
|
||||
cy.wait(500);
|
||||
cy.get("[data-dismissable-layer]").within(() => {
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
"@editorjs/table": "2.4.2",
|
||||
"@vueuse/core": "^14.1.0",
|
||||
"ace-builds": "1.36.2",
|
||||
"apexcharts": "4.3.0",
|
||||
"chart.js": "4.4.1",
|
||||
"codemirror": "6.0.1",
|
||||
"dayjs": "1.11.10",
|
||||
"dompurify": "3.2.6",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<FrappeUIProvider>
|
||||
<Layout class="isolate text-base">
|
||||
<Layout class="isolate text-p-base">
|
||||
<router-view />
|
||||
</Layout>
|
||||
<InstallPrompt v-if="isMobile && !settings.data?.disable_pwa" />
|
||||
|
||||
@@ -421,6 +421,8 @@ const canGradeSubmission = computed(() => {
|
||||
const canModifyAssignment = computed(() => {
|
||||
if (canGradeSubmission.value) {
|
||||
return true
|
||||
} else if (props.submissionName == 'new') {
|
||||
return true
|
||||
} else if (
|
||||
submissionResource.doc?.owner == user.data?.name &&
|
||||
submissionResource.doc?.status == 'Not Graded'
|
||||
|
||||
@@ -90,21 +90,26 @@
|
||||
{{ __('Get Certificate') }}
|
||||
</Button>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<div class="space-y-3">
|
||||
<div class="font-medium text-ink-gray-9">
|
||||
{{ __('This course has:') }}
|
||||
</div>
|
||||
<div class="flex items-center text-ink-gray-9">
|
||||
<BookOpen class="h-4 w-4 stroke-1.5" />
|
||||
<span class="ml-2">
|
||||
{{ course.data.lessons }} {{ __('Lessons') }}
|
||||
{{ course.data.lessons }}
|
||||
{{ course.data.lessons > 1 ? __('lessons') : __('lesson') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center text-ink-gray-9">
|
||||
<Users class="h-4 w-4 stroke-1.5" />
|
||||
<span class="ml-2">
|
||||
{{ formatAmount(course.data.enrollments) }}
|
||||
{{ __('Enrolled Students') }}
|
||||
{{
|
||||
course.data.enrollments > 1
|
||||
? __('enrolled students')
|
||||
: __('enrolled student')
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
@@ -113,7 +118,7 @@
|
||||
>
|
||||
<Star class="size-4 stroke-1.5 fill-yellow-500 text-transparent" />
|
||||
<span class="ml-2">
|
||||
{{ course.data.rating }} {{ __('Rating') }}
|
||||
{{ course.data.rating }} {{ __('average rating') }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
<div class="text-lg font-semibold text-ink-gray-7 mb-2.5">
|
||||
{{ __('No {0}').format(type?.toLowerCase()) }}
|
||||
</div>
|
||||
<div
|
||||
class="leading-5 text-base w-full md:w-2/5 text-base text-center text-ink-gray-7"
|
||||
>
|
||||
<div class="text-p-base w-full md:w-2/5 text-center text-ink-gray-7">
|
||||
{{
|
||||
__(
|
||||
'There are no {0} currently. Keep an eye out, fresh learning experiences are on the way!'
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
: __('Edit Assignment')
|
||||
}}
|
||||
</div>
|
||||
<div class="space-y-4 max-h-[75vh] overflow-y-auto">
|
||||
<div class="space-y-4 max-h-[75vh] overflow-y-auto p-1">
|
||||
<FormControl
|
||||
v-model="assignment.title"
|
||||
:label="__('Title')"
|
||||
@@ -43,7 +43,7 @@
|
||||
@change="(val) => (assignment.question = val)"
|
||||
:editable="true"
|
||||
:fixedMenu="true"
|
||||
editorClass="prose-sm max-w-none border-b border-x border-outline-gray-modals bg-surface-gray-2 rounded-b-md py-1 px-2 min-h-[7rem] max-h-[18rem] overflow-y-auto"
|
||||
editorClass="prose-sm max-w-none border-b border-x border-outline-gray-modals bg-surface-gray-2 rounded-b-md py-1 px-2 min-h-[10rem] max-h-[18rem] overflow-y-auto"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,7 +73,7 @@
|
||||
import { Button, Dialog, FormControl, TextEditor, toast } from 'frappe-ui'
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import { escapeHTML, sanitizeHTML } from '@/utils'
|
||||
import { Link } from 'frappe-ui/frappe'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
|
||||
const show = defineModel()
|
||||
const assignments = defineModel<Assignments>('assignments')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
size: '5xl',
|
||||
size: '3xl',
|
||||
}"
|
||||
>
|
||||
<template #body>
|
||||
@@ -10,17 +10,14 @@
|
||||
<div class="text-lg font-semibold text-ink-gray-9 mb-5">
|
||||
{{ __(props.title) }}
|
||||
</div>
|
||||
<div
|
||||
<Switch
|
||||
v-if="!editMode"
|
||||
class="flex items-center text-xs text-ink-gray-7 space-x-5"
|
||||
>
|
||||
<Switch
|
||||
size="sm"
|
||||
:label="__('Choose an existing question')"
|
||||
v-model="chooseFromExisting"
|
||||
class="!p-0"
|
||||
/>
|
||||
</div>
|
||||
size="sm"
|
||||
:label="__('Choose an existing question')"
|
||||
:description="__('Select from questions you have already created')"
|
||||
v-model="chooseFromExisting"
|
||||
class="!p-0"
|
||||
/>
|
||||
<div v-if="!chooseFromExisting || editMode">
|
||||
<div>
|
||||
<label class="block text-xs text-ink-gray-5 mb-1">
|
||||
@@ -164,7 +161,7 @@ populateFields()
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: __('Add a new question'),
|
||||
default: __('Add new question'),
|
||||
},
|
||||
questionDetail: {
|
||||
type: [Object, null],
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<Search class="size-4 stroke-1.5 text-ink-gray-5" />
|
||||
</template>
|
||||
</FormControl>
|
||||
<div class="overflow-auto h-[60vh]">
|
||||
<div class="overflow-auto max-h-[60vh]">
|
||||
<div class="divide-y divide-outline-gray-modals">
|
||||
<div
|
||||
v-for="evaluator in evaluators.data"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<Search class="size-4 stroke-1.5 text-ink-gray-5" />
|
||||
</template>
|
||||
</FormControl>
|
||||
<div class="overflow-y-scroll h-[60vh]">
|
||||
<div class="overflow-y-scroll max-h-[60vh]">
|
||||
<ul class="divide-y divide-outline-gray-modals">
|
||||
<li
|
||||
v-for="member in memberList"
|
||||
|
||||
@@ -55,17 +55,18 @@
|
||||
:label="__('Member')"
|
||||
doctype="User"
|
||||
v-model="transactionData.member"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.member?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Billing Name')"
|
||||
v-model="transactionData.billing_name"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.billing_name?.reqd"
|
||||
/>
|
||||
<Link
|
||||
:label="__('Source')"
|
||||
v-model="transactionData.source"
|
||||
doctype="LMS Source"
|
||||
:required="!!fieldMeta.source?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
type="select"
|
||||
@@ -73,12 +74,14 @@
|
||||
:label="__('Payment For Document Type')"
|
||||
v-model="transactionData.payment_for_document_type"
|
||||
doctype="DocType"
|
||||
:required="!!fieldMeta.payment_for_document_type?.reqd"
|
||||
/>
|
||||
<Link
|
||||
v-if="transactionData.payment_for_document_type"
|
||||
:label="__('Payment For Document')"
|
||||
v-model="transactionData.payment_for_document"
|
||||
:doctype="transactionData.payment_for_document_type"
|
||||
:required="!!fieldMeta.payment_for_document?.reqd"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -90,17 +93,18 @@
|
||||
:label="__('Currency')"
|
||||
v-model="transactionData.currency"
|
||||
doctype="Currency"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.currency?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Amount')"
|
||||
v-model="transactionData.amount"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.amount?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="transactionData.amount_with_gst"
|
||||
:label="__('Amount with GST')"
|
||||
v-model="transactionData.amount_with_gst"
|
||||
:required="!!fieldMeta.amount_with_gst?.reqd"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -113,21 +117,25 @@
|
||||
v-if="transactionData.coupon"
|
||||
:label="__('Coupon Code')"
|
||||
v-model="transactionData.coupon"
|
||||
:required="!!fieldMeta.coupon?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="transactionData.coupon"
|
||||
:label="__('Coupon Code')"
|
||||
v-model="transactionData.coupon_code"
|
||||
:required="!!fieldMeta.coupon_code?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="transactionData.coupon"
|
||||
:label="__('Discount Amount')"
|
||||
v-model="transactionData.discount_amount"
|
||||
:required="!!fieldMeta.discount_amount?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="transactionData.coupon"
|
||||
:label="__('Original Amount')"
|
||||
v-model="transactionData.original_amount"
|
||||
:required="!!fieldMeta.original_amount?.reqd"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -140,17 +148,27 @@
|
||||
:label="__('Address')"
|
||||
v-model="transactionData.address"
|
||||
doctype="Address"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.address?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('GSTIN')"
|
||||
v-model="transactionData.gstin"
|
||||
:required="!!fieldMeta.gstin?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('PAN')"
|
||||
v-model="transactionData.pan"
|
||||
:required="!!fieldMeta.pan?.reqd"
|
||||
/>
|
||||
<FormControl :label="__('GSTIN')" v-model="transactionData.gstin" />
|
||||
<FormControl :label="__('PAN')" v-model="transactionData.pan" />
|
||||
<FormControl
|
||||
:label="__('Payment ID')"
|
||||
v-model="transactionData.payment_id"
|
||||
:required="!!fieldMeta.payment_id?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Order ID')"
|
||||
v-model="transactionData.order_id"
|
||||
:required="!!fieldMeta.order_id?.reqd"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -171,6 +189,10 @@ const show = defineModel('show')
|
||||
const props = defineProps<{
|
||||
transactions: any
|
||||
data: any
|
||||
fieldMeta: Record<
|
||||
string,
|
||||
{ reqd?: number; default?: string; description?: string }
|
||||
>
|
||||
}>()
|
||||
|
||||
const saveTransaction = () => {
|
||||
@@ -211,48 +233,49 @@ const updateTransaction = () => {
|
||||
}
|
||||
|
||||
const openDetails = () => {
|
||||
if (props.data) {
|
||||
const docType = props.data.payment_for_document_type
|
||||
const docName = props.data.payment_for_document
|
||||
if (docType && docName) {
|
||||
router.push({
|
||||
name: docType == 'LMS Course' ? 'CourseDetail' : 'BatchDetail',
|
||||
params: {
|
||||
[docType == 'LMS Course' ? 'courseName' : 'batchName']: docName,
|
||||
},
|
||||
})
|
||||
}
|
||||
const docType = transactionData.value?.payment_for_document_type
|
||||
const docName = transactionData.value?.payment_for_document
|
||||
if (docType && docName) {
|
||||
router.push({
|
||||
name: docType == 'LMS Course' ? 'CourseDetail' : 'BatchDetail',
|
||||
params: {
|
||||
[docType == 'LMS Course' ? 'courseName' : 'batchName']: docName,
|
||||
},
|
||||
})
|
||||
show.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const emptyTransactionData = {
|
||||
const getDefault = (fieldname: string) =>
|
||||
props.fieldMeta[fieldname]?.default || null
|
||||
|
||||
const getEmptyTransactionData = () => ({
|
||||
payment_received: false,
|
||||
payment_for_certificate: false,
|
||||
member: null,
|
||||
billing_name: null,
|
||||
source: null,
|
||||
payment_for_document_type: null,
|
||||
payment_for_document: null,
|
||||
member: getDefault('member'),
|
||||
billing_name: getDefault('billing_name'),
|
||||
source: getDefault('source'),
|
||||
payment_for_document_type: getDefault('payment_for_document_type'),
|
||||
payment_for_document: getDefault('payment_for_document'),
|
||||
member_consent: false,
|
||||
currency: null,
|
||||
amount: null,
|
||||
amount_with_gst: null,
|
||||
coupon: null,
|
||||
coupon_code: null,
|
||||
discount_amount: null,
|
||||
original_amount: null,
|
||||
order_id: null,
|
||||
payment_id: null,
|
||||
gstin: null,
|
||||
pan: null,
|
||||
address: null,
|
||||
}
|
||||
currency: getDefault('currency'),
|
||||
amount: getDefault('amount'),
|
||||
amount_with_gst: getDefault('amount_with_gst'),
|
||||
coupon: getDefault('coupon'),
|
||||
coupon_code: getDefault('coupon_code'),
|
||||
discount_amount: getDefault('discount_amount'),
|
||||
original_amount: getDefault('original_amount'),
|
||||
order_id: getDefault('order_id'),
|
||||
payment_id: getDefault('payment_id'),
|
||||
gstin: getDefault('gstin'),
|
||||
pan: getDefault('pan'),
|
||||
address: getDefault('address'),
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
(newVal) => {
|
||||
transactionData.value = newVal ? { ...newVal } : emptyTransactionData
|
||||
transactionData.value = newVal ? { ...newVal } : getEmptyTransactionData()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
v-if="step == 'new'"
|
||||
:transactions="transactions"
|
||||
:data="data"
|
||||
:fieldMeta="fieldMeta.data || {}"
|
||||
v-model:show="show"
|
||||
@updateStep="updateStep"
|
||||
/>
|
||||
@@ -17,13 +18,14 @@
|
||||
v-else-if="step == 'details'"
|
||||
:transactions="transactions"
|
||||
:data="data"
|
||||
:fieldMeta="fieldMeta.data || {}"
|
||||
v-model:show="show"
|
||||
@updateStep="updateStep"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { createListResource } from 'frappe-ui'
|
||||
import { createListResource, createResource } from 'frappe-ui'
|
||||
import TransactionList from '@/components/Settings/Transactions/TransactionList.vue'
|
||||
import TransactionDetails from '@/components/Settings/Transactions/TransactionDetails.vue'
|
||||
|
||||
@@ -45,6 +47,11 @@ const updateStep = (newStep: 'list' | 'new' | 'edit', newData: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const fieldMeta = createResource({
|
||||
url: 'lms.lms.api.get_payment_field_meta',
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const transactions = createListResource({
|
||||
doctype: 'LMS Payment',
|
||||
fields: [
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
<script setup>
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { Dropdown } from 'frappe-ui'
|
||||
import { call, Dropdown, toast } from 'frappe-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { convertToTitleCase } from '@/utils'
|
||||
import { usersStore } from '@/stores/user'
|
||||
@@ -85,7 +85,7 @@ import {
|
||||
User,
|
||||
Settings,
|
||||
Sun,
|
||||
Zap,
|
||||
Trash2,
|
||||
} from 'lucide-vue-next'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -175,6 +175,19 @@ const userDropdownOptions = computed(() => {
|
||||
return userResource.data?.is_moderator
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Clear Demo Data',
|
||||
icon: Trash2,
|
||||
onClick: () => {
|
||||
clearDemoDataConfirmation()
|
||||
},
|
||||
condition: () => {
|
||||
return (
|
||||
userResource.data?.is_moderator &&
|
||||
settingsStore.settings.data?.demo_data_present
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: FrappeCloudIcon,
|
||||
label: 'Login to Frappe Cloud',
|
||||
@@ -234,4 +247,36 @@ const loginToFrappeCloud = () => {
|
||||
let redirect_to = '/dashboard/sites/' + userResource.data.sitename
|
||||
window.open(`${frappeCloudBaseEndpoint}${redirect_to}`, '_blank')
|
||||
}
|
||||
|
||||
const clearDemoDataConfirmation = () => {
|
||||
$dialog({
|
||||
title: __('Confirm clearing demo data?'),
|
||||
message: __(
|
||||
'Are you sure you want to clear the demo data? This would delete the course "A guide to Frappe Learning" along with all its associated data. This action cannot be undone.'
|
||||
),
|
||||
actions: [
|
||||
{
|
||||
label: __('Confirm'),
|
||||
theme: 'red',
|
||||
variant: 'solid',
|
||||
onClick(close) {
|
||||
clearDemoData()
|
||||
close()
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
const clearDemoData = () => {
|
||||
call('lms.lms.api.clear_demo_data')
|
||||
.then(() => {
|
||||
window.location.href = '/lms'
|
||||
toast.success(__('Demo data cleared successfully'))
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error(__(error.message || 'Error clearing demo data'))
|
||||
console.error('Error clearing demo data:', error)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</Button>
|
||||
</div>
|
||||
<Dropdown
|
||||
v-else-if="isAdmin"
|
||||
v-else-if="isAdmin && batchMenu.length"
|
||||
:options="batchMenu"
|
||||
placement="left"
|
||||
side="left"
|
||||
@@ -209,6 +209,9 @@ const canMakeAnnouncement = () => {
|
||||
}
|
||||
|
||||
const batchMenu = computed(() => {
|
||||
if (!batch.data?.certification && !canMakeAnnouncement()) {
|
||||
return []
|
||||
}
|
||||
let options = [
|
||||
{
|
||||
label: __('Generate Certificates'),
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="!readOnlyMode">
|
||||
<div v-if="!readOnlyMode && !canAccessBatch">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'Billing',
|
||||
@@ -71,7 +71,7 @@
|
||||
batch.data.accept_enrollments
|
||||
"
|
||||
>
|
||||
<Button v-if="!canAccessBatch" class="w-full mt-4" variant="solid">
|
||||
<Button class="w-full mt-4" variant="solid">
|
||||
<template #prefix>
|
||||
<CreditCard class="size-4 stroke-1.5" />
|
||||
</template>
|
||||
@@ -151,6 +151,10 @@ const enrollInBatch = () => {
|
||||
},
|
||||
})
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(__(err.messages?.[0] || err))
|
||||
console.error(err)
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -169,14 +173,6 @@ const isEvaluator = computed(() => {
|
||||
return user.data?.is_evaluator
|
||||
})
|
||||
|
||||
const isInstructor = computed(() => {
|
||||
return (
|
||||
props.batch.data?.instructors?.filter(
|
||||
(instructor) => instructor.name === user.data?.name
|
||||
).length > 0
|
||||
)
|
||||
})
|
||||
|
||||
const canAccessBatch = computed(() => {
|
||||
if (!user.data) {
|
||||
return false
|
||||
@@ -184,7 +180,7 @@ const canAccessBatch = computed(() => {
|
||||
return isModerator.value || isStudent.value || isEvaluator.value
|
||||
})
|
||||
|
||||
const canEditBatch = computed(() => {
|
||||
return isModerator.value || isInstructor.value
|
||||
const isAdmin = computed(() => {
|
||||
return isModerator.value || isEvaluator.value
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
v-model="batch.title"
|
||||
:label="__('Title')"
|
||||
:required="true"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="batch.start_date"
|
||||
@@ -42,6 +43,7 @@
|
||||
v-model="batch.timezone"
|
||||
:label="__('Timezone')"
|
||||
:required="true"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<Link
|
||||
doctype="LMS Category"
|
||||
@@ -72,6 +74,13 @@
|
||||
|
||||
<div class="space-y-5 border-t mt-5 pt-5">
|
||||
<div class="grid grid-cols-2 gap-5">
|
||||
<FormControl
|
||||
v-model="batch.description"
|
||||
:label="__('Description')"
|
||||
type="textarea"
|
||||
:required="true"
|
||||
:rows="4"
|
||||
/>
|
||||
<MultiSelect
|
||||
v-model="batch.instructors"
|
||||
doctype="Course Evaluator"
|
||||
@@ -80,13 +89,6 @@
|
||||
:onCreate="(close: () => void) => openSettings('Evaluators', close)"
|
||||
:filters="{ ignore_user_type: 1 }"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="batch.description"
|
||||
:label="__('Description')"
|
||||
type="textarea"
|
||||
:required="true"
|
||||
:rows="4"
|
||||
/>
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="mb-1.5 text-sm text-ink-gray-5">
|
||||
|
||||
@@ -114,25 +114,27 @@
|
||||
<FormControl
|
||||
:label="__('Billing Name')"
|
||||
v-model="billingDetails.billing_name"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.billing_name?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Address Line 1')"
|
||||
v-model="billingDetails.address_line1"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.address_line1?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Address Line 2')"
|
||||
v-model="billingDetails.address_line2"
|
||||
:required="!!fieldMeta.address_line2?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('City')"
|
||||
v-model="billingDetails.city"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.city?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('State/Province')"
|
||||
v-model="billingDetails.state"
|
||||
:required="!!fieldMeta.state?.reqd"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
@@ -141,34 +143,36 @@
|
||||
:value="billingDetails.country"
|
||||
@change="(option) => changeCurrency(option)"
|
||||
:label="__('Country')"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.country?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Postal Code')"
|
||||
v-model="billingDetails.pincode"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.pincode?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
:label="__('Phone Number')"
|
||||
v-model="billingDetails.phone"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.phone?.reqd"
|
||||
/>
|
||||
<Link
|
||||
doctype="LMS Source"
|
||||
:value="billingDetails.source"
|
||||
@change="(option) => (billingDetails.source = option)"
|
||||
:label="__('Where did you hear about us?')"
|
||||
:required="true"
|
||||
:required="!!fieldMeta.source?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="billingDetails.country == 'India'"
|
||||
:label="__('GST Number')"
|
||||
v-model="billingDetails.gstin"
|
||||
:required="!!fieldMeta.gstin?.reqd"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="billingDetails.country == 'India'"
|
||||
:label="__('PAN Number')"
|
||||
v-model="billingDetails.pan"
|
||||
:required="!!fieldMeta.pan?.reqd"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -273,6 +277,7 @@ const access = createResource({
|
||||
name: props.name,
|
||||
},
|
||||
onSuccess(data) {
|
||||
Object.assign(fieldMeta, data.billing_field_meta || {})
|
||||
setBillingDetails(data.address)
|
||||
orderSummary.submit()
|
||||
},
|
||||
@@ -295,19 +300,24 @@ const orderSummary = createResource({
|
||||
|
||||
const appliedCoupon = ref(null)
|
||||
const billingDetails = reactive({})
|
||||
const fieldMeta = reactive({})
|
||||
|
||||
const getDefault = (fieldname) => fieldMeta[fieldname]?.default || ''
|
||||
|
||||
const setBillingDetails = (data) => {
|
||||
billingDetails.billing_name = data?.billing_name || ''
|
||||
billingDetails.address_line1 = data?.address_line1 || ''
|
||||
billingDetails.address_line2 = data?.address_line2 || ''
|
||||
billingDetails.city = data?.city || ''
|
||||
billingDetails.state = data?.state || ''
|
||||
billingDetails.country = data?.country || ''
|
||||
billingDetails.pincode = data?.pincode || ''
|
||||
billingDetails.phone = data?.phone || ''
|
||||
billingDetails.source = data?.source || ''
|
||||
billingDetails.gstin = data?.gstin || ''
|
||||
billingDetails.pan = data?.pan || ''
|
||||
billingDetails.billing_name = data?.billing_name || getDefault('billing_name')
|
||||
billingDetails.address_line1 =
|
||||
data?.address_line1 || getDefault('address_line1')
|
||||
billingDetails.address_line2 =
|
||||
data?.address_line2 || getDefault('address_line2')
|
||||
billingDetails.city = data?.city || getDefault('city')
|
||||
billingDetails.state = data?.state || getDefault('state')
|
||||
billingDetails.country = data?.country || getDefault('country')
|
||||
billingDetails.pincode = data?.pincode || getDefault('pincode')
|
||||
billingDetails.phone = data?.phone || getDefault('phone')
|
||||
billingDetails.source = data?.source || getDefault('source')
|
||||
billingDetails.gstin = data?.gstin || getDefault('gstin')
|
||||
billingDetails.pan = data?.pan || getDefault('pan')
|
||||
}
|
||||
|
||||
const paymentLink = createResource({
|
||||
@@ -336,7 +346,7 @@ const generatePaymentLink = () => {
|
||||
{},
|
||||
{
|
||||
validate() {
|
||||
if (!billingDetails.source) {
|
||||
if (!billingDetails.source && fieldMeta.source?.reqd) {
|
||||
return __('Please let us know where you heard about us from.')
|
||||
}
|
||||
if (!billingDetails.member_consent) {
|
||||
@@ -370,15 +380,19 @@ function removeCoupon() {
|
||||
}
|
||||
|
||||
const validateAddress = () => {
|
||||
let mandatoryFields = [
|
||||
let billingFields = [
|
||||
'billing_name',
|
||||
'address_line1',
|
||||
'address_line2',
|
||||
'city',
|
||||
'state',
|
||||
'pincode',
|
||||
'country',
|
||||
'phone',
|
||||
'source',
|
||||
'gstin',
|
||||
'pan',
|
||||
]
|
||||
let mandatoryFields = billingFields.filter((f) => fieldMeta[f]?.reqd)
|
||||
for (let field of mandatoryFields) {
|
||||
if (!billingDetails[field])
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<div class="pl-5">
|
||||
<div class="grid grid-cols-1 md:grid-cols-[70%,30%]">
|
||||
<div v-if="courseResource.doc" class="lg:max-h-[88vh] lg:overflow-y-auto">
|
||||
<div
|
||||
v-if="courseResource.doc"
|
||||
class="lg:max-h-[88vh] lg:overflow-y-auto px-1"
|
||||
>
|
||||
<div class="my-5">
|
||||
<div class="pr-5 md:pr-10 pb-5 mb-5 space-y-5 border-b">
|
||||
<div class="text-lg font-semibold mb-4 text-ink-gray-9">
|
||||
@@ -71,7 +74,11 @@
|
||||
<ColorSwatches
|
||||
v-model="courseResource.doc.card_gradient"
|
||||
:label="__('Color')"
|
||||
:description="__('Choose a color for the course card')"
|
||||
:description="
|
||||
__(
|
||||
'Select a fallback color for the course card when no image is set.'
|
||||
)
|
||||
"
|
||||
class="w-full"
|
||||
@update:modelValue="makeFormDirty()"
|
||||
/>
|
||||
|
||||
@@ -187,26 +187,6 @@ const setCategories = (data) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isPersonaCaptured = async () => {
|
||||
let persona = await call('frappe.client.get_single_value', {
|
||||
doctype: 'LMS Settings',
|
||||
field: 'persona_captured',
|
||||
})
|
||||
return persona
|
||||
}
|
||||
|
||||
const identifyUserPersona = async () => {
|
||||
if (user.data?.is_system_manager && !user.data?.developer_mode) {
|
||||
let personaCaptured = await isPersonaCaptured()
|
||||
if (personaCaptured) return
|
||||
if (!courseCount.value) {
|
||||
router.push({
|
||||
name: 'PersonaForm',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getCourseCount = () => {
|
||||
if (!user.data) return
|
||||
if (!user.data.is_moderator) return
|
||||
@@ -214,7 +194,6 @@ const getCourseCount = () => {
|
||||
doctype: 'LMS Course',
|
||||
}).then((data) => {
|
||||
courseCount.value = data
|
||||
identifyUserPersona()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,14 @@
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { call, createResource, usePageMeta } from 'frappe-ui'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { useRouter } from 'vue-router'
|
||||
import StudentHome from '@/pages/Home/StudentHome.vue'
|
||||
import AdminHome from '@/pages/Home/AdminHome.vue'
|
||||
import Streak from '@/pages/Home/Streak.vue'
|
||||
|
||||
const user = inject<any>('$user')
|
||||
const { brand } = sessionStore()
|
||||
const router = useRouter()
|
||||
const evalCount = ref(0)
|
||||
const currentTab = ref<'student' | 'instructor'>('student')
|
||||
const showStreakModal = ref(false)
|
||||
@@ -71,7 +73,32 @@ const isAdmin = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const isPersonaCaptured = async () => {
|
||||
let persona = await call('frappe.client.get_single_value', {
|
||||
doctype: 'LMS Settings',
|
||||
field: 'persona_captured',
|
||||
})
|
||||
return persona
|
||||
}
|
||||
|
||||
const identifyUserPersona = async () => {
|
||||
if (user.data?.is_system_manager && !user.data?.developer_mode) {
|
||||
let personaCaptured = await isPersonaCaptured()
|
||||
if (personaCaptured) return
|
||||
let courseCount = await call('frappe.client.get_count', {
|
||||
doctype: 'LMS Course',
|
||||
filters: {
|
||||
title: ['not like', '%A guide to Frappe Learning%'],
|
||||
},
|
||||
})
|
||||
if (!courseCount) {
|
||||
router.push({ name: 'PersonaForm' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
identifyUserPersona()
|
||||
if (isAdmin.value) {
|
||||
currentTab.value = 'instructor'
|
||||
} else {
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</router-link>
|
||||
</div>
|
||||
</header>
|
||||
<div class="grid md:grid-cols-[70%,30%] h-screen">
|
||||
<div class="grid md:grid-cols-[70%,30%] h-[94vh]">
|
||||
<div v-if="lesson.data.no_preview" class="border-r">
|
||||
<div class="shadow rounded-md w-3/4 mt-10 mx-auto text-center p-4">
|
||||
<div class="flex items-center justify-center mt-4 space-x-2">
|
||||
@@ -263,7 +263,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="lesson.data"
|
||||
v-if="lesson.data && (allowDiscussions || tabs.length > 1)"
|
||||
class="mt-10 pb-20 pt-5 border-t px-5"
|
||||
ref="discussionsContainer"
|
||||
>
|
||||
@@ -399,15 +399,10 @@ const { brand } = sessionStore()
|
||||
const sidebarStore = useSidebar()
|
||||
const plyrSources = ref([])
|
||||
const showInlineMenu = ref(false)
|
||||
const currentTab = ref('Notes')
|
||||
const currentTab = ref(null)
|
||||
let timerInterval = null
|
||||
|
||||
const tabs = ref([
|
||||
{
|
||||
label: __('Notes'),
|
||||
value: 'Notes',
|
||||
},
|
||||
])
|
||||
const tabs = ref([])
|
||||
|
||||
const props = defineProps({
|
||||
courseName: {
|
||||
@@ -887,24 +882,24 @@ const updateNotes = () => {
|
||||
}
|
||||
|
||||
watch(allowDiscussions, () => {
|
||||
if (allowDiscussions.value) {
|
||||
tabs.value = [
|
||||
{
|
||||
if (!isAdmin.value) {
|
||||
if (!tabs.value.find((tab) => tab.value === 'Notes')) {
|
||||
tabs.value.push({
|
||||
label: __('Notes'),
|
||||
value: 'Notes',
|
||||
},
|
||||
{
|
||||
})
|
||||
}
|
||||
currentTab.value = 'Notes'
|
||||
} else {
|
||||
currentTab.value = allowDiscussions.value ? 'Community' : null
|
||||
}
|
||||
if (allowDiscussions.value) {
|
||||
if (!tabs.value.find((tab) => tab.value === 'Community')) {
|
||||
tabs.value.push({
|
||||
label: __('Community'),
|
||||
value: 'Community',
|
||||
},
|
||||
]
|
||||
} else {
|
||||
tabs.value = [
|
||||
{
|
||||
label: __('Notes'),
|
||||
value: 'Notes',
|
||||
},
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ const submitPersona = () => {
|
||||
responses: JSON.stringify(responses),
|
||||
}).then(() => {
|
||||
router.push({
|
||||
name: 'Courses',
|
||||
name: 'Home',
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -87,12 +87,12 @@ const submitPersona = () => {
|
||||
const skipPersonaForm = () => {
|
||||
call('frappe.client.set_value', {
|
||||
doctype: 'LMS Settings',
|
||||
name: null,
|
||||
name: 'LMS Settings',
|
||||
fieldname: 'persona_captured',
|
||||
value: 1,
|
||||
}).then(() => {
|
||||
router.push({
|
||||
name: 'Courses',
|
||||
name: 'Home',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -199,11 +199,16 @@ const evaluator = createResource({
|
||||
if (data.slots.unavailable_from) from.value = data.slots.unavailable_from
|
||||
if (data.slots.unavailable_to) to.value = data.slots.unavailable_to
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(err.messages?.[0] || err)
|
||||
console.error(err)
|
||||
},
|
||||
})
|
||||
|
||||
const createSlot = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
makeParams(values) {
|
||||
console.log(evaluator.data)
|
||||
return {
|
||||
doc: {
|
||||
doctype: 'Evaluator Schedule',
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
@change="(val: string) => (exercise.problem_statement = val)"
|
||||
:editable="true"
|
||||
:fixedMenu="true"
|
||||
editorClass="prose-sm max-w-none border-b border-x border-outline-gray-modals bg-surface-gray-2 rounded-b-md py-1 px-2 min-h-[7rem] max-h-[21rem] overflow-y-auto"
|
||||
editorClass="prose-sm max-w-none border-b border-x border-outline-gray-modals bg-surface-gray-2 rounded-b-md py-1 px-2 min-h-[10rem] max-h-[21rem] overflow-y-auto"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,6 +71,7 @@
|
||||
{{ __('Delete') }}
|
||||
</Button>
|
||||
<router-link
|
||||
v-if="exerciseID != 'new'"
|
||||
:to="{
|
||||
name: 'ProgrammingExerciseSubmission',
|
||||
params: {
|
||||
@@ -87,6 +88,7 @@
|
||||
</Button>
|
||||
</router-link>
|
||||
<router-link
|
||||
v-if="exerciseID != 'new'"
|
||||
:to="{
|
||||
name: 'ProgrammingExerciseSubmissions',
|
||||
query: {
|
||||
@@ -148,6 +150,7 @@ const languageOptions = [
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
exerciseID: string
|
||||
getExerciseCount: () => Promise<number>
|
||||
}>(),
|
||||
{
|
||||
exerciseID: 'new',
|
||||
@@ -185,7 +188,6 @@ const setExerciseData = () => {
|
||||
const testCases = createListResource({
|
||||
doctype: 'LMS Test Case',
|
||||
fields: ['input', 'expected_output', 'name'],
|
||||
cache: ['testCases', props.exerciseID],
|
||||
parent: 'LMS Programming Exercise',
|
||||
orderBy: 'idx',
|
||||
onSuccess(data: TestCase[]) {
|
||||
@@ -207,7 +209,7 @@ const fetchTestCases = () => {
|
||||
},
|
||||
})
|
||||
testCases.reload()
|
||||
originalTestCaseCount.value = testCases.data.length
|
||||
originalTestCaseCount.value = testCases.data?.length
|
||||
}
|
||||
|
||||
const validateTitle = () => {
|
||||
@@ -223,7 +225,7 @@ watch(
|
||||
)
|
||||
|
||||
watch(testCases, () => {
|
||||
if (testCases.data.length !== originalTestCaseCount.value) {
|
||||
if (testCases.data?.length !== originalTestCaseCount.value) {
|
||||
isDirty.value = true
|
||||
}
|
||||
})
|
||||
@@ -255,6 +257,7 @@ const createNewExercise = (close: () => void) => {
|
||||
close()
|
||||
isDirty.value = false
|
||||
exercises.value?.reload()
|
||||
props.getExerciseCount()
|
||||
toast.success(__('Programming Exercise created successfully'))
|
||||
},
|
||||
onError(err: any) {
|
||||
|
||||
@@ -300,7 +300,7 @@ const loadFalcon = () => {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const script = document.createElement('script')
|
||||
script.src = `${falconURL.value}static/livecode.js`
|
||||
script.src = `${falconURL.value}/static/livecode.js`
|
||||
script.onload = resolve
|
||||
script.onerror = reject
|
||||
document.head.appendChild(script)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<Breadcrumbs :items="breadcrumbs" />
|
||||
<div class="space-x-2">
|
||||
<router-link
|
||||
v-if="exercises.data?.length"
|
||||
:to="{
|
||||
name: 'ProgrammingExerciseSubmissions',
|
||||
}"
|
||||
@@ -120,8 +121,9 @@
|
||||
</div>
|
||||
<ProgrammingExerciseForm
|
||||
v-model="showForm"
|
||||
:exerciseID="exerciseID"
|
||||
v-model:exercises="exercises"
|
||||
:exerciseID="exerciseID"
|
||||
:getExerciseCount="getExerciseCount"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@@ -152,7 +154,7 @@ const exerciseCount = ref<number>(0)
|
||||
const readOnlyMode = window.read_only_mode
|
||||
const { brand } = sessionStore()
|
||||
const showForm = ref<boolean>(false)
|
||||
const exerciseID = ref<string | null>('new')
|
||||
const exerciseID = ref<string>('new')
|
||||
const user = inject<any>('$user')
|
||||
const titleFilter = ref<string>('')
|
||||
const languageFilter = ref<string>('')
|
||||
|
||||
@@ -194,11 +194,7 @@
|
||||
v-model="showQuestionModal"
|
||||
:questionDetail="currentQuestion"
|
||||
v-model:quiz="quizDetails"
|
||||
:title="
|
||||
currentQuestion.question
|
||||
? __('Edit the question')
|
||||
: __('Add a new question')
|
||||
"
|
||||
:title="currentQuestion.question ? __('Edit Question') : __('Add Question')"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
@@ -12,12 +12,8 @@
|
||||
</header>
|
||||
<div class="py-5 mx-5">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="text-lg font-semibold text-ink-gray-7">
|
||||
{{
|
||||
quizzes.data?.length
|
||||
? __('{0} Quizzes').format(quizzes.data.length)
|
||||
: __('No Quizzes')
|
||||
}}
|
||||
<div class="text-lg font-semibold">
|
||||
{{ __('{0} Quizzes').format(quizzes.data.length) }}
|
||||
</div>
|
||||
<FormControl v-model="search" type="text" placeholder="Search">
|
||||
<template #prefix>
|
||||
@@ -116,6 +112,7 @@
|
||||
v-model="title"
|
||||
:label="__('Title')"
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
@keydown.enter="insertQuiz(() => (showForm = false))"
|
||||
/>
|
||||
</template>
|
||||
|
||||
548
lms/demo/demo_data.py
Normal file
548
lms/demo/demo_data.py
Normal file
@@ -0,0 +1,548 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
|
||||
from lms.lms.doctype.lms_course.lms_course import update_course_statistics
|
||||
from lms.lms.utils import get_course_progress
|
||||
|
||||
|
||||
def create_demo_data(args: dict = None):
|
||||
course = create_course()
|
||||
student = create_user("Ashley", "Ippolito", "ash@ipp.com", "/assets/lms/images/student.jpg")
|
||||
student1 = create_user("John", "Doe", "john.doe@example.com", "/assets/lms/images/student1.jpeg")
|
||||
student2 = create_user("Jane", "Smith", "jane.smith@example.com", "/assets/lms/images/student2.jpeg")
|
||||
create_chapter(course)
|
||||
create_lessons(course)
|
||||
enroll_student_in_course(student, course)
|
||||
enroll_student_in_course(student1, course)
|
||||
enroll_student_in_course(student2, course)
|
||||
create_reviews(course, student)
|
||||
create_progress(course, student, 3)
|
||||
create_progress(course, student1, 2)
|
||||
create_progress(course, student2, 4)
|
||||
frappe.db.set_single_value("LMS Settings", "demo_data_present", 1)
|
||||
|
||||
|
||||
def create_course():
|
||||
title = "A guide to Frappe Learning"
|
||||
filters = {"title": title}
|
||||
if frappe.db.exists("LMS Course", filters):
|
||||
return frappe.get_doc("LMS Course", filters)
|
||||
|
||||
instructor = create_instructor()
|
||||
course = frappe.new_doc("LMS Course")
|
||||
course.update(
|
||||
{
|
||||
"title": title,
|
||||
"category": "Business",
|
||||
"tags": "Frappe, Demo",
|
||||
"published": 1,
|
||||
"published_on": frappe.utils.now(),
|
||||
"video_link": "VIt_bsbBjLI",
|
||||
"instructors": [{"instructor": instructor.name}],
|
||||
"short_introduction": "Learn the basics of Frappe Learning and how to get started with your very first course.",
|
||||
"image": "/assets/lms/images/course_card.jpeg",
|
||||
}
|
||||
)
|
||||
|
||||
course.description = """
|
||||
This course will cover the fundamentals of Frappe Learning, including how to create and manage courses, enroll students, and track progress. You will learn about the following key features of the app:
|
||||
<br>
|
||||
<h3>Key Features</h3>
|
||||
<br>
|
||||
1. Structured Learning: Design a course with a 3-level hierarchy, where your courses have chapters, and you can group your lessons within these chapters. This ensures that the context of each lesson is clearly defined by its chapter.
|
||||
<br>
|
||||
<br>
|
||||
2. Live Classes: Group learners into batches based on courses and duration. You can then create Zoom live classes for these batches directly from the app. Learners can view all the live classes they need to attend as part of their batch.
|
||||
<br>
|
||||
<br>
|
||||
3. Quizzes and Assignments: Create quizzes with single-choice, multiple-choice, or open-ended questions. Instructors can also add assignments that learners can submit as PDFs or documents.
|
||||
<br>
|
||||
<br>
|
||||
4. Getting Certified: Once a learner completes the course or batch, you can grant them a certificate. The app provides an inbuilt certificate template that you can use as-is or customize by creating your own template.
|
||||
<br>
|
||||
<br>
|
||||
To know more about the app and its features, <a href="https://docs.frappe.io/learning">check out the documentation</a>.
|
||||
"""
|
||||
course.save()
|
||||
return course
|
||||
|
||||
|
||||
def create_instructor():
|
||||
if (
|
||||
frappe.db.count(
|
||||
"User",
|
||||
{
|
||||
"name": ["not in", ("Administrator", "Guest")],
|
||||
},
|
||||
)
|
||||
> 0
|
||||
):
|
||||
user = frappe.get_all(
|
||||
"User",
|
||||
{
|
||||
"name": ["not in", ("Administrator", "Guest")],
|
||||
},
|
||||
pluck="name",
|
||||
limit=1,
|
||||
)[0]
|
||||
return frappe.get_doc("User", user)
|
||||
|
||||
return create_user("Jannat", "Patel", "jannat@example.com", "/assets/lms/images/instructor.png")
|
||||
|
||||
|
||||
def create_user(first_name, last_name, email, user_image):
|
||||
filters = {"first_name": first_name, "last_name": last_name, "email": email}
|
||||
if frappe.db.exists("User", filters):
|
||||
return frappe.get_doc("User", filters)
|
||||
|
||||
user = frappe.new_doc("User")
|
||||
user.first_name = first_name
|
||||
user.last_name = last_name
|
||||
user.user_image = user_image
|
||||
user.email = email
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
def create_chapter(course):
|
||||
prepare_chapter(course, "Introduction")
|
||||
prepare_chapter(course, "Adding content to your lessons")
|
||||
prepare_chapter(course, "Assessments")
|
||||
|
||||
|
||||
def prepare_chapter(course, chapter_title):
|
||||
chapter_exists = check_if_chapter_exists(course, chapter_title)
|
||||
if chapter_exists:
|
||||
return frappe.get_doc("Course Chapter", chapter_exists)
|
||||
|
||||
chapter1 = frappe.new_doc("Course Chapter")
|
||||
chapter1.course = course.name
|
||||
chapter1.title = chapter_title
|
||||
chapter1.save()
|
||||
add_chapter_to_course(course, chapter1)
|
||||
|
||||
|
||||
def check_if_chapter_exists(course, chapter_title):
|
||||
filters = {"course": course.name, "title": chapter_title}
|
||||
return frappe.db.exists("Course Chapter", filters)
|
||||
|
||||
|
||||
def add_chapter_to_course(course, chapter):
|
||||
course.reload()
|
||||
course.append("chapters", {"chapter": chapter.name})
|
||||
course.save()
|
||||
|
||||
|
||||
def create_lessons(course):
|
||||
create_intro_lesson_1(course)
|
||||
create_intro_lesson_2(course)
|
||||
create_content_lesson_1(course)
|
||||
create_content_lesson_2(course)
|
||||
create_assessment_lesson_1(course)
|
||||
|
||||
|
||||
def get_chapter(course, chapter_title):
|
||||
filters = {"course": course.name, "title": chapter_title}
|
||||
return frappe.get_doc("Course Chapter", filters)
|
||||
|
||||
|
||||
def create_lesson(course, chapter, title, content):
|
||||
filters = {"course": course.name, "chapter": chapter.name, "title": title}
|
||||
|
||||
if frappe.db.exists("Course Lesson", filters):
|
||||
return frappe.get_doc("Course Lesson", filters)
|
||||
|
||||
lesson = frappe.new_doc("Course Lesson")
|
||||
lesson.course = course.name
|
||||
lesson.chapter = chapter.name
|
||||
lesson.title = title
|
||||
lesson.content = content
|
||||
lesson.save()
|
||||
add_lesson_to_chapter(chapter, lesson)
|
||||
|
||||
|
||||
def add_lesson_to_chapter(chapter, lesson):
|
||||
chapter.reload()
|
||||
chapter.append("lessons", {"lesson": lesson.name})
|
||||
chapter.save()
|
||||
|
||||
|
||||
def create_intro_lesson_1(course):
|
||||
title = "What is a Learning Management System?"
|
||||
chapter = get_chapter(course, "Introduction")
|
||||
content = """
|
||||
{"time":1772449622100,"blocks":[{"id":"vYTdcXYVgI","type":"embed","data":{"service":"youtube","source":"https://www.youtube.com/watch?v=-Ulzqjj49lk","embed":"-Ulzqjj49lk","caption":""}}],"version":"2.29.0"}
|
||||
"""
|
||||
create_lesson(course, chapter, title, content)
|
||||
|
||||
|
||||
def create_intro_lesson_2(course):
|
||||
title = "What is Frappe Learning?"
|
||||
chapter = get_chapter(course, "Introduction")
|
||||
content = """
|
||||
{"time":1772449622100,"blocks":[{"id":"vYTdcXYVgI","type":"embed","data":{"service":"youtube","source":"https://www.youtube.com/watch?v=VIt_bsbBjLI","embed":"VIt_bsbBjLI","caption":""}}],"version":"2.29.0"}
|
||||
"""
|
||||
create_lesson(course, chapter, title, content)
|
||||
|
||||
|
||||
def create_content_lesson_1(course):
|
||||
title = "Video Content"
|
||||
chapter = get_chapter(course, "Adding content to your lessons")
|
||||
content = json.dumps(get_video_content())
|
||||
create_lesson(course, chapter, title, content)
|
||||
|
||||
|
||||
def create_content_lesson_2(course):
|
||||
title = "Content from Google Suite"
|
||||
chapter = get_chapter(course, "Adding content to your lessons")
|
||||
content = json.dumps(get_google_suite_content())
|
||||
create_lesson(course, chapter, title, content)
|
||||
|
||||
|
||||
def create_assessment_lesson_1(course):
|
||||
quiz = create_quiz()
|
||||
title = "Quiz Time"
|
||||
chapter = get_chapter(course, "Assessments")
|
||||
content = f"""{{
|
||||
"time": 1770118649591,
|
||||
"blocks": [
|
||||
{{
|
||||
"id": "3xqARGZqQa",
|
||||
"type": "quiz",
|
||||
"data": {{ "quiz": "{quiz.name}" }}
|
||||
}}
|
||||
],
|
||||
"version": "2.29.0"
|
||||
}}"""
|
||||
create_lesson(course, chapter, title, content)
|
||||
|
||||
|
||||
def create_quiz():
|
||||
title = "Do you know Frappe Learning?"
|
||||
filters = {"title": title}
|
||||
if frappe.db.exists("LMS Quiz", filters):
|
||||
return frappe.get_doc("LMS Quiz", filters)
|
||||
|
||||
questions = []
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"What is Frappe Learning primarily used for?",
|
||||
"Project Management",
|
||||
False,
|
||||
"Learning Management",
|
||||
True,
|
||||
)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"Which of the following can be added to a course in Frappe Learning?",
|
||||
"Lessons",
|
||||
True,
|
||||
"Issues",
|
||||
False,
|
||||
)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"What is the top-level structure in Frappe Learning?", "Chapter", False, "Course", True
|
||||
)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions("Can you create quizzes in Frappe Learning?", "Yes", True, "No", False)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"Which of the following content can be added to lessons?", "Bugs", False, "Videos", True
|
||||
)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions("Can you track learner progress in Frappe Learning?", "Yes", True, "No", False)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"What is the purpose of a batch in Frappe Learning?",
|
||||
"To group learners",
|
||||
True,
|
||||
"To store website themes",
|
||||
False,
|
||||
)
|
||||
)
|
||||
questions.append(
|
||||
create_quiz_questions(
|
||||
"How can you create custom certificates in Frappe Learning?",
|
||||
"Using Server Scripts",
|
||||
False,
|
||||
"Using Print Formats",
|
||||
True,
|
||||
)
|
||||
)
|
||||
quiz = frappe.new_doc("LMS Quiz")
|
||||
quiz.update(
|
||||
{
|
||||
"title": title,
|
||||
"passing_percentage": 70,
|
||||
"total_marks": 40,
|
||||
}
|
||||
)
|
||||
for question in questions:
|
||||
quiz.append(
|
||||
"questions",
|
||||
{
|
||||
"question": question.name,
|
||||
"marks": 5,
|
||||
},
|
||||
)
|
||||
quiz.save()
|
||||
return quiz
|
||||
|
||||
|
||||
def create_quiz_questions(question, option_1, is_correct_1, option_2, is_correct_2):
|
||||
doc = frappe.new_doc("LMS Question")
|
||||
doc.update(
|
||||
{
|
||||
"question": question,
|
||||
"type": "Choices",
|
||||
"option_1": option_1,
|
||||
"is_correct_1": is_correct_1,
|
||||
"option_2": option_2,
|
||||
"is_correct_2": is_correct_2,
|
||||
}
|
||||
)
|
||||
doc.save()
|
||||
return doc
|
||||
|
||||
|
||||
def create_reviews(course, student):
|
||||
frappe.session.user = student.name
|
||||
review = frappe.new_doc("LMS Course Review")
|
||||
review.course = course.name
|
||||
review.rating = 0.8
|
||||
review.review = "This is a great course to get started with Frappe Learning. The content is well-structured and easy to follow."
|
||||
review.save()
|
||||
frappe.session.user = "Administrator"
|
||||
update_course_statistics()
|
||||
|
||||
|
||||
def enroll_student_in_course(student, course):
|
||||
filters = {"member": student.name, "course": course.name}
|
||||
if not frappe.db.exists("LMS Enrollment", filters):
|
||||
enrollment = frappe.new_doc("LMS Enrollment")
|
||||
enrollment.member = student.name
|
||||
enrollment.course = course.name
|
||||
enrollment.save()
|
||||
|
||||
|
||||
def create_progress(course, student, limit=None):
|
||||
lessons = frappe.get_all(
|
||||
"Course Lesson", {"course": course.name}, pluck="name", limit=limit, order_by="creation asc"
|
||||
)
|
||||
for lesson in lessons:
|
||||
filters = {"member": student.name, "lesson": lesson, "course": course.name}
|
||||
if not frappe.db.exists("LMS Course Progress", filters):
|
||||
progress = frappe.new_doc("LMS Course Progress")
|
||||
progress.member = student.name
|
||||
progress.lesson = lesson
|
||||
progress.course = course.name
|
||||
progress.status = "Complete"
|
||||
progress.save()
|
||||
|
||||
progress = get_course_progress(course.name, student.name)
|
||||
frappe.db.set_value(
|
||||
"LMS Enrollment", {"member": student.name, "course": course.name}, "progress", progress
|
||||
)
|
||||
|
||||
|
||||
def get_video_content():
|
||||
return {
|
||||
"time": 1772450228627,
|
||||
"blocks": [
|
||||
{
|
||||
"id": "bj6mK0D36z",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": "Frappe Learning allows you to embed videos in lessons using popular video hosting platforms."
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "1ooWPn5Zmq",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": "You don't need to upload videos directly into Frappe Learning - simply copy the video URL from your preferred provider and paste it into the Lesson Editor."
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "tCJD0yMAGd",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": "Frappe Learning automatically detects the video source and embeds it for learners."
|
||||
},
|
||||
},
|
||||
{"id": "KpfuszbA09", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "PZYmdlzQj2", "type": "header", "data": {"text": "YouTube", "level": 2}},
|
||||
{
|
||||
"id": "mJsIbQSHYO",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "YouTube videos can be embedded using the standard watch URL."},
|
||||
},
|
||||
{"id": "-H8fLBsAMk", "type": "paragraph", "data": {"text": "<b>Supported URL format</b>"}},
|
||||
{
|
||||
"id": "Aiq-BfQkwZ",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://www.youtube.com/watch?v=<video-id></code>'
|
||||
},
|
||||
},
|
||||
{"id": "8hMi323AbM", "type": "paragraph", "data": {"text": "<b>Example</b>"}},
|
||||
{
|
||||
"id": "3H6BzIshWg",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://www.youtube.com/watch?v=SLNSSz41v_o</code>'
|
||||
},
|
||||
},
|
||||
{"id": "yGSuw7Im0i", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "WRVOABPAZO", "type": "header", "data": {"text": "Vimeo", "level": 2}},
|
||||
{
|
||||
"id": "AabHQjaQvo",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "Vimeo videos are supported using the video URL."},
|
||||
},
|
||||
{"id": "q_9aNfNHEP", "type": "paragraph", "data": {"text": "<b>Supported URL format</b>"}},
|
||||
{
|
||||
"id": "1YYctmoyod",
|
||||
"type": "paragraph",
|
||||
"data": {"text": '<code class="inline-code">https://vimeo.com/<video-id></code>'},
|
||||
},
|
||||
{"id": "OX_NGBxJTY", "type": "paragraph", "data": {"text": "<b>Example</b>"}},
|
||||
{
|
||||
"id": "KZYnrs_Dnf",
|
||||
"type": "paragraph",
|
||||
"data": {"text": '<code class="inline-code">https://vimeo.com/825334862</code>'},
|
||||
},
|
||||
{"id": "-mkC711EdF", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "nSzyGY6f68", "type": "header", "data": {"text": "Cloudflare Stream", "level": 2}},
|
||||
{
|
||||
"id": "-cpNtfvP5T",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "Cloudflare Stream provides secure video hosting with adaptive streaming."},
|
||||
},
|
||||
{"id": "e2fQ-DG6Nd", "type": "paragraph", "data": {"text": "<b>Supported URL format</b>"}},
|
||||
{
|
||||
"id": "av_Q4P66hb",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://customer-<account-id>.cloudflarestream.com/<video-id>/watch</code>'
|
||||
},
|
||||
},
|
||||
{"id": "8KCsx40NpJ", "type": "paragraph", "data": {"text": "<b>Example</b>"}},
|
||||
{
|
||||
"id": "USi0pW91df",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://customer-f33zs165nr7gyfy4.cloudflarestream.com/6b9e68b07dfee8cc2d116e4c51d6a957/watch</code>'
|
||||
},
|
||||
},
|
||||
{"id": "e6I0VuwXx9", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "C-u44GnaTz", "type": "header", "data": {"text": "Bunny Stream", "level": 2}},
|
||||
{
|
||||
"id": "uR8XZtPVC5",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "Bunny Stream allows fast, global video delivery with built-in analytics."},
|
||||
},
|
||||
{"id": "BYkm4Hy_v8", "type": "paragraph", "data": {"text": "<b>Supported URL format</b>"}},
|
||||
{
|
||||
"id": "TCM9COabp8",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://iframe.mediadelivery.net/play/<library-id>/<video-id></code>'
|
||||
},
|
||||
},
|
||||
{"id": "KCiA6zVRYf", "type": "paragraph", "data": {"text": "<b>Example</b>"}},
|
||||
{
|
||||
"id": "kYDFL8Dn1v",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": '<code class="inline-code">https://iframe.mediadelivery.net/play/579970/54b3e5a1-cf95-4f88-96d3-8387d93dc2f2</code>'
|
||||
},
|
||||
},
|
||||
{"id": "jfnSgNAv5Q", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "NCY3opj8uc", "type": "header", "data": {"text": "Important Notes", "level": 2}},
|
||||
{
|
||||
"id": "xHWE56ECqw",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "Paste only the video URL, not iframe embed code"},
|
||||
},
|
||||
{
|
||||
"id": "ZzrV99rSxJ",
|
||||
"type": "paragraph",
|
||||
"data": {"text": "The URL must match one of the supported formats above"},
|
||||
},
|
||||
{
|
||||
"id": "jjg_inGE2B",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": "Video privacy, access control, and streaming limits are managed by the video provider"
|
||||
},
|
||||
},
|
||||
],
|
||||
"version": "2.29.0",
|
||||
}
|
||||
|
||||
|
||||
def get_google_suite_content():
|
||||
return {
|
||||
"time": 1772450743148,
|
||||
"blocks": [
|
||||
{
|
||||
"id": "73fFo3DS18",
|
||||
"type": "paragraph",
|
||||
"data": {
|
||||
"text": "You can integrate live Google Docs, Sheets, and Slides into your lessons to provide dynamic, up-to-date documentation and presentations."
|
||||
},
|
||||
},
|
||||
{"id": "Z6I1ZV7Fvr", "type": "markdown", "data": {"text": ""}},
|
||||
{
|
||||
"id": "hiJVoYEhfN",
|
||||
"type": "header",
|
||||
"data": {"text": "How to Embed Google Workspace Files", "level": 3},
|
||||
},
|
||||
{
|
||||
"id": "v9_hXM3d8b",
|
||||
"type": "list",
|
||||
"data": {
|
||||
"style": "ordered",
|
||||
"items": [
|
||||
{"content": "Open your Google Doc, Sheet, or Slide.", "items": []},
|
||||
{"content": "Make sure your permissions are set properly", "items": []},
|
||||
{"content": "Copy your URL from the top browser address bar", "items": []},
|
||||
{"content": "Now paste it in your lesson", "items": []},
|
||||
],
|
||||
},
|
||||
},
|
||||
{"id": "ycS1sd-0us", "type": "markdown", "data": {"text": ""}},
|
||||
{"id": "NjN6_ixXRW", "type": "header", "data": {"text": "Integration Options", "level": 3}},
|
||||
{
|
||||
"id": "MgXDT0xV4X",
|
||||
"type": "list",
|
||||
"data": {
|
||||
"style": "unordered",
|
||||
"items": [
|
||||
{
|
||||
"content": "Google Slides: Perfect for presentations. These render with full navigation controls for the student.",
|
||||
"items": [],
|
||||
},
|
||||
{
|
||||
"content": "Google Sheets: Useful for sharing live data tables or interactive calculators.",
|
||||
"items": [],
|
||||
},
|
||||
{
|
||||
"content": "Google Docs: Best for course handouts, reading material, or live-updating documentation.",
|
||||
"items": [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
"version": "2.29.0",
|
||||
}
|
||||
13
lms/hooks.py
13
lms/hooks.py
@@ -8,17 +8,20 @@ app_publisher = "Frappe"
|
||||
app_description = "Open Source Learning Management System built with Frappe Framework"
|
||||
app_icon_url = "/assets/lms/images/lms-logo.png"
|
||||
app_icon_title = "Learning"
|
||||
app_icon_route = "/lms"
|
||||
app_color = "grey"
|
||||
app_email = "jannat@frappe.io"
|
||||
app_license = "AGPL"
|
||||
required_apps = ["frappe/payments"]
|
||||
|
||||
|
||||
def get_lms_path():
|
||||
return (frappe.conf.get("lms_path") or "lms").strip("/")
|
||||
path = "lms"
|
||||
if frappe.conf and frappe.conf.get("lms_path"):
|
||||
path = frappe.conf.get("lms_path")
|
||||
return path.strip("/")
|
||||
|
||||
|
||||
app_icon_route = f"/{get_lms_path()}"
|
||||
|
||||
# Includes in <head>
|
||||
# ------------------
|
||||
|
||||
@@ -71,7 +74,7 @@ web_include_js = []
|
||||
after_install = "lms.install.after_install"
|
||||
after_sync = "lms.install.after_sync"
|
||||
before_uninstall = "lms.install.before_uninstall"
|
||||
setup_wizard_requires = "assets/lms/js/setup_wizard.js"
|
||||
setup_wizard_complete = "lms.demo.demo_data.create_demo_data"
|
||||
after_migrate = [
|
||||
"lms.sqlite.build_index_in_background",
|
||||
]
|
||||
@@ -134,7 +137,7 @@ scheduler_events = {
|
||||
],
|
||||
"hourly": [
|
||||
"lms.lms.doctype.lms_certificate_request.lms_certificate_request.schedule_evals",
|
||||
"lms.lms.api.update_course_statistics",
|
||||
"lms.lms.doctype.lms_course.lms_course.update_course_statistics",
|
||||
"lms.lms.doctype.lms_certificate_request.lms_certificate_request.mark_eval_as_completed",
|
||||
"lms.lms.doctype.lms_live_class.lms_live_class.update_attendance",
|
||||
],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import frappe
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
|
||||
|
||||
from lms.lms.api import give_discussions_permission
|
||||
|
||||
|
||||
101
lms/lms/api.py
101
lms/lms/api.py
@@ -37,6 +37,7 @@ from lms.lms.utils import (
|
||||
get_average_rating,
|
||||
get_batch_details,
|
||||
get_course_details,
|
||||
get_field_meta,
|
||||
get_instructors,
|
||||
get_lesson_count,
|
||||
get_lms_route,
|
||||
@@ -103,7 +104,54 @@ def validate_billing_access(billing_type: str, name: str):
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
return {"access": access, "message": message, "address": address}
|
||||
payment_fields = get_payment_field_meta()
|
||||
address_fields = get_field_meta(
|
||||
"Address",
|
||||
[
|
||||
"address_line1",
|
||||
"address_line2",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"pincode",
|
||||
"phone",
|
||||
],
|
||||
)
|
||||
billing_field_meta = {**payment_fields, **address_fields}
|
||||
|
||||
return {
|
||||
"access": access,
|
||||
"message": message,
|
||||
"address": address,
|
||||
"billing_field_meta": billing_field_meta,
|
||||
}
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_payment_field_meta():
|
||||
return get_field_meta(
|
||||
"LMS Payment",
|
||||
[
|
||||
"member",
|
||||
"billing_name",
|
||||
"source",
|
||||
"payment_for_document_type",
|
||||
"payment_for_document",
|
||||
"currency",
|
||||
"amount",
|
||||
"amount_with_gst",
|
||||
"original_amount",
|
||||
"discount_amount",
|
||||
"coupon",
|
||||
"coupon_code",
|
||||
"address",
|
||||
"gstin",
|
||||
"pan",
|
||||
"payment_id",
|
||||
"order_id",
|
||||
"member_consent",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def verify_billing_access(doctype, name, billing_type):
|
||||
@@ -793,24 +841,6 @@ def get_new_gateway_fields(doctype: str):
|
||||
return transformed_fields
|
||||
|
||||
|
||||
def update_course_statistics():
|
||||
courses = frappe.get_all("LMS Course", fields=["name"])
|
||||
|
||||
for course in courses:
|
||||
lessons = get_lesson_count(course.name)
|
||||
|
||||
enrollments = frappe.db.count("LMS Enrollment", {"course": course.name, "member_type": "Student"})
|
||||
|
||||
avg_rating = get_average_rating(course.name) or 0
|
||||
avg_rating = flt(avg_rating, frappe.get_system_settings("float_precision") or 3)
|
||||
|
||||
frappe.db.set_value(
|
||||
"LMS Course",
|
||||
course.name,
|
||||
{"lessons": lessons, "enrollments": enrollments, "rating": avg_rating},
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_announcements(batch: str):
|
||||
roles = frappe.get_roles()
|
||||
@@ -855,6 +885,7 @@ def delete_course(course: str):
|
||||
|
||||
frappe.db.delete("LMS Enrollment", {"course": course})
|
||||
frappe.db.delete("LMS Course Progress", {"course": course})
|
||||
frappe.db.delete("LMS Course Review", {"course": course})
|
||||
frappe.db.set_value("LMS Quiz", {"course": course}, "course", None)
|
||||
frappe.db.set_value("LMS Quiz Submission", {"course": course}, "course", None)
|
||||
|
||||
@@ -1311,6 +1342,7 @@ def get_lms_settings():
|
||||
"livecode_url",
|
||||
"disable_pwa",
|
||||
"allow_job_posting",
|
||||
"demo_data_present",
|
||||
]
|
||||
|
||||
settings = frappe._dict()
|
||||
@@ -1865,23 +1897,27 @@ def get_my_live_classes():
|
||||
@frappe.whitelist()
|
||||
def get_created_courses():
|
||||
created_courses = []
|
||||
roles = frappe.get_roles()
|
||||
|
||||
CourseInstructor = frappe.qb.DocType("Course Instructor")
|
||||
Course = frappe.qb.DocType("LMS Course")
|
||||
|
||||
query = (
|
||||
base_query = (
|
||||
frappe.qb.from_(CourseInstructor)
|
||||
.join(Course)
|
||||
.on(CourseInstructor.parent == Course.name)
|
||||
.select(Course.name)
|
||||
.where(CourseInstructor.instructor == frappe.session.user)
|
||||
.orderby(Course.published_on, order=frappe.qb.desc)
|
||||
.limit(3)
|
||||
)
|
||||
|
||||
query = base_query.where(CourseInstructor.instructor == frappe.session.user)
|
||||
results = query.run(as_dict=True)
|
||||
courses = [row["name"] for row in results]
|
||||
|
||||
if not len(results) and ("Moderator" in roles):
|
||||
results = base_query.run(as_dict=True)
|
||||
|
||||
courses = [row["name"] for row in results]
|
||||
for course in courses:
|
||||
course_details = get_course_details(course)
|
||||
created_courses.append(course_details)
|
||||
@@ -1954,6 +1990,7 @@ def get_admin_evals():
|
||||
{
|
||||
"evaluator": frappe.session.user,
|
||||
"date": [">=", getdate()],
|
||||
"status": "Upcoming",
|
||||
},
|
||||
[
|
||||
"name",
|
||||
@@ -2248,3 +2285,23 @@ def get_badges(member: str):
|
||||
)
|
||||
|
||||
return badges
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def clear_demo_data():
|
||||
frappe.only_for("Moderator")
|
||||
quiz_title = "Do you know Frappe Learning?"
|
||||
if frappe.db.exists("LMS Quiz", {"title": quiz_title}):
|
||||
frappe.db.delete("LMS Quiz", {"title": quiz_title})
|
||||
|
||||
demo_course = frappe.get_all("LMS Course", {"title": "A guide to Frappe Learning"}, pluck="name")
|
||||
|
||||
if len(demo_course):
|
||||
delete_course(demo_course[0])
|
||||
|
||||
users = ["ash@ipp.com", "john.doe@example.com", "jane.smith@example.com", "jannat@example.com"]
|
||||
for user in users:
|
||||
if frappe.db.exists("User", user):
|
||||
frappe.delete_doc("User", user, ignore_permissions=True)
|
||||
|
||||
frappe.db.set_single_value("LMS Settings", "demo_data_present", False)
|
||||
|
||||
@@ -9,7 +9,7 @@ from frappe.model.document import Document
|
||||
from frappe.realtime import get_website_room
|
||||
from frappe.utils.telemetry import capture
|
||||
|
||||
from lms.lms.utils import get_course_progress, recalculate_course_progress
|
||||
from lms.lms.utils import get_course_progress, is_demo_course, recalculate_course_progress
|
||||
|
||||
from ...md import find_macros
|
||||
|
||||
@@ -127,7 +127,8 @@ def save_progress(lesson: str, course: str, scorm_details: dict = None):
|
||||
)
|
||||
|
||||
progress = get_course_progress(course)
|
||||
capture_progress_for_analytics()
|
||||
if not is_demo_course(course):
|
||||
capture("course_progress", "lms")
|
||||
|
||||
# Had to get doc, as on_change doesn't trigger when you use set_value. The trigger is necessary for badge to get assigned.
|
||||
enrollment = frappe.get_doc("LMS Enrollment", membership)
|
||||
@@ -145,10 +146,6 @@ def save_progress(lesson: str, course: str, scorm_details: dict = None):
|
||||
return progress
|
||||
|
||||
|
||||
def capture_progress_for_analytics():
|
||||
capture("course_progress", "lms")
|
||||
|
||||
|
||||
def get_quiz_progress(lesson):
|
||||
lesson_details = frappe.db.get_value("Course Lesson", lesson, ["body", "content"], as_dict=1)
|
||||
quizzes = []
|
||||
|
||||
@@ -7,11 +7,13 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.desk.doctype.notification_log.notification_log import make_notification_logs
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, today
|
||||
from frappe.utils import cint, flt, today
|
||||
|
||||
from ...utils import (
|
||||
generate_slug,
|
||||
get_average_rating,
|
||||
get_instructors,
|
||||
get_lesson_count,
|
||||
get_lms_route,
|
||||
update_payment_record,
|
||||
validate_image,
|
||||
@@ -215,3 +217,21 @@ def send_system_notification_for_published_courses(courses):
|
||||
)
|
||||
make_notification_logs(notification, students)
|
||||
frappe.db.set_value("LMS Course", course.name, "notification_sent", 1)
|
||||
|
||||
|
||||
def update_course_statistics():
|
||||
courses = frappe.get_all("LMS Course", fields=["name"])
|
||||
|
||||
for course in courses:
|
||||
lessons = get_lesson_count(course.name)
|
||||
|
||||
enrollments = frappe.db.count("LMS Enrollment", {"course": course.name, "member_type": "Student"})
|
||||
|
||||
avg_rating = get_average_rating(course.name) or 0
|
||||
avg_rating = flt(avg_rating, frappe.get_system_settings("float_precision") or 3)
|
||||
|
||||
frappe.db.set_value(
|
||||
"LMS Course",
|
||||
course.name,
|
||||
{"lessons": lessons, "enrollments": enrollments, "rating": avg_rating},
|
||||
)
|
||||
|
||||
@@ -154,7 +154,8 @@
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"label": "Source",
|
||||
"options": "LMS Source"
|
||||
"options": "LMS Source",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -202,8 +203,8 @@
|
||||
"link_fieldname": "payment"
|
||||
}
|
||||
],
|
||||
"modified": "2026-02-03 10:54:12.361407",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"modified": "2026-03-06 17:38:02.235044",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Payment",
|
||||
"owner": "Administrator",
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
"send_calendar_invite_for_evaluations",
|
||||
"column_break_zdel",
|
||||
"disable_pwa",
|
||||
"persona_captured",
|
||||
"default_home",
|
||||
"persona_captured",
|
||||
"demo_data_present",
|
||||
"column_break_bjis",
|
||||
"unsplash_access_key",
|
||||
"livecode_url",
|
||||
@@ -484,14 +485,21 @@
|
||||
"fieldname": "allow_job_posting",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Job Posting"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "demo_data_present",
|
||||
"fieldtype": "Check",
|
||||
"label": "Demo Data Present",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2026-02-19 16:28:15.310145",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"modified": "2026-03-05 13:57:56.303744",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
"owner": "Administrator",
|
||||
|
||||
@@ -2328,3 +2328,25 @@ def recalculate_course_progress(course: str, member: str):
|
||||
)
|
||||
frappe.db.set_value("LMS Enrollment", membership, "progress", progress)
|
||||
update_program_progress(member)
|
||||
|
||||
|
||||
def get_field_meta(doctype, fieldnames):
|
||||
"""Returns field metadata for 'fieldnames' from 'doctype'"""
|
||||
meta = frappe.get_meta(doctype)
|
||||
fieldnames_meta = {}
|
||||
|
||||
for fieldname in fieldnames:
|
||||
field = meta.get_field(fieldname)
|
||||
if field:
|
||||
fieldnames_meta[fieldname] = {
|
||||
"reqd": field.reqd,
|
||||
"default": field.default,
|
||||
"description": field.description,
|
||||
}
|
||||
|
||||
return fieldnames_meta
|
||||
|
||||
|
||||
def is_demo_course(course: str) -> bool:
|
||||
title = frappe.db.get_value("LMS Course", course, "title")
|
||||
return title == "A guide to Frappe Learning"
|
||||
|
||||
2161
lms/locale/main.pot
2161
lms/locale/main.pot
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ msgstr ""
|
||||
"Project-Id-Version: frappe\n"
|
||||
"Report-Msgid-Bugs-To: jannat@frappe.io\n"
|
||||
"POT-Creation-Date: 2026-01-23 16:05+0000\n"
|
||||
"PO-Revision-Date: 2026-03-01 18:33\n"
|
||||
"PO-Revision-Date: 2026-03-07 00:33\n"
|
||||
"Last-Translator: jannat@frappe.io\n"
|
||||
"Language-Team: Russian\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -4850,7 +4850,7 @@ msgstr "Наши предстоящие пакеты"
|
||||
#. Label of the output (Data) field in DocType 'LMS Test Case Submission'
|
||||
#: lms/lms/doctype/lms_test_case_submission/lms_test_case_submission.json
|
||||
msgid "Output"
|
||||
msgstr ""
|
||||
msgstr "Выход"
|
||||
|
||||
#: frontend/src/components/Settings/BadgeForm.vue:216
|
||||
#: lms/lms/doctype/lms_badge/lms_badge.js:37
|
||||
@@ -6337,7 +6337,7 @@ msgstr "Организация запуска"
|
||||
|
||||
#: frontend/src/pages/Billing.vue:134
|
||||
msgid "State/Province"
|
||||
msgstr ""
|
||||
msgstr "Штат/провинция"
|
||||
|
||||
#. Label of the tab_4_tab (Tab Break) field in DocType 'LMS Course'
|
||||
#. Label of the statistics (Check) field in DocType 'LMS Settings'
|
||||
|
||||
BIN
lms/public/images/course_card.jpeg
Normal file
BIN
lms/public/images/course_card.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
BIN
lms/public/images/instructor.png
Normal file
BIN
lms/public/images/instructor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
BIN
lms/public/images/student.jpg
Normal file
BIN
lms/public/images/student.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
lms/public/images/student1.jpeg
Normal file
BIN
lms/public/images/student1.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
BIN
lms/public/images/student2.jpeg
Normal file
BIN
lms/public/images/student2.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
@@ -1,116 +0,0 @@
|
||||
{
|
||||
"app": "lms",
|
||||
"creation": "2025-11-24 14:35:18.461657",
|
||||
"docstatus": 0,
|
||||
"doctype": "Workspace Sidebar",
|
||||
"header_icon": "education",
|
||||
"idx": 0,
|
||||
"items": [
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Home",
|
||||
"link_to": "Learning",
|
||||
"link_type": "Workspace",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Users",
|
||||
"link_to": "User",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Course",
|
||||
"link_to": "LMS Course",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Enrollments",
|
||||
"link_to": "LMS Enrollment",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Batch",
|
||||
"link_to": "LMS Batch",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Batch Enrollment",
|
||||
"link_to": "LMS Batch Enrollment",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Evaluation Request",
|
||||
"link_to": "LMS Certificate Request",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Evaluation",
|
||||
"link_to": "LMS Certificate Evaluation",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"child": 0,
|
||||
"collapsible": 1,
|
||||
"indent": 0,
|
||||
"keep_closed": 0,
|
||||
"label": "Certificate",
|
||||
"link_to": "LMS Certificate",
|
||||
"link_type": "DocType",
|
||||
"show_arrow": 0,
|
||||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2026-03-02 13:07:37.040316",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS",
|
||||
"owner": "Administrator",
|
||||
"standard": 1,
|
||||
"title": "LMS"
|
||||
}
|
||||
Reference in New Issue
Block a user