From 071e8dc529a999991a71a253f284dd40c28f91c7 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Wed, 8 Apr 2026 12:15:23 +0530 Subject: [PATCH] fix: lesson progress after assignment submission --- frontend/src/components/Assignment.vue | 53 +++++++++++-------- .../lms_assignment_submission.json | 11 ++-- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/Assignment.vue b/frontend/src/components/Assignment.vue index 8740b9cd..7c740529 100644 --- a/frontend/src/components/Assignment.vue +++ b/frontend/src/components/Assignment.vue @@ -17,7 +17,7 @@
- {{ __('Assignment Question') }} + {{ __('Assignment') }}: {{ assignment.data.title }}
{ } } -const addNewSubmission = () => { +const prepareSubmissionDoc = () => { let doc = { doctype: 'LMS Assignment Submission', assignment: props.assignmentID, @@ -311,24 +311,31 @@ const addNewSubmission = () => { } else { doc.assignment_attachment = attachment.value } + return doc +} + +const addNewSubmission = () => { + let doc = prepareSubmissionDoc() + if (!doc.assignment_attachment && !doc.answer) { + toast.error( + __('Please provide an answer or upload a file before submitting.') + ) + return + } call('frappe.client.insert', { doc: doc, }) .then((data) => { toast.success(__('Assignment submitted successfully')) - if (router.currentRoute.value.name == 'AssignmentSubmission') { - router.push({ - name: 'AssignmentSubmission', - params: { - assignmentID: props.assignmentID, - submissionName: data.name, - }, - query: { fromLesson: router.currentRoute.value.query.fromLesson }, - }) - } else { - markLessonProgress() - router.go() - } + router.push({ + name: 'AssignmentSubmission', + params: { + assignmentID: props.assignmentID, + submissionName: data.name, + }, + query: { fromLesson: router.currentRoute.value.query.fromLesson }, + }) + markLessonProgress() isDirty.value = false submissionResource.name = data.name submissionResource.reload() @@ -372,15 +379,17 @@ const saveSubmission = (file) => { } const markLessonProgress = () => { - if (router.currentRoute.value.name == 'Lesson') { - let courseName = router.currentRoute.value.params.courseName - let chapterNumber = router.currentRoute.value.params.chapterNumber - let lessonNumber = router.currentRoute.value.params.lessonNumber + let pathname = window.location.pathname.split('/') + if (!pathname.includes('courses')) + pathname = window.parent.location.pathname.split('/') + if (pathname[2] != 'courses') return + let lessonIndex = pathname.pop().split('-') + if (lessonIndex.length == 2) { call('lms.lms.api.mark_lesson_progress', { - course: courseName, - chapter_number: chapterNumber, - lesson_number: lessonNumber, + course: pathname[3], + chapter_number: lessonIndex[0], + lesson_number: lessonIndex[1], }) } } diff --git a/lms/lms/doctype/lms_assignment_submission/lms_assignment_submission.json b/lms/lms/doctype/lms_assignment_submission/lms_assignment_submission.json index 485cef55..c1e6c1fa 100644 --- a/lms/lms/doctype/lms_assignment_submission/lms_assignment_submission.json +++ b/lms/lms/doctype/lms_assignment_submission/lms_assignment_submission.json @@ -20,11 +20,12 @@ "section_break_ydgh", "column_break_oqqy", "status", + "question", + "column_break_tbnv", "comments", "section_break_rqal", - "question", - "column_break_esgd", "course", + "column_break_esgd", "lesson" ], "fields": [ @@ -145,13 +146,17 @@ { "fieldname": "section_break_ydgh", "fieldtype": "Section Break" + }, + { + "fieldname": "column_break_tbnv", + "fieldtype": "Column Break" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], "make_attachments_public": 1, - "modified": "2026-02-05 11:38:03.792865", + "modified": "2026-04-06 18:24:11.837953", "modified_by": "sayali@frappe.io", "module": "LMS", "name": "LMS Assignment Submission",