fix: mark lesson progress when quiz and assignment are submitted

This commit is contained in:
Jannat Patel
2024-12-31 13:15:25 +05:30
parent 1293294593
commit 048cee654e
4 changed files with 85 additions and 19 deletions

View File

@@ -133,6 +133,7 @@
import {
Badge,
Button,
call,
createResource,
createDocumentResource,
FileUploader,
@@ -247,6 +248,7 @@ const addNewSubmission = () => {
},
})
} else {
markLessonProgress()
router.go()
}
},
@@ -261,6 +263,20 @@ const saveSubmission = (file) => {
submissionFile.value = 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
call('lms.lms.api.mark_lesson_progress', {
course: courseName,
chapter_number: chapterNumber,
lesson_number: lessonNumber,
})
}
}
const getType = () => {
const type = assignment.data?.type
if (type == 'Image') {

View File

@@ -271,6 +271,7 @@
import {
Badge,
Button,
call,
createResource,
ListView,
TextEditor,
@@ -280,6 +281,7 @@ import { ref, watch, reactive, inject, computed } from 'vue'
import { createToast } from '@/utils/'
import { CheckCircle, XCircle, MinusCircle } from 'lucide-vue-next'
import { timeAgo } from '@/utils'
import { useRouter } from 'vue-router'
import ProgressBar from '@/components/ProgressBar.vue'
const user = inject('$user')
@@ -291,6 +293,7 @@ let questions = reactive([])
const possibleAnswer = ref(null)
const timer = ref(0)
let timerInterval = null
const router = useRouter()
const props = defineProps({
quizName: {
@@ -560,6 +563,7 @@ const createSubmission = () => {
{},
{
onSuccess(data) {
markLessonProgress()
if (quiz.data && quiz.data.max_attempts) attempts.reload()
if (quiz.data.duration) clearInterval(timerInterval)
},
@@ -583,6 +587,16 @@ const getInstructions = (question) => {
else return __('Type your answer')
}
const markLessonProgress = () => {
if (router.currentRoute.value.name == 'Lesson') {
call('lms.lms.api.mark_lesson_progress', {
course: router.currentRoute.value.params.courseName,
chapter_number: router.currentRoute.value.params.chapterNumber,
lesson_number: router.currentRoute.value.params.lessonNumber,
})
}
}
const getSubmissionColumns = () => {
return [
{