fix: patched quiz submission data
This commit is contained in:
@@ -11,11 +11,11 @@
|
|||||||
@click="redirectToCourseForm()"
|
@click="redirectToCourseForm()"
|
||||||
class="flex items-center space-x-2"
|
class="flex items-center space-x-2"
|
||||||
:class="{
|
:class="{
|
||||||
'cursor-pointer': !onboardingDetails.data.course_created.length,
|
'cursor-pointer': !onboardingDetails.data.course_created?.length,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="onboardingDetails.data.course_created.length"
|
v-if="onboardingDetails.data.course_created?.length"
|
||||||
class="py-1 px-1 bg-white rounded-full"
|
class="py-1 px-1 bg-white rounded-full"
|
||||||
>
|
>
|
||||||
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
||||||
@@ -32,13 +32,13 @@
|
|||||||
class="flex items-center space-x-2"
|
class="flex items-center space-x-2"
|
||||||
:class="{
|
:class="{
|
||||||
'cursor-pointer':
|
'cursor-pointer':
|
||||||
onboardingDetails.data.course_created.length &&
|
onboardingDetails.data.course_created?.length &&
|
||||||
!onboardingDetails.data.chapter_created.length,
|
!onboardingDetails.data.chapter_created?.length,
|
||||||
'text-gray-400': !onboardingDetails.data.course_created.length,
|
'text-gray-400': !onboardingDetails.data.course_created?.length,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="onboardingDetails.data.chapter_created.length"
|
v-if="onboardingDetails.data.chapter_created?.length"
|
||||||
class="py-1 px-1 bg-white rounded-full"
|
class="py-1 px-1 bg-white rounded-full"
|
||||||
>
|
>
|
||||||
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
||||||
@@ -55,15 +55,15 @@
|
|||||||
class="flex items-center space-x-2"
|
class="flex items-center space-x-2"
|
||||||
:class="{
|
:class="{
|
||||||
'cursor-pointer':
|
'cursor-pointer':
|
||||||
onboardingDetails.data.course_created.length &&
|
onboardingDetails.data.course_created?.length &&
|
||||||
onboardingDetails.data.chapter_created.length,
|
onboardingDetails.data.chapter_created?.length,
|
||||||
'text-gray-400':
|
'text-gray-400':
|
||||||
!onboardingDetails.data.course_created.length ||
|
!onboardingDetails.data.course_created?.length ||
|
||||||
!onboardingDetails.data.chapter_created.length,
|
!onboardingDetails.data.chapter_created?.length,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="onboardingDetails.data.lesson_created.length"
|
v-if="onboardingDetails.data.lesson_created?.length"
|
||||||
class="py-1 px-1 bg-white rounded-full"
|
class="py-1 px-1 bg-white rounded-full"
|
||||||
>
|
>
|
||||||
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
<Check class="h-4 w-4 stroke-2 text-green-600" />
|
||||||
|
|||||||
@@ -118,16 +118,28 @@ import {
|
|||||||
Dialog,
|
Dialog,
|
||||||
FormControl,
|
FormControl,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { computed, inject, ref } from 'vue'
|
import { computed, inject, onMounted, ref } from 'vue'
|
||||||
import { BookOpen, Edit, Plus } from 'lucide-vue-next'
|
import { BookOpen, Edit, Plus } from 'lucide-vue-next'
|
||||||
import CourseCard from '@/components/CourseCard.vue'
|
import CourseCard from '@/components/CourseCard.vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { showToast, singularize } from '@/utils'
|
import { showToast, singularize } from '@/utils'
|
||||||
|
import { useSettings } from '@/stores/settings'
|
||||||
|
|
||||||
const user = inject('$user')
|
const user = inject('$user')
|
||||||
const showDialog = ref(false)
|
const showDialog = ref(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
|
const settings = useSettings()
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (
|
||||||
|
!settings.learningPaths.data &&
|
||||||
|
!user.data?.is_moderator &&
|
||||||
|
!user.data?.is_instructor
|
||||||
|
) {
|
||||||
|
router.push({ name: 'Courses' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const programs = createResource({
|
const programs = createResource({
|
||||||
url: 'lms.lms.utils.get_programs',
|
url: 'lms.lms.utils.get_programs',
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div v-if="submisisonDetails.doc" class="w-1/2 mx-auto py-5 space-y-4">
|
<div v-if="submisisonDetails.doc" class="w-1/2 mx-auto py-5 space-y-7">
|
||||||
|
<div class="text-xl font-semibold">
|
||||||
|
{{ submisisonDetails.doc.member_name }}
|
||||||
|
</div>
|
||||||
|
<div class="space-y-4 border p-5 rounded-md">
|
||||||
<div class="grid grid-cols-2 gap-5">
|
<div class="grid grid-cols-2 gap-5">
|
||||||
<FormControl
|
<FormControl
|
||||||
v-model="submisisonDetails.doc.quiz_title"
|
v-model="submisisonDetails.doc.quiz_title"
|
||||||
@@ -41,12 +45,15 @@
|
|||||||
:disabled="true"
|
:disabled="true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-for="row in submisisonDetails.doc.result"
|
v-for="row in submisisonDetails.doc.result"
|
||||||
class="border p-5 rounded-md space-y-4"
|
class="border p-5 rounded-md space-y-4"
|
||||||
>
|
>
|
||||||
<div class="font-semibold">{{ row.idx }}. {{ row.question }}</div>
|
<div class="flex space-x-1 font-semibold">
|
||||||
|
<span class="leading-5" v-html="row.question"> </span>
|
||||||
|
</div>
|
||||||
<div v-html="row.answer" class="leading-5"></div>
|
<div v-html="row.answer" class="leading-5"></div>
|
||||||
<div class="grid grid-cols-2 gap-5">
|
<div class="grid grid-cols-2 gap-5">
|
||||||
<FormControl v-model="row.marks" :label="__('Marks')" />
|
<FormControl v-model="row.marks" :label="__('Marks')" />
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ def quiz_summary(quiz, results):
|
|||||||
result["marks"] = marks
|
result["marks"] = marks
|
||||||
score += marks
|
score += marks
|
||||||
|
|
||||||
del result["question_name"]
|
|
||||||
else:
|
else:
|
||||||
result["is_correct"] = 0
|
result["is_correct"] = 0
|
||||||
is_open_ended = True
|
is_open_ended = True
|
||||||
@@ -146,6 +145,7 @@ def quiz_summary(quiz, results):
|
|||||||
|
|
||||||
submission = frappe.new_doc("LMS Quiz Submission")
|
submission = frappe.new_doc("LMS Quiz Submission")
|
||||||
# Score and percentage are calculated by the controller function
|
# Score and percentage are calculated by the controller function
|
||||||
|
print(results)
|
||||||
submission.update(
|
submission.update(
|
||||||
{
|
{
|
||||||
"doctype": "LMS Quiz Submission",
|
"doctype": "LMS Quiz Submission",
|
||||||
|
|||||||
@@ -858,7 +858,8 @@ def get_telemetry_boot_info():
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def is_onboarding_complete():
|
def is_onboarding_complete():
|
||||||
if not has_course_moderator_role():
|
if not has_course_moderator_role():
|
||||||
return {"is_onboarded": False}
|
return {"is_onboarded": True}
|
||||||
|
|
||||||
course_created = frappe.db.a_row_exists("LMS Course")
|
course_created = frappe.db.a_row_exists("LMS Course")
|
||||||
chapter_created = frappe.db.a_row_exists("Course Chapter")
|
chapter_created = frappe.db.a_row_exists("Course Chapter")
|
||||||
lesson_created = frappe.db.a_row_exists("Course Lesson")
|
lesson_created = frappe.db.a_row_exists("Course Lesson")
|
||||||
|
|||||||
@@ -95,3 +95,4 @@ lms.patches.v2_0.add_course_statistics #21-10-2024
|
|||||||
lms.patches.v2_0.give_discussions_permissions
|
lms.patches.v2_0.give_discussions_permissions
|
||||||
lms.patches.v2_0.delete_web_forms
|
lms.patches.v2_0.delete_web_forms
|
||||||
lms.patches.v2_0.update_desk_access_for_lms_roles
|
lms.patches.v2_0.update_desk_access_for_lms_roles
|
||||||
|
lms.patches.v2_0.update_quiz_submission_data
|
||||||
47
lms/patches/v2_0/update_quiz_submission_data.py
Normal file
47
lms/patches/v2_0/update_quiz_submission_data.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
set_question_data()
|
||||||
|
set_submission_data()
|
||||||
|
|
||||||
|
|
||||||
|
def set_question_data():
|
||||||
|
questions = frappe.get_all("LMS Quiz Question", fields=["name", "question"])
|
||||||
|
|
||||||
|
for question in questions:
|
||||||
|
question_doc = frappe.db.get_value(
|
||||||
|
"LMS Question", question.question, ["question", "type"], as_dict=1
|
||||||
|
)
|
||||||
|
frappe.db.set_value(
|
||||||
|
"LMS Quiz Question",
|
||||||
|
question.name,
|
||||||
|
{"question_detail": question_doc.question, "type": question_doc.type},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def set_submission_data():
|
||||||
|
submissions = frappe.get_all("LMS Quiz Submission", fields=["name", "quiz"])
|
||||||
|
|
||||||
|
for submission in submissions:
|
||||||
|
quiz_title = frappe.db.get_value("LMS Quiz", submission.quiz, "title")
|
||||||
|
frappe.db.set_value("LMS Quiz Submission", submission.name, "quiz_title", quiz_title)
|
||||||
|
|
||||||
|
questions = frappe.get_all(
|
||||||
|
"LMS Quiz Result", filters={"parent": submission.name}, fields=["question_name"]
|
||||||
|
)
|
||||||
|
|
||||||
|
for question in questions:
|
||||||
|
if question.question_name:
|
||||||
|
marks_out_of = frappe.db.get_value(
|
||||||
|
"LMS Quiz Question",
|
||||||
|
{"parent": submission.quiz, "question": question.question_name},
|
||||||
|
["marks"],
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.db.set_value(
|
||||||
|
"LMS Quiz Result",
|
||||||
|
{"parent": submission.name, "question_name": question.question_name},
|
||||||
|
"marks_out_of",
|
||||||
|
marks_out_of,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user