From 1293294593f908ed1fc271b4f9b7c908396b8aa4 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 31 Dec 2024 12:20:01 +0530 Subject: [PATCH] feat: assignment in lesson --- frontend/src/components/Assignment.vue | 333 ++++++++++++++++++++ frontend/src/components/AssignmentBlock.vue | 46 +++ frontend/src/pages/AssignmentForm.vue | 20 +- frontend/src/pages/AssignmentSubmission.vue | 326 ++----------------- frontend/src/pages/Batch.vue | 1 + frontend/src/utils/assignment.js | 7 +- 6 files changed, 421 insertions(+), 312 deletions(-) create mode 100644 frontend/src/components/Assignment.vue create mode 100644 frontend/src/components/AssignmentBlock.vue diff --git a/frontend/src/components/Assignment.vue b/frontend/src/components/Assignment.vue new file mode 100644 index 00000000..7d0d1efa --- /dev/null +++ b/frontend/src/components/Assignment.vue @@ -0,0 +1,333 @@ + + diff --git a/frontend/src/components/AssignmentBlock.vue b/frontend/src/components/AssignmentBlock.vue new file mode 100644 index 00000000..fcc8736b --- /dev/null +++ b/frontend/src/components/AssignmentBlock.vue @@ -0,0 +1,46 @@ + + diff --git a/frontend/src/pages/AssignmentForm.vue b/frontend/src/pages/AssignmentForm.vue index 39e761c2..8808fd04 100644 --- a/frontend/src/pages/AssignmentForm.vue +++ b/frontend/src/pages/AssignmentForm.vue @@ -64,7 +64,14 @@ import { FormControl, TextEditor, } from 'frappe-ui' -import { computed, inject, onMounted, onBeforeUnmount, reactive } from 'vue' +import { + computed, + inject, + onMounted, + onBeforeUnmount, + reactive, + watch, +} from 'vue' import { showToast } from '@/utils' import { useRouter } from 'vue-router' @@ -113,11 +120,6 @@ const assignment = createDocumentResource({ doctype: 'LMS Assignment', name: props.assignmentID, auto: false, - onSuccess(data) { - Object.keys(data).forEach((key) => { - model[key] = data[key] - }) - }, }) const newAssignment = createResource({ @@ -161,6 +163,12 @@ const saveAssignment = () => { } } +watch(assignment, () => { + Object.keys(assignment.doc).forEach((key) => { + model[key] = assignment.doc[key] + }) +}) + const breadcrumbs = computed(() => [ { label: __('Assignments'), diff --git a/frontend/src/pages/AssignmentSubmission.vue b/frontend/src/pages/AssignmentSubmission.vue index 357fdede..b646485c 100644 --- a/frontend/src/pages/AssignmentSubmission.vue +++ b/frontend/src/pages/AssignmentSubmission.vue @@ -3,154 +3,22 @@ class="flex justify-between sticky top-0 z-10 border-b bg-white px-3 py-2.5 sm:px-5" > -
- - {{ submissionResource.doc.status }} - - -
-
-
-
- {{ __('Question') }} -
-
-
- -
-
-
- {{ __('Submission') }} -
-
- {{ __("You've successfully submitted the assignment.") }} - {{ - __( - "Once the moderator grades your submission, you'll find the details here." - ) - }} - {{ __('Feel free to make edits to your submission if needed.') }} -
-
-
- {{ - __('Add your assignment as {0}').format(assignment.data.type) - }} -
- - - -
-
-
- -
-
- - {{ submissionFile.file_name }} - - - {{ getFileSize(submissionFile.file_size) }} - -
- -
-
-
-
-
- {{ __('Enter a URL') }} -
- -
-
-
- {{ __('Write your answer here') }} -
- -
-
- -
-
- {{ __('Grading') }} -
- - -
-
+
+
diff --git a/frontend/src/pages/Batch.vue b/frontend/src/pages/Batch.vue index 523caf38..a94d3771 100644 --- a/frontend/src/pages/Batch.vue +++ b/frontend/src/pages/Batch.vue @@ -195,6 +195,7 @@ import { SendIcon, MessageCircle, Globe, + ShieldCheck, } from 'lucide-vue-next' import { formatTime, updateDocumentTitle } from '@/utils' import BatchDashboard from '@/components/BatchDashboard.vue' diff --git a/frontend/src/utils/assignment.js b/frontend/src/utils/assignment.js index 731cf611..7d9e1c47 100644 --- a/frontend/src/utils/assignment.js +++ b/frontend/src/utils/assignment.js @@ -1,8 +1,10 @@ import { Pencil } from 'lucide-vue-next' import { createApp, h } from 'vue' import AssessmentPlugin from '@/components/AssessmentPlugin.vue' +import AssignmentBlock from '@/components/AssignmentBlock.vue' import translationPlugin from '../translation' -import { usersStore } from '../stores/user' +import { usersStore } from '@/stores/user' +import router from '../router' export class Assignment { constructor({ data, api, readOnly }) { @@ -42,9 +44,10 @@ export class Assignment { renderAssignment(assignment) { if (this.readOnly) { const app = createApp(AssignmentBlock, { - assignment: assignment, + assignmentID: assignment, }) app.use(translationPlugin) + app.use(router) const { userResource } = usersStore() app.provide('$user', userResource) app.mount(this.wrapper)