chore: fixed linters

This commit is contained in:
Jannat Patel
2024-08-12 10:04:42 +05:30
parent 61f01cc51b
commit 7f7986d77a
4 changed files with 53 additions and 49 deletions

View File

@@ -91,8 +91,10 @@
<div> <div>
{{ option.label }} {{ option.label }}
</div> </div>
<div class="text-xs text-gray-700" v-html="option.description"> <div
</div> class="text-xs text-gray-700"
v-html="option.description"
></div>
</div> </div>
</slot> </slot>
</li> </li>

View File

@@ -2,7 +2,10 @@
<Dialog v-model="show" :options="dialogOptions"> <Dialog v-model="show" :options="dialogOptions">
<template #body-content> <template #body-content>
<div class="space-y-4"> <div class="space-y-4">
<div v-if="!editMode" class="flex items-center text-xs text-gray-700 space-x-5"> <div
v-if="!editMode"
class="flex items-center text-xs text-gray-700 space-x-5"
>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<input <input
type="radio" type="radio"
@@ -95,12 +98,7 @@
</Dialog> </Dialog>
</template> </template>
<script setup> <script setup>
import { import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
Dialog,
FormControl,
TextEditor,
createResource,
} from 'frappe-ui'
import { computed, watch, reactive, ref } from 'vue' import { computed, watch, reactive, ref } from 'vue'
import Link from '@/components/Controls/Link.vue' import Link from '@/components/Controls/Link.vue'
import { showToast } from '@/utils' import { showToast } from '@/utils'
@@ -163,31 +161,26 @@ const questionData = createResource({
question[`is_correct_${counter}`] = data[`is_correct_${counter}`] question[`is_correct_${counter}`] = data[`is_correct_${counter}`]
? true ? true
: false : false
counter++; counter++
} }
question.marks = props.questionDetail.marks question.marks = props.questionDetail.marks
}, },
}); })
watch(show, () => { watch(show, () => {
if (show.value) { if (show.value) {
editMode.value = false editMode.value = false
if (props.questionDetail.question) if (props.questionDetail.question) questionData.fetch()
questionData.fetch()
else { else {
question.question = "", ;(question.question = ''), (question.marks = 0)
question.marks = 0 question.type = 'Choices'
question.type = "Choices" existingQuestion.question = ''
existingQuestion.question = ""
existingQuestion.marks = 0 existingQuestion.marks = 0
questionType.value = null questionType.value = null
populateFields() populateFields()
} }
if (props.questionDetail.marks) if (props.questionDetail.marks) question.marks = props.questionDetail.marks
question.marks = props.questionDetail.marks
} }
}) })
@@ -284,7 +277,7 @@ const questionUpdate = createResource({
...question, ...question,
}, },
} }
} },
}) })
const marksUpdate = createResource({ const marksUpdate = createResource({
@@ -298,7 +291,7 @@ const marksUpdate = createResource({
marks: question.marks, marks: question.marks,
}, },
} }
} },
}) })
const updateQuestion = (close) => { const updateQuestion = (close) => {
@@ -306,19 +299,26 @@ const updateQuestion = (close) => {
{}, {},
{ {
onSuccess() { onSuccess() {
marksUpdate.submit({}, { marksUpdate.submit(
onSuccess() { {},
show.value = false {
showToast(__('Success'), __('Question updated successfully'), 'check') onSuccess() {
quiz.value.reload() show.value = false
close() showToast(
}, __('Success'),
onError(err) { __('Question updated successfully'),
showToast(__('Error'), __(err.message?.[0] || err), 'x') 'check'
close() )
}, quiz.value.reload()
}) close()
} },
onError(err) {
showToast(__('Error'), __(err.message?.[0] || err), 'x')
close()
},
}
)
},
} }
) )
} }

View File

@@ -54,7 +54,6 @@
type="checkbox" type="checkbox"
:label="__('Show Submission History')" :label="__('Show Submission History')"
/> />
</div> </div>
</div> </div>
@@ -68,15 +67,14 @@
type="checkbox" type="checkbox"
:label="__('Shuffle Questions')" :label="__('Shuffle Questions')"
/> />
<FormControl v-if="quiz.shuffle_questions" <FormControl
v-if="quiz.shuffle_questions"
v-model="quiz.limit_questions_to" v-model="quiz.limit_questions_to"
:label="__('Limit Questions To')" :label="__('Limit Questions To')"
/> />
</div> </div>
</div> </div>
<!-- Questions --> <!-- Questions -->
<div> <div>
<div class="flex items-center justify-between mb-4"> <div class="flex items-center justify-between mb-4">
@@ -113,9 +111,9 @@
<ListRowItem :item="item"> <ListRowItem :item="item">
<div <div
v-if="column.key == 'question_detail'" v-if="column.key == 'question_detail'"
class="text-xs truncate h-4" v-html="item" class="text-xs truncate h-4"
> v-html="item"
</div> ></div>
<div v-else class="text-xs"> <div v-else class="text-xs">
{{ item }} {{ item }}
</div> </div>
@@ -144,7 +142,9 @@
:questionDetail="currentQuestion" :questionDetail="currentQuestion"
v-model:quiz="quizDetails" v-model:quiz="quizDetails"
:title=" :title="
currentQuestion.question ? __('Edit the question') : __('Add a new question') currentQuestion.question
? __('Edit the question')
: __('Add a new question')
" "
/> />
</template> </template>
@@ -181,7 +181,7 @@ const showQuestionModal = ref(false)
const currentQuestion = reactive({ const currentQuestion = reactive({
question: '', question: '',
marks: 0, marks: 0,
name: '' name: '',
}) })
const user = inject('$user') const user = inject('$user')
const router = useRouter() const router = useRouter()
@@ -385,7 +385,6 @@ const deleteQuiz = createResource({
}, },
}) })
const deleteQuizzes = (selections, unselectAll) => { const deleteQuizzes = (selections, unselectAll) => {
selections.forEach(async (quiz) => { selections.forEach(async (quiz) => {
deleteQuiz.submit({ quiz }) deleteQuiz.submit({ quiz })

View File

@@ -12,6 +12,7 @@ class LMSQuestion(Document):
validate_correct_answers(self) validate_correct_answers(self)
update_question_title(self) update_question_title(self)
def validate_correct_answers(question): def validate_correct_answers(question):
if question.type == "Choices": if question.type == "Choices":
validate_duplicate_options(question) validate_duplicate_options(question)
@@ -61,15 +62,17 @@ def validate_possible_answer(question):
) )
) )
def update_question_title(question): def update_question_title(question):
if not question.is_new(): if not question.is_new():
question_rows = frappe.get_all("LMS Quiz Question", { question_rows = frappe.get_all(
"question": question.name "LMS Quiz Question", {"question": question.name}, pluck="name"
}, pluck="name") )
for row in question_rows: for row in question_rows:
frappe.db.set_value("LMS Quiz Question", row, "question_detail", question.question) 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 = []
correct_option_fields = [ correct_option_fields = [