feat: upcoming evals

This commit is contained in:
Jannat Patel
2024-01-08 16:17:50 +05:30
parent 3a33f047f5
commit 09ae61492f
48 changed files with 33659 additions and 24452 deletions

View File

@@ -12,7 +12,6 @@
"frappe-ui": "^0.1.16",
"lucide-vue-next": "^0.259.0",
"pinia": "^2.0.33",
"qalendar": "^3.6.1",
"tailwindcss": "^3.2.7",
"vue": "^3.2.25",
"dayjs": "^1.11.6",

View File

@@ -0,0 +1,47 @@
<template>
<div>
<div class="text-lg font-semibold mb-4">
{{ __('Assessments') }}
</div>
<div v-if="assessments?.length">
<ListView
:columns="getAssessmentColumns()"
:rows="attempts?.data"
row-key="name"
:options="{ selectable: false, showTooltip: false }"
>
</ListView>
</div>
<div v-else class="text-sm italic text-gray-600">
{{ __('No Assessments') }}
</div>
</div>
</template>
<script setup>
import { ListView } from 'frappe-ui'
const props = defineProps({
assessments: {
type: Array,
default: [],
},
})
const getSubmissionColumns = () => {
return [
{
label: 'Assessment',
key: 'title',
},
{
label: 'Type',
key: 'type',
},
{
label: 'Status/Score',
key: 'status',
align: 'center',
},
]
}
</script>

View File

@@ -29,7 +29,7 @@
</div>
<div class="flex items-center mb-3">
<BookOpen class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span> {{ batch.courses }} {{ __('Courses') }} </span>
<span> {{ batch.courses.length }} {{ __('Courses') }} </span>
</div>
<div class="flex items-center mb-3">
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />

View File

@@ -0,0 +1,17 @@
<template>
<div>
<UpcomingEvaluations :upcoming_evals="batch.data.upcoming_evals" />
<Assessments :assessments="batch.data.assessments" />
</div>
</template>
<script setup>
import UpcomingEvaluations from './UpcomingEvaluations.vue'
import Assessments from './Assessments.vue'
const props = defineProps({
batch: {
type: Object,
default: null,
},
})
</script>

View File

@@ -1,38 +1,38 @@
<template>
<div class="shadow rounded-md p-5" style="width: 300px">
<div v-if="batch.data" class="shadow rounded-md p-5" style="width: 300px">
<Badge
v-if="batch.doc.seat_count && seats_left > 0"
v-if="batch.data.seat_count && seats_left > 0"
theme="green"
class="self-start mb-2 float-right"
>
{{ seats_left }} {{ __('Seat Left') }}
</Badge>
<Badge
v-else-if="batch.doc.seat_count && seats_left <= 0"
v-else-if="batch.data.seat_count && seats_left <= 0"
theme="red"
class="self-start mb-2 float-right"
>
{{ __('Sold Out') }}
</Badge>
<div v-if="batch.doc.amount" class="text-lg font-semibold mb-3">
{{ formatNumberIntoCurrency(batch.doc.amount, batch.doc.currency) }}
<div v-if="batch.data.amount" class="text-lg font-semibold mb-3">
{{ formatNumberIntoCurrency(batch.data.amount, batch.data.currency) }}
</div>
<div class="flex items-center mb-3">
<BookOpen class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span> {{ batch.doc.courses.length }} {{ __('Courses') }} </span>
<span> {{ batch.data.courses.length }} {{ __('Courses') }} </span>
</div>
<div class="flex items-center mb-3">
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span>
{{ dayjs(batch.doc.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.doc.end_date).format('DD MMM YYYY') }}
{{ dayjs(batch.data.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.data.end_date).format('DD MMM YYYY') }}
</span>
</div>
<div class="flex items-center">
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span>
{{ formatTime(batch.doc.start_time) }} -
{{ formatTime(batch.doc.end_time) }}
{{ formatTime(batch.data.start_time) }} -
{{ formatTime(batch.data.end_time) }}
</span>
</div>
<Button v-if="user?.data?.is_moderator" class="w-full mt-4">
@@ -41,7 +41,7 @@
</span>
</Button>
<Button
v-else-if="batch.doc.paid_batch"
v-else-if="batch.data.paid_batch"
class="w-full mt-4"
variant="solid"
>
@@ -73,8 +73,8 @@ const props = defineProps({
})
const seats_left = computed(() => {
if (props.batch.doc.seat_count) {
return props.batch.doc.seat_count - props.batch.doc.students.length
if (props.batch.data?.seat_count) {
return props.batch.data?.seat_count - props.batch.data?.students?.length
}
return null
})

View File

@@ -114,35 +114,13 @@ import { Badge, createResource } from 'frappe-ui'
import { ref, watchEffect } from 'vue'
const { user } = sessionStore()
let course = ref({})
const props = defineProps({
course: {
type: [Object, String],
type: Object,
default: null,
},
})
const courseDetails = createResource({
url: 'lms.lms.utils.get_course_details',
cache: ['course', props.courseName],
makeParams() {
return {
course: props.course,
}
},
transform(data) {
course.value = data
},
})
/* watchEffect(() => {
if (props.course && typeof props.course === "object") {
course.value = props.course;
} else {
courseDetails.reload();
}
}); */
</script>
<style>
.course-image {

View File

@@ -0,0 +1,53 @@
<template>
<div class="mb-10">
<div class="text-lg font-semibold mb-4">
{{ __('Upcoming Evaluations') }}
</div>
<div v-if="upcoming_evals.length">
<div class="grid grid-cols-2">
<div v-for="evl in upcoming_evals">
<div class="border rounded-md p-3">
<div class="font-medium mb-3">
{{ evl.course_title }}
</div>
<div class="flex items-center mb-2">
<Calendar class="w-4 h-4 stroke-1.5" />
<span class="ml-2">
{{ dayjs(evl.date).format('DD MMMM YYYY') }}
</span>
</div>
<div class="flex items-center mb-2">
<Clock class="w-4 h-4 stroke-1.5" />
<span class="ml-2">
{{ formatTime(evl.start_time) }}
</span>
</div>
<div class="flex items-center">
<UserCog2 class="w-4 h-4 stroke-1.5" />
<span class="ml-2">
{{ evl.evaluator_name }}
</span>
</div>
</div>
</div>
</div>
</div>
<div v-else class="text-sm italic text-gray-600">
{{ __('No upcoming evaluations.') }}
</div>
</div>
</template>
<script setup>
import { Calendar, Clock, UserCog2 } from 'lucide-vue-next'
import { inject } from 'vue'
import { formatTime } from '../utils'
const dayjs = inject('$dayjs')
const props = defineProps({
upcoming_evals: {
type: Array,
default: [],
},
})
</script>

View File

@@ -1,44 +1,135 @@
<template>
<div class="h-screen text-base">
<div v-if="user.data?.is_moderator || is_student" class="h-screen text-base">
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs class="h-7" :items="breadcrumbs" />
</header>
<div v-if="batch.doc">
<div v-if="batch.data">
<div class="grid grid-cols-[70%,30%] h-full">
<div class="border-r-2"></div>
<div class="border-r-2">
<Tabs class="overflow-hidden" v-model="tabIndex" :tabs="tabs">
<template #tab="{ tab, selected }">
<div>
<button
class="group -mb-px flex items-center gap-1 border-b border-transparent py-2.5 text-base text-gray-600 duration-300 ease-in-out hover:border-gray-400 hover:text-gray-900"
:class="{ 'text-gray-900': selected }"
>
<component
v-if="tab.icon"
:is="tab.icon"
class="h-4 stroke-1.5"
/>
{{ __(tab.label) }}
<Badge
v-if="tab.count"
:class="{
'text-gray-900 border border-gray-900': selected,
}"
variant="subtle"
theme="gray"
size="sm"
>
{{ tab.count }}
</Badge>
</button>
</div>
</template>
<template #default="{ tab }">
<div class="p-10">
<div v-if="tab.label == 'Courses'">
<div class="text-xl font-semibold">
{{ __('Courses') }}
</div>
<div
class="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 gap-8 mt-5"
>
<div v-for="course in courses.data">
<router-link
:to="{
name: 'CourseDetail',
params: {
courseName: course.name,
},
}"
>
<CourseCard :key="course.name" :course="course" />
</router-link>
</div>
</div>
</div>
<div v-else-if="tab.label == 'Dashboard'">
<BatchDashboard :batch="batch" />
</div>
</div>
</template>
</Tabs>
</div>
<div class="p-5">
<div class="text-2xl font-semibold mb-3">
{{ batch.doc.title }}
{{ batch.data.title }}
</div>
<div class="flex items-center mb-2">
<div class="flex items-center mb-3">
<Calendar class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span>
{{ dayjs(batch.doc.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.doc.end_date).format('DD MMM YYYY') }}
{{ dayjs(batch.data.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.data.end_date).format('DD MMM YYYY') }}
</span>
</div>
<div class="flex items-center mb-6">
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
<span>
{{ formatTime(batch.doc.start_time) }} -
{{ formatTime(batch.doc.end_time) }}
{{ formatTime(batch.data.start_time) }} -
{{ formatTime(batch.data.end_time) }}
</span>
</div>
<div v-html="batch.doc.description"></div>
<div v-html="batch.data.description"></div>
</div>
</div>
</div>
</div>
<div v-else class="h-screen">
<div class="text-base border rounded-md w-1/3 mx-auto my-32">
<div class="border-b px-5 py-3 font-medium">
<span
class="inline-flex items-center before:bg-red-600 before:w-2 before:h-2 before:rounded-md before:mr-2"
></span>
{{ __('Not Permitted') }}
</div>
<div class="px-5 py-3">
<div class="mb-4 leading-6">
{{
__(
'You are not a member of this batch. Please checkout our upcoming batches.'
)
}}
</div>
<router-link
:to="{
name: 'Batches',
params: {
batchName: batch.data?.name,
},
}"
>
<Button variant="solid" class="w-full">
{{ __('Upcoming Batches') }}
</Button>
</router-link>
</div>
</div>
</div>
</template>
<script setup>
import { Breadcrumbs, createDocumentResource } from 'frappe-ui'
import { computed, inject } from 'vue'
import { Calendar, Clock } from 'lucide-vue-next'
import { Breadcrumbs, Button, createResource, Tabs, Badge } from 'frappe-ui'
import { computed, inject, ref } from 'vue'
import { Calendar, Clock, LayoutDashboard, BookOpen } from 'lucide-vue-next'
import { formatTime } from '@/utils'
import CourseCard from '@/components/CourseCard.vue'
import BatchDashboard from '@/components/BatchDashboard.vue'
const dayjs = inject('$dayjs')
const user = inject('$user')
const props = defineProps({
batchName: {
@@ -47,10 +138,12 @@ const props = defineProps({
},
})
const batch = createDocumentResource({
doctype: 'LMS Batch',
name: props.batchName,
const batch = createResource({
url: 'lms.lms.utils.get_batch_details',
cache: ['batch', props.batchName],
params: {
batch: props.batchName,
},
auto: true,
})
@@ -62,9 +155,42 @@ const breadcrumbs = computed(() => {
route: { name: 'BatchDetail', params: { batchName: props.batchName } },
},
{
label: batch?.doc?.title,
label: batch?.data?.title,
route: { name: 'Batch', params: { batchName: props.batchName } },
},
]
})
const is_student = computed(() => {
return (
user?.data &&
batch.data?.students.length &&
batch.data?.students.includes(user.data.name)
)
})
const tabIndex = ref(0)
const tabs = []
if (is_student) {
tabs.push({
label: 'Dashboard',
icon: LayoutDashboard,
})
}
tabs.push({
label: 'Courses',
count: computed(() => courses?.data?.length),
icon: BookOpen,
})
const courses = createResource({
url: 'lms.lms.utils.get_batch_courses',
params: {
batch: props.batchName,
},
cache: ['batchCourses', props.batchName],
auto: true,
})
</script>

View File

@@ -1,42 +1,45 @@
<template>
<div v-if="batch.doc" class="h-screen text-base">
<div v-if="batch.data" class="h-screen text-base">
<header class="sticky top-0 z-10 border-b bg-white px-3 py-2.5 sm:px-5">
<Breadcrumbs :items="breadcrumbs" />
</header>
<div class="m-5 pb-10">
<div>
<div class="text-3xl font-semibold">
{{ batch.doc.title }}
{{ batch.data.title }}
</div>
<div class="my-3">
{{ batch.doc.description }}
{{ batch.data.description }}
</div>
<div class="flex items-center justify-between w-1/2">
<div class="flex items-center">
<BookOpen class="h-4 w-4 text-gray-700 mr-2" />
<span> {{ batch.doc.courses.length }} {{ __('Courses') }} </span>
<span> {{ batch.data.courses.length }} {{ __('Courses') }} </span>
</div>
<span v-if="batch.doc.courses">&middot;</span>
<span v-if="batch.data.courses">&middot;</span>
<div class="flex items-center">
<Calendar class="h-4 w-4 text-gray-700 mr-2" />
<span>
{{ dayjs(batch.doc.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.doc.end_date).format('DD MMM YYYY') }}
{{ dayjs(batch.data.start_date).format('DD MMM YYYY') }} -
{{ dayjs(batch.data.end_date).format('DD MMM YYYY') }}
</span>
</div>
<span v-if="batch.doc.start_date">&middot;</span>
<span v-if="batch.data.start_date">&middot;</span>
<div class="flex items-center">
<Clock class="h-4 w-4 text-gray-700 mr-2" />
<span>
{{ formatTime(batch.doc.start_time) }} -
{{ formatTime(batch.doc.end_time) }}
{{ formatTime(batch.data.start_time) }} -
{{ formatTime(batch.data.end_time) }}
</span>
</div>
</div>
</div>
<div class="grid grid-cols-[60%,20%] gap-20 mt-10">
<div class="">
<div v-html="batch.doc.batch_details" class="batch-description"></div>
<div
v-html="batch.data.batch_details"
class="batch-description"
></div>
</div>
<div>
<BatchOverlay :batch="batch" />
@@ -46,29 +49,41 @@
<div class="text-2xl font-semibold">
{{ __('Courses') }}
</div>
<div
v-if="batch.doc.courses"
v-for="course in batch.doc.courses"
:key="course.course"
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5"
>
<router-link
:to="{
name: 'CourseDetail',
params: {
courseName: course.course,
},
}"
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5">
<div
v-if="batch.data.courses"
v-for="course in courses.data"
:key="course.course"
>
<CourseCard :course="course.course" :key="course.course" />
</router-link>
<router-link
:to="{
name: 'CourseDetail',
params: {
courseName: course.name,
},
}"
>
<CourseCard :course="course" :key="course.name" />
</router-link>
</div>
</div>
<div v-if="batch.data.batch_details_raw">
<div
v-html="batch.data.batch_details_raw"
class="batch-description"
></div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { Breadcrumbs, createDocumentResource } from 'frappe-ui'
import {
Breadcrumbs,
createDocumentResource,
createListResource,
createResource,
} from 'frappe-ui'
import { BookOpen, Calendar, Clock } from 'lucide-vue-next'
import { formatTime } from '../utils'
import { computed, inject } from 'vue'
@@ -84,18 +99,29 @@ const props = defineProps({
},
})
const batch = createDocumentResource({
doctype: 'LMS Batch',
name: props.batchName,
const batch = createResource({
url: 'lms.lms.utils.get_batch_details',
cache: ['batch', props.batchName],
params: {
batch: props.batchName,
},
auto: true,
})
const courses = createResource({
url: 'lms.lms.utils.get_batch_courses',
params: {
batch: props.batchName,
},
cache: ['batchCourses', props.batchName],
auto: true,
})
const breadcrumbs = computed(() => {
let items = [{ label: 'All Batches', route: { name: 'Batches' } }]
items.push({
label: batch?.doc?.title,
route: { name: 'BatchDetail', params: { batchName: batch?.doc?.name } },
label: batch?.data?.title,
route: { name: 'BatchDetail', params: { batchName: batch?.data?.name } },
})
return items
})

View File

@@ -1,119 +1,151 @@
<template>
<div class="h-screen">
<div v-if="courses.data">
<header class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5">
<Breadcrumbs class="h-7" :items="[{ label: __('All Courses'), route: { name: 'Courses' } }]" />
<div class="flex">
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __("New Course") }}
</Button>
</div>
</header>
<div class="mx-5 py-5">
<Tabs class="overflow-hidden" v-model="tabIndex" :tabs="tabs">
<template #tab="{ tab, selected }">
<div>
<button
class="group -mb-px flex items-center gap-2 border-b border-transparent py-2.5 text-base text-gray-600 duration-300 ease-in-out hover:border-gray-400 hover:text-gray-900"
:class="{ 'text-gray-900': selected }">
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
{{ __(tab.label) }}
<Badge :class="{ 'text-gray-900 border border-gray-900': selected }" variant="subtle" theme="gray"
size="sm">
{{ tab.count }}
</Badge>
</button>
</div>
</template>
<template #default="{ tab }">
<div v-if="tab.courses && tab.courses.value.length" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5">
<router-link v-for="course in tab.courses.value"
:to="course.membership && course.current_lesson
? {
name: 'Lesson', params: {
courseName: course.name,
chapterNumber: course.current_lesson.split('.')[0],
lessonNumber: course.current_lesson.split('.')[1]
}
}
: course.membership ? {
name: 'Lesson', params: {
courseName: course.name,
chapterNumber: 1,
lessonNumber: 1
}
} : { name: 'CourseDetail', params: { courseName: course.name } }">
<CourseCard :course="course" />
</router-link>
</div>
<div v-else class="grid flex-1 place-items-center text-xl font-medium text-gray-500">
<div class="flex flex-col items-center justify-center mt-4">
<div>
{{ __("No {0} courses found").format(tab.label.toLowerCase()) }}
</div>
</div>
</div>
</template>
</Tabs>
</div>
</div>
</div>
<div class="h-screen">
<div v-if="courses.data">
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs
class="h-7"
:items="[{ label: __('All Courses'), route: { name: 'Courses' } }]"
/>
<div class="flex">
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('New Course') }}
</Button>
</div>
</header>
<div class="mx-5 py-5">
<Tabs class="overflow-hidden" v-model="tabIndex" :tabs="tabs">
<template #tab="{ tab, selected }">
<div>
<button
class="group -mb-px flex items-center gap-2 border-b border-transparent py-2.5 text-base text-gray-600 duration-300 ease-in-out hover:border-gray-400 hover:text-gray-900"
:class="{ 'text-gray-900': selected }"
>
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
{{ __(tab.label) }}
<Badge
:class="{ 'text-gray-900 border border-gray-900': selected }"
variant="subtle"
theme="gray"
size="sm"
>
{{ tab.count }}
</Badge>
</button>
</div>
</template>
<template #default="{ tab }">
<div
v-if="tab.courses && tab.courses.value.length"
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 mt-5"
>
<router-link
v-for="course in tab.courses.value"
:to="
course.membership && course.current_lesson
? {
name: 'Lesson',
params: {
courseName: course.name,
chapterNumber: course.current_lesson.split('.')[0],
lessonNumber: course.current_lesson.split('.')[1],
},
}
: course.membership
? {
name: 'Lesson',
params: {
courseName: course.name,
chapterNumber: 1,
lessonNumber: 1,
},
}
: {
name: 'CourseDetail',
params: { courseName: course.name },
}
"
>
<CourseCard :course="course" />
</router-link>
</div>
<div
v-else
class="grid flex-1 place-items-center text-xl font-medium text-gray-500"
>
<div class="flex flex-col items-center justify-center mt-4">
<div>
{{
__('No {0} courses found').format(tab.label.toLowerCase())
}}
</div>
</div>
</div>
</template>
</Tabs>
</div>
</div>
</div>
</template>
<script setup>
import { sessionStore } from '@/stores/session'
import { createListResource, Breadcrumbs, Tabs, Badge, Button } from 'frappe-ui';
import CourseCard from '@/components/CourseCard.vue';
import { createListResource, Breadcrumbs, Tabs, Badge, Button } from 'frappe-ui'
import CourseCard from '@/components/CourseCard.vue'
import { Plus } from 'lucide-vue-next'
import { ref, computed, inject } from 'vue'
const user = inject("$user")
const user = inject('$user')
const courses = createListResource({
type: 'list',
doctype: 'LMS Course',
cache: ["courses", user?.data?.email],
url: "lms.lms.utils.get_courses",
auto: true,
});
type: 'list',
doctype: 'LMS Course',
cache: ['courses', user?.data?.email],
url: 'lms.lms.utils.get_courses',
auto: true,
})
const tabIndex = ref(0)
const tabs = [
{
label: 'Live',
courses: computed(() => courses.data?.live || []),
count: computed(() => courses.data?.live?.length),
},
{
label: 'Upcoming',
courses: computed(() => courses.data?.upcoming),
count: computed(() => courses.data?.upcoming?.length),
}
];
{
label: 'Live',
courses: computed(() => courses.data?.live || []),
count: computed(() => courses.data?.live?.length),
},
{
label: 'Upcoming',
courses: computed(() => courses.data?.upcoming),
count: computed(() => courses.data?.upcoming?.length),
},
]
if (user.data) {
tabs.push({
label: 'Enrolled',
courses: computed(() => courses.data?.enrolled),
count: computed(() => courses.data?.enrolled?.length),
});
tabs.push({
label: 'Enrolled',
courses: computed(() => courses.data?.enrolled),
count: computed(() => courses.data?.enrolled?.length),
})
if (user.data.is_moderator || user.data.is_instructor || courses.data?.created?.length) {
tabs.push({
label: 'Created',
courses: computed(() => courses.data?.created),
count: computed(() => courses.data?.created?.length),
});
};
if (
user.data.is_moderator ||
user.data.is_instructor ||
courses.data?.created?.length
) {
tabs.push({
label: 'Created',
courses: computed(() => courses.data?.created),
count: computed(() => courses.data?.created?.length),
})
}
if (user.data.is_moderator) {
tabs.push({
label: 'Under Review',
courses: computed(() => courses.data?.under_review),
count: computed(() => courses.data?.under_review?.length),
});
}
};
</script>
if (user.data.is_moderator) {
tabs.push({
label: 'Under Review',
courses: computed(() => courses.data?.under_review),
count: computed(() => courses.data?.under_review?.length),
})
}
}
</script>