PREVIEW_CHANGE : AADHAVAN

This commit is contained in:
aadhavan valli 2023-10-20 10:22:11 +05:30
parent 66cf6b37bf
commit 8c4070625e
5 changed files with 57 additions and 24 deletions

View File

@ -72,8 +72,9 @@ function CheakQnType(question, questionIndex, depth,nested) {
}
}
let count =0
var count =0
var count1 =0
var romanNumerals = ["", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"];
function processQuestion(question, questionIndex, depth,nested) {
const questionTex = question.question;
const questionText = questionTex.replace('<p>', '<p id="question_Text">');
@ -84,14 +85,14 @@ function processQuestion(question, questionIndex, depth,nested) {
// Add appropriate indentation for nested questions
const questionIndentation = " ".repeat(depth + 1);
if (nested == 1) {// this adds the inside the questionGroup
count1++
questionPaper += `<div class="text-qus-align">${questionIndentation}${count}.${count1}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
count1++;
var romanNumeral=romanNumerals[count1];
questionPaper += `<div class="text-qus-choice">${questionIndentation}${romanNumeral}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
} else {
count++
questionPaper += `<div class="text-qus-align">${questionIndentation}${count}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
}
// If it's an MCQ question, add choices
// If it's an MCquestionText
if (question.question_type === "group") {
const answers = question.answers;
const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options
@ -138,7 +139,7 @@ function GroupQuestion(question, questionIndex, depth) {
// Function to recursively convert JSON to a formatted question paper
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionIndex = 1) {
const sections = data.sections;
console.log(sections);
// console.log(sections);
// Extract the heading information
const questionPaperTitle = data.question_paper_title;
const questionPaperDescription = data.question_paper_description;
@ -164,7 +165,7 @@ function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionI
const indentation = " ".repeat(depth);
// questionPaper += `${indentation}${sectionTitle}${sectionAttempt}${sectionMark}${indentation}${sectionDescription}`;
questionPaper += `${indentation}${modifiedSectionTitle}${sectionMark}${sectionAttempt}${indentation}${sectionDescription}`;
questionPaper += `${indentation}<hr id="horizontal">${modifiedSectionTitle}${sectionMark}${sectionAttempt}${indentation}${sectionDescription}`;
// Process each question in the section
@ -184,5 +185,4 @@ function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionI
const formattedQuestionPaper = convertJSONToQuestionPaper(jsonData, 0, 1, 1);
const questionPaperElement = document.getElementById("questionPaper");
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
}

View File

@ -49,22 +49,33 @@
<style>
hr{
height: 2px;
}
#horizontal:first-of-type{
display: none;
}
p{
font-weight: 500;
}
/* Question Group Mark */
.text-qus-align{
/* .text-qus-align{
display: inline-flex;
}
} */
.group_attempt_any{
display: inline-flex;
float: right;
margin-right: 40px;
margin-right: 115px;
margin-top:-35px;
}
.group_marks{
display: inline-flex;
float: right;
margin-top:-35px;
margin-right: 4px;
}
@ -77,6 +88,7 @@
display: inline-block;
margin-right: 10px;
float: right;
margin-top:-25px;
}
/* Section SectionAttempt SectionMark */
@ -88,11 +100,13 @@
display: inline-block;
margin-right: 40px;
float: right;
/* margin-top:-27px; */
}
#sectionMark{
display: inline-block;
margin-right: 10px;
float: right;
/* margin-top:-27px; */
}
/* End the this */
@ -109,14 +123,14 @@
.MathJax.CtxtMenu_Attached_0{
display: contents !important;
}
.text-qus-align{margin-left: -16px;padding-right: 250px; }
.text-qus-align{margin-left: -16px;padding-right: 250px;display:flex; }
.text-qus-align p{ margin:0; }
.text-des{ margin-left: 20px;margin-top: 0px;} /* Change there aadhavan top-6px*/
.text-option-align{display:flex;margin-top: 0%;margin-left: 45px;} /* Change there aadhavan 10px*/
.text-option-align p{ margin:0; }
#sectionTitle {border-top: 2px solid gray
; width: 100%;}
#sectionTitle:first-of-type {border:none;}
/* #sectionTitle {border-top: 2px solid gray
; width:99%;} */
/* #sectionTitle:first-of-type {border:none;} */
mjx-container[jax="CHTML"][display="true"] {
display: block;
text-align: center;
@ -297,7 +311,7 @@
//XmlPath get from .env
const xmlPathenv=process.env.XML_FILE_PATH;
const xmlPath =path.join(__dirname,xmlPathenv);
console.log(xmlFileName)
// console.log(xmlFileName)
return new Promise((resolve, reject) => {
fs.readFile(`${xmlPath}`+xmlFileName, 'utf8', (error, data) => {
if (error) {

View File

@ -613,7 +613,6 @@
const url = new URL(window.location.href);// Get the URL of the current page for JSON
const params = new URLSearchParams(url.search);// Create a URLSearchParams object from the query string
var FileName = params.get('filename');// Get the value of a specific parameter
var xmlPath ="" //get the xml filepath in .env file local variable
$(document).ready(function() {
@ -666,10 +665,28 @@ document.addEventListener('DOMContentLoaded', function () {
});
//EditPreview and Create Previe
//EditPreview and Create Preview
var previewbutton = document.getElementById("editPreview");
previewbutton.addEventListener("click", async () => {
if (FileName) {
const saveButton = document.getElementById('SaveButton');
if (saveButton) {
saveButton.click();
setTimeout(function() {
var popupInput = document.getElementById("swal2-input");
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
submitButton.addEventListener("click", function() {
FileName = popupInput.value;
FileName += ".xml"
if(FileName){
var anchorElement = document.getElementById("editPreview");
if (anchorElement) {
anchorElement.click();
}
}
});
}, 1000);
}
previewbutton.href = "QuestionPreview.html?filename=" + FileName;
} else {
const saveButton = document.getElementById('SaveButton');

View File

@ -36,7 +36,7 @@ const isEncrypted = process.env.ENCRYPTED;
//end the autosave
function saveXmlToFile(xmlData, filePath) {
console.log(filePath);
// console.log(filePath);
// Check if the file path is provided
if (!filePath) {
console.error('File path is required.');
@ -139,13 +139,14 @@ function promptBox() {
confirmButtonText: 'Submit',
cancelButtonText: 'Cancel',
inputValidator: (value) => {
// console.log(value);
const entervalue =value+'.xml'
if (!value) {
return 'You need to enter Filename!'
}
else if (value){
const fileexists =fileexists(entervalue);
if(fileexists){
const fileexist =fileexists(entervalue);
if(fileexist){
Swal.update({ showDenyButton: true });
return 'This file Name already exists'
}else {
@ -154,7 +155,7 @@ function promptBox() {
}
}
}).then((result) => {
console.log(result);
// console.log(result);
if (result.isConfirmed) {
const inputValue = result.value

View File

@ -54,8 +54,9 @@ function getQuestionsNodes(questionNode,type)
{
var tempChoiceobj = {};
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
// console.log(tempChoiceobj);
questionObj['answers'].push(tempChoiceobj);