@@ -2,7 +2,7 @@
|
|||||||
<Button
|
<Button
|
||||||
v-if="user.data.is_moderator"
|
v-if="user.data.is_moderator"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
class="float-right mb-3"
|
class="float-right mb-5"
|
||||||
@click="openLiveClassModal"
|
@click="openLiveClassModal"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
@@ -12,14 +12,20 @@
|
|||||||
{{ __('Add Live Class') }}
|
{{ __('Add Live Class') }}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
<div class="text-lg font-semibold mb-4">
|
<div class="text-lg font-semibold mb-5">
|
||||||
{{ __('Live Class') }}
|
{{ __('Live Class') }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="liveClasses.data?.length" class="grid grid-cols-2 gap-5">
|
<div v-if="liveClasses.data?.length" class="grid grid-cols-2 gap-5">
|
||||||
<div v-for="cls in liveClasses.data" class="border rounded-md h-full p-3">
|
<div
|
||||||
|
v-for="cls in liveClasses.data"
|
||||||
|
class="flex flex-col border rounded-md h-full p-3"
|
||||||
|
>
|
||||||
<div class="font-semibold text-lg mb-4">
|
<div class="font-semibold text-lg mb-4">
|
||||||
{{ cls.title }}
|
{{ cls.title }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
{{ cls.description }}
|
||||||
|
</div>
|
||||||
<div class="flex items-center mb-2">
|
<div class="flex items-center mb-2">
|
||||||
<Calendar class="w-4 h-4 stroke-1.5" />
|
<Calendar class="w-4 h-4 stroke-1.5" />
|
||||||
<span class="ml-2">
|
<span class="ml-2">
|
||||||
@@ -32,10 +38,7 @@
|
|||||||
{{ formatTime(cls.time) }}
|
{{ formatTime(cls.time) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-5">
|
<div class="flex items-center space-x-2 mt-auto">
|
||||||
{{ cls.description }}
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<a
|
<a
|
||||||
:href="cls.start_url"
|
:href="cls.start_url"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #default="{ tab }">
|
<template #default="{ tab }">
|
||||||
<div class="pt-5 px-10 pb-10">
|
<div class="pt-5 px-5 pb-10">
|
||||||
<div v-if="tab.label == 'Courses'">
|
<div v-if="tab.label == 'Courses'">
|
||||||
<BatchCourses :batch="batch.data.name" />
|
<BatchCourses :batch="batch.data.name" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -227,11 +227,6 @@ const lesson = createResource({
|
|||||||
},
|
},
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
if (data.membership)
|
|
||||||
current_lesson.submit({
|
|
||||||
name: data.membership.name,
|
|
||||||
lesson_name: data.name,
|
|
||||||
})
|
|
||||||
markProgress(data)
|
markProgress(data)
|
||||||
|
|
||||||
if (data.content) editor = renderEditor('editor', data.content)
|
if (data.content) editor = renderEditor('editor', data.content)
|
||||||
@@ -260,18 +255,6 @@ const markProgress = (data) => {
|
|||||||
if (user.data && !data.progress) progress.submit()
|
if (user.data && !data.progress) progress.submit()
|
||||||
}
|
}
|
||||||
|
|
||||||
const current_lesson = createResource({
|
|
||||||
url: 'frappe.client.set_value',
|
|
||||||
makeParams(values) {
|
|
||||||
return {
|
|
||||||
doctype: 'LMS Enrollment',
|
|
||||||
name: values.name,
|
|
||||||
fieldname: 'current_lesson',
|
|
||||||
value: values.lesson_name,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const progress = createResource({
|
const progress = createResource({
|
||||||
url: 'lms.lms.doctype.course_lesson.course_lesson.save_progress',
|
url: 'lms.lms.doctype.course_lesson.course_lesson.save_progress',
|
||||||
makeParams() {
|
makeParams() {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
await userResource.reload()
|
await userResource.promise
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
isLoggedIn &&
|
isLoggedIn &&
|
||||||
@@ -163,7 +163,7 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
to.name == 'Notifications' ||
|
to.name == 'Notifications' ||
|
||||||
to.name == 'Badge')
|
to.name == 'Badge')
|
||||||
) {
|
) {
|
||||||
await allUsers.reload()
|
await allUsers.promise
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
isLoggedIn = false
|
isLoggedIn = false
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const usersStore = defineStore('lms-users', () => {
|
|||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const allUsers = createResource({
|
const allUsers = createResource({
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ def save_progress(lesson, course):
|
|||||||
if not membership:
|
if not membership:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
||||||
|
|
||||||
quiz_completed = get_quiz_progress(lesson)
|
quiz_completed = get_quiz_progress(lesson)
|
||||||
if not quiz_completed:
|
if not quiz_completed:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -1018,31 +1018,42 @@ def get_payment_options(doctype, docname, phone, country):
|
|||||||
|
|
||||||
|
|
||||||
def check_multicurrency(amount, currency, country=None, amount_usd=None):
|
def check_multicurrency(amount, currency, country=None, amount_usd=None):
|
||||||
show_usd_equivalent = frappe.db.get_single_value("LMS Settings", "show_usd_equivalent")
|
settings = frappe.get_single("LMS Settings")
|
||||||
exception_country = frappe.get_all(
|
show_usd_equivalent = settings.show_usd_equivalent
|
||||||
"Payment Country", filters={"parent": "LMS Settings"}, pluck="country"
|
|
||||||
)
|
|
||||||
country = (
|
|
||||||
country
|
|
||||||
or frappe.db.get_value("Address", {"email_id": frappe.session.user}, "country")
|
|
||||||
or frappe.db.get_value("User", frappe.session.user, "country")
|
|
||||||
or get_country_code()
|
|
||||||
)
|
|
||||||
|
|
||||||
if amount_usd and country and country not in exception_country:
|
# Countries for which currency should not be converted
|
||||||
return amount_usd, "USD"
|
exception_country = settings.exception_country
|
||||||
|
exception_country = [country.country for country in exception_country]
|
||||||
|
|
||||||
if not show_usd_equivalent or currency == "USD":
|
# Get users country
|
||||||
return amount, currency
|
if not country:
|
||||||
|
country = frappe.db.get_value("Address", {"email_id": frappe.session.user}, "country")
|
||||||
|
|
||||||
|
if not country:
|
||||||
|
country = frappe.db.get_value("User", frappe.session.user, "country")
|
||||||
|
|
||||||
|
if not country:
|
||||||
|
country = get_country_code()
|
||||||
|
|
||||||
|
# If the country is the one for which conversion is not needed then return as is
|
||||||
if not country or (exception_country and country in exception_country):
|
if not country or (exception_country and country in exception_country):
|
||||||
return amount, currency
|
return amount, currency
|
||||||
|
|
||||||
|
# If conversion is disabled from settings or the currency is already USD then return as is
|
||||||
|
if not show_usd_equivalent or currency == "USD":
|
||||||
|
return amount, currency
|
||||||
|
|
||||||
|
# If Explicit USD price is given then return that without conversion
|
||||||
|
if amount_usd and country and country not in exception_country:
|
||||||
|
return amount_usd, "USD"
|
||||||
|
|
||||||
|
# Conversion logic starts here. Exchange rate is fetched and amount is converted.
|
||||||
exchange_rate = get_current_exchange_rate(currency, "USD")
|
exchange_rate = get_current_exchange_rate(currency, "USD")
|
||||||
amount = amount * exchange_rate
|
amount = amount * exchange_rate
|
||||||
currency = "USD"
|
currency = "USD"
|
||||||
|
|
||||||
apply_rounding = frappe.db.get_single_value("LMS Settings", "apply_rounding")
|
# Check if the amount should be rounded and then apply rounding
|
||||||
|
apply_rounding = settings.apply_rounding
|
||||||
if apply_rounding and amount % 100 != 0:
|
if apply_rounding and amount % 100 != 0:
|
||||||
amount = amount + 100 - amount % 100
|
amount = amount + 100 - amount % 100
|
||||||
|
|
||||||
@@ -1466,10 +1477,13 @@ def get_neighbour_lesson(course, chapter, lesson):
|
|||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def get_batches():
|
def get_batches():
|
||||||
batches = []
|
batches = []
|
||||||
batch_list = frappe.get_all("LMS Batch", pluck="name")
|
filters = {}
|
||||||
|
if frappe.session.user == "Guest":
|
||||||
|
filters.update({"start_date": [">=", getdate()], "published": 1})
|
||||||
|
batch_list = frappe.get_all("LMS Batch", filters)
|
||||||
|
|
||||||
for batch in batch_list:
|
for batch in batch_list:
|
||||||
batches.append(get_batch_details(batch))
|
batches.append(get_batch_details(batch.name))
|
||||||
|
|
||||||
batches = categorize_batches(batches)
|
batches = categorize_batches(batches)
|
||||||
return batches
|
return batches
|
||||||
@@ -1508,18 +1522,14 @@ def get_batch_details(batch):
|
|||||||
batch_details.students = frappe.get_all(
|
batch_details.students = frappe.get_all(
|
||||||
"Batch Student", {"parent": batch}, pluck="student"
|
"Batch Student", {"parent": batch}, pluck="student"
|
||||||
)
|
)
|
||||||
if batch_details.paid_batch:
|
if batch_details.paid_batch and batch_details.start_date >= getdate():
|
||||||
batch_details.amount, batch_details.currency = check_multicurrency(
|
batch_details.amount, batch_details.currency = check_multicurrency(
|
||||||
batch_details.amount, batch_details.currency, None, batch_details.amount_usd
|
batch_details.amount, batch_details.currency, None, batch_details.amount_usd
|
||||||
)
|
)
|
||||||
batch_details.price = fmt_money(batch_details.amount, 0, batch_details.currency)
|
batch_details.price = fmt_money(batch_details.amount, 0, batch_details.currency)
|
||||||
|
|
||||||
if batch_details.seat_count:
|
if batch_details.seat_count:
|
||||||
students_enrolled = frappe.db.count(
|
batch_details.seats_left = batch_details.seat_count - len(batch_details.students)
|
||||||
"Batch Student",
|
|
||||||
{"parent": batch},
|
|
||||||
)
|
|
||||||
batch_details.seats_left = batch_details.seat_count - students_enrolled
|
|
||||||
|
|
||||||
return batch_details
|
return batch_details
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user