Merge pull request #1226 from pateljannat/issues-61

fix: misc batch issues
This commit is contained in:
Jannat Patel
2025-01-03 17:57:42 +05:30
committed by GitHub
3 changed files with 78 additions and 51 deletions

View File

@@ -125,7 +125,11 @@
@click="openStudentProgressModal(row)" @click="openStudentProgressModal(row)"
> >
<template #default="{ column, item }"> <template #default="{ column, item }">
<ListRowItem :item="row[column.key]" :align="column.align"> <ListRowItem
:item="row[column.key]"
:align="column.align"
class="text-sm"
>
<template #prefix> <template #prefix>
<div v-if="column.key == 'full_name'"> <div v-if="column.key == 'full_name'">
<Avatar <Avatar
@@ -141,6 +145,7 @@
class="flex items-center space-x-4 w-full" class="flex items-center space-x-4 w-full"
> >
<ProgressBar :progress="row[column.key]" size="sm" /> <ProgressBar :progress="row[column.key]" size="sm" />
<div class="text-xs">{{ row[column.key] }}%</div>
</div> </div>
<div <div
v-else-if="column.key == 'copy'" v-else-if="column.key == 'copy'"
@@ -256,13 +261,13 @@ const getStudentColumns = () => {
{ {
label: 'Progress', label: 'Progress',
key: 'progress', key: 'progress',
width: '10rem', width: '15rem',
icon: 'activity', icon: 'activity',
}, },
{ {
label: 'Last Active', label: 'Last Active',
key: 'last_active', key: 'last_active',
width: '15rem', width: '10rem',
align: 'center', align: 'center',
icon: 'clock', icon: 'clock',
}, },

View File

@@ -15,45 +15,55 @@
<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 <div
v-for="cls in liveClasses.data" v-for="cls in liveClasses.data"
class="flex flex-col border rounded-md h-full text-sm text-gray-700 p-3" class="flex flex-col border rounded-md h-full text-gray-700 p-3"
> >
<div class="font-semibold text-gray-900 text-lg mb-4"> <div class="font-semibold text-gray-900 text-lg mb-1">
{{ cls.title }} {{ cls.title }}
</div> </div>
<div class="leading-5 text-gray-700 text-sm mb-4"> <div class="short-introduction">
{{ cls.description }} {{ cls.description }}
</div> </div>
<div class="flex items-center mb-2"> <div class="space-y-3">
<Calendar class="w-4 h-4 stroke-1.5 text-gray-700" /> <div class="flex items-center space-x-2">
<span class="ml-2"> <Calendar class="w-4 h-4 stroke-1.5" />
{{ dayjs(cls.date).format('DD MMMM YYYY') }} <span>
</span> {{ dayjs(cls.date).format('DD MMMM YYYY') }}
</div> </span>
<div class="flex items-center mb-5"> </div>
<Clock class="w-4 h-4 stroke-1.5" /> <div class="flex items-center space-x-2">
<span class="ml-2"> <Clock class="w-4 h-4 stroke-1.5" />
{{ formatTime(cls.time) }} <span>
</span> {{ formatTime(cls.time) }}
</div> </span>
<div class="flex items-center space-x-2 text-gray-900 mt-auto"> </div>
<a <div
v-if="user.data?.is_moderator || user.data?.is_evaluator" v-if="cls.date >= dayjs().format('YYYY-MM-DD')"
:href="cls.start_url" class="flex items-center space-x-2 text-gray-900 mt-auto"
target="_blank"
class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
> >
<Monitor class="h-4 w-4 stroke-1.5" /> <a
{{ __('Start') }} v-if="user.data?.is_moderator || user.data?.is_evaluator"
</a> :href="cls.start_url"
<a target="_blank"
v-if="cls.date <= dayjs().format('YYYY-MM-DD')" class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
:href="cls.join_url" >
target="_blank" <Monitor class="h-4 w-4 stroke-1.5" />
class="w-full cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded" {{ __('Start') }}
> </a>
<Video class="h-4 w-4 stroke-1.5" /> <a
{{ __('Join') }} :href="cls.join_url"
</a> target="_blank"
class="w-full cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
>
<Video class="h-4 w-4 stroke-1.5" />
{{ __('Join') }}
</a>
</div>
<div v-else class="flex items-center space-x-2 text-yellow-700">
<Info class="w-4 h-4 stroke-1.5" />
<span>
{{ __('This class has ended') }}
</span>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -68,7 +78,7 @@
</template> </template>
<script setup> <script setup>
import { createListResource, Button } from 'frappe-ui' import { createListResource, Button } from 'frappe-ui'
import { Plus, Clock, Calendar, Video, Monitor } from 'lucide-vue-next' import { Plus, Clock, Calendar, Video, Monitor, Info } from 'lucide-vue-next'
import { inject } from 'vue' import { inject } from 'vue'
import LiveClassModal from '@/components/Modals/LiveClassModal.vue' import LiveClassModal from '@/components/Modals/LiveClassModal.vue'
import { ref } from 'vue' import { ref } from 'vue'
@@ -107,3 +117,15 @@ const openLiveClassModal = () => {
showLiveClassModal.value = true showLiveClassModal.value = true
} }
</script> </script>
<style>
.short-introduction {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
width: 100%;
overflow: hidden;
margin: 0.25rem 0 1.5rem;
line-height: 1.5;
}
</style>

View File

@@ -1499,7 +1499,7 @@ def get_batch_students(batch):
detail.progress = 0 detail.progress = 0
students.append(detail) students.append(detail)
students = sorted(students, key=lambda x: x.progress, reverse=True)
return students return students
@@ -1750,31 +1750,31 @@ def enroll_in_batch(batch, payment_name=None):
if not frappe.db.exists( if not frappe.db.exists(
"Batch Student", {"parent": batch, "student": frappe.session.user} "Batch Student", {"parent": batch, "student": frappe.session.user}
): ):
student = frappe.new_doc("Batch Student") batch_doc = frappe.get_doc("LMS Batch", batch)
current_count = frappe.db.count("Batch Student", {"parent": batch}) if batch_doc.seat_count and len(batch_doc.students) >= batch_doc.seat_count:
frappe.throw(_("The batch is full. Please contact the Administrator."))
student.update( new_student = {
{ "student": frappe.session.user,
"student": frappe.session.user, "parent": batch,
"parent": batch, "parenttype": "LMS Batch",
"parenttype": "LMS Batch", "parentfield": "students",
"parentfield": "students", "idx": len(batch_doc.students) + 1,
"idx": current_count + 1, }
}
)
if payment_name: if payment_name:
payment = frappe.db.get_value( payment = frappe.db.get_value(
"LMS Payment", payment_name, ["name", "source"], as_dict=True "LMS Payment", payment_name, ["name", "source"], as_dict=True
) )
student.update( new_student.update(
{ {
"payment": payment.name, "payment": payment.name,
"source": payment.source, "source": payment.source,
} }
) )
student.save(ignore_permissions=True) batch_doc.append("students", new_student)
batch_doc.save(ignore_permissions=True)
@frappe.whitelist() @frappe.whitelist()