CODE MERGE : RV

This commit is contained in:
venkateswaran ubuntu 2023-10-20 10:56:58 +05:30
commit 17d09eeeb5
5 changed files with 60 additions and 21 deletions

View File

@ -72,8 +72,9 @@ function CheakQnType(question, questionIndex, depth,nested) {
} }
} }
let count =0 var count =0
var count1 =0 var count1 =0
var romanNumerals = ["", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"];
function processQuestion(question, questionIndex, depth,nested) { function processQuestion(question, questionIndex, depth,nested) {
// console.log('question Data') // console.log('question Data')
// console.log(question); // console.log(question);
@ -88,16 +89,21 @@ function processQuestion(question, questionIndex, depth,nested) {
const questionIndentation = " ".repeat(depth + 1); const questionIndentation = " ".repeat(depth + 1);
console.log(questionIndentation) console.log(questionIndentation)
if (nested == 1) {// this adds the inside the questionGroup if (nested == 1) {// this adds the inside the questionGroup
count1++ 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>`; 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 { } else {
count++ 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>`; 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>`;
} }
console.log(questionPaper); console.log(questionPaper);
// If it's an MCQ question, add choices // If it's an MCQ question, add choices
// If it's an MCquestionText
if (question.question_type === "group") { if (question.question_type === "group") {
const answers = question.answers; const answers = question.answers;
const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options
@ -144,7 +150,7 @@ function GroupQuestion(question, questionIndex, depth) {
// Function to recursively convert JSON to a formatted question paper // Function to recursively convert JSON to a formatted question paper
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionIndex = 1) { function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionIndex = 1) {
const sections = data.sections; const sections = data.sections;
console.log(sections); // console.log(sections);
// Extract the heading information // Extract the heading information
const questionPaperTitle = data.question_paper_title; const questionPaperTitle = data.question_paper_title;
const questionPaperDescription = data.question_paper_description; const questionPaperDescription = data.question_paper_description;
@ -170,7 +176,7 @@ function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionI
const indentation = " ".repeat(depth); const indentation = " ".repeat(depth);
// questionPaper += `${indentation}${sectionTitle}${sectionAttempt}${sectionMark}${indentation}${sectionDescription}`; // 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 // Process each question in the section
@ -191,5 +197,4 @@ const formattedQuestionPaper = convertJSONToQuestionPaper(jsonData, 0, 1, 1);
const questionPaperElement = document.getElementById("questionPaper"); const questionPaperElement = document.getElementById("questionPaper");
console.log(questionPaperElement); console.log(questionPaperElement);
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
} }

View File

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

View File

@ -612,7 +612,6 @@
const url = new URL(window.location.href);// Get the URL of the current page for JSON 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 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 FileName = params.get('filename');// Get the value of a specific parameter
var xmlPath ="" //get the xml filepath in .env file local variable var xmlPath ="" //get the xml filepath in .env file local variable
$(document).ready(function() { $(document).ready(function() {
@ -665,10 +664,28 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
//EditPreview and Create Previe //EditPreview and Create Preview
var previewbutton = document.getElementById("editPreview"); var previewbutton = document.getElementById("editPreview");
previewbutton.addEventListener("click", async () => { previewbutton.addEventListener("click", async () => {
if (FileName) { 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; previewbutton.href = "QuestionPreview.html?filename=" + FileName;
} else { } else {
const saveButton = document.getElementById('SaveButton'); const saveButton = document.getElementById('SaveButton');

View File

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

View File

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