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>
{{ option.label }}
</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>
</slot>
</li>

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ class LMSQuestion(Document):
validate_correct_answers(self)
update_question_title(self)
def validate_correct_answers(question):
if question.type == "Choices":
validate_duplicate_options(question)
@@ -61,15 +62,17 @@ 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")
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):
correct_options = []
correct_option_fields = [