fix: fetch question details
This commit is contained in:
@@ -49,10 +49,11 @@
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Dialog, FormControl, TextEditor } from 'frappe-ui'
|
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
|
||||||
import { computed, onMounted, reactive } from 'vue'
|
import { computed, onMounted, reactive, inject } from 'vue'
|
||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
|
const user = inject('$user')
|
||||||
const question = reactive({
|
const question = reactive({
|
||||||
question: '',
|
question: '',
|
||||||
type: 'Choices',
|
type: 'Choices',
|
||||||
@@ -60,7 +61,19 @@ const question = reactive({
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
populateFields()
|
populateFields()
|
||||||
populateQuestionDetail()
|
console.log(props.questionName)
|
||||||
|
if (
|
||||||
|
props.questionName == 'new' &&
|
||||||
|
!user.data?.is_moderator &&
|
||||||
|
!user.data?.is_instructor
|
||||||
|
) {
|
||||||
|
router.push({ name: 'Courses' })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.courseName !== 'new') {
|
||||||
|
questionDoc.reload()
|
||||||
|
}
|
||||||
|
window.addEventListener('keydown', keyboardShortcut)
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -68,9 +81,29 @@ const props = defineProps({
|
|||||||
type: String,
|
type: String,
|
||||||
default: __('Add a Question'),
|
default: __('Add a Question'),
|
||||||
},
|
},
|
||||||
questionDetail: {
|
questionName: {
|
||||||
type: Object,
|
type: String,
|
||||||
default: {},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const questionDoc = createResource({
|
||||||
|
url: 'frappe.client.get',
|
||||||
|
makeParams: (values) => {
|
||||||
|
return {
|
||||||
|
doctype: 'LMS Question',
|
||||||
|
name: props.questionName,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess(data) {
|
||||||
|
let counter = 1
|
||||||
|
Object.keys(data).forEach((key) => {
|
||||||
|
if (Object.hasOwn(question, key)) question[key] = data[key]
|
||||||
|
})
|
||||||
|
while (counter <= 4) {
|
||||||
|
question[`is_correct_${counter}`] = question[`is_correct_${counter}`]
|
||||||
|
? true
|
||||||
|
: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -85,13 +118,14 @@ const populateFields = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const populateQuestionDetail = () => {
|
const keyboardShortcut = (e) => {
|
||||||
if (Object.keys(props.questionDetail).length) {
|
if (
|
||||||
Object.keys(props.questionDetail).forEach((key) => {
|
e.key === 's' &&
|
||||||
if (Object.hasOwn(question, key)) {
|
(e.ctrlKey || e.metaKey) &&
|
||||||
question[key] = props.questionDetail[key]
|
!e.target.classList.contains('ProseMirror')
|
||||||
}
|
) {
|
||||||
})
|
submitQuestion()
|
||||||
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@
|
|||||||
row-key="name"
|
row-key="name"
|
||||||
:options="{
|
:options="{
|
||||||
showTooltip: false,
|
showTooltip: false,
|
||||||
onRowClick: (row) => emit('openQuestionModal', row.name),
|
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<ListHeader
|
<ListHeader
|
||||||
@@ -88,9 +87,16 @@
|
|||||||
:row="row"
|
:row="row"
|
||||||
v-slot="{ idx, column, item }"
|
v-slot="{ idx, column, item }"
|
||||||
v-for="row in quiz.questions"
|
v-for="row in quiz.questions"
|
||||||
|
@click="openQuestionModal(row.question)"
|
||||||
>
|
>
|
||||||
<ListRowItem :item="item">
|
<ListRowItem :item="item">
|
||||||
<div class="text-xs">
|
<div
|
||||||
|
v-if="column.key == 'question_detail'"
|
||||||
|
class="text-xs truncate"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</div>
|
||||||
|
<div v-else class="text-xs">
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</div>
|
</div>
|
||||||
</ListRowItem>
|
</ListRowItem>
|
||||||
@@ -99,7 +105,7 @@
|
|||||||
</ListView>
|
</ListView>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Question v-model="showQuestionModal" :question="currentQuestion" />
|
<Question v-model="showQuestionModal" :questionName="currentQuestion" />
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
@@ -144,7 +150,7 @@ const quizDetails = createDocumentResource({
|
|||||||
doctype: 'LMS Quiz',
|
doctype: 'LMS Quiz',
|
||||||
name: props.quizID,
|
name: props.quizID,
|
||||||
auto: true,
|
auto: true,
|
||||||
cache: ['quiz', props.quiz],
|
cache: ['quiz', props.quizID],
|
||||||
onSuccess(data) {
|
onSuccess(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]
|
||||||
@@ -162,29 +168,29 @@ const quizDetails = createDocumentResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(quizDetails)
|
|
||||||
|
|
||||||
const questionColumns = computed(() => {
|
const questionColumns = computed(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: __('ID'),
|
label: __('ID'),
|
||||||
key: 'question',
|
key: 'question',
|
||||||
width: 1,
|
width: '25%',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __('Question'),
|
label: __('Question'),
|
||||||
key: __('question_detail'),
|
key: __('question_detail'),
|
||||||
width: 3,
|
width: '60%',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __('Marks'),
|
label: __('Marks'),
|
||||||
key: 'marks',
|
key: 'marks',
|
||||||
width: 0.5,
|
width: '10%',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
const openQuestionModal = (question = {}) => {
|
const openQuestionModal = (question = null) => {
|
||||||
|
console.log('called')
|
||||||
|
console.log(question)
|
||||||
currentQuestion.value = question
|
currentQuestion.value = question
|
||||||
showQuestionModal.value = true
|
showQuestionModal.value = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class LMSCertificateRequest(Document):
|
|||||||
self.validate_if_existing_requests()
|
self.validate_if_existing_requests()
|
||||||
self.validate_evaluation_end_date()
|
self.validate_evaluation_end_date()
|
||||||
|
|
||||||
|
def after_insert(self):
|
||||||
|
self.send_notification()
|
||||||
|
|
||||||
def set_evaluator(self):
|
def set_evaluator(self):
|
||||||
if not self.evaluator:
|
if not self.evaluator:
|
||||||
self.evaluator = get_evaluator(self.course, self.batch_name)
|
self.evaluator = get_evaluator(self.course, self.batch_name)
|
||||||
@@ -107,6 +110,35 @@ class LMSCertificateRequest(Document):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def send_notification(self):
|
||||||
|
outgoing_email_account = frappe.get_cached_value(
|
||||||
|
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
|
||||||
|
)
|
||||||
|
if outgoing_email_account or frappe.conf.get("mail_login"):
|
||||||
|
subject = _("Your evaluation slot has been booked")
|
||||||
|
template = "certificate_request_notification"
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"course": frappe.db.get_value("LMS Course", self.course, "title"),
|
||||||
|
"timezone": frappe.db.get_value("LMS Batch", self.batch_name, "timezone")
|
||||||
|
if self.batch_name
|
||||||
|
else "",
|
||||||
|
"date": format_date(self.date, "medium"),
|
||||||
|
"member_name": self.member_name,
|
||||||
|
"start_time": format_time(self.start_time, "short"),
|
||||||
|
"evaluator": frappe.db.get_value("User", self.evaluator, "full_name"),
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.sendmail(
|
||||||
|
recipients=[self.member],
|
||||||
|
cc=[self.evaluator],
|
||||||
|
subject=subject,
|
||||||
|
template=template,
|
||||||
|
args=args,
|
||||||
|
header=[subject, "green"],
|
||||||
|
retry=3,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def schedule_evals():
|
def schedule_evals():
|
||||||
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
|
||||||
|
|||||||
@@ -195,7 +195,8 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-05-24 16:12:26.331351",
|
"make_attachments_public": 1,
|
||||||
|
"modified": "2024-08-01 12:53:22.540990",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Question",
|
"name": "LMS Question",
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Notification",
|
"doctype": "Notification",
|
||||||
"document_type": "LMS Certificate Request",
|
"document_type": "LMS Certificate Request",
|
||||||
"enabled": 1,
|
"enabled": 0,
|
||||||
"event": "New",
|
"event": "New",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }}\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }} </p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
||||||
"message_type": "HTML",
|
"message_type": "HTML",
|
||||||
"modified": "2024-07-10 15:51:03.429317",
|
"modified": "2024-08-01 12:17:40.647724",
|
||||||
"modified_by": "sayali@erpnext.com",
|
"modified_by": "jannat@frappe.io",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Certificate Request Creation",
|
"name": "Certificate Request Creation",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<p> {{ _("Hey {0}").format(member_name) }} </p>
|
||||||
|
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, date, start_time, timezone) }}</p>
|
||||||
|
<p> {{ _("Your evaluator is {0}").format(evaluator) }} </p>
|
||||||
|
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>
|
||||||
Reference in New Issue
Block a user