fix: update question title in quiz
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<div class="text-sm font-semibold mb-4">
|
<div class="text-sm font-semibold mb-4">
|
||||||
{{ __('Details') }}
|
{{ __('Details') }}
|
||||||
</div>
|
</div>
|
||||||
|
{{ quiz }}
|
||||||
<FormControl
|
<FormControl
|
||||||
v-model="quiz.title"
|
v-model="quiz.title"
|
||||||
:label="
|
:label="
|
||||||
@@ -106,9 +107,8 @@
|
|||||||
<ListRowItem :item="item">
|
<ListRowItem :item="item">
|
||||||
<div
|
<div
|
||||||
v-if="column.key == 'question_detail'"
|
v-if="column.key == 'question_detail'"
|
||||||
class="text-xs truncate"
|
class="text-xs truncate" v-html="item"
|
||||||
>
|
>
|
||||||
{{ item }}
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="text-xs">
|
<div v-else class="text-xs">
|
||||||
{{ item }}
|
{{ item }}
|
||||||
@@ -133,7 +133,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
createDocumentResource,
|
|
||||||
createResource,
|
createResource,
|
||||||
FormControl,
|
FormControl,
|
||||||
ListView,
|
ListView,
|
||||||
@@ -172,6 +171,7 @@ onMounted(() => {
|
|||||||
router.push({ name: 'Courses' })
|
router.push({ name: 'Courses' })
|
||||||
}
|
}
|
||||||
if (props.quizID !== 'new') {
|
if (props.quizID !== 'new') {
|
||||||
|
console.log("mounted")
|
||||||
quizDetails.reload()
|
quizDetails.reload()
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', keyboardShortcut)
|
window.addEventListener('keydown', keyboardShortcut)
|
||||||
@@ -220,6 +220,7 @@ const quizDetails = createResource({
|
|||||||
auto: false,
|
auto: false,
|
||||||
|
|
||||||
onSuccess(data) {
|
onSuccess(data) {
|
||||||
|
console.log(data)
|
||||||
Object.keys(data).forEach((key) => {
|
Object.keys(data).forEach((key) => {
|
||||||
if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
|
if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
|
||||||
})
|
})
|
||||||
@@ -233,6 +234,7 @@ const quizDetails = createResource({
|
|||||||
let key = checkboxes[idx]
|
let key = checkboxes[idx]
|
||||||
quiz[key] = quiz[key] ? true : false
|
quiz[key] = quiz[key] ? true : false
|
||||||
}
|
}
|
||||||
|
console.log(quiz)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -337,6 +339,7 @@ watch(
|
|||||||
(newVal) => {
|
(newVal) => {
|
||||||
console.log(props.quizID)
|
console.log(props.quizID)
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
|
console.log("in watch")
|
||||||
quizDetails.reload()
|
quizDetails.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from lms.lms.utils import has_course_instructor_role, has_course_moderator_role
|
|||||||
class LMSQuestion(Document):
|
class LMSQuestion(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
validate_correct_answers(self)
|
validate_correct_answers(self)
|
||||||
|
update_question_title(self)
|
||||||
|
|
||||||
def validate_correct_answers(question):
|
def validate_correct_answers(question):
|
||||||
if question.type == "Choices":
|
if question.type == "Choices":
|
||||||
@@ -60,6 +61,14 @@ def validate_possible_answer(question):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_question_title(question):
|
||||||
|
if not question.is_new():
|
||||||
|
question_rows = frappe.get_all("LMS Quiz Question", {
|
||||||
|
"question": question.name
|
||||||
|
}, pluck="name")
|
||||||
|
|
||||||
|
for row in question_rows:
|
||||||
|
frappe.db.set_value("LMS Quiz Question", row, "question_detail", question.question)
|
||||||
|
|
||||||
def get_correct_options(question):
|
def get_correct_options(question):
|
||||||
correct_options = []
|
correct_options = []
|
||||||
|
|||||||
Reference in New Issue
Block a user