Skip to content

Commit

Permalink
Merge pull request #1226 from pateljannat/issues-61
Browse files Browse the repository at this point in the history
fix: misc batch issues
  • Loading branch information
pateljannat authored Jan 3, 2025
2 parents 34548b9 + f77686f commit 4759736
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 52 deletions.
11 changes: 8 additions & 3 deletions frontend/src/components/BatchStudents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@
@click="openStudentProgressModal(row)"
>
<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>
<div v-if="column.key == 'full_name'">
<Avatar
Expand All @@ -141,6 +145,7 @@
class="flex items-center space-x-4 w-full"
>
<ProgressBar :progress="row[column.key]" size="sm" />
<div class="text-xs">{{ row[column.key] }}%</div>
</div>
<div
v-else-if="column.key == 'copy'"
Expand Down Expand Up @@ -256,13 +261,13 @@ const getStudentColumns = () => {
{
label: 'Progress',
key: 'progress',
width: '10rem',
width: '15rem',
icon: 'activity',
},
{
label: 'Last Active',
key: 'last_active',
width: '15rem',
width: '10rem',
align: 'center',
icon: 'clock',
},
Expand Down
90 changes: 56 additions & 34 deletions frontend/src/components/LiveClass.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,55 @@
<div v-if="liveClasses.data?.length" class="grid grid-cols-2 gap-5">
<div
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 }}
</div>
<div class="leading-5 text-gray-700 text-sm mb-4">
<div class="short-introduction">
{{ cls.description }}
</div>
<div class="flex items-center mb-2">
<Calendar class="w-4 h-4 stroke-1.5 text-gray-700" />
<span class="ml-2">
{{ dayjs(cls.date).format('DD MMMM YYYY') }}
</span>
</div>
<div class="flex items-center mb-5">
<Clock class="w-4 h-4 stroke-1.5" />
<span class="ml-2">
{{ formatTime(cls.time) }}
</span>
</div>
<div class="flex items-center space-x-2 text-gray-900 mt-auto">
<a
v-if="user.data?.is_moderator || user.data?.is_evaluator"
:href="cls.start_url"
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"
<div class="space-y-3">
<div class="flex items-center space-x-2">
<Calendar class="w-4 h-4 stroke-1.5" />
<span>
{{ dayjs(cls.date).format('DD MMMM YYYY') }}
</span>
</div>
<div class="flex items-center space-x-2">
<Clock class="w-4 h-4 stroke-1.5" />
<span>
{{ formatTime(cls.time) }}
</span>
</div>
<div
v-if="cls.date >= dayjs().format('YYYY-MM-DD')"
class="flex items-center space-x-2 text-gray-900 mt-auto"
>
<Monitor class="h-4 w-4 stroke-1.5" />
{{ __('Start') }}
</a>
<a
v-if="cls.date <= dayjs().format('YYYY-MM-DD')"
:href="cls.join_url"
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>
<a
v-if="user.data?.is_moderator || user.data?.is_evaluator"
:href="cls.start_url"
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" />
{{ __('Start') }}
</a>
<a
:href="cls.join_url"
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>
Expand All @@ -68,7 +78,7 @@
</template>
<script setup>
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 LiveClassModal from '@/components/Modals/LiveClassModal.vue'
import { ref } from 'vue'
Expand Down Expand Up @@ -107,3 +117,15 @@ const openLiveClassModal = () => {
showLiveClassModal.value = true
}
</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>
30 changes: 15 additions & 15 deletions lms/lms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ def get_batch_students(batch):
detail.progress = 0

students.append(detail)

students = sorted(students, key=lambda x: x.progress, reverse=True)
return students


Expand Down Expand Up @@ -1750,31 +1750,31 @@ def enroll_in_batch(batch, payment_name=None):
if not frappe.db.exists(
"Batch Student", {"parent": batch, "student": frappe.session.user}
):
student = frappe.new_doc("Batch Student")
current_count = frappe.db.count("Batch Student", {"parent": batch})

student.update(
{
"student": frappe.session.user,
"parent": batch,
"parenttype": "LMS Batch",
"parentfield": "students",
"idx": current_count + 1,
}
)
batch_doc = frappe.get_doc("LMS Batch", 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."))

new_student = {
"student": frappe.session.user,
"parent": batch,
"parenttype": "LMS Batch",
"parentfield": "students",
"idx": len(batch_doc.students) + 1,
}

if payment_name:
payment = frappe.db.get_value(
"LMS Payment", payment_name, ["name", "source"], as_dict=True
)
student.update(
new_student.update(
{
"payment": payment.name,
"source": payment.source,
}
)

student.save(ignore_permissions=True)
batch_doc.append("students", new_student)
batch_doc.save(ignore_permissions=True)


@frappe.whitelist()
Expand Down

0 comments on commit 4759736

Please sign in to comment.