@@ -2,7 +2,7 @@
|
||||
<Button
|
||||
v-if="user.data.is_moderator"
|
||||
variant="solid"
|
||||
class="float-right mb-3"
|
||||
class="float-right mb-5"
|
||||
@click="openLiveClassModal"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -12,14 +12,20 @@
|
||||
{{ __('Add Live Class') }}
|
||||
</span>
|
||||
</Button>
|
||||
<div class="text-lg font-semibold mb-4">
|
||||
<div class="text-lg font-semibold mb-5">
|
||||
{{ __('Live Class') }}
|
||||
</div>
|
||||
<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">
|
||||
{{ cls.title }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ cls.description }}
|
||||
</div>
|
||||
<div class="flex items-center mb-2">
|
||||
<Calendar class="w-4 h-4 stroke-1.5" />
|
||||
<span class="ml-2">
|
||||
@@ -32,10 +38,7 @@
|
||||
{{ formatTime(cls.time) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
{{ cls.description }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex items-center space-x-2 mt-auto">
|
||||
<a
|
||||
:href="cls.start_url"
|
||||
target="_blank"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<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'">
|
||||
<BatchCourses :batch="batch.data.name" />
|
||||
</div>
|
||||
|
||||
@@ -227,11 +227,6 @@ const lesson = createResource({
|
||||
},
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
if (data.membership)
|
||||
current_lesson.submit({
|
||||
name: data.membership.name,
|
||||
lesson_name: data.name,
|
||||
})
|
||||
markProgress(data)
|
||||
|
||||
if (data.content) editor = renderEditor('editor', data.content)
|
||||
@@ -260,18 +255,6 @@ const markProgress = (data) => {
|
||||
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({
|
||||
url: 'lms.lms.doctype.course_lesson.course_lesson.save_progress',
|
||||
makeParams() {
|
||||
|
||||
@@ -154,7 +154,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
try {
|
||||
if (isLoggedIn) {
|
||||
await userResource.reload()
|
||||
await userResource.promise
|
||||
}
|
||||
if (
|
||||
isLoggedIn &&
|
||||
@@ -163,7 +163,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
to.name == 'Notifications' ||
|
||||
to.name == 'Badge')
|
||||
) {
|
||||
await allUsers.reload()
|
||||
await allUsers.promise
|
||||
}
|
||||
} catch (error) {
|
||||
isLoggedIn = false
|
||||
|
||||
@@ -9,6 +9,7 @@ export const usersStore = defineStore('lms-users', () => {
|
||||
router.push('/login')
|
||||
}
|
||||
},
|
||||
auto: true,
|
||||
})
|
||||
|
||||
const allUsers = createResource({
|
||||
|
||||
@@ -95,6 +95,8 @@ def save_progress(lesson, course):
|
||||
if not membership:
|
||||
return 0
|
||||
|
||||
frappe.db.set_value("LMS Enrollment", membership, "current_lesson", lesson)
|
||||
|
||||
quiz_completed = get_quiz_progress(lesson)
|
||||
if not quiz_completed:
|
||||
return 0
|
||||
|
||||
@@ -1018,31 +1018,42 @@ def get_payment_options(doctype, docname, phone, country):
|
||||
|
||||
|
||||
def check_multicurrency(amount, currency, country=None, amount_usd=None):
|
||||
show_usd_equivalent = frappe.db.get_single_value("LMS Settings", "show_usd_equivalent")
|
||||
exception_country = frappe.get_all(
|
||||
"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()
|
||||
)
|
||||
settings = frappe.get_single("LMS Settings")
|
||||
show_usd_equivalent = settings.show_usd_equivalent
|
||||
|
||||
if amount_usd and country and country not in exception_country:
|
||||
return amount_usd, "USD"
|
||||
# Countries for which currency should not be converted
|
||||
exception_country = settings.exception_country
|
||||
exception_country = [country.country for country in exception_country]
|
||||
|
||||
if not show_usd_equivalent or currency == "USD":
|
||||
return amount, currency
|
||||
# Get users country
|
||||
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):
|
||||
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")
|
||||
amount = amount * exchange_rate
|
||||
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:
|
||||
amount = amount + 100 - amount % 100
|
||||
|
||||
@@ -1466,10 +1477,13 @@ def get_neighbour_lesson(course, chapter, lesson):
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_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:
|
||||
batches.append(get_batch_details(batch))
|
||||
batches.append(get_batch_details(batch.name))
|
||||
|
||||
batches = categorize_batches(batches)
|
||||
return batches
|
||||
@@ -1508,18 +1522,14 @@ def get_batch_details(batch):
|
||||
batch_details.students = frappe.get_all(
|
||||
"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, None, batch_details.amount_usd
|
||||
)
|
||||
batch_details.price = fmt_money(batch_details.amount, 0, batch_details.currency)
|
||||
|
||||
if batch_details.seat_count:
|
||||
students_enrolled = frappe.db.count(
|
||||
"Batch Student",
|
||||
{"parent": batch},
|
||||
)
|
||||
batch_details.seats_left = batch_details.seat_count - students_enrolled
|
||||
batch_details.seats_left = batch_details.seat_count - len(batch_details.students)
|
||||
|
||||
return batch_details
|
||||
|
||||
|
||||
Reference in New Issue
Block a user