PREVIEW_ISSUES_FIXES : RV
This commit is contained in:
parent
c63b2062b4
commit
3ef12dc65a
@ -1,4 +1,3 @@
|
||||
|
||||
function QuestionPaperPreview(jsonData){
|
||||
// The provided JSON data
|
||||
// console.log(jsonData)
|
||||
@ -40,24 +39,46 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
|
||||
function convertToLatex(text, mathstatus) {
|
||||
// console.log(text);
|
||||
// Parse mathstatus into a boolean
|
||||
const mathStatusBoolean = JSON.parse(mathstatus);
|
||||
// console.log('convertToLatex : ', mathstatus);
|
||||
// console.log('convertToLatex text : ', text);
|
||||
// const mathStatusBoolean = JSON.parse(mathstatus);
|
||||
// Check if the text contains <p> tags
|
||||
if (!/<p>|<\/p>/i.test(text)) {
|
||||
if (mathStatusBoolean) {
|
||||
if (mathstatus === 'Math') {
|
||||
// Use MathJax to convert the text to LaTeX
|
||||
const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
return cov;
|
||||
// console.log('Latex Full : ', cov);
|
||||
const onlyMath = convertMathJaxToLatex(cov)
|
||||
// console.log('Latex small : ', onlyMath);
|
||||
return onlyMath;
|
||||
} else {
|
||||
// Return the text as-is
|
||||
return text;
|
||||
}
|
||||
} else {
|
||||
// Return the text as-is
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
function convertMathJaxToLatex(mathJaxCode) {
|
||||
// Replace MathJax-specific tags and attributes
|
||||
let latexCode = mathJaxCode
|
||||
.replace(/<mjx-container[^>]*>/g, '')
|
||||
.replace(/<\/mjx-container>/g, '')
|
||||
.replace(/<mjx-math[^>]*>/g, '')
|
||||
.replace(/<\/mjx-math>/g, '')
|
||||
.replace(/<mjx-mi[^>]*>/g, '')
|
||||
.replace(/<\/mjx-mi>/g, '')
|
||||
.replace(/<mjx-c[^>]*>/g, '')
|
||||
.replace(/<\/mjx-c>/g, '')
|
||||
.replace(/<mjx-assistive-mml[^>]*>/g, '')
|
||||
.replace(/<\/mjx-assistive-mml>/g, '')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
|
||||
return latexCode;
|
||||
}
|
||||
|
||||
|
||||
// Initialize the formatted question paper string
|
||||
let questionPaper = "";
|
||||
|
||||
@ -69,10 +90,22 @@ function QuestionPaperPreview(jsonData){
|
||||
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex , questionIndex = 1) {
|
||||
const sections = data.sections;
|
||||
const questionPaperTitle = data.question_paper_title;
|
||||
const questionPaperDescription = data.question_paper_description;
|
||||
|
||||
console.log(data);
|
||||
var title = removeHtmlTags(questionPaperTitle)
|
||||
var questionPaperDescription = data.question_paper_description;
|
||||
|
||||
var title = '';
|
||||
if(questionPaperTitle == '' || questionPaperTitle == '<p><br></p>' || questionPaperTitle == null){
|
||||
var title = 'Untitled'
|
||||
}else{
|
||||
title = removeHtmlTags(questionPaperTitle);
|
||||
}
|
||||
|
||||
if(questionPaperDescription == '' || questionPaperDescription == '<p><br></p>' || questionPaperDescription == null){
|
||||
var questionPaperDescription = ''
|
||||
}else{
|
||||
questionPaperDescription = data.question_paper_description;
|
||||
}
|
||||
|
||||
console.log('questionPaperDescription : ', questionPaperDescription)
|
||||
|
||||
// Wrap the heading elements in <div> elements with CSS for centering
|
||||
questionPaper += `<div style="text-align: center; font-weight: bolder; "><h1>${title}</h1></div>`;
|
||||
@ -89,8 +122,8 @@ function QuestionPaperPreview(jsonData){
|
||||
const sectionTitle = section.section_title;
|
||||
const modifiedSectionTitle = sectionTitle.replaceAll('<p>', '<p id="sectionTitle">');//add the id for Section Title
|
||||
// console.log(section.section_attempt_any);
|
||||
if (section.section_attempt_any) {
|
||||
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.section_attempt_any}</p>`;
|
||||
if (section.attributes.AttemptAny) {
|
||||
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.attributes.AttemptAny}</p>`;
|
||||
|
||||
} else {
|
||||
var sectionAttempt = `<p id="sectionAttempt"> </p>`;
|
||||
@ -103,7 +136,8 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
}
|
||||
|
||||
var displayMarks = section.section_display_marks;
|
||||
var displayMarks = section.attributes.DisplayMarks;
|
||||
// console.log('displayMarks : ', displayMarks)
|
||||
if (displayMarks === 'false') {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(sectionMark, 'text/html');
|
||||
@ -115,7 +149,7 @@ function QuestionPaperPreview(jsonData){
|
||||
var doc = parser.parseFromString(sectionAttempt, 'text/html');
|
||||
var questionMarkElement = doc.body.firstChild;
|
||||
questionMarkElement.style.marginRight = '106px';
|
||||
console.log(questionMarkElement);
|
||||
// console.log(questionMarkElement);
|
||||
sectionAttempt =questionMarkElement.outerHTML
|
||||
|
||||
}
|
||||
@ -145,18 +179,22 @@ function QuestionPaperPreview(jsonData){
|
||||
var description_align =25;
|
||||
function displayQuestions(data,parentSno =''){
|
||||
var questionIndentation = " ".repeat(depth2);
|
||||
console.log(data)
|
||||
var dataa =data.questions;
|
||||
dataa.forEach((question, index) =>{
|
||||
|
||||
|
||||
console.log(question.descriptionMath);
|
||||
|
||||
var currentSno = parentSno + (index + 1) + '.';
|
||||
console.log('currentSno : ', currentSno);
|
||||
var temp_sno= currentSno.slice(0,-1)
|
||||
|
||||
var currentSno_length =currentSno.length-(currentSno.length/2)
|
||||
console.log('currentSno_length : ', currentSno_length);
|
||||
if (currentSno_length == 1) {
|
||||
description_align =27
|
||||
} else if (currentSno_length == 2) {
|
||||
description_align =33
|
||||
description_align =20
|
||||
}else if(currentSno_length == 3){
|
||||
description_align =48
|
||||
}else if(currentSno_length == 4) {
|
||||
@ -166,11 +204,15 @@ function QuestionPaperPreview(jsonData){
|
||||
description_align =78
|
||||
}
|
||||
|
||||
if(question.descriptionMath == 'Math'){
|
||||
description_align = -364
|
||||
}
|
||||
|
||||
|
||||
var GroupQuestionTilteAlign = 0;
|
||||
if (question.group_title) {
|
||||
let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','');
|
||||
var question_id_length =cleanedText.length;
|
||||
if (question_id_length == 1) {
|
||||
|
||||
@ -197,9 +239,8 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
const questionGroupSetP = `${question.group_title}`;
|
||||
const questionGroupmodify =questionGroupSetP.replaceAll('<p>', `<p id="question-Group-Id" style="padding-left:${GroupQuestionTilteAlign}px">`)
|
||||
if (question.group_attempt_any) {
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.group_attempt_any} </p>`
|
||||
|
||||
if (question.attributes.AttemptAny) {
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.attributes.AttemptAny} </p>`
|
||||
}else{
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny"> </p>`
|
||||
|
||||
@ -210,7 +251,7 @@ function QuestionPaperPreview(jsonData){
|
||||
var questionGroupMark = `<p id="group_marks">Marks : ${question.group_marks} </p>`
|
||||
|
||||
}
|
||||
var displayMarks = question.group_display_marks;
|
||||
var displayMarks = question.attributes.DisplayMarks;
|
||||
if (displayMarks === 'false') {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(questionGroupMark, 'text/html');
|
||||
@ -240,8 +281,8 @@ function QuestionPaperPreview(jsonData){
|
||||
questionPaper += `<div class="group-descrip" style="margin-left:${description_align}px">${questionGroupDescription}</div></div>`;
|
||||
depth2++
|
||||
} else if (question.question) {
|
||||
|
||||
let cleanedTex = question.questionId.replace(/\s+/g, ' ').trim();
|
||||
// console.log('serial no : ', question.attributes.No);
|
||||
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||
var question_id_length =cleanedText.length;
|
||||
if (question_id_length == 1) {
|
||||
@ -263,6 +304,7 @@ function QuestionPaperPreview(jsonData){
|
||||
// console.log(question);
|
||||
// const questionId =`<p class="questionId">${cleanedText})</p>`;
|
||||
const questionI =cleanedText;
|
||||
// console.log('cleanedText : ', questionI);
|
||||
var questionId = questionI.replace('<p>', '<p class="questionId">');
|
||||
|
||||
const questionTex = question.question;
|
||||
@ -270,21 +312,23 @@ function QuestionPaperPreview(jsonData){
|
||||
// console.log(questionText);
|
||||
const questionDescriptio = question.question_description;
|
||||
const questionDescription = questionDescriptio.replaceAll('<p>', '<p class="question-Description">')
|
||||
const mathstatus = question.is_math_enabled;
|
||||
const mathstatus = question.descriptionMath;
|
||||
const titlemathstatus = question.titleMath;
|
||||
console.log('questionText : ', questionText)
|
||||
console.log('titlemathstatus : ', titlemathstatus)
|
||||
if (question.marks == 0 || question.marks == '' ) {
|
||||
var questionMark = `<p id="question-mark"> </p>`;
|
||||
} else {
|
||||
var questionMark = `<p id="question-mark">Marks :${question.marks}</p>`;
|
||||
|
||||
}
|
||||
var displayMarks =question.display_marks
|
||||
var displayMarks =question.attributes.DisplayMarks
|
||||
|
||||
if (displayMarks === 'false') {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(questionMark, 'text/html');
|
||||
var questionMarkElement = doc.body.firstChild;
|
||||
questionMarkElement.setAttribute('hidden', 'hidden');
|
||||
questionMark =questionMarkElement.outerHTML
|
||||
questionMark =questionMarkElement.outerHTML;
|
||||
}
|
||||
|
||||
// console.log(questionMark);
|
||||
@ -293,23 +337,21 @@ function QuestionPaperPreview(jsonData){
|
||||
questionMark = questionMark.replace('<p id="question-mark">', '<p id="question-mark" hidden>')
|
||||
}
|
||||
|
||||
|
||||
|
||||
// questionPaper += `<div id="parent" class="text-qus-align">${temp_sno})${convertToLatex(questionText, mathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px">${convertToLatex(questionDescription, mathstatus)}</div>`;
|
||||
questionPaper += `<div id="parent" class="text-qus-align">${questionId})${convertToLatex(questionText, mathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px">${convertToLatex(questionDescription, mathstatus)}</div>`;
|
||||
//
|
||||
questionPaper += `<div id="parent" class="text-qus-align">${questionId})${convertToLatex(questionText, titlemathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px;">${convertToLatex(questionDescription, mathstatus)}</div>`;
|
||||
|
||||
|
||||
if (question.question_type === "group") {
|
||||
var answers = question.answers;
|
||||
var answerId =question.question_id;
|
||||
console.log('choice answers math: ', question.answers)
|
||||
var choisealgin =25
|
||||
// var currentSno_length1 =currentSno.length-(currentSno.length/2)
|
||||
var currentSno_length1 =question_id_length
|
||||
console.log(answerId);
|
||||
// console.log(answerId);
|
||||
// console.log(currentSno_length1);
|
||||
if (currentSno_length1 == 1) {
|
||||
choisealgin =26
|
||||
// choisealgin =26
|
||||
choisealgin =52
|
||||
} else if (currentSno_length1 == 2) {
|
||||
choisealgin =25
|
||||
}else if(currentSno_length1 == 3){
|
||||
@ -335,14 +377,23 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
var math = answers[i].is_math_enabled;
|
||||
// var choice_name_set =answers[i].choice_name.replace('<p>','<p class="Choise_Question_Align">')
|
||||
|
||||
|
||||
var choiceClass = ''
|
||||
if (math === 'Math') {
|
||||
choiceClass = 'text-option-align2';
|
||||
}else{
|
||||
choiceClass = 'text-option-align';
|
||||
}
|
||||
|
||||
const answerA = answers[i] ? `${optionA}. ${convertToLatex(answers[i].choice_name, math)}` : '';
|
||||
console.log('choice latex : ',answerA);
|
||||
// const answerB = answers[i + 1] ? `${optionB}. ${convertToLatex(answers[i + 1].choice_name, mathstatus)}` : '';
|
||||
if (multipleAnswer == 'false') {
|
||||
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input class="optionSelectArea" type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
|
||||
questionPaper += `<div class="${choiceClass}" style="margin-left:${choisealgin}px;"><input class="optionSelectArea" type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
|
||||
}else{
|
||||
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input class="optionSelectArea" type="checkbox" name="answer" value="A"> <p class="ChoiceOptionMultiple">${answerA.padEnd(10)}</p></div>`;
|
||||
questionPaper += `<div class="${choiceClass}" style="margin-left:${choisealgin}px;"><input class="optionSelectArea" type="checkbox" name="answer" value="A"> <p class="ChoiceOptionMultiple">${answerA.padEnd(10)}</p></div>`;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,17 +418,6 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function removeHtmlTags(inputString) {
|
||||
|
||||
const cheerio = require('cheerio');
|
||||
@ -387,33 +427,33 @@ function removeHtmlTags(inputString) {
|
||||
return text;
|
||||
}
|
||||
|
||||
function convertToLatex(text, mathstatus) {
|
||||
// Parse mathstatus into a boolean
|
||||
const mathStatusBoolean = true
|
||||
// Check if the text contains <p> tags
|
||||
console.log(text);
|
||||
// console.log("ff")
|
||||
if (!/<p>|<\/p>/i.test(text)) {
|
||||
// console.log('text:' , text)
|
||||
if (mathStatusBoolean) {
|
||||
// console.log('text1:' , text)
|
||||
// Use MathJax to convert the text to LaTeX
|
||||
const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
console.log('cov:' , cov)
|
||||
// function convertToLatex(text, mathstatus) {
|
||||
// // Parse mathstatus into a boolean
|
||||
// const mathStatusBoolean = true
|
||||
// // Check if the text contains <p> tags
|
||||
// console.log(text);
|
||||
// // console.log("ff")
|
||||
// if (!/<p>|<\/p>/i.test(text)) {
|
||||
// // console.log('text:' , text)
|
||||
// if (mathStatusBoolean) {
|
||||
// // console.log('text1:' , text)
|
||||
// // Use MathJax to convert the text to LaTeX
|
||||
// const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
// console.log('cov:' , cov)
|
||||
|
||||
return cov;
|
||||
} else {
|
||||
// Return the text as-is
|
||||
// return cov;
|
||||
// } else {
|
||||
// // Return the text as-is
|
||||
|
||||
return text;
|
||||
}
|
||||
} else {
|
||||
console.log("pq")
|
||||
const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
console.log('cov:' , cov)
|
||||
// return text;
|
||||
// }
|
||||
// } else {
|
||||
// console.log("pq")
|
||||
// const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
// console.log('cov:' , cov)
|
||||
|
||||
return cov;
|
||||
// Return the text as-is
|
||||
return text;
|
||||
}
|
||||
}
|
||||
// return cov;
|
||||
// // Return the text as-is
|
||||
// return text;
|
||||
// }style="margin-left:27px;position: absolute;right: 546px;bottom: 10px;"
|
||||
// }
|
||||
@ -235,6 +235,7 @@
|
||||
margin-right: 10px;
|
||||
float: right;
|
||||
margin-top:-27px;
|
||||
margin-top:-41px;
|
||||
}
|
||||
|
||||
/* Section SectionAttempt SectionMark */
|
||||
@ -295,11 +296,33 @@
|
||||
/* top:30px */
|
||||
}
|
||||
.text-qus-align p{ margin:0; }
|
||||
.text-des{ margin-left: 20px;
|
||||
/* margin-top: 23px; */
|
||||
inline-size: 790px;} /* Change there aadhavan top-6px*/
|
||||
.text-option-align{display:flow-root;margin-top: -2%;margin-left: 45px; inline-size: 790px; } /* Change there aadhavan 10px*/
|
||||
.text-option-align p{ margin:0; text-wrap: balance;}
|
||||
.text-des{
|
||||
margin-left: 20px;
|
||||
margin-top: 23px;
|
||||
inline-size: 790px;
|
||||
} /* Change there aadhavan top-6px*/
|
||||
.text-option-align{
|
||||
display:flow-root;
|
||||
margin-top: -2%;
|
||||
margin-left: 45px;
|
||||
inline-size: 790px;
|
||||
position: relative;
|
||||
bottom: 13px;
|
||||
} /* Change there aadhavan 10px*/
|
||||
.text-option-align p{
|
||||
margin:0;
|
||||
text-wrap: balance;
|
||||
}
|
||||
.text-option-align2{
|
||||
display:flow-root;
|
||||
margin-top: 20px;
|
||||
margin-left: 45px;
|
||||
inline-size: 790px;
|
||||
} /* Change there aadhavan 10px*/
|
||||
.text-option-align2 p{
|
||||
margin:0;
|
||||
text-wrap: balance;
|
||||
}
|
||||
/* #sectionTitle {border-top: 2px solid gray
|
||||
; width:99%;} */
|
||||
/* #sectionTitle:first-of-type {border:none;} */
|
||||
@ -346,7 +369,11 @@
|
||||
}
|
||||
.question-Group-Description{
|
||||
inline-size: 660px;
|
||||
text-wrap: wrap;
|
||||
text-wrap: wrap;
|
||||
position: relative;
|
||||
bottom: 30px;
|
||||
right: 12px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.text-group-align{
|
||||
/* display: flex; */
|
||||
@ -357,6 +384,8 @@
|
||||
margin-top: -54px;
|
||||
float: right;
|
||||
display:inline;
|
||||
position: relative;
|
||||
left: 10px;
|
||||
}
|
||||
.group-descrip{
|
||||
position: relative;
|
||||
@ -417,6 +446,12 @@ color: #1d3557 !important;
|
||||
color: #1d3557 !important;
|
||||
}
|
||||
|
||||
math {
|
||||
position: relative;
|
||||
bottom: 24px;
|
||||
left: 21px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
80
addform.html
80
addform.html
@ -89,6 +89,11 @@
|
||||
.jodit-toolbar__box{
|
||||
display: none;
|
||||
}
|
||||
|
||||
math {
|
||||
position: relative;
|
||||
top: 6px;
|
||||
}
|
||||
|
||||
.ql-toolbar .ql-picker.ql-table .ql-picker-item{
|
||||
display: block !important;
|
||||
@ -1661,6 +1666,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (FileName) {
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveFile()
|
||||
saveButton.click();
|
||||
if (count == 0) {
|
||||
setTimeout(function() {
|
||||
@ -1691,6 +1697,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
} else {
|
||||
const saveButton = document.getElementById('SaveButton');
|
||||
if (saveButton) {
|
||||
saveFile()
|
||||
saveButton.click();
|
||||
setTimeout(function() {
|
||||
var popupInput = document.getElementById("swal2-input");
|
||||
@ -1712,6 +1719,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2905,7 +2913,7 @@ function groupQuestion(question_id = false, section_id = false , group_question_
|
||||
<div class="form_box">
|
||||
<label class="titleSpace">Question:<span id='partOf_${addChoiceAreaId}'> <input style=" width: 200px !important;border: 2px solid #EEECFE;height: 37px; margin-left: 4px; margin-top: -29px;" id="QuestionChoiceId_${addChoiceAreaId}" class="QuestionChoiceId SerialNo" contenteditable="true" value="${questionIdS}" placeholder="SNo...."></label>
|
||||
<div class="richText" id="textQuestionName_${addChoiceAreaId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionTitle ? questionTitle : ''}</div>
|
||||
<math-field id="textQuestiontitleMath_${addChoiceAreaId}" contenteditable="true">${mathEnabled == 'Math' ? questionTitle : ''}</math-field>
|
||||
<math-field id="textQuestiontitleMath_${addChoiceAreaId}" contenteditable="true">${titleMath == 'Math' ? questionTitle : ''}</math-field>
|
||||
<span class="mathQuestions">Math</span> <input class="checkbox" style="width:14px; height:14px" type="checkbox" id="titlemath_${addChoiceAreaId}">
|
||||
<input type="file" id="fileInput_${addChoiceAreaId}" style="display: none;">
|
||||
</div>
|
||||
@ -3011,8 +3019,6 @@ function groupQuestion(question_id = false, section_id = false , group_question_
|
||||
|
||||
$(TitleMathSwitchId1).change(function() {
|
||||
|
||||
alert('hi')
|
||||
|
||||
if (TitleMathSwitchId1.checked) {
|
||||
|
||||
var idToRemove = 'textQuestionName_' + addChoiceAreaId;
|
||||
@ -3510,6 +3516,25 @@ $(textQuestiontitle_mathId).keyup(function(event) {
|
||||
|
||||
});
|
||||
|
||||
$(document).on("click", function (event) {
|
||||
|
||||
const targetElement = event.target;
|
||||
var tragetedId = event.target.id.startsWith("ML");
|
||||
const classList = Array.from(event.target.classList);
|
||||
const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action") || className.startsWith("loaded"));
|
||||
const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
|
||||
|
||||
if (tragetedId !== false || hasMLKClass !== false || isSvgElement !== null) {
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
if (TitleMathSwitchId.checked) {
|
||||
check_Remove_Empty_Question(textQuestiontitle_math);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var choicei = 'QuestionChoiceId_'+ addChoiceAreaId;
|
||||
var inputElemen = document.getElementById(choicei);
|
||||
@ -3899,7 +3924,7 @@ textQuestion +=
|
||||
<div class="form_box">
|
||||
<label class="titleSpace">Question:<span id='partOf_${addTextQuestionId}'> <input type='text'style="border: 2px solid #EEECFE; height:34px;width: 200px !important;margin-left: 4px;" id='QuestionTextIdSet_${addTextQuestionId}' class='QuestionTextIdSet SerialNo' contenteditable="true" value="${ssa}" placeholder="SNo...."></label>
|
||||
<div type="text" class="richText" id="textQuestionName_${addTextQuestionId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${QuestionObj.hasOwnProperty('questionTitle') ? QuestionObj.questionTitle : ''}</div>
|
||||
<math-field id="textQuestiontitleMath_${addTextQuestionId}" contenteditable="true">${mathEnabled == 'Math' ? QuestionObj.questionTitle : ''}</math-field>
|
||||
<math-field id="textQuestiontitleMath_${addTextQuestionId}" contenteditable="true">${QuestionObj.titleMath == 'Math' ? QuestionObj.questionTitle : ''}</math-field>
|
||||
<span class="mathQuestions">Math</span> <input class="checkbox" style="width:14px; height:14px" type="checkbox" id="titlemath_${addTextQuestionId}">
|
||||
<input type="file" id="fileInput_${addTextQuestionId}" style="display: none;">
|
||||
</div>
|
||||
@ -4167,7 +4192,6 @@ const titleElements = textQuestiontitleId.previousElementSibling;
|
||||
if (mathEnabled === 'Math')
|
||||
{
|
||||
console.log('mathEnabled === true');
|
||||
|
||||
ChoiceMathSwitchId.checked = true;
|
||||
$(Elements).hide();
|
||||
$(textQuestionSubtitle_mathId).show();
|
||||
@ -4193,7 +4217,7 @@ if (ChoiceMathSwitchId.checked) {
|
||||
});
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
if (titleMathEnabled === 'true')
|
||||
if (titleMathEnabled === 'Math')
|
||||
{
|
||||
|
||||
TitleMathSwitchId.checked = true;
|
||||
@ -4333,10 +4357,23 @@ var tempQuestionTitle = inputElement.innerHTML;
|
||||
});
|
||||
|
||||
|
||||
$('.ML__keyboard').focus(function(){
|
||||
console.log('hi')
|
||||
})
|
||||
$(document).on("click", function (event) {
|
||||
|
||||
const targetElement = event.target;
|
||||
var tragetedId = event.target.id.startsWith("ML");
|
||||
const classList = Array.from(event.target.classList);
|
||||
const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action") || className.startsWith("loaded"));
|
||||
const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
|
||||
|
||||
if (tragetedId !== false || hasMLKClass !== false || isSvgElement !== null) {
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
if (TitleMathSwitchId.checked) {
|
||||
check_Remove_Empty_Question(textQuestiontitle_math);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -4474,14 +4511,19 @@ function collect_Empty_Question_Id(arrayString, ID) {
|
||||
//find the empty question
|
||||
function check_Empty_Question()
|
||||
{
|
||||
|
||||
// console.log("Check Empty Enter");
|
||||
var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION');
|
||||
// console.log('check_Empty_Question JSON_FOR_EMPTY_QUESTION', title_id);
|
||||
var attrId = '';
|
||||
if (title_id) {
|
||||
var parsedArray = JSON.parse(title_id);
|
||||
// console.log(parsedArray);
|
||||
parsedArray.forEach(function(Id, index,array) {
|
||||
|
||||
|
||||
var getMathFiled = Id.replace(/\d/g, '');
|
||||
console.log('getMathFiled : ', getMathFiled)
|
||||
|
||||
if (index === array.length - 1) {
|
||||
var idclass= document.getElementById(Id);
|
||||
// console.log(idclass == "QuestionTextIdSet SerialNo");
|
||||
@ -4489,7 +4531,6 @@ function check_Empty_Question()
|
||||
if (idclass == '' || idclass == null) {
|
||||
check_Remove_Empty_Question(Id,1)
|
||||
attrId ="1";
|
||||
|
||||
} else if ( idclass === 'QuestionTextIdSet SerialNo' || idclass === 'QuestionsGroupIdset SerialNo' || idclass === 'QuestionChoiceId SerialNo' ) {
|
||||
attrId = document.getElementById(Id).innerHTML
|
||||
}else if(idclass === 'multipleAnswerorNot'){
|
||||
@ -4497,16 +4538,23 @@ function check_Empty_Question()
|
||||
var remove = Id.replace('multipleAnswer_','')
|
||||
Id ='ChoiceCorrectAnswer_'+remove;
|
||||
}else {
|
||||
|
||||
var elementid = document.getElementById(Id);
|
||||
if(elementid.tagName == 'INPUT'){
|
||||
|
||||
}else{
|
||||
const previousElement = elementid.previousElementSibling;
|
||||
console.log(previousElement);
|
||||
if (previousElement == null) {
|
||||
attrId =elementid;
|
||||
} else {
|
||||
var focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
attrId = focus;
|
||||
var value = ''
|
||||
if(getMathFiled == 'textQuestiontitleMath_'){
|
||||
value = elementid.value;
|
||||
}else{
|
||||
value = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
}
|
||||
attrId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4973,6 +5021,7 @@ function removeSection(RandomId, IndexValue) {
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
if (element) {
|
||||
|
||||
|
||||
var sectionTitle= 'section_title_text_'+RandomId;
|
||||
// jsonData.sections.forEach(function (section) {
|
||||
@ -5003,10 +5052,13 @@ function removeSection(RandomId, IndexValue) {
|
||||
check_Remove_Empty_Question(sectionTitle,1);
|
||||
|
||||
element.remove();
|
||||
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
html2json();
|
||||
json2xml();
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -2,11 +2,18 @@ function json2nav() {
|
||||
// console.clear();
|
||||
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
var textQuestionId = 'textQuestionName_' + element_id;
|
||||
// var textQuestionId = 'textQuestionName_' + element_id;
|
||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('titlemath_' + element_id).checked;
|
||||
var questionTitle = "";
|
||||
var textQuestionId = "";
|
||||
|
||||
if(isMathEnabled == true){
|
||||
textQuestionId = 'textQuestiontitleMath_' + element_id;
|
||||
}else{
|
||||
textQuestionId = 'textQuestionName_' + element_id;
|
||||
}
|
||||
|
||||
if(isMathEnabled == true){
|
||||
|
||||
@ -33,12 +40,18 @@ function json2nav() {
|
||||
|
||||
$.fn.getChoiceQuestion = function(element_id) {
|
||||
|
||||
var choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
// var choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
||||
// var questionType = 'Group';
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('titlemath_' + element_id).checked;
|
||||
var questionTitle = "";
|
||||
var choiceQuestionId = "";
|
||||
|
||||
if(isMathEnabled == true){
|
||||
choiceQuestionId = 'textQuestiontitleMath_' + element_id;
|
||||
}else{
|
||||
choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
}
|
||||
|
||||
if(isMathEnabled == true){
|
||||
|
||||
|
||||
27
nav_pane.js
27
nav_pane.js
@ -332,15 +332,13 @@ function navpane() {
|
||||
if(nodeDataType == 'text')
|
||||
{
|
||||
bulletPoint = document.createElement('img');
|
||||
|
||||
|
||||
bulletPoint.src = 'assets/images/navtext.svg';
|
||||
bulletPoint.style.marginRight = '5px';
|
||||
bulletPoint.style.width = '13px';
|
||||
bulletPoint.style.fontWeight = 'bold';
|
||||
bulletPoint.style.color = '#00aaff';
|
||||
// bulletPoint.textContent = '\u2022';
|
||||
bulletPoint.setAttribute("title", "Descriptive");
|
||||
// bulletPoint.setAttribute("title", "Descriptive");
|
||||
nodeDivChildForIconAlgin.appendChild(bulletPoint);
|
||||
nodeDiv.id =`nav_removeAndCloneTextQuestion_${navPaneQuestionId}`;
|
||||
nodeDiv.setAttribute('draggable', 'true');
|
||||
@ -400,13 +398,13 @@ function navpane() {
|
||||
questionLink.style.maxWidth = '190px';
|
||||
questionLink.style.fontWeight = '100';
|
||||
|
||||
if(nodeDataType == 'text')
|
||||
{
|
||||
questionLink.setAttribute("title", "Descriptive");
|
||||
}else if(nodeDataType == 'text'){
|
||||
questionLink.setAttribute("title", "MCQ");
|
||||
// if(nodeDataType == 'text')
|
||||
// {
|
||||
// questionLink.setAttribute("title", "DescriptiveQuestion");
|
||||
// }else if(nodeDataType == 'group'){
|
||||
// questionLink.setAttribute("title", "MultiChoiceQuestion");
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// QuestionID.addEventListener('click', function () {
|
||||
// if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||
@ -886,9 +884,18 @@ function navpane() {
|
||||
|
||||
// Function to scroll to the specified element with smooth behavior
|
||||
function scrollToElement(elementId) {
|
||||
console.log('scroll elementId : ', elementId)
|
||||
var getMathFieldId = elementId.replace(/\d/g, '');
|
||||
console.log('getMathFieldId : ', getMathFieldId);
|
||||
const element = document.getElementById(elementId);
|
||||
const previousElement = element.previousElementSibling;
|
||||
var focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg');
|
||||
var focus = ''
|
||||
if(getMathFieldId == 'textQuestiontitleMath_'){
|
||||
focus = element
|
||||
}
|
||||
else{
|
||||
focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg');
|
||||
}
|
||||
if (element) {
|
||||
focus.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
}
|
||||
|
||||
@ -3821,8 +3821,4 @@ font-size: 14px;
|
||||
display:none;
|
||||
}
|
||||
|
||||
math {
|
||||
position: relative;
|
||||
top: 6px;
|
||||
}
|
||||
|
||||
|
||||
@ -18,37 +18,52 @@ function getAttributesOfXMLNode(node)
|
||||
return attributes;
|
||||
}
|
||||
|
||||
function getAttributesOfXMLNodeWithoutArray(node)
|
||||
{
|
||||
// console.log('xmal attributes');
|
||||
// console.log(node);
|
||||
// Get attributes of the node (if any)
|
||||
attributes = {};
|
||||
if (node.attributes.length > 0) {
|
||||
for (let i = 0; i < node.attributes.length; i++) {
|
||||
const attribute = node.attributes[i];
|
||||
attributes = attribute.nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
function getQuestionsNodes(questionNode,type)
|
||||
{
|
||||
// console.log(questionNode);
|
||||
var questionObj = {};
|
||||
if(type == 1)
|
||||
{
|
||||
questionObj['questionId'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
|
||||
questionObj['question'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
|
||||
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'text';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
|
||||
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
|
||||
questionObj['question_sub_type'] = 'false';
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
questionObj['questionId'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
|
||||
questionObj['question'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
|
||||
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
|
||||
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['answers'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[7].childNodes;
|
||||
questionObj['correct_answer'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[4].childNodes;
|
||||
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
@ -58,7 +73,7 @@ function getQuestionsNodes(questionNode,type)
|
||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].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 : "");
|
||||
tempChoiceobj['is_math_enabled'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
|
||||
@ -71,18 +86,14 @@ function getQuestionsNodes(questionNode,type)
|
||||
|
||||
function getQuestionGroupNodes(questionGroup)
|
||||
{
|
||||
var questionGroupObj = {};
|
||||
questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
|
||||
|
||||
questionGroupObj['group_title'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_marks'] = (questionGroup.childNodes[3].firstChild !== null ? questionGroup.childNodes[3].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].firstChild.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[5].firstChild !== null ? questionGroup.childNodes[5].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
var questionGroupObj = {};
|
||||
questionGroupObj['group_title'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[6].childNodes;
|
||||
var questionList = questionGroup.childNodes[3].childNodes;
|
||||
// console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
@ -133,14 +144,12 @@ jsonObj['sections'] = [];
|
||||
tempObj['section_title'] = (sectionsList[i].childNodes[0].firstChild !== null ? sectionsList[i].childNodes[0].firstChild.nodeValue : "");
|
||||
tempObj['section_description'] = (sectionsList[i].childNodes[1].firstChild !== null ? sectionsList[i].childNodes[1].firstChild.nodeValue : "");
|
||||
tempObj['section_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
|
||||
tempObj['section_display_marks'] = sectionsList[i].childNodes[3].firstChild.nodeValue;
|
||||
tempObj['section_attempt_any'] = (sectionsList[i].childNodes[4].firstChild !== null && sectionsList[i].childNodes[4].firstChild !== undefined ? sectionsList[i].childNodes[4].firstChild.nodeValue : "");
|
||||
tempObj['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
|
||||
tempObj['questions'] = [];
|
||||
|
||||
|
||||
//handle questions
|
||||
var questionList = sectionsList[i].childNodes[5].childNodes;
|
||||
var questionList = sectionsList[i].childNodes[3].childNodes;
|
||||
// console.log('No of quetions:' + questionList.length);
|
||||
// console.log("Question List")
|
||||
// console.log(questionList);
|
||||
@ -169,7 +178,7 @@ jsonObj['sections'] = [];
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
localStorage.setItem('pjsonData', jsonData );
|
||||
// console.log(jsonData);
|
||||
console.log('xml2json_for_questionpaper : ',jsonData);
|
||||
QuestionPaperPreview(jsonObj);
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user