fix: lesson progress issue

This commit is contained in:
Jannat Patel
2026-02-23 11:49:06 +05:30
parent 61d13aeb12
commit e8edf33be6

View File

@@ -12,7 +12,7 @@
</template> </template>
</Button> </Button>
</Tooltip> </Tooltip>
<Button v-if="canSeeStats()" @click="showVideoStats()"> <Button v-if="isAdmin" @click="showVideoStats()">
<template #icon> <template #icon>
<TrendingUp class="size-4 stroke-1.5" /> <TrendingUp class="size-4 stroke-1.5" />
</template> </template>
@@ -326,7 +326,7 @@
@updateNotes="updateNotes" @updateNotes="updateNotes"
/> />
<VideoStatistics <VideoStatistics
v-if="showStatsDialog" v-if="isAdmin"
v-model="showStatsDialog" v-model="showStatsDialog"
:lessonName="lesson.data?.name" :lessonName="lesson.data?.name"
:lessonTitle="lesson.data?.title" :lessonTitle="lesson.data?.title"
@@ -524,7 +524,14 @@ const renderEditor = (holder, content) => {
const markProgress = () => { const markProgress = () => {
if (user.data && lesson.data && !lesson.data.progress) { if (user.data && lesson.data && !lesson.data.progress) {
progress.submit() progress.submit(
{},
{
onError(err) {
console.error(err)
},
}
)
} }
} }
@@ -605,7 +612,6 @@ watch(
plyrSources.value = [] plyrSources.value = []
await nextTick() await nextTick()
resetLessonState(newChapterNumber, newLessonNumber) resetLessonState(newChapterNumber, newLessonNumber)
startTimer()
updateNotes() updateNotes()
checkIfDiscussionsAllowed() checkIfDiscussionsAllowed()
checkQuiz() checkQuiz()
@@ -674,6 +680,7 @@ watch(
() => lesson.data, () => lesson.data,
async (data) => { async (data) => {
setupLesson(data) setupLesson(data)
startTimer()
getPlyrSource() getPlyrSource()
updateNotes() updateNotes()
if (data.icon == 'icon-youtube') clearInterval(timerInterval) if (data.icon == 'icon-youtube') clearInterval(timerInterval)
@@ -769,17 +776,19 @@ const checkIfDiscussionsAllowed = () => {
} }
} }
const isAdmin = computed(() => {
let isInstructor = lesson.data?.instructors?.includes(user.data?.name)
return user.data?.is_moderator || isInstructor
})
const allowEdit = () => { const allowEdit = () => {
if (window.read_only_mode) return false if (window.read_only_mode) return false
if (user.data?.is_moderator) return true return isAdmin.value
if (lesson.data?.instructors?.includes(user.data?.name)) return true
return false
} }
const allowInstructorContent = () => { const allowInstructorContent = () => {
if (user.data?.is_moderator) return true if (window.read_only_mode) return false
if (lesson.data?.instructors?.includes(user.data?.name)) return true return isAdmin.value
return false
} }
const enrollment = createResource({ const enrollment = createResource({
@@ -819,11 +828,6 @@ const toggleInlineMenu = async () => {
} }
} }
const canSeeStats = () => {
if (user.data?.is_moderator || user.data?.is_instructor) return true
return false
}
const showVideoStats = () => { const showVideoStats = () => {
showStatsDialog.value = true showStatsDialog.value = true
} }