fix(quiz): questions list empty on back navigation from test quiz
This commit is contained in:
@@ -226,7 +226,6 @@ import {
|
|||||||
onMounted,
|
onMounted,
|
||||||
inject,
|
inject,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
watch,
|
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import { sessionStore } from '../stores/session'
|
import { sessionStore } from '../stores/session'
|
||||||
import { ClipboardList, ListChecks, Plus, Trash2 } from 'lucide-vue-next'
|
import { ClipboardList, ListChecks, Plus, Trash2 } from 'lucide-vue-next'
|
||||||
@@ -252,7 +251,9 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const questions = ref([])
|
const questions = computed(() => {
|
||||||
|
return quizDetails.doc?.questions || []
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
if (!user.data?.is_moderator && !user.data?.is_instructor) {
|
||||||
@@ -273,24 +274,10 @@ onBeforeUnmount(() => {
|
|||||||
window.removeEventListener('keydown', keyboardShortcut)
|
window.removeEventListener('keydown', keyboardShortcut)
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.quizID !== 'new',
|
|
||||||
(newVal) => {
|
|
||||||
if (newVal) {
|
|
||||||
quizDetails.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const quizDetails = createDocumentResource({
|
const quizDetails = createDocumentResource({
|
||||||
doctype: 'LMS Quiz',
|
doctype: 'LMS Quiz',
|
||||||
name: props.quizID,
|
name: props.quizID,
|
||||||
auto: false,
|
auto: false,
|
||||||
onSuccess(doc) {
|
|
||||||
if (doc.questions && doc.questions.length > 0) {
|
|
||||||
questions.value = doc.questions.map((question) => question)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const validateTitle = () => {
|
const validateTitle = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user