Skip to content

Commit

Permalink
feat: students and assessment tab in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Jan 10, 2024
1 parent 09ae614 commit 1a6a119
Show file tree
Hide file tree
Showing 51 changed files with 4,094 additions and 2,335 deletions.
12 changes: 6 additions & 6 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"dayjs": "^1.11.6",
"feather-icons": "^4.28.0",
"frappe-ui": "^0.1.16",
"frappe-ui": "^0.1.22",
"lucide-vue-next": "^0.259.0",
"markdown-it": "^14.0.0",
"pinia": "^2.0.33",
"tailwindcss": "^3.2.7",
"vue": "^3.2.25",
"dayjs": "^1.11.6",
"vue-router": "^4.0.12",
"markdown-it": "^14.0.0"
"vue-router": "^4.0.12"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.0.0",
"autoprefixer": "^10.4.2",
"postcss": "^8.4.5",
"vite": "^3.0.0"
"vite": "^5.0.11"
}
}
51 changes: 40 additions & 11 deletions frontend/src/components/Assessments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="text-lg font-semibold mb-4">
{{ __('Assessments') }}
</div>
<div v-if="assessments?.length">
<div v-if="assessments.data?.length">
<ListView
:columns="getAssessmentColumns()"
:rows="attempts?.data"
:rows="assessments.data"
row-key="name"
:options="{ selectable: false, showTooltip: false }"
>
Expand All @@ -18,30 +18,59 @@
</div>
</template>
<script setup>
import { ListView } from 'frappe-ui'
import { ListView, createResource } from 'frappe-ui'
import { inject } from 'vue'
const user = inject('$user')
const props = defineProps({
assessments: {
batch: {
type: String,
required: true,
},
rows: {
type: Array,
},
columns: {
type: Array,
default: [],
},
options: {
type: Object,
default: () => ({
selectable: true,
totalCount: 0,
rowCount: 0,
}),
},
})
const getSubmissionColumns = () => {
return [
const assessments = createResource({
url: 'lms.lms.utils.get_assessments',
params: {
batch: props.batch,
},
auto: true,
})
const getAssessmentColumns = () => {
let columns = [
{
label: 'Assessment',
key: 'title',
},
{
label: 'Type',
key: 'type',
key: 'assessment_type',
},
{
]
if (!user.data?.is_moderator) {
columns.push({
label: 'Status/Score',
key: 'status',
align: 'center',
},
]
})
}
return columns
}
</script>
17 changes: 13 additions & 4 deletions frontend/src/components/BatchDashboard.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<template>
<div>
<UpcomingEvaluations :upcoming_evals="batch.data.upcoming_evals" />
<Assessments :assessments="batch.data.assessments" />
<UpcomingEvaluations
:batch="batch.data.name"
:endDate="batch.data.evaluation_end_date"
:courses="batch.data.courses"
:isStudent="isStudent"
/>
<Assessments :batch="batch.data.name" />
</div>
</template>
<script setup>
import UpcomingEvaluations from './UpcomingEvaluations.vue'
import Assessments from './Assessments.vue'
import UpcomingEvaluations from '@/components/UpcomingEvaluations.vue'
import Assessments from '@/components/Assessments.vue'
const props = defineProps({
batch: {
type: Object,
default: null,
},
isStudent: {
type: Boolean,
default: false,
},
})
</script>
20 changes: 15 additions & 5 deletions frontend/src/components/BatchOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@
{{ formatTime(batch.data.end_time) }}
</span>
</div>
<Button v-if="user?.data?.is_moderator" class="w-full mt-4">
<span>
{{ __('Manage Batch') }}
</span>
</Button>
<router-link
v-if="user?.data?.is_moderator"
:to="{
name: 'Batch',
params: {
batchName: batch.data.name,
},
}"
>
<Button variant="solid" class="w-full mt-4">
<span>
{{ __('Manage Batch') }}
</span>
</Button>
</router-link>
<Button
v-else-if="batch.data.paid_batch"
class="w-full mt-4"
Expand Down
153 changes: 153 additions & 0 deletions frontend/src/components/BatchStudents.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<template>
<Button class="float-right mb-3" variant="solid" @click="openStudentModal()">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
{{ __('Add Student') }}
</Button>
<div class="text-lg font-semibold mb-4">
{{ __('Students') }}
</div>
<div v-if="students.data?.length">
<ListView
:columns="getStudentColumns()"
:rows="students.data"
row-key="name"
:options="{ showTooltip: false }"
>
<ListHeader
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
>
<ListHeaderItem :item="item" v-for="item in getStudentColumns()">
<template #prefix="{ item }">
<component
v-if="item.icon"
:is="item.icon"
class="h-4 w-4 stroke-1.5 ml-4"
/>
</template>
</ListHeaderItem>
</ListHeader>
<ListRows>
<ListRow :row="row" v-for="row in students.data">
<template #default="{ column, item }">
<ListRowItem :item="row[column.key]" :align="column.align">
<template #prefix>
<div v-if="column.key == 'full_name'">
<Avatar
class="flex items-center"
:image="row['user_image']"
:label="item"
size="sm"
/>
</div>
</template>
<div>
{{ row[column.key] }}
</div>
</ListRowItem>
</template>
</ListRow>
</ListRows>
<ListSelectBanner>
<template #actions="{ unselectAll, selections }">
<div class="flex gap-2">
<Button variant="ghost" @click="removeStudents(selections)">
<Trash2 class="h-4 w-4 stroke-1.5" />
</Button>
<Button
variant="ghost"
label="Unselect all"
@click="unselectAll.toString()"
/>
</div>
</template>
</ListSelectBanner>
</ListView>
</div>
<StudentModal
:batch="props.batch"
v-model="showStudentModal"
v-model:reloadStudents="students"
/>
</template>
<script setup>
import {
createResource,
ListHeader,
ListHeaderItem,
ListSelectBanner,
ListRow,
ListRows,
ListView,
ListRowItem,
Avatar,
Button,
} from 'frappe-ui'
import { Settings, Trash2, Plus } from 'lucide-vue-next'
import { ref } from 'vue'
import StudentModal from '@/components/StudentModal.vue'
const showStudentModal = ref(false)
const props = defineProps({
batch: {
type: String,
default: null,
},
})
const students = createResource({
url: 'lms.lms.utils.get_batch_students',
cache: ['students', props.batch],
params: {
batch: props.batch,
},
auto: true,
})
const getStudentColumns = () => {
return [
{
label: 'Full Name',
key: 'full_name',
},
{
label: 'Courses Done',
key: 'courses_completed',
align: 'center',
},
{
label: 'Assessments Done',
key: 'assessments_completed',
align: 'center',
},
{
label: 'Last Active',
key: 'last_active',
},
]
}
const openStudentModal = () => {
showStudentModal.value = true
}
const removeStudent = createResource({
url: 'frappe.client.delete',
makeParams(values) {
return {
doctype: 'Batch Student',
name: values.student,
}
},
})
const removeStudents = (selections) => {
selections.forEach(async (student) => {
console.log(student)
removeStudent.submit({ student })
await setTimeout(1000)
})
}
</script>
Loading

0 comments on commit 1a6a119

Please sign in to comment.