From 9ecf0fba6a0e3e720d96b76c72cf6a8d01a57789 Mon Sep 17 00:00:00 2001 From: Alejandra Orozco Date: Wed, 8 Nov 2023 16:32:47 -0600 Subject: [PATCH] =?UTF-8?q?Agregada=20funci=C3=B3n=20para=20descargar=20en?= =?UTF-8?q?=20PDF=20y=20correcci=C3=B3n=20de=20incisos=20Se=20implement?= =?UTF-8?q?=C3=B3=20una=20funci=C3=B3n=20que=20permite=20a=20los=20usuario?= =?UTF-8?q?s=20descargar=20el=20examen=20en=20formato=20PDF,=20facilitando?= =?UTF-8?q?=20la=20impresi=C3=B3n=20y=20el=20uso=20posterior.=20Tambi?= =?UTF-8?q?=C3=A9n=20se=20corrigi=C3=B3=20la=20generaci=C3=B3n=20de=20inci?= =?UTF-8?q?sos=20para=20mostrar=20letras=20min=C3=BAsculas=20(a),=20(b),?= =?UTF-8?q?=20(c)=20para=20opciones=20y=20n=C3=BAmeros=20(1),=20(2),=20(3)?= =?UTF-8?q?=20si=20se=20agotan=20las=20letras?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AsisstantView.vue | 148 ++++++++++++++++++--------- src/views/Auth/LoginPage.vue | 3 +- src/views/DataBaseView.vue | 189 ++++++++++++++++++++++++----------- 3 files changed, 234 insertions(+), 106 deletions(-) diff --git a/src/views/AsisstantView.vue b/src/views/AsisstantView.vue index 649ebf1..bfbac9d 100644 --- a/src/views/AsisstantView.vue +++ b/src/views/AsisstantView.vue @@ -6,10 +6,8 @@ import { DocumentTextIcon } from '@heroicons/vue/24/outline' import { onBeforeMount, onMounted, ref } from 'vue' +import jsPDF from 'jspdf' -const printPDF = () => { - window.print() -} const step = ref(1) const showQuestionsBlock = ref(false) const isMounted = ref(false) @@ -33,7 +31,7 @@ const examen = ref({ ] }) -// Método para agregar una nueva pregunta +//Agregar preguntas const addQuestion = () => { examen.value.questions.push({ type: examen.value.selectedQuestionType, @@ -51,6 +49,77 @@ const addQuestion = () => { showQuestionsBlock.value = true } +const getInciso = (index: number) => { + const letras = 'abcdefghijklmnopqrstuvwxyz' // Puedes agregar más letras según tus necesidades + if (index < letras.length) { + return letras[index] + ')' // Devuelve letras minúsculas como incisos (a), (b), (c), ... + } else { + return index - letras.length + 1 + ')' // Utiliza números para más opciones (1), (2), (3), ... + } +} + +const downloadPDF = () => { + const doc = new jsPDF() + + doc.setFontSize(16) + doc.text(examen.value.name, 10, 10) + + let y = 30 + doc.setFontSize(12) + + doc.text(`Escuela: ${examen.value.school}`, 10, y) + y += 10 + doc.text(`Docente: ${examen.value.teacher}`, 10, y) + y += 10 + doc.text(`Materia: ${examen.value.subject}`, 10, y) + + y += 20 + doc.setFontSize(12) + doc.text('Instrucciones', 10, y) + + const instructions = [ + `1. Este examen consta de ${examen.value.questions.length} preguntas.`, + '2. No se permite el uso de dispositivos electrónicos.', + '3. Tiempo máximo: 60 minutos.' + ] + + y += 10 + doc.setFontSize(10) + instructions.forEach((instruction) => { + y += 10 + doc.text(instruction, 15, y) + }) + + // Agrega las preguntas y opciones al PDF + examen.value.questions.forEach((question, index) => { + y += 20 + doc.setFontSize(12) + doc.text(`Pregunta ${index + 1}: ${question.question}`, 10, y) + + if (question.options.length > 0) { + y += 10 + doc.setFontSize(10) + question.options.forEach((option, optionIndex) => { + y += 10 + doc.text(`- ${option.option}`, 15, y) + }) + } + }) + + // Agrega el espacio para calificación y firmas + y += 20 + doc.setFontSize(10) + doc.text('Calificación: ________ / 10', 10, y) + y += 10 + doc.text('Firma del Estudiante: __________________________', 10, y) + y += 10 + doc.text('Firma del Profesor: ___________________________', 10, y) + + // Guarda y descarga el PDF + doc.save('ExamenTestForge.pdf') +} + +//Opciones preguntas cerradas const addOption = (question: { options: Array<{ option: string; isCorrect: boolean }> }) => { question.options.push({ option: '', @@ -58,6 +127,7 @@ const addOption = (question: { options: Array<{ option: string; isCorrect: boole }) } +//Eliminar Opcion de respuesta const removeOption = ( question: { options: Array<{ option: string; isCorrect: boolean }> @@ -67,9 +137,12 @@ const removeOption = ( question.options.splice(optionIndex, 1) } +//Eliminar preguntas agregadas const removeQuestion = (index: number) => { examen.value.questions.splice(index, 1) } + +//Descargar en PDF el examen