Skip to content

Commit 8048cb4

Browse files
committed
feat: filter assignments by course in lesson
1 parent 984a63c commit 8048cb4

5 files changed

Lines changed: 56 additions & 14 deletions

File tree

frontend/src/components/AssessmentPlugin.vue

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,51 @@
2626
v-model="quiz"
2727
doctype="LMS Quiz"
2828
:label="__('Select a quiz')"
29+
placeholder=" "
2930
:onCreate="(value, close) => redirectToForm()"
3031
/>
31-
<Link
32-
v-else
33-
v-model="assignment"
34-
doctype="LMS Assignment"
35-
:label="__('Select an assignment')"
36-
:onCreate="(value, close) => redirectToForm()"
37-
/>
32+
<div v-else class="space-y-4">
33+
<Link
34+
v-if="filterAssignmentsByCourse"
35+
v-model="assignment"
36+
doctype="LMS Assignment"
37+
:filters="{
38+
course: route.params.courseName,
39+
}"
40+
placeholder=" "
41+
:label="__('Select an Assignment')"
42+
:onCreate="(value, close) => redirectToForm()"
43+
/>
44+
<Link
45+
v-else
46+
v-model="assignment"
47+
doctype="LMS Assignment"
48+
placeholder=" "
49+
:label="__('Select an Assignment')"
50+
:onCreate="(value, close) => redirectToForm()"
51+
/>
52+
<FormControl
53+
type="checkbox"
54+
:label="__('Filter assignments by course')"
55+
v-model="filterAssignmentsByCourse"
56+
/>
57+
</div>
3858
</div>
3959
</div>
4060
</template>
4161
</Dialog>
4262
</template>
4363
<script setup>
44-
import { Dialog } from 'frappe-ui'
45-
import { onMounted, ref, nextTick } from 'vue'
46-
import Link from '@/components/Controls/Link.vue'
64+
import { Dialog, FormControl } from 'frappe-ui'
65+
import { nextTick, onMounted, ref } from 'vue'
66+
import { useRoute } from 'vue-router'
67+
import { Link } from 'frappe-ui/frappe'
4768
4869
const show = ref(false)
4970
const quiz = ref(null)
5071
const assignment = ref(null)
72+
const filterAssignmentsByCourse = ref(false)
73+
const route = useRoute()
5174
5275
const props = defineProps({
5376
type: {

frontend/src/components/Modals/AssignmentForm.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
:label="__('Submission Type')"
2828
:required="true"
2929
/>
30+
<Link
31+
v-model="assignment.course"
32+
:label="__('Course')"
33+
doctype="LMS Course"
34+
placeholder=" "
35+
/>
3036
<div>
3137
<div class="text-xs text-ink-gray-5 mb-2">
3238
{{ __('Question') }}
@@ -67,6 +73,7 @@
6773
import { Button, Dialog, FormControl, TextEditor, toast } from 'frappe-ui'
6874
import { computed, reactive, watch } from 'vue'
6975
import { escapeHTML, sanitizeHTML } from '@/utils'
76+
import { Link } from 'frappe-ui/frappe'
7077
7178
const show = defineModel()
7279
const assignments = defineModel<Assignments>('assignments')
@@ -75,6 +82,7 @@ interface Assignment {
7582
title: string
7683
type: string
7784
question: string
85+
course?: string
7886
}
7987
8088
interface Assignments {
@@ -89,6 +97,7 @@ const assignment = reactive({
8997
title: '',
9098
type: '',
9199
question: '',
100+
course: '',
92101
})
93102
94103
const props = defineProps({
@@ -107,6 +116,7 @@ watch(
107116
assignment.title = row.title
108117
assignment.type = row.type
109118
assignment.question = row.question
119+
assignment.course = row.course || ''
110120
}
111121
})
112122
}

frontend/src/pages/Assignments.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const assignmentFilter = computed(() => {
148148
149149
const assignments = createListResource({
150150
doctype: 'LMS Assignment',
151-
fields: ['name', 'title', 'type', 'creation', 'question'],
151+
fields: ['name', 'title', 'type', 'creation', 'question', 'course'],
152152
orderBy: 'modified desc',
153153
cache: ['assignments'],
154154
transform(data) {

frontend/src/utils/assignment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import AssessmentPlugin from '@/components/AssessmentPlugin.vue'
44
import translationPlugin from '../translation'
55
import { usersStore } from '@/stores/user'
66
import { call } from 'frappe-ui'
7+
import router from '@/router'
78

89
export class Assignment {
910
constructor({ data, api, readOnly }) {
@@ -84,6 +85,7 @@ export class Assignment {
8485
},
8586
})
8687
app.use(translationPlugin)
88+
app.use(router)
8789
app.mount(this.wrapper)
8890
}
8991

lms/lms/doctype/lms_assignment/lms_assignment.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
"engine": "InnoDB",
1010
"field_order": [
1111
"title",
12-
"question",
13-
"column_break_hmwv",
1412
"type",
1513
"grade_assignment",
14+
"course",
15+
"column_break_hmwv",
16+
"question",
1617
"section_break_sjti",
1718
"show_answer",
1819
"answer"
@@ -68,12 +69,18 @@
6869
{
6970
"fieldname": "section_break_sjti",
7071
"fieldtype": "Section Break"
72+
},
73+
{
74+
"fieldname": "course",
75+
"fieldtype": "Link",
76+
"label": "Course",
77+
"options": "LMS Course"
7178
}
7279
],
7380
"grid_page_length": 50,
7481
"index_web_pages_for_search": 1,
7582
"links": [],
76-
"modified": "2025-12-17 14:47:05.489937",
83+
"modified": "2025-12-19 16:30:58.531722",
7784
"modified_by": "sayali@frappe.io",
7885
"module": "LMS",
7986
"name": "LMS Assignment",

0 commit comments

Comments
 (0)