Compare commits
No commits in common. "jodit" and "dev" have entirely different histories.
@ -1,3 +1,4 @@
|
||||
|
||||
function QuestionPaperPreview(jsonData){
|
||||
// The provided JSON data
|
||||
// console.log(jsonData)
|
||||
@ -39,46 +40,24 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
|
||||
function convertToLatex(text, mathstatus) {
|
||||
// console.log('convertToLatex : ', mathstatus);
|
||||
// console.log('convertToLatex text : ', text);
|
||||
// const mathStatusBoolean = JSON.parse(mathstatus);
|
||||
// console.log(text);
|
||||
// Parse mathstatus into a boolean
|
||||
const mathStatusBoolean = JSON.parse(mathstatus);
|
||||
// Check if the text contains <p> tags
|
||||
if (!/<p>|<\/p>/i.test(text)) {
|
||||
if (mathstatus === 'Math') {
|
||||
if (mathStatusBoolean) {
|
||||
// Use MathJax to convert the text to LaTeX
|
||||
const cov = MathJax.tex2chtml(text).outerHTML;
|
||||
// console.log('Latex Full : ', cov);
|
||||
const onlyMath = convertMathJaxToLatex(cov)
|
||||
// console.log('Latex small : ', onlyMath);
|
||||
return onlyMath;
|
||||
return cov;
|
||||
} 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 = "";
|
||||
|
||||
@ -90,22 +69,9 @@ function QuestionPaperPreview(jsonData){
|
||||
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex , questionIndex = 1) {
|
||||
const sections = data.sections;
|
||||
const questionPaperTitle = data.question_paper_title;
|
||||
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)
|
||||
const questionPaperDescription = data.question_paper_description;
|
||||
|
||||
var title = removeHtmlTags(questionPaperTitle)
|
||||
|
||||
// Wrap the heading elements in <div> elements with CSS for centering
|
||||
questionPaper += `<div style="text-align: center; font-weight: bolder; "><h1>${title}</h1></div>`;
|
||||
@ -122,8 +88,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.attributes.AttemptAny) {
|
||||
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.attributes.AttemptAny}</p>`;
|
||||
if (section.section_attempt_any) {
|
||||
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.section_attempt_any}</p>`;
|
||||
|
||||
} else {
|
||||
var sectionAttempt = `<p id="sectionAttempt"> </p>`;
|
||||
@ -136,8 +102,7 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
}
|
||||
|
||||
var displayMarks = section.attributes.DisplayMarks;
|
||||
// console.log('displayMarks : ', displayMarks)
|
||||
var displayMarks = section.section_display_marks;
|
||||
if (displayMarks === 'false') {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(sectionMark, 'text/html');
|
||||
@ -149,7 +114,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
|
||||
|
||||
}
|
||||
@ -179,22 +144,18 @@ 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 =20
|
||||
description_align =33
|
||||
}else if(currentSno_length == 3){
|
||||
description_align =48
|
||||
}else if(currentSno_length == 4) {
|
||||
@ -204,15 +165,11 @@ function QuestionPaperPreview(jsonData){
|
||||
description_align =78
|
||||
}
|
||||
|
||||
if(question.descriptionMath == 'Math'){
|
||||
description_align = -364
|
||||
}
|
||||
|
||||
|
||||
var GroupQuestionTilteAlign = 0;
|
||||
if (question.group_title) {
|
||||
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','');
|
||||
let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||
var question_id_length =cleanedText.length;
|
||||
if (question_id_length == 1) {
|
||||
|
||||
@ -239,8 +196,9 @@ 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.attributes.AttemptAny) {
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.attributes.AttemptAny} </p>`
|
||||
if (question.group_attempt_any) {
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.group_attempt_any} </p>`
|
||||
|
||||
}else{
|
||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny"> </p>`
|
||||
|
||||
@ -251,7 +209,7 @@ function QuestionPaperPreview(jsonData){
|
||||
var questionGroupMark = `<p id="group_marks">Marks : ${question.group_marks} </p>`
|
||||
|
||||
}
|
||||
var displayMarks = question.attributes.DisplayMarks;
|
||||
var displayMarks = question.group_display_marks;
|
||||
if (displayMarks === 'false') {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(questionGroupMark, 'text/html');
|
||||
@ -273,16 +231,16 @@ function QuestionPaperPreview(jsonData){
|
||||
// questionGroupMark = questionGroupMark.replace('<p id="group_marks">', '<p id="group_marks" hidden>')
|
||||
// }
|
||||
|
||||
questionPaper += `<div class="textGroup"><div class="text-group-align" style="margin-left:0px;">${questionId})${questionGroupmodify}</div>`
|
||||
questionPaper += `<div class="text-group-align" style="margin-left:0px;">${questionId})${questionGroupmodify}</div>`
|
||||
|
||||
questionPaper += `<div class="group_marks_attmpt">${questionGroupAttempt}${questionGroupMark}</div>`;
|
||||
// questionPaper += `<div class="group_attempt_any">${questionGroupAttempt}</div>`;
|
||||
|
||||
questionPaper += `<div class="group-descrip" style="margin-left:${description_align}px">${questionGroupDescription}</div></div>`;
|
||||
questionPaper += `<div class="group-descrip" style="margin-left:${description_align}px">${questionGroupDescription}</div>`;
|
||||
depth2++
|
||||
} else if (question.question) {
|
||||
// console.log('serial no : ', question.attributes.No);
|
||||
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
|
||||
|
||||
let cleanedTex = question.questionId.replace(/\s+/g, ' ').trim();
|
||||
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||
var question_id_length =cleanedText.length;
|
||||
if (question_id_length == 1) {
|
||||
@ -304,7 +262,6 @@ 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;
|
||||
@ -312,23 +269,21 @@ function QuestionPaperPreview(jsonData){
|
||||
// console.log(questionText);
|
||||
const questionDescriptio = question.question_description;
|
||||
const questionDescription = questionDescriptio.replaceAll('<p>', '<p class="question-Description">')
|
||||
const mathstatus = question.descriptionMath;
|
||||
const titlemathstatus = question.titleMath;
|
||||
console.log('questionText : ', questionText)
|
||||
console.log('titlemathstatus : ', titlemathstatus)
|
||||
const mathstatus = question.is_math_enabled;
|
||||
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.attributes.DisplayMarks
|
||||
var displayMarks =question.display_marks
|
||||
|
||||
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);
|
||||
@ -337,23 +292,25 @@ 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, titlemathstatus)}</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>`;
|
||||
//
|
||||
|
||||
|
||||
if (question.question_type === "group") {
|
||||
var answers = question.answers;
|
||||
console.log('choice answers math: ', question.answers)
|
||||
var answerId =question.question_id;
|
||||
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 =52
|
||||
choisealgin =26
|
||||
} else if (currentSno_length1 == 2) {
|
||||
choisealgin = 52
|
||||
choisealgin =25
|
||||
}else if(currentSno_length1 == 3){
|
||||
choisealgin =33
|
||||
}else if(currentSno_length1 == 4) {
|
||||
@ -371,29 +328,19 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options
|
||||
for (let i = 0; i < answers.length; i++) { // change the i +=2 aadhavan
|
||||
// console.log(answers);
|
||||
const optionA = alphabetOptions[i];
|
||||
// const optionB = alphabetOptions[i + 1];
|
||||
|
||||
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="${choiceClass}" 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="text-option-align" style="margin-left:${choisealgin}px"><input type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
|
||||
}else{
|
||||
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>`;
|
||||
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input type="checkbox" name="answer" value="A"> <p class="ChoiceOption"> ${answerA.padEnd(10)}</p></div>`;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,6 +365,17 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function removeHtmlTags(inputString) {
|
||||
|
||||
const cheerio = require('cheerio');
|
||||
@ -427,33 +385,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;
|
||||
// }style="margin-left:27px;position: absolute;right: 546px;bottom: 10px;"
|
||||
// }
|
||||
return cov;
|
||||
// Return the text as-is
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,10 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- <title>Project-B</title> -->
|
||||
<title id="dynamicTitle"></title>
|
||||
|
||||
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Favicon -->
|
||||
@ -51,29 +53,8 @@
|
||||
|
||||
|
||||
<style>
|
||||
.textGroup{
|
||||
margin-top:30px;
|
||||
}
|
||||
/* .ChoiceOption{
|
||||
position: absolute;
|
||||
margin-top: 28px !important;
|
||||
margin-left: -25px !important;
|
||||
} */
|
||||
|
||||
.optionSelectArea{
|
||||
position: absolute;
|
||||
margin-top: 36px;
|
||||
}
|
||||
input[type=checkbox], input[type=radio] {
|
||||
margin-left: -32px;
|
||||
}
|
||||
img{
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.question_Text img{
|
||||
margin-top: 30px;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
|
||||
@ -85,22 +66,9 @@
|
||||
margin-top: 22px;
|
||||
display: flex;
|
||||
}
|
||||
.ChoiceOptionMultiple{
|
||||
align-items: center;
|
||||
display: inline;
|
||||
/* margin-left: -6px !important; */
|
||||
position: absolute;
|
||||
margin-top: 28px !important;
|
||||
margin-left: -30px !important;
|
||||
}
|
||||
.ChoiceOption{
|
||||
/* display: flex; */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
display: inline;
|
||||
/* margin-left: -6px !important; */
|
||||
position: absolute;
|
||||
margin-top: 28px !important;
|
||||
margin-left: -25px !important;
|
||||
}
|
||||
.ql-align-right.table-border{
|
||||
width: 167px !important;
|
||||
@ -234,7 +202,6 @@
|
||||
margin-right: 10px;
|
||||
float: right;
|
||||
margin-top:-27px;
|
||||
margin-top:-41px;
|
||||
}
|
||||
|
||||
/* Section SectionAttempt SectionMark */
|
||||
@ -286,44 +253,11 @@
|
||||
.MathJax.CtxtMenu_Attached_0{
|
||||
display: contents !important;
|
||||
}
|
||||
.text-qus-align{
|
||||
padding-right: 62px;
|
||||
/* margin-top: 37px; */
|
||||
inline-size: 790px;
|
||||
display:table-footer-group;
|
||||
/* position: relative; */
|
||||
/* top:30px */
|
||||
}
|
||||
.text-qus-align{padding-right: 62px; }
|
||||
.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;
|
||||
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;
|
||||
position: relative;
|
||||
bottom: 50px;
|
||||
} /* Change there aadhavan 10px*/
|
||||
.text-option-align2 p{
|
||||
margin:0;
|
||||
text-wrap: balance;
|
||||
}
|
||||
.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; text-wrap: balance;}
|
||||
/* #sectionTitle {border-top: 2px solid gray
|
||||
; width:99%;} */
|
||||
/* #sectionTitle:first-of-type {border:none;} */
|
||||
@ -357,13 +291,11 @@
|
||||
|
||||
.section-Description{
|
||||
inline-size: 680px;
|
||||
/* overflow-wrap: break-word;
|
||||
hyphens: manual; */
|
||||
/* overflow-wrap: break-word;
|
||||
hyphens: manual; */
|
||||
text-wrap: wrap;
|
||||
/* display: inline-flex; */
|
||||
/* margin-right: 10px; */
|
||||
/* margin-bottom: -40px; */
|
||||
margin-bottom: 10px;
|
||||
/* margin-right: 10px; */
|
||||
}
|
||||
.question-Description{
|
||||
inline-size: 660px;
|
||||
@ -371,11 +303,7 @@
|
||||
}
|
||||
.question-Group-Description{
|
||||
inline-size: 660px;
|
||||
text-wrap: wrap;
|
||||
position: relative;
|
||||
bottom: 30px;
|
||||
right: 12px;
|
||||
margin-bottom: 15px;
|
||||
text-wrap: wrap;
|
||||
}
|
||||
.text-group-align{
|
||||
/* display: flex; */
|
||||
@ -386,14 +314,11 @@
|
||||
margin-top: -54px;
|
||||
float: right;
|
||||
display:inline;
|
||||
position: relative;
|
||||
left: 10px;
|
||||
}
|
||||
.group-descrip{
|
||||
position: relative;
|
||||
top: 8px;
|
||||
margin-bottom: -26px;
|
||||
inline-size: 790px;
|
||||
top: -21px;
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
/* p.question_Text:not(:first-of-type) {
|
||||
margin-left: 34px;
|
||||
@ -448,12 +373,6 @@ color: #1d3557 !important;
|
||||
color: #1d3557 !important;
|
||||
}
|
||||
|
||||
math {
|
||||
position: relative;
|
||||
bottom: 24px;
|
||||
left: 21px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
@ -481,7 +400,7 @@ math {
|
||||
<div class="col-lg-12">
|
||||
<div class="nav-menu">
|
||||
<div class="header-logo">
|
||||
<a href="dashboard.html" ><img class="logo-d" src="assets/images/Nexa_Author Logo.png" alt="" style="position: relative !important; bottom: 11px !important;"></a>
|
||||
<a href="dashboard.html" ><img class="logo-d" src="assets/images/project-b-logo.png" alt=""></a>
|
||||
</div>
|
||||
<div class="heder-menu">
|
||||
<ul>
|
||||
@ -507,13 +426,12 @@ math {
|
||||
|
||||
<div class="copy-right-area">
|
||||
<div class="copy-left">
|
||||
<span id="copyright" style="color: #1D3557;"></span>
|
||||
<span style="color: #1D3557;">© 2023 Project-B. All rights reserved.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- jquery js -->
|
||||
<script src="assets/js/vendor/jquery-3.2.1.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
|
||||
<!-- <script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script> -->
|
||||
<script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
|
||||
<!-- mathjax -->
|
||||
<script src="./node_modules/mathjax/es5/tex-chtml-full.js"></script>
|
||||
<!-- bootstrap js -->
|
||||
@ -537,7 +455,7 @@ math {
|
||||
<!-- venobox min js -->
|
||||
<script src="venobox/venobox.min.js"></script>
|
||||
<!-- isotope js -->
|
||||
<!-- <script src="assets/js/isotope.pkgd.min.js"></script> -->
|
||||
<script src="assets/js/isotope.pkgd.min.js"></script>
|
||||
<!-- jquery nivo slider pack js -->
|
||||
<script src="assets/js/jquery.nivo.slider.pack.js"></script>
|
||||
<!-- jquery meanmenu js -->
|
||||
@ -557,17 +475,6 @@ math {
|
||||
|
||||
<script>
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var currentYear = new Date().getFullYear();
|
||||
var copyrightElement = document.getElementById('copyright');
|
||||
|
||||
if (copyrightElement) {
|
||||
// Update the year in the copyright notice
|
||||
var notice = "© " + currentYear + " Nexa Author. All rights reserved.";
|
||||
copyrightElement.innerHTML = notice;
|
||||
}
|
||||
});
|
||||
|
||||
$("#overlay").show();
|
||||
const fs = require('fs');
|
||||
const path =require('path');
|
||||
@ -615,7 +522,6 @@ function loadXML(xmlFileName) {
|
||||
if(filelist !== false)
|
||||
{
|
||||
//JSON File Read Function
|
||||
console.log(encodedJsonFilePath);
|
||||
fs.readFile(encodedJsonFilePath, 'utf8', (error, data) => {
|
||||
if (error) {
|
||||
console.error('Error reading file:', error);
|
||||
@ -818,7 +724,7 @@ try {
|
||||
|
||||
<!-- Start this is Add TItle Dynamic -->
|
||||
<script>
|
||||
var dynamicTitleValue = 'Nexa Author';
|
||||
var dynamicTitleValue = configObject.TITLE;
|
||||
document.getElementById("dynamicTitle").innerText = dynamicTitleValue;
|
||||
</script>
|
||||
<!-- End this is Add TItle Dynamic -->
|
||||
|
||||
@ -26,11 +26,4 @@ This README would normally document whatever steps are necessary to get your app
|
||||
### Who do I talk to? ###
|
||||
|
||||
* Repo owner or admin
|
||||
* Other community or team contact
|
||||
|
||||
|
||||
### Replace Quill to Jodit ##
|
||||
|
||||
* 06-01-2024 Saturday 11:28 AM
|
||||
* Reason : Quill Table is Not Working Properly
|
||||
* So we prefer JODIT Text editor
|
||||
* Other community or team contact
|
||||
6792
addform.html
2688
addform_old.html
Normal file
@ -1 +0,0 @@
|
||||
{"AppSetting":["WorkArea,MathCheckbox,TextQuestionButton,MCQQuestionButton"]}
|
||||
@ -1 +0,0 @@
|
||||
{"AppSetting":["SubTitle"]}
|
||||
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 18 KiB |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12"><path d="M2.22 2.22a.749.749 0 0 1 1.06 0L6 4.939 8.72 2.22a.749.749 0 1 1 1.06 1.06L7.061 6 9.78 8.72a.749.749 0 1 1-1.06 1.06L6 7.061 3.28 9.78a.749.749 0 1 1-1.06-1.06L4.939 6 2.22 3.28a.749.749 0 0 1 0-1.06Z" style="fill: #BF303B;"></path></svg>
|
||||
|
Before Width: | Height: | Size: 332 B |
@ -1,3 +0,0 @@
|
||||
<svg id="Layer_1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1">
|
||||
<path d="m460.256 204.036-112.732-123.706a7 7 0 0 0 -5.173-2.286h-18.8l-60.836-66.759a7 7 0 0 0 -5.174-2.285h-177.755c-16.47 0-29.868 14.4-29.868 32.094v360.767c0 17.7 13.4 32.1 29.867 32.1h54.944v36.949c0 17.7 13.4 32.1 29.867 32.1h267.618c16.47 0 29.868-14.4 29.868-32.1v-262.16a7 7 0 0 0 -1.826-4.714zm-21.024-2.286h-89.519l-.308-98.571zm-359.447 218.206c-8.749 0-15.867-8.117-15.867-18.1v-360.762c0-9.977 7.118-18.094 15.868-18.094h174.663l50.161 55.044h-140.01c-16.469 0-29.867 14.4-29.867 32.094v309.818zm352.429 69.044h-267.614c-8.749 0-15.867-8.117-15.867-18.1v-360.762c0-9.977 7.118-18.094 15.867-18.094h170.771l.363 116.728a7 7 0 0 0 7 6.978h105.348v255.155c0 9.978-7.118 18.095-15.868 18.095zm-35.2-227.25a7 7 0 0 1 -7 7h-183.221a7 7 0 0 1 0-14h183.224a7 7 0 0 1 7 7zm0 61a7 7 0 0 1 -7 7h-183.221a7 7 0 0 1 0-14h183.224a7 7 0 0 1 7 7zm0 61a7 7 0 0 1 -7 7h-183.221a7 7 0 0 1 0-14h183.224a7 7 0 0 1 7 7z" style="fill: #BF303B;" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path opacity="1" fill="#1E3050" d="M0 96C0 60.7 28.7 32 64 32H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h96 32H424c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>
|
||||
|
Before Width: | Height: | Size: 667 B |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 25 KiB |
@ -1,4 +0,0 @@
|
||||
|
||||
|
||||
|
||||
var a =document.
|
||||
@ -1,328 +0,0 @@
|
||||
|
||||
var dragStartElement= null;
|
||||
var dragDropElement=null;
|
||||
var draggedItem = null;
|
||||
|
||||
//DragStart Function
|
||||
function dragStart(a,e){
|
||||
// console.log("Start->",a.id);
|
||||
dragStartElement = a;
|
||||
a.classList.add('draggedElementStart');
|
||||
// draggedItem = this;
|
||||
// e.dataTransfer.effectAllowed = 'move';
|
||||
// e.dataTransfer.setData('text/html', this.innerHTML);
|
||||
}
|
||||
|
||||
//DragOver Function
|
||||
function dragOver(element , event) {
|
||||
var sectionArea = element.parentNode.previousElementSibling
|
||||
if (sectionArea.id.replace(/\d/g, '') == "nav_section_title_" || element.id.replace(/\d+/g, '') == "nav_section_title_") {
|
||||
element.style.border = '2px solid rgba(255, 0, 0, 0.5)';
|
||||
}else {
|
||||
element.style.border = '2px solid rgba(128, 128, 128, 0.5)';
|
||||
}
|
||||
|
||||
// console.log("Over -> ",element.id);
|
||||
|
||||
// element.classList.add("dragOverElement")
|
||||
|
||||
// if (element.id.replace(/\d/g, '') == "nav_removeAndCloneTextQuestion_" || element.id.replace(/\d/g, '') == 'nav_removeAndCloneQroupQuestion_') {
|
||||
// element.style.border = '2px solid rgba(169, 169, 0, 0.5)';
|
||||
// } else if(element.id.replace(/\d/g, '') == "nav_draggedGroup_"){
|
||||
// element.style.border = '2px solid rgba(128, 128, 128, 0.5)';
|
||||
// }else{
|
||||
// element.style.border = '2px solid rgba(255, 0, 0, 0.5)';
|
||||
// }
|
||||
|
||||
// console.log(element);
|
||||
element.style.borderRadius = '5px';
|
||||
dragDropElement = element;
|
||||
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
}
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function dragLeave(element, event) {
|
||||
element.style.border = 'none';
|
||||
// element.classList.remove('dragOverElement');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//DragEnd Function
|
||||
function dragEnd(element, e) {
|
||||
// console.log("DragEnd -> ",element.id);
|
||||
element.classList.remove('draggedElementStart');
|
||||
// element.classList.remove('dragOverElement');
|
||||
|
||||
}
|
||||
|
||||
|
||||
//DragDrop
|
||||
async function dragDrop(element,e) {
|
||||
element.style.border = 'none';
|
||||
// element.classList.remove('dragOverElement');
|
||||
// console.log("DragDrop -> ", element.id);
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
//Nav Pane full Element
|
||||
const container = document.getElementById('questionPaper');
|
||||
const dropTarget = e.target;
|
||||
// console.log('dropTarget : ', dropTarget)
|
||||
if (container.contains(dropTarget)) {
|
||||
//Before Insert OF the HTML Node
|
||||
if (e.clientY < dropTarget.getBoundingClientRect().top + dropTarget.clientHeight / 2) {
|
||||
console.log("BEFORE INSERTS....");
|
||||
//Check Start And Drop Element true And Two Not equal to
|
||||
if (dragStartElement && dragDropElement && dragStartElement !== dragDropElement) {
|
||||
// var list = document.getElementById(dragDropElement.id);
|
||||
//Check Drop Element is Group Question
|
||||
if (dragDropElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
//Check First Element is Group Question
|
||||
if (dragStartElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
var dragStartElementChild = dragStartElement.nextElementSibling;
|
||||
// var addbefore = dragStartElement.previousElementSibling;
|
||||
dragDropElement.parentNode.insertBefore(dragStartElement,dragDropElement);
|
||||
// dragStartElement.parentNode.insertBefore(addbefore , dragStartElement)
|
||||
dragDropElement.parentNode.insertBefore(dragStartElementChild , dragDropElement);
|
||||
insertElement(dragStartElement, dragDropElement,"before")
|
||||
} else {
|
||||
dragDropElement.parentNode.insertBefore(dragStartElement,dragDropElement)
|
||||
insertElement(dragStartElement, dragDropElement,"before")
|
||||
}
|
||||
}else if (dragDropElement.id.replace(/\d+/g, '') == "nav_section_title_") {
|
||||
|
||||
}
|
||||
else {
|
||||
dragDropElement.parentNode.insertBefore( dragStartElement, dragDropElement);
|
||||
insertElement(dragStartElement,dragDropElement,"before");
|
||||
}
|
||||
}
|
||||
}
|
||||
//After Insert of the HTML Node
|
||||
else {
|
||||
console.log("AFTER INSERT .....");
|
||||
//Check Start And Drop Element true And Two Not equal to
|
||||
if (dragStartElement && dragDropElement && dragStartElement !== dragDropElement) {
|
||||
// var list = document.getElementById(dragDropElement.id);
|
||||
//Check Drop Element is Group Question
|
||||
// console.log('First If');
|
||||
if (dragDropElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
// console.log('Second If');
|
||||
if (dragStartElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
// console.log('third If');
|
||||
var dragDropElementChild = dragDropElement.nextElementSibling.dragStartElementChild;
|
||||
var dragStartElementChild = dragStartElement.nextElementSibling;
|
||||
if (dragDropElementChild) {
|
||||
// console.log('Fourth If');
|
||||
dragDropElementChild.parentNode.insertBefore(dragStartElement , dragDropElementChild)
|
||||
dragDropElementChild.parentNode.insertBefore(dragStartElementChild, dragDropElementChild)
|
||||
insertElement(dragStartElement,dragDropElement,"after");
|
||||
} else {
|
||||
// console.log('Fourth If else');
|
||||
dragDropElementChild = dragDropElement.nextElementSibling;
|
||||
dragDropElementChild.appendChild(dragStartElement)
|
||||
dragDropElementChild.appendChild(dragStartElementChild)
|
||||
insertElement(dragStartElement, dragDropElement,"after")
|
||||
// console.log(dragDropElementChild);
|
||||
}
|
||||
} else {
|
||||
var dragDropElementNextElement=dragDropElement.nextElementSibling.firstChild;
|
||||
if (dragDropElementNextElement) {
|
||||
dragDropElementNextElement.parentNode.insertBefore(dragStartElement, dragDropElementNextElement)
|
||||
insertElement(dragStartElement ,dragDropElement,"after")
|
||||
} else {
|
||||
dragDropElementNextElement = dragDropElement.nextElementSibling;
|
||||
dragDropElementNextElement.appendChild(dragStartElement);
|
||||
insertElement(dragStartElement , dragDropElement, "after")
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check Drop Element is Section
|
||||
else if(dragDropElement.id.replace(/\d+/g, '') == "nav_section_title_"){
|
||||
// console.log('Second else If');
|
||||
var dragDropElementChild = dragDropElement.nextElementSibling.firstChild;
|
||||
if (dragDropElementChild) {
|
||||
dragDropElementChild.parentNode.insertBefore(dragStartElement , dragDropElementChild);
|
||||
insertElement(dragStartElement, dragDropElement);
|
||||
} else {
|
||||
if (dragStartElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
var firstChild = dragStartElement.nextElementSibling;
|
||||
dragDropElementChild = dragDropElement.nextElementSibling;
|
||||
dragDropElementChild.appendChild(dragStartElement);
|
||||
dragDropElementChild.appendChild(firstChild)
|
||||
} else {
|
||||
dragDropElementChild = dragDropElement.nextElementSibling;
|
||||
dragDropElementChild.appendChild(dragStartElement);
|
||||
insertElement(dragStartElement, dragDropElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
//THis Entered in Text and Choice Question
|
||||
else {
|
||||
// console.log('Second If else');
|
||||
//Check the Start Element is Group Question
|
||||
if (dragStartElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
|
||||
// console.log('Second if else if')
|
||||
var parent = dragDropElement.parentNode;
|
||||
// console.log('parent : ', parent)
|
||||
var lastChild = parent.lastChild;
|
||||
// console.log('lastChild : ', lastChild);
|
||||
var dragStartElementChild = dragStartElement.nextElementSibling;
|
||||
parent.insertBefore(dragStartElement, lastChild.nextElementSibling);
|
||||
parent.insertBefore(dragStartElementChild , dragStartElement.nextElementSibling);
|
||||
insertElement(dragStartElement , dragDropElement , "after");
|
||||
}
|
||||
// this Entered Text and Choice Question
|
||||
else {
|
||||
// console.log('Second if else else')
|
||||
dragDropElement.parentNode.insertBefore( dragStartElement, dragDropElement.nextElementSibling);
|
||||
insertElement(dragStartElement,dragDropElement,"after");
|
||||
// dragStartElement = null;
|
||||
// dragDropElement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//THis function is Replicate the Nav Pane Change
|
||||
function insertElement(dragStartElement, dragDropElement, position){
|
||||
|
||||
|
||||
var mainpaneSection = document.getElementById('addNewSection')
|
||||
var matches = dragDropElement.id.match(/([a-zA-Z_]+)([0-9]+)/);
|
||||
|
||||
var Section = document.getElementById('question_area_'+matches[2]);
|
||||
var innerElementCount = ''
|
||||
if(Section){
|
||||
innerElementCount = Section.childElementCount;
|
||||
}
|
||||
else{
|
||||
innerElementCount = 1;
|
||||
}
|
||||
|
||||
if(innerElementCount === 0){
|
||||
var QuestionStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var QuestionDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
|
||||
//Check First Element is Group
|
||||
if (QuestionStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
if (QuestionStartElement && Section && QuestionStartElement !== Section) {
|
||||
Section.appendChild(QuestionStartElement)
|
||||
}
|
||||
} else {
|
||||
if (QuestionStartElement && Section && QuestionStartElement !== Section) {
|
||||
Section.appendChild(QuestionStartElement)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
//Check All is true this for
|
||||
if (dragStartElement && dragDropElement && position) {
|
||||
|
||||
//Check IS before
|
||||
if (position == "before") {
|
||||
//Check DragFirst Element have id
|
||||
if (!dragStartElement.id) {
|
||||
var dragStartElementChild = dragStartElement.dragStartElementChild
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElementChild.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
}
|
||||
} else {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
// After element Node Added
|
||||
else {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
|
||||
// console.log('maindragDropElement : ', maindragDropElement);
|
||||
|
||||
// End Element is Section
|
||||
if (maindragDropElement.id.replace(/\d+/g, '') == "section_title_") {
|
||||
//Check First Element is Group
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area')
|
||||
// console.log('groupQuestionAddSection : ', groupQuestionAddSection);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddSection.appendChild(maindragStartElement)
|
||||
// test.parentNode.insertBefore(maindragStartElement, test)
|
||||
}
|
||||
} else {
|
||||
var textAndChoiceAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area');
|
||||
// console.log('textAndChoiceAddSection : ', textAndChoiceAddSection);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
textAndChoiceAddSection.parentNode.insertBefore(maindragStartElement, textAndChoiceAddSection)
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check the Second Element is Group Question
|
||||
else if(maindragDropElement.id.replace(/\d+/g, '') == "draggedGroup_"){
|
||||
//Check First Element is Group Question
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddGroupQuestion = maindragDropElement.querySelector('.nested-sortable');
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddGroupQuestion.appendChild(maindragStartElement)
|
||||
}
|
||||
}
|
||||
//This allows Text and Choice
|
||||
else {
|
||||
var groupQuestionAddTextChoice= maindragDropElement.querySelector('.nested-sortable').dragStartElementChild;
|
||||
if (groupQuestionAddTextChoice) {
|
||||
groupQuestionAddTextChoice.parentNode.insertBefore(maindragStartElement , groupQuestionAddTextChoice)
|
||||
} else {
|
||||
var groupQuestionAdd = maindragDropElement.querySelector('.nested-sortable')
|
||||
// console.log(groupQuestionAdd);
|
||||
groupQuestionAdd.appendChild(maindragStartElement)
|
||||
// console.log(groupQuestionAdd);
|
||||
// alert("111")
|
||||
// test.parentNode.insertBefore(maindragStartElement , test)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// console.log('parentNode : ', maindragDropElement.parentNode);
|
||||
// console.log('maindragStartElement : ', maindragStartElement);
|
||||
maindragDropElement.parentNode.insertBefore(maindragStartElement , maindragDropElement.nextSibling)
|
||||
}
|
||||
}
|
||||
}
|
||||
//no need
|
||||
else {
|
||||
|
||||
console.log('ELSE');
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement.nextElementSibling);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const strippedId = dragStartElement.id.replace('nav_', '');
|
||||
console.log(strippedId);
|
||||
|
||||
const element = document.getElementById(`${strippedId}`);
|
||||
console.log(element);
|
||||
if (element) {
|
||||
|
||||
element.focus();
|
||||
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
/* .section.main-heading:hover{
|
||||
background-color: gray;
|
||||
color: #333;
|
||||
} */
|
||||
/* .sectionHoverClass:hover{
|
||||
background-color: aquamarine;
|
||||
} */
|
||||
|
||||
/* .sectionHoverClass {
|
||||
width: 500px;
|
||||
height: 30px;
|
||||
background-color: white;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.sectionHoverClass:active {
|
||||
background-color: aquamarine;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.questionDragHover {
|
||||
width: 500px;
|
||||
height: 30px;
|
||||
background-color: white;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.questionDragHover:hover{
|
||||
height: 60px;
|
||||
}
|
||||
.questionDragHover:active {
|
||||
background-color: aquamarine;
|
||||
} */
|
||||
|
||||
|
||||
|
||||
|
||||
/* .draggedElementStart{
|
||||
height: 30px;
|
||||
font-weight: 50%;
|
||||
|
||||
} */
|
||||
|
||||
/* .draggedElementLeave{
|
||||
|
||||
background-color: #ccc;
|
||||
} */
|
||||
|
||||
|
||||
.dragOverElement{
|
||||
/* width: 270px; */
|
||||
/* padding: 40px 0px 0px 0px 0px ; */
|
||||
/* margin-left: -20px; */
|
||||
/* border: 2px solid #000; */
|
||||
border: 2px solid rgba(0, 0, 0, 0.5);
|
||||
border-radius: 10px;
|
||||
/* height: 50px; */
|
||||
/* padding-left: 200px; */
|
||||
|
||||
/* background-color: #ccc; */
|
||||
}
|
||||
|
||||
|
||||
.fa-grip-horizontal{
|
||||
/* position: absolute; */
|
||||
/* right: -72px !important; */
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
|
||||
|
||||
|
||||
module.exports.takeNumberOnly = function (text) {
|
||||
let number = text.match(/\d+/)[0];
|
||||
return number
|
||||
}
|
||||
|
||||
|
||||
|
||||
502
dashboard.html
@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title id="dynamicTitle"></title>
|
||||
<!-- <title>Project-B</title> -->
|
||||
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
@ -44,99 +45,12 @@
|
||||
<!-- <link href='https://fonts.googleapis.com/css?family=Titillium+Web:400,600' rel='stylesheet' type='text/css'> -->
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap-icons/font/bootstrap-icons.css">
|
||||
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css"> -->
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.switch-label {
|
||||
width: 20px !important;
|
||||
/* width: -webkit-fill-available; */
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
margin-right: 10px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.option {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.option + .switch-label {
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.option + .switch-label::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 30px;
|
||||
height: 15px;
|
||||
background-color: #ccc;
|
||||
border-radius: 15px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.option + .switch-label::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 7px;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%); /* Center vertically and horizontally */
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
transition: left 0.3s;
|
||||
}
|
||||
|
||||
.option:checked + .switch-label::before {
|
||||
background-color: #BF303B;
|
||||
}
|
||||
|
||||
.option:checked + .switch-label::after {
|
||||
left: calc(93% - 16px); /* Adjusted for circle size */
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
#popupTitleId{
|
||||
text-align: center;
|
||||
font-size: 30px;
|
||||
/* color: black; */
|
||||
font-weight: bold;
|
||||
margin-top: 48px;
|
||||
}
|
||||
|
||||
.popup {
|
||||
width: 379px;
|
||||
height: 420px;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
/* width: 300px; */
|
||||
background-color: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
padding: 20px;
|
||||
margin-top: 25px;
|
||||
margin-left: 57px;
|
||||
}
|
||||
|
||||
.blur-background {
|
||||
filter: blur(5px);
|
||||
}
|
||||
|
||||
|
||||
/* The Modal (background) */
|
||||
.modal {
|
||||
display: none; /* Hidden by default */
|
||||
@ -313,13 +227,12 @@ margin-left: -16px;
|
||||
<div class="col-lg-12">
|
||||
<div class="nav-menu">
|
||||
<div class="header-logo">
|
||||
<a href="dashboard.html"><img class="logo-d" src="assets/images/Nexa_Author Logo.png" alt=""></a>
|
||||
<a href="dashboard.html" ><img class="logo-d" src="assets/images/project-b-logo.png" alt=""></a>
|
||||
</div>
|
||||
<div class="heder-menu">
|
||||
<ul>
|
||||
<li><a href="addform.html"><img class="addPageMenu" src="assets/images/new.svg" alt="">New</a></li>
|
||||
<li><a href="#" id="myBtn"><img class="addPageMenu" src="assets/images/open.svg" alt="">Open</a></li>
|
||||
<li><a href="#" id="settingButton"><img class="addPageMenu" src="assets/images/settings.png" alt="" style="width: 19px;">Settings</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -356,11 +269,11 @@ margin-left: -16px;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="copy-right-area">
|
||||
<div class="copy-left">
|
||||
<span id="copyright" style="color: #1D3557;"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copy-right-area">
|
||||
<div class="copy-left">
|
||||
<span style="color: #1D3557;">© 2023 Project-B. All rights reserved.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- jquery js -->
|
||||
<script src="assets/js/vendor/jquery-3.2.1.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
|
||||
@ -406,18 +319,7 @@ margin-left: -16px;
|
||||
|
||||
|
||||
<!-- jquery js -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var currentYear = new Date().getFullYear();
|
||||
var copyrightElement = document.getElementById('copyright');
|
||||
|
||||
if (copyrightElement) {
|
||||
// Update the year in the copyright notice
|
||||
var notice = "© " + currentYear + " Nexa Author. All rights reserved.";
|
||||
copyrightElement.innerHTML = notice;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var configObject = convertBaseToString();
|
||||
@ -696,186 +598,6 @@ if (fileList !== false) {
|
||||
|
||||
|
||||
|
||||
function duplicateFile(oldfilename) {
|
||||
|
||||
var filename ='';
|
||||
|
||||
Swal.fire({
|
||||
title: 'Enter Filename',
|
||||
input: 'text',
|
||||
inputValue: '',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Submit',
|
||||
cancelButtonText: 'Cancel',
|
||||
inputValidator: (value) => {
|
||||
// console.log(value);
|
||||
|
||||
|
||||
function removeXmlExtension(value) {
|
||||
if (value.endsWith('.xml')) {
|
||||
return value.slice(0, -4);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
const entervalue = removeXmlExtension(value);
|
||||
|
||||
if (value == '') {
|
||||
return 'You need to enter Filename!'
|
||||
}
|
||||
else if (value){
|
||||
|
||||
const xmlFilePath = `${xmlPath}`;
|
||||
const xmlFileNameParts = oldfilename.split('.xml');
|
||||
const xmlBaseName = xmlFileNameParts[0];
|
||||
const jsonFileName = `${xmlBaseName}_answer.json`;
|
||||
const jsonFilePath = `${xmlPath}${jsonFileName}`;
|
||||
|
||||
|
||||
const newXmlFileNameParts = entervalue;
|
||||
// const newXmlBaseName = newXmlFileNameParts[0];
|
||||
const newJsonFileName = `${newXmlFileNameParts}_answer.json`;
|
||||
|
||||
var fileList = findFile(jsonFilePath);
|
||||
|
||||
const downloadsPath = xmlPath;
|
||||
|
||||
|
||||
const isEncrypted = configObject.ENCRYPTED.trim();
|
||||
|
||||
const filePathToSave = path.join(downloadsPath);
|
||||
const jsonFilePathToSave = path.join(downloadsPath);
|
||||
|
||||
|
||||
|
||||
if(isEncrypted == 'YES'){
|
||||
// const content = fs.readFileSync(`${xmlFilePath}${oldfilename}`, 'utf-8');
|
||||
const content =decode(`${xmlFilePath}${oldfilename}`);
|
||||
const encrypt = encode(content);
|
||||
try {
|
||||
fs.writeFileSync(`${xmlFilePath}${entervalue}.xml`, encrypt, 'utf-8');
|
||||
Swal.fire({
|
||||
title: "File Duplicated",
|
||||
icon: "success"
|
||||
});
|
||||
} catch (err) {
|
||||
let errorMessage = "";
|
||||
if (err.code === 'EACCES') {
|
||||
errorMessage = `Permission Denied.<br> Path: ${filePathToSave}`;
|
||||
} else if (err.code === 'ENOENT') {
|
||||
errorMessage = `No Such File Directory. <br> Path: ${filePathToSave}`;
|
||||
} else {
|
||||
errorMessage = `Unknown Error. <br> Path: ${filePathToSave}`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: "File Duplicate Failed",
|
||||
html: errorMessage,
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
|
||||
if (fileList !== false)
|
||||
{
|
||||
try {
|
||||
const content =decode(jsonFilePath);
|
||||
const encrypt = encode(content);
|
||||
// console.log('json', content);
|
||||
fs.writeFileSync(`${jsonFilePathToSave}${newJsonFileName}`, encrypt, 'utf-8');
|
||||
Swal.fire({
|
||||
title: "File Duplicated",
|
||||
icon: "success"
|
||||
});
|
||||
} catch (err) {
|
||||
let errorMessage = "";
|
||||
if (err.code === 'EACCES') {
|
||||
errorMessage = `Permission Denied.<br> Path: ${jsonFilePathToSave}`;
|
||||
} else if (err.code === 'ENOENT') {
|
||||
errorMessage = `No Such File Directory. <br> Path: ${jsonFilePathToSave}`;
|
||||
} else {
|
||||
errorMessage = `Unknown Error. <br> Path: ${jsonFilePathToSave}`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: "File Duplicate Failed",
|
||||
html: errorMessage,
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
try {
|
||||
const content = fs.readFileSync(`${xmlFilePath}${oldfilename}`, 'utf-8');
|
||||
fs.writeFileSync(`${xmlFilePath}${entervalue}.xml`, content, 'utf-8');
|
||||
Swal.fire({
|
||||
title: "File Duplicated",
|
||||
icon: "success"
|
||||
});
|
||||
} catch (err) {
|
||||
let errorMessage = "";
|
||||
if (err.code === 'EACCES') {
|
||||
errorMessage = `Permission Denied.<br> Path: ${filePathToSave}`;
|
||||
} else if (err.code === 'ENOENT') {
|
||||
errorMessage = `No Such File Directory. <br> Path: ${filePathToSave}`;
|
||||
} else {
|
||||
errorMessage = `Unknown Error. <br> Path: ${filePathToSave}`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: "File Duplicate Failed",
|
||||
html: errorMessage,
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
|
||||
// Duplicate JSON File
|
||||
if (fileList !== false)
|
||||
{
|
||||
try {
|
||||
const content = fs.readFileSync(jsonFilePath, 'utf-8');
|
||||
// console.log('json', content);
|
||||
fs.writeFileSync(`${jsonFilePathToSave}${newJsonFileName}`, content, 'utf-8');
|
||||
Swal.fire({
|
||||
title: "File Duplicated",
|
||||
icon: "success"
|
||||
});
|
||||
} catch (err) {
|
||||
let errorMessage = "";
|
||||
if (err.code === 'EACCES') {
|
||||
errorMessage = `Permission Denied.<br> Path: ${jsonFilePathToSave}`;
|
||||
} else if (err.code === 'ENOENT') {
|
||||
errorMessage = `No Such File Directory. <br> Path: ${jsonFilePathToSave}`;
|
||||
} else {
|
||||
errorMessage = `Unknown Error. <br> Path: ${jsonFilePathToSave}`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: "File Duplicate Failed",
|
||||
html: errorMessage,
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const inputValue = result.value
|
||||
savexml(inputValue)
|
||||
}else if(result.isDenied){
|
||||
savexml(RawFileName)
|
||||
}
|
||||
window.location.reload();
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Function for Finding the JSON File in the folder
|
||||
function findFile(filePath) {
|
||||
try {
|
||||
@ -927,216 +649,12 @@ function copyFile(sourceFilePath, destinationFilePath) {
|
||||
|
||||
<!-- Start this is Add TItle Dynamic -->
|
||||
<script>
|
||||
var dynamicTitleValue = 'Nexa Author';
|
||||
var dynamicTitleValue = configObject.TITLE;
|
||||
document.getElementById("dynamicTitle").innerText = dynamicTitleValue;
|
||||
</script>
|
||||
<!-- End this is Add TItle Dynamic -->
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
const settingBtn = document.getElementById('settingButton');
|
||||
const overlay = document.getElementById('overlay');
|
||||
|
||||
settingBtn.onclick = function() {
|
||||
openPopup();
|
||||
};
|
||||
|
||||
function openPopup() {
|
||||
var headermenu = document.querySelector('.heder-menu')
|
||||
|
||||
headermenu.style.display= 'none';
|
||||
|
||||
const popup = document.createElement('div');
|
||||
popup.className = 'popup';
|
||||
|
||||
const iconElement = document.createElement('i');
|
||||
iconElement.className = 'fas fa-icon-class';
|
||||
iconElement.style = "margin-right: 15px; margin-top: 15px;float: right;";
|
||||
iconElement.onclick = closePopup;
|
||||
|
||||
const iconimage = document.createElement('img');
|
||||
iconimage.src= "assets/images/close.svg";
|
||||
iconimage.style="width: 25px";
|
||||
iconElement.appendChild(iconimage)
|
||||
|
||||
const popupTitle = document.createElement('p');
|
||||
popupTitle.id='popupTitleId';
|
||||
popupTitle.textContent = 'App Settings';
|
||||
|
||||
const popupContent = document.createElement('div');
|
||||
popupContent.className = 'popup-content';
|
||||
|
||||
const radioOptions = [
|
||||
{value: 'WorkArea', label: 'Work Area'},
|
||||
{value: 'SubTitle', label: 'Sub Title'},
|
||||
{value: 'MathCheckbox', label: 'Math'},
|
||||
{value: 'TextQuestionButton', label: 'Text Question'},
|
||||
{value: 'MCQQuestionButton', label: 'MCQ Question '}
|
||||
];
|
||||
|
||||
radioOptions.forEach(option => {
|
||||
const checkboxInput = document.createElement('input');
|
||||
checkboxInput.type = 'checkbox';
|
||||
checkboxInput.name = option.value; // Set name attribute if needed
|
||||
checkboxInput.value = option.value; // Set value attribute if needed
|
||||
checkboxInput.id = `switch-${option.value}`; // Set unique id for each checkbox
|
||||
checkboxInput.className = 'option'; // Add class name if needed
|
||||
popupContent.appendChild(checkboxInput);
|
||||
|
||||
// Create label for the checkbox
|
||||
const label = document.createElement('label');
|
||||
// label.textContent = option.label; // Set label text
|
||||
label.setAttribute('for', `switch-${option.value}`); // Set for attribute to match the checkbox's id attribute
|
||||
label.className = 'switch-label'; // Add class name if needed
|
||||
popupContent.appendChild(label);
|
||||
|
||||
const label2 = document.createElement('label');
|
||||
label2.textContent = option.label;
|
||||
popupContent.appendChild(label2);
|
||||
|
||||
|
||||
popupContent.appendChild(document.createElement('br'));
|
||||
});
|
||||
|
||||
// Add submit button
|
||||
const submitButton = document.createElement('button');
|
||||
submitButton.style=style="width: 142px; border-radius: 10px; margin-left: 41px; margin-top: 28px; border-color: #BF303B; /* color: #BF3054; */ /* background-color: #BF303B; */";
|
||||
submitButton.textContent = 'Submit';
|
||||
submitButton.type = 'button'; // Set type to button to prevent form submission
|
||||
submitButton.addEventListener('click', () => {
|
||||
submitValues();
|
||||
closePopup();
|
||||
});
|
||||
popupContent.appendChild(submitButton);
|
||||
|
||||
popup.appendChild(iconElement);
|
||||
popup.appendChild(popupTitle)
|
||||
popup.appendChild(popupContent);
|
||||
document.body.appendChild(popup);
|
||||
|
||||
// Show overlay
|
||||
overlay.style.display = 'block';
|
||||
}
|
||||
|
||||
// Function to close popup and hide overlay
|
||||
function closePopup() {
|
||||
var headermenu = document.querySelector('.heder-menu')
|
||||
|
||||
headermenu.style.display= 'block';
|
||||
|
||||
const popup = document.querySelector('.popup');
|
||||
if (popup) {
|
||||
popup.parentNode.removeChild(popup);
|
||||
}
|
||||
// Hide overlay
|
||||
overlay.style.display = 'none';
|
||||
}
|
||||
|
||||
// Function to submit selected values to server
|
||||
function submitValues() {
|
||||
var headermenu = document.querySelector('.heder-menu')
|
||||
|
||||
headermenu.style.display= 'block';
|
||||
|
||||
// const selectedValues = Array.from(document.querySelectorAll('input[class=option]:checked')).map(input => input.value);
|
||||
|
||||
const allOptions = Array.from(document.querySelectorAll('input[class=option]'));
|
||||
|
||||
const uncheckedValues = allOptions.filter(input => !input.checked).map(input => input.value);
|
||||
|
||||
const checkedValues = allOptions.filter(input => input.checked).map(input => input.value);
|
||||
|
||||
|
||||
|
||||
const array = checkedValues;
|
||||
const string = array.join(',');
|
||||
const jsonString = JSON.stringify(string);
|
||||
const wrappedJsonString = `{"AppSetting":[${jsonString}]}`;
|
||||
|
||||
|
||||
//ForUnchecked
|
||||
const string2 = uncheckedValues.join(',')
|
||||
const jsonString2 = JSON.stringify(string2);
|
||||
const wrappedJsonString2 = `{"AppSetting":[${jsonString2}]}`;
|
||||
|
||||
|
||||
const newPath = xmlPath.replace(/\\xml\\/i, '\\');
|
||||
|
||||
const savexmlpath = path.join(__dirname, `./assets/appSetting/AppSetting.json`);
|
||||
const savexmlpath2 = path.join(__dirname, `./assets/appSetting/AppSettingUnchecked.json`);
|
||||
|
||||
|
||||
fs.writeFileSync(savexmlpath, wrappedJsonString, 'utf-8');
|
||||
fs.writeFileSync(savexmlpath2, wrappedJsonString2, 'utf-8');
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function popupCheck() {
|
||||
const filePath = path.join(__dirname, `./assets/appSetting/AppSetting.json`);
|
||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.error('Error reading file:', err);
|
||||
return;
|
||||
}
|
||||
const jsonObject = JSON.parse(data);
|
||||
|
||||
var aa= jsonObject.AppSetting;
|
||||
const inputString = aa[0];
|
||||
|
||||
const valuesArray = inputString.split(',');
|
||||
valuesArray.forEach(value => {
|
||||
|
||||
if(value === 'WorkArea'){
|
||||
var elements = document.querySelector('[name="WorkArea"]');
|
||||
if (elements) {
|
||||
elements.checked = true;
|
||||
}
|
||||
|
||||
}else if( value === 'SubTitle'){
|
||||
var elements = document.querySelector('[name="SubTitle"]');
|
||||
if (elements) {
|
||||
elements.checked = true;
|
||||
}
|
||||
|
||||
}else if(value === 'MathCheckbox'){
|
||||
var elements = document.querySelector('[name="MathCheckbox"]');
|
||||
if (elements) {
|
||||
elements.checked = true;
|
||||
}
|
||||
}else if(value === 'TextQuestionButton'){
|
||||
var elements = document.querySelector('[name="TextQuestionButton"]');
|
||||
if (elements) {
|
||||
elements.checked = true;
|
||||
}
|
||||
}else if(value === 'MCQQuestionButton'){
|
||||
var elements = document.querySelector('[name="MCQQuestionButton"]');
|
||||
if (elements) {
|
||||
elements.checked = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
var settingButtonParent = document.getElementById('settingButton').parentElement;
|
||||
|
||||
if (settingButtonParent) {
|
||||
settingButtonParent.addEventListener('click', function(event) {
|
||||
popupCheck();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// popupCheck();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -93,7 +93,7 @@ function envConverter(value) {
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
// console.log(args);
|
||||
console.log(args);
|
||||
envConverter(args[0]);
|
||||
|
||||
module.exports = convertBaseToString;
|
||||
|
||||
66
html2json.js
@ -3,34 +3,21 @@ function html2json() {
|
||||
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
var questionTitleIdSet = document.getElementById('QuestionTextIdSet_'+element_id).value;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||
var questionUUID = document.getElementById('Text_Question_UUID_ID_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||
var isMathEnabled2 = document.getElementById('titlemath_' + element_id).checked;
|
||||
var displayMarks = document.getElementById('Text_Question_Display_Marks_Id_' + element_id).checked;
|
||||
var questionTitle = "";
|
||||
var questionSubTitle = "";
|
||||
|
||||
//for Descriptive question Description math check
|
||||
if(isMathEnabled == true){
|
||||
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||
}else{
|
||||
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).innerHTML;
|
||||
}
|
||||
|
||||
//for Descriptive question Title math check
|
||||
if(isMathEnabled2 == true){
|
||||
|
||||
questionTitle = document.getElementById('textQuestiontitleMath_' + element_id).value;
|
||||
}else{
|
||||
|
||||
questionTitle = document.getElementById('textQuestionName_' + element_id).innerHTML;
|
||||
else
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
|
||||
// var questionSubType = document.getElementById('longAnswer_' + element_id).checked;
|
||||
var questionSubType = 'false';
|
||||
|
||||
@ -41,7 +28,6 @@ function html2json() {
|
||||
"question_type": questionType,
|
||||
"question_sub_type": questionSubType,
|
||||
"is_math_enabled": isMathEnabled,
|
||||
"is_math_enabled2": isMathEnabled2,
|
||||
"display_marks": displayMarks,
|
||||
"marks":marks,
|
||||
"text_question_uuid":questionUUID,
|
||||
@ -51,37 +37,24 @@ function html2json() {
|
||||
$.fn.getChoiceQuestion = function(element_id) {
|
||||
|
||||
var questionChoiceId = document.getElementById('QuestionChoiceId_' + element_id).value;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).innerHTML;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
||||
var questionUUID = document.getElementById('Choice_Question_UUID_ID_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||
var isMathEnabled2 = document.getElementById('titlemath_' + element_id).checked;
|
||||
var displayMarks = document.getElementById('Choice_Question_Display_Marks_Id_' + element_id).checked;
|
||||
var questionTitle = "";
|
||||
var questionSubTitle = "";
|
||||
// var choiceQuestiondiv = document.getElementById('removeAndCloneQroupQuestion_' + element_id)
|
||||
var choiceQuestioncheckInput = document.getElementById('ChoiceCorrectAnswer_' + element_id)
|
||||
|
||||
//for MultiChoice question Description math check
|
||||
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).innerHTML;
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
|
||||
//for MultiChoice question Title math check
|
||||
if(isMathEnabled2 == true){
|
||||
|
||||
questionTitle = document.getElementById('textQuestiontitleMath_' + element_id).value;
|
||||
}else{
|
||||
|
||||
questionTitle = document.getElementById('textQuestionName_' + element_id).innerHTML;
|
||||
}
|
||||
|
||||
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
// console.log(questionType);
|
||||
var questionSubType = document.getElementById('multipleAnswer_' + element_id).checked;
|
||||
@ -98,7 +71,7 @@ function html2json() {
|
||||
}
|
||||
else
|
||||
{
|
||||
choice_name = document.getElementById('choiceTextField_' + element_id).innerHTML;
|
||||
choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
var choice_group_fixed_uuid = document.getElementById('Choice_Group_Fixed_UUID_ID_' + element_id).value;
|
||||
answers.push({
|
||||
@ -140,7 +113,7 @@ function html2json() {
|
||||
}
|
||||
else
|
||||
{
|
||||
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).innerHTML;
|
||||
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
// console.log('choice_description id in the html to json script');
|
||||
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
||||
@ -169,7 +142,6 @@ function html2json() {
|
||||
"question_type": questionType,
|
||||
"question_sub_type": questionSubType,
|
||||
"is_math_enabled": isMathEnabled,
|
||||
"is_math_enabled2": isMathEnabled2,
|
||||
"display_marks": displayMarks,
|
||||
"marks":marks,
|
||||
"choice_question_uuid":questionUUID,
|
||||
@ -243,8 +215,8 @@ function html2json() {
|
||||
var group_attempt_any = document.getElementById('Question_Attempt_Any_Id_' + rand_id);
|
||||
groupQuestion['question_id'] = ((typeof question_id !== null && question_id !== 'undefined') ? (question_id !== null ? question_id.value : null) : null);
|
||||
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.innerHTML : null) : null);
|
||||
groupQuestion['group_description'] = ((typeof group_description !== null && group_description !== 'undefined') ? (group_description !== null ? group_description.innerHTML : null) : null);
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
groupQuestion['group_description'] = ((typeof group_description !== null && group_description !== 'undefined') ? (group_description !== null ? group_description.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
groupQuestion['group_marks'] = ((typeof group_marks !== null && group_marks !== 'undefined') ? (group_marks !== null ? group_marks.value : null) : null);
|
||||
groupQuestion['group_uuid'] = ((typeof group_uuid !== null && group_uuid !== 'undefined') ? (group_uuid !== null ? group_uuid.value : null) : null);
|
||||
groupQuestion['group_display_marks'] = ((typeof group_display_marks !== null && group_display_marks !== 'undefined') ? (group_display_marks !== null ? group_display_marks.checked : null) : null);
|
||||
@ -274,8 +246,8 @@ function html2json() {
|
||||
var section_uuid = document.getElementById('Section_UUID_ID_' + rand_id);
|
||||
var section_display_marks = document.getElementById('Section_Display_Marks_Id_' + rand_id);
|
||||
var section_attempt_any = document.getElementById('Section_Attempt_Any_Id_' + rand_id);
|
||||
section['section_title'] = ((typeof section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.innerHTML : null) : null);
|
||||
section['section_description'] = ((typeof section_description !== null && section_description !== 'undefined') ? (section_description !== null ? section_description.innerHTML : null) : null);
|
||||
section['section_title'] = ((typeof section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
section['section_description'] = ((typeof section_description !== null && section_description !== 'undefined') ? (section_description !== null ? section_description.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
section['section_marks'] = ((typeof section_marks !== null && section_marks !== 'undefined') ? (section_marks !== null ? section_marks.value : null) : null);
|
||||
section['section_uuid'] = ((typeof section_uuid !== null && section_uuid !== 'undefined') ? (section_uuid !== null ? section_uuid.value : null) : null);
|
||||
section['section_display_marks'] = ((typeof section_display_marks !== null && section_display_marks !== 'undefined') ? (section_display_marks !== null ? section_display_marks.checked : null) : null);
|
||||
@ -293,8 +265,8 @@ function html2json() {
|
||||
|
||||
var formData = {};
|
||||
|
||||
var question_paper_title = document.getElementById('Question_title').innerHTML;
|
||||
var question_paper_description = document.getElementById('Question_description').innerHTML;
|
||||
var question_paper_title = document.getElementById('Question_title').querySelector('.ql-editor').innerHTML;
|
||||
var question_paper_description = document.getElementById('Question_description').querySelector('.ql-editor').innerHTML;
|
||||
var max_marks = document.getElementById('Max_Marks').value;
|
||||
var course_ID = document.getElementById('Course_ID').value;
|
||||
var course_Code = document.getElementById('Course_Code').value;
|
||||
@ -331,10 +303,10 @@ function html2json() {
|
||||
|
||||
});
|
||||
|
||||
// console.log((formData));
|
||||
console.log((formData));
|
||||
// return false
|
||||
// console.log(JSON.stringify(formData, null, 1));
|
||||
localStorage.setItem("json", JSON.stringify((formData)));
|
||||
// console.log(JSON.stringify(formData));
|
||||
console.log(JSON.stringify(formData));
|
||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||
}
|
||||
|
||||
@ -2,83 +2,35 @@ function json2nav() {
|
||||
// console.clear();
|
||||
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
// var textQuestionId = 'textQuestionName_' + element_id;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var textQuestionId = 'textQuestionName_' + element_id;
|
||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||
// var questionType = 'Text';
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('titlemath_' + element_id).checked;
|
||||
var questionTitle = "";
|
||||
var textQuestionId = "";
|
||||
var element_serialnumber='';
|
||||
if(isMathEnabled == true){
|
||||
textQuestionId = 'textQuestiontitleMath_' + element_id;
|
||||
}else{
|
||||
textQuestionId = 'textQuestionName_' + element_id;
|
||||
}
|
||||
|
||||
if(isMathEnabled == true){
|
||||
|
||||
questionTitle = document.getElementById('textQuestiontitleMath_' + element_id).value;
|
||||
element_serialnumber = document.getElementById('QuestionTextIdSet_'+ element_id).value
|
||||
|
||||
}else{
|
||||
|
||||
const element = document.getElementById('textQuestionName_' + element_id);
|
||||
element_serialnumber = document.getElementById('QuestionTextIdSet_'+ element_id).value
|
||||
|
||||
const previousElement = element.previousElementSibling;
|
||||
var questionTitleData = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
questionTitle = questionTitleData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"serial_Number": element_serialnumber,
|
||||
"question_Id":textQuestionId,
|
||||
"marks":marks,
|
||||
"isMathEnabled":isMathEnabled,
|
||||
"question_type":questionType
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.getChoiceQuestion = function(element_id) {
|
||||
|
||||
// var choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
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 = "";
|
||||
var serial_Number = "";
|
||||
|
||||
if(isMathEnabled == true){
|
||||
choiceQuestionId = 'textQuestiontitleMath_' + element_id;
|
||||
}else{
|
||||
choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
}
|
||||
|
||||
if(isMathEnabled == true){
|
||||
|
||||
questionTitle = document.getElementById('textQuestiontitleMath_' + element_id).value;
|
||||
}else{
|
||||
|
||||
const element = document.getElementById('textQuestionName_' + element_id);
|
||||
serial_Number = document.getElementById('QuestionChoiceId_'+element_id).value;
|
||||
const previousElement = element.previousElementSibling;
|
||||
var questionTitleData = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
questionTitle = questionTitleData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"serial_Number": serial_Number,
|
||||
"question_Id":choiceQuestionId,
|
||||
"marks":marks,
|
||||
"isMathEnabled":isMathEnabled,
|
||||
"question_type":questionType
|
||||
}
|
||||
}
|
||||
@ -133,19 +85,11 @@ function json2nav() {
|
||||
// console.log(rand_id);
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var groupQuestion = {}
|
||||
|
||||
const groupelement = document.getElementById('subSection_title_text_' + rand_id);
|
||||
const previousElement = groupelement.previousElementSibling;
|
||||
var group_title_data = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
|
||||
var serial_Number = document.getElementById('Questions_Group_id_'+rand_id).value
|
||||
|
||||
var group_title = group_title_data;
|
||||
var group_title = document.getElementById('subSection_title_text_' + rand_id);
|
||||
var group_attempt_any = document.getElementById('Question_Attempt_Any_Id_' + rand_id);
|
||||
var group_marks = document.getElementById('Question_Group_Marks_Id_' + rand_id);
|
||||
|
||||
groupQuestion['serial_Number'] = serial_Number
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title : null) : null);
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
groupQuestion['question_group_id'] = 'subSection_title_text_' + rand_id;
|
||||
groupQuestion['group_attempt_any'] = ((typeof group_attempt_any !== null && group_attempt_any !== 'undefined') ? (group_attempt_any !== null ? group_attempt_any.value : null) : null);
|
||||
groupQuestion['group_marks'] = ((typeof group_marks !== null && group_marks !== 'undefined') ? (group_marks !== null ? group_marks.value : null) : null);
|
||||
@ -161,23 +105,18 @@ function json2nav() {
|
||||
|
||||
$.fn.getSectionDataNavigation = function(element) {
|
||||
// console.log('getSectionData');
|
||||
// console.log(element.id);
|
||||
const rand_id = (element.id).split("_").slice(-1)[0];
|
||||
// console.log(rand_id);
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var section = {}
|
||||
|
||||
const sectionelement = document.getElementById('section_title_text_' + rand_id);
|
||||
const previousElement = sectionelement.previousElementSibling;
|
||||
var section_title_data = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
|
||||
|
||||
var section_title = section_title_data;
|
||||
var section_title = document.getElementById('section_title_text_' + rand_id);
|
||||
var section_marks = document.getElementById('Section_Marks_Id_' + rand_id);
|
||||
var section_attempt_any = document.getElementById('Section_Attempt_Any_Id_' + rand_id);
|
||||
// console.log('section title in nav script');
|
||||
// console.log(section_title);
|
||||
// section['section_title'] = ((section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.innerHTML : null) : null);
|
||||
section['section_title'] = ((typeof section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title : null) : null);
|
||||
// section['section_title'] = ((section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
section['section_title'] = (section_title && section_title.querySelector('.ql-editor') ? section_title.querySelector('.ql-editor').innerHTML : null);
|
||||
section['section_id'] = 'section_title_text_' + rand_id;
|
||||
section['section_attempt_any'] = ((typeof section_attempt_any !== null && section_attempt_any !== 'undefined') ? (section_attempt_any !== null ? section_attempt_any.value : null) : null);
|
||||
section['section_marks'] = ((typeof section_marks !== null && section_marks !== 'undefined') ? (section_marks !== null ? section_marks.value : null) : null);
|
||||
@ -194,24 +133,7 @@ function json2nav() {
|
||||
|
||||
var formData = {};
|
||||
|
||||
var questionTitleElement = document.getElementById('questionTitleValue');
|
||||
|
||||
var questionTitleData = '';
|
||||
if (questionTitleElement) {
|
||||
|
||||
var joditWysiwygElement = questionTitleElement.querySelector('.jodit-wysiwyg');
|
||||
var questionTitleData = joditWysiwygElement.innerHTML;
|
||||
|
||||
} else {
|
||||
|
||||
questionTitleData = document.getElementById('Question_title').innerHTML;
|
||||
}
|
||||
|
||||
|
||||
// console.log(questionPaperTitleData);
|
||||
|
||||
|
||||
var question_paper_title = questionTitleData;
|
||||
var question_paper_title = document.getElementById('Question_title').querySelector('.ql-editor').innerHTML;
|
||||
formData['question_paper_title'] = question_paper_title;
|
||||
formData['Question_title_id'] = 'Question_title';
|
||||
formData['sections'] = [];
|
||||
|
||||
224
html2json_old.js
Normal file
@ -0,0 +1,224 @@
|
||||
function html2json() {
|
||||
// console.clear();
|
||||
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||
var questionSubTitle = "";
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
var questionSubType = document.getElementById('longAnswer_' + element_id).checked;
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"question_description": questionSubTitle,
|
||||
"question_type": questionType,
|
||||
"question_sub_type": questionSubType,
|
||||
"is_math_enabled": isMathEnabled
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.getChoiceQuestion = function(element_id) {
|
||||
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||
var questionSubTitle = "";
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
var questionSubType = document.getElementById('multipleAnswer_' + element_id).checked;
|
||||
var answers = [];
|
||||
|
||||
//get choice group
|
||||
|
||||
//get default choice details
|
||||
var choice_name = "";
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
choice_name = document.getElementById('choiceTextField_math_' + element_id).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
var choice_description = document.getElementById('commentField_' + element_id).value;
|
||||
// var choice_image = document.getElementById('imageInput_' + element_id).value;
|
||||
answers.push({
|
||||
"choice_name": choice_name,
|
||||
"choice_description": choice_description
|
||||
});
|
||||
|
||||
// console.log('before group');
|
||||
//get dynamically added choice detailscolor: #999;
|
||||
var $newlyAddedChoices = $('#addChoiceArea_' + element_id);
|
||||
|
||||
$newlyAddedChoices.children().each(function(index, element) {
|
||||
|
||||
var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[0];
|
||||
var individualChoiceId = (element.id).split('.').slice(-1)[0];
|
||||
// console.log('newChoiceTextField_'+groupChoiceId+'.'+individualChoiceId);
|
||||
var choice_name = "";
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
choice_name = document.getElementById('newchoiceTextField_math_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
// console.log('choice_description id in the html to json script');
|
||||
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
||||
// console.log(id);
|
||||
var choice_description = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
|
||||
|
||||
// var choice_image = document.getElementById('newChoiceImageInput_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
|
||||
answers.push({
|
||||
"choice_name": choice_name,
|
||||
"choice_description": choice_description,
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"question_description": questionSubTitle,
|
||||
"question_type": questionType,
|
||||
"question_sub_type": questionSubType,
|
||||
"is_math_enabled": isMathEnabled,
|
||||
"answers": answers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$.fn.getQuestionsData = function(element_id, type = 'question') // type for single question or group question
|
||||
{
|
||||
// console.log('getQuestionsData - '+element_id);
|
||||
|
||||
var $questionArea = (type == 'question' ? $('#question_area_' + element_id) : $('#group_question_area_' + element_id));
|
||||
// console.log('getQuestionsData');
|
||||
// console.log($questionArea);
|
||||
|
||||
var questionsArr = [];
|
||||
$questionArea.children("div").each(function(index, element) {
|
||||
|
||||
var questionRowID = (element.id).split("_").slice(-1)[0];
|
||||
// console.log('row question' + questionRowID);
|
||||
var question_type = document.getElementById('question_type_' + questionRowID);
|
||||
// check whether current element is single question or question group
|
||||
if (typeof question_type !== null && question_type != undefined) {
|
||||
if (document.getElementById('question_type_' + questionRowID).value == 'text') {
|
||||
//get text type question data
|
||||
var textQuestion = $.fn.getTextQuestion(questionRowID);
|
||||
questionsArr.push(textQuestion);
|
||||
|
||||
} else {
|
||||
// console.log('get choice question');
|
||||
//get choice type question data
|
||||
var getChoiceQuestion = $.fn.getChoiceQuestion(questionRowID);
|
||||
questionsArr.push(getChoiceQuestion)
|
||||
}
|
||||
} else // handle question group
|
||||
{
|
||||
// console.log('QUESTION GROUP');
|
||||
// console.log('row question' + questionRowID);
|
||||
var questionGroupData = $.fn.getQuestionQroupData(element);
|
||||
questionsArr.push(questionGroupData)
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return questionsArr
|
||||
}
|
||||
|
||||
$.fn.getQuestionQroupData = function(element) {
|
||||
// console.log('getSectionData');
|
||||
// console.log(element.id);
|
||||
const rand_id = (element.id).split("_").slice(-1)[0];
|
||||
// console.log(rand_id);
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var groupQuestion = {}
|
||||
var group_title = document.getElementById('subSection_title_text_' + rand_id);
|
||||
var group_description = document.getElementById('subSection_description_text_' + rand_id);
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
groupQuestion['group_description'] = ((typeof group_description !== null && group_description !== 'undefined') ? (group_description !== null ? group_description.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
|
||||
if (group_title !== null) {
|
||||
var questionsData = $.fn.getQuestionsData(rand_id, 'group');
|
||||
// console.log('Section Data');
|
||||
// console.log(questionsData);
|
||||
groupQuestion['questions'] = questionsData;
|
||||
return groupQuestion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$.fn.getSectionData = function(element) {
|
||||
// console.log('getSectionData');
|
||||
// console.log(element.id);
|
||||
const rand_id = (element.id).split("_").slice(-1)[0];
|
||||
// console.log(rand_id);
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var section = {}
|
||||
var section_title = document.getElementById('section_title_text_' + rand_id);
|
||||
var section_description = document.getElementById('section_description_text_' + rand_id);
|
||||
section['section_title'] = ((typeof section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
section['section_description'] = ((typeof section_description !== null && section_description !== 'undefined') ? (section_description !== null ? section_description.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
|
||||
if (section_title !== null) {
|
||||
var questionsData = $.fn.getQuestionsData(rand_id);
|
||||
// console.log('Section Data');
|
||||
// console.log(questionsData);
|
||||
section['questions'] = questionsData;
|
||||
return section;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var formData = {};
|
||||
|
||||
var question_paper_title = document.getElementById('Question_title').querySelector('.ql-editor').innerHTML;
|
||||
var question_paper_description = document.getElementById('Question_description').querySelector('.ql-editor').innerHTML;
|
||||
formData['question_paper_title'] = question_paper_title;
|
||||
formData['question_paper_description'] = question_paper_description;
|
||||
formData['sections'] = [];
|
||||
// console.log(formData);
|
||||
// return False;
|
||||
|
||||
var $parentSectionElement = $("#addNewSection");
|
||||
$parentSectionElement.find(".section").each(function(index, element) {
|
||||
// console.log(element);
|
||||
// if(index == 2){return false;}
|
||||
var sectionData = $.fn.getSectionData(element);
|
||||
// console.log(sectionData);
|
||||
if (sectionData !== null && sectionData !== undefined) {
|
||||
formData['sections'].push(sectionData);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// console.log((formData));
|
||||
// console.log(JSON.stringify(formData, null, 1));
|
||||
localStorage.setItem("json", JSON.stringify((formData)));
|
||||
console.log(JSON.stringify(formData));
|
||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||
}
|
||||
18
index.js
@ -60,11 +60,11 @@ files.forEach((file) => {
|
||||
// Function to load and display XML files in a loop
|
||||
async function loadMultipleXMLs() {
|
||||
for (const xmlFile of filePaths) {
|
||||
console.log(xmlFile)
|
||||
try {
|
||||
const titleText = await loadList(xmlFile); // Initially load in list view
|
||||
|
||||
const dynamicIdDownload = `download-button-${Date.now()}`;
|
||||
const dynamicIdDuplicate = `duplicate-button-${Date.now()}`
|
||||
const dynamicId = `download-button-${Date.now()}`;
|
||||
|
||||
// Handle list view
|
||||
const html_for_list = `
|
||||
@ -75,12 +75,9 @@ async function loadMultipleXMLs() {
|
||||
<a class="icons" href="addform.html?filename=${xmlFile}" title="Edit">
|
||||
<i><img src="assets/images/edit.svg" alt=""></i>
|
||||
</a>
|
||||
<a class="icons" href="#" id="${dynamicIdDownload}" data-filename="${xmlFile}" title="Download">
|
||||
<a class="icons" href="#" id="${dynamicId}" data-filename="${xmlFile}" title="Download">
|
||||
<i><img src="assets/images/download.svg" alt=""></i>
|
||||
</a>
|
||||
<a class="icons" href="#" id="${dynamicIdDuplicate}" data-filename="${xmlFile}" title="Duplicate">
|
||||
<i><img src="assets/images/duplicate.svg" alt="" style="width: 25px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="resent-post-single-box">
|
||||
<div class="resent-thunb">
|
||||
@ -93,19 +90,12 @@ async function loadMultipleXMLs() {
|
||||
$('#list').append(html_for_list);
|
||||
|
||||
// Add event listener for download buttons
|
||||
$('#'+dynamicIdDownload).on('click',function (event) {
|
||||
$('#'+dynamicId).on('click',function (event) {
|
||||
event.preventDefault();
|
||||
const filename =$(this).data('filename');
|
||||
downloadFile(filename);
|
||||
});
|
||||
|
||||
|
||||
$('#'+dynamicIdDuplicate).on('click',function (event) {
|
||||
event.preventDefault();
|
||||
const filename =$(this).data('filename');
|
||||
duplicateFile(filename);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error loading XML:", error);
|
||||
}
|
||||
|
||||
39
json2html.js
@ -12,8 +12,8 @@ function jsonToHtml(jsonData) {
|
||||
|
||||
if(jsonData == "" || jsonData == null)
|
||||
{
|
||||
document.getElementById('Question_title').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = "";
|
||||
document.getElementById('Question_description').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = "";
|
||||
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = "";
|
||||
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = "";
|
||||
document.getElementById('Max_Marks').value = "";
|
||||
document.getElementById('Course_ID').value = "";
|
||||
document.getElementById('Course_Code').value = "";
|
||||
@ -37,10 +37,8 @@ function jsonToHtml(jsonData) {
|
||||
var paper_No = jsonData.attributes.PaperNo;
|
||||
var subject_Name = jsonData.attributes.SubjectName;
|
||||
var sub_Paper_Prefix = jsonData.attributes.SubPaperPrefix;
|
||||
document.getElementById('questionTitleValue').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = title;
|
||||
document.getElementById('questionTitleDescriptionValue').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = description;
|
||||
document.getElementById('Question_title').innerHTML = title;
|
||||
document.getElementById('Question_description').innerHTML = description;
|
||||
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = title;
|
||||
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = description;
|
||||
document.getElementById('Max_Marks').value = max_marks;
|
||||
document.getElementById('Course_ID').value = course_ID;
|
||||
document.getElementById('Course_Code').value = course_Code;
|
||||
@ -61,8 +59,8 @@ function jsonToHtml(jsonData) {
|
||||
var sectionDescription = section.section_description;
|
||||
var sectionMarks = section.section_marks;
|
||||
var sectionUUID = section.attributes.Id;
|
||||
var sectionDispalyMarks = section.attributes.DisplayMarks;
|
||||
var sectionAttemptAny = section.attributes.AttemptAny;
|
||||
var sectionDispalyMarks = section.section_display_marks;
|
||||
var sectionAttemptAny = section.section_attempt_any;
|
||||
|
||||
|
||||
var SectionObj = {
|
||||
@ -71,8 +69,8 @@ function jsonToHtml(jsonData) {
|
||||
'sectionDescription' :section.section_description,
|
||||
'sectionMarks' :section.section_marks,
|
||||
'sectionUUID' :section.attributes.Id,
|
||||
'sectionDispalyMarks':section.attributes.DisplayMarks,
|
||||
'sectionAttemptAny' :section.attributes.AttemptAny,
|
||||
'sectionDispalyMarks':section.section_display_marks,
|
||||
'sectionAttemptAny' :section.section_attempt_any,
|
||||
}
|
||||
|
||||
// addSection(SectionObj); //call the addSection() function and send the sectionObject to that function
|
||||
@ -108,17 +106,15 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
|
||||
{
|
||||
questionTypeFormets ='question_group';
|
||||
}
|
||||
var questionId = Question.attributes.No
|
||||
var questionId = Question.question_id
|
||||
var questionTitle = Question.question;
|
||||
var questionDescription = Question.question_description;
|
||||
var questionType = questionTypeFormets;
|
||||
var questionSubType = Question.question_sub_type;
|
||||
var mathEnabled = Question.is_math_enabled;
|
||||
var titleMath = Question.titleMath;
|
||||
var descriptionMath = Question.descriptionMath;
|
||||
var questionMarks = Question.marks;
|
||||
var questionUUID = Question.attributes.Id;
|
||||
var questionDisplayMarks = Question.attributes.DisplayMarks;
|
||||
var questionDisplayMarks = Question.display_marks;
|
||||
var Choice = Question.answers;
|
||||
var CorrectAnswer = Question.correct_answer;
|
||||
|
||||
@ -128,16 +124,15 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
|
||||
"question_area_id" :questionAreaId,
|
||||
'questionRandomNo' :questionRandomNo,
|
||||
|
||||
'questionId' :Question.attributes.No,
|
||||
'questionId' :Question.question_id,
|
||||
'questionTitle' :Question.question,
|
||||
'questionDescription' :Question.question_description,
|
||||
'questionType' :questionTypeFormets,
|
||||
'questionSubType' :Question.question_sub_type,
|
||||
'titleMath' :Question.titleMath,
|
||||
'descriptionMath' :Question.descriptionMath,
|
||||
'mathEnabled' :Question.is_math_enabled,
|
||||
'questionMarks' :Question.marks,
|
||||
'questionUUID' :Question.attributes.Id,
|
||||
'questionDisplayMarks' :Question.attributes.DisplayMarks,
|
||||
'questionDisplayMarks' :Question.display_marks,
|
||||
'Choice' :Question.answers,
|
||||
'CorrectAnswer' :Question.correct_answer
|
||||
}
|
||||
@ -150,7 +145,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
|
||||
}
|
||||
else if (questionType == 'group')
|
||||
{
|
||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, descriptionMath, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId,CorrectAnswer[0], titleMath);
|
||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId,CorrectAnswer[0]);
|
||||
Choice = Choice.slice(1);
|
||||
Choice.forEach(function(choicenames, indexs) {
|
||||
var choiceName = choicenames.choice_name;
|
||||
@ -173,11 +168,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
|
||||
//function for Generate QuestionGroup
|
||||
function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||
{
|
||||
var idObj = {
|
||||
"section_question_area_id":questionAreaId,
|
||||
'question_group_obj': Question,
|
||||
'questions_randon_id':questionRandomNo
|
||||
};
|
||||
var idObj = {"section_question_area_id":questionAreaId, 'question_group_obj': Question, 'questions_randon_id':questionRandomNo};
|
||||
|
||||
addQuestionGroup(idObj);
|
||||
Question.questions.forEach(function(GroupQuestions, index) {
|
||||
|
||||
58
json2xml.js
@ -62,24 +62,25 @@ function json2xml() {
|
||||
doc,
|
||||
element
|
||||
} = createStandaloneXMLNode('Question', {
|
||||
// "xsi:type": (question['question_type'] == 'text' ? 'DescriptiveQuestion' : 'MultiChoiceQuestion'),
|
||||
"xsi:type": (question['question_type'] == 'text' ? 'DescriptiveQuestion' : 'MultiChoiceQuestion'),
|
||||
'Id': (question['question_type'] == 'text' ? question['text_question_uuid'] : question['choice_question_uuid']),
|
||||
'Type': (question['question_type'] == 'text' ? 'Descriptive' : 'MCQ'),
|
||||
'No': (question['question_id'] ? question['question_id'] : question['questionChoiceId']),
|
||||
'DisplayMarks': (question['display_marks'] === true ? 'true' : 'false'),
|
||||
'type': (question['question_type'] == 'text' ? 'Descriptive' : 'Mcq')
|
||||
|
||||
}, '');
|
||||
|
||||
if (question['question_id'] !== undefined) {
|
||||
var questionChoiceId =createElementWithText(doc, element, 'Text', question['question_id'])
|
||||
} else {
|
||||
// If question['question_id'] is undefined, create a new variable
|
||||
var questionIdSet = createElementWithText(doc, element , 'Text', question['questionChoiceId'])
|
||||
}
|
||||
|
||||
|
||||
var questionTitle = createElementWithText(doc, element, 'Text', question['question']);
|
||||
if(question['is_math_enabled2'] === true){
|
||||
questionTitle.setAttribute('Type',(question['is_math_enabled2'] === true ? 'Math' : ''));
|
||||
}
|
||||
var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
|
||||
if(question['is_math_enabled'] === true){
|
||||
questionDesc.setAttribute('Type',(question['is_math_enabled'] === true ? 'Math' : ''));
|
||||
}
|
||||
var marks = createElementWithText(doc, element, 'Marks', question['marks']);
|
||||
var display_marks = createElementWithText(doc, element, 'DispalyMarks', (question['display_marks'] === true ? 'true' : 'false'), {});
|
||||
var is_math_enabled = createElementWithText(doc, element, 'Math', (question['is_math_enabled'] === true ? 'true' : 'false'), {});
|
||||
|
||||
if (question['question_type'] == 'group') {
|
||||
// console.log(question);
|
||||
@ -91,9 +92,7 @@ function json2xml() {
|
||||
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
||||
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {});
|
||||
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_name'], {});
|
||||
if(question['answers'][choice]['is_math_enabled'] === true){
|
||||
text.setAttribute('Type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : ''));
|
||||
}
|
||||
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
|
||||
|
||||
}
|
||||
// choicesElement.appendChild();
|
||||
@ -111,24 +110,33 @@ function json2xml() {
|
||||
doc,
|
||||
element
|
||||
} = createStandaloneXMLNode('Question', {
|
||||
// 'xsi:type': 'QuestionGroup',
|
||||
'xsi:type': 'QuestionGroup',
|
||||
'Id': singleQuestion['group_uuid'],
|
||||
'Type': 'QuestionGroup',
|
||||
'No': (singleQuestion['question_id'] ? singleQuestion['question_id'] : '' ),
|
||||
'DisplayMarks':(singleQuestion['group_display_marks'] === true ? 'true' : 'false' ),
|
||||
...(singleQuestion['group_attempt_any'] !== '' ? {'AttemptAny': singleQuestion['group_attempt_any']} : {})
|
||||
'No': singleQuestion['group_title'],
|
||||
'Order': 0
|
||||
}, '');
|
||||
|
||||
|
||||
// var groupQuestionElement = createElementWithText(xmlDoc, sectionElement, 'Question', '', {
|
||||
// 'xsi:type': 'QuestionGroup',
|
||||
// 'Id': singleQuestion['group_uuid'],
|
||||
// 'Type': 'QuestionGroup',
|
||||
// 'No': singleQuestion['group_title'],
|
||||
// 'Order': 0
|
||||
// });
|
||||
var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['question_id']);
|
||||
var groupQuestionTitle = createElementWithText(doc, element, 'Text', singleQuestion['group_title']);
|
||||
var groupQuestionDesc = createElementWithText(doc, element, 'Subtext', singleQuestion['group_description']);
|
||||
var groupQuestionMarks = createElementWithText(doc, element, 'Marks', singleQuestion['group_marks']);
|
||||
var groupQuestionDisplayMarks = createElementWithText(doc, element, 'DisplayMarks', (singleQuestion['group_display_marks'] === true ? 'true' : 'false' ));
|
||||
var groupQuestionAttemptAny = createElementWithText(doc, element, 'AttemptAny', singleQuestion['group_attempt_any'] );
|
||||
var groupQuestionItemsElement = createElementWithText(doc, element, 'Items', '');
|
||||
|
||||
//gather questions data inside question group
|
||||
if (singleQuestion['questions'].length != 0) {
|
||||
var tempGroupQuestions = singleQuestion['questions'];
|
||||
// console.log(tempGroupQuestions);
|
||||
console.log(tempGroupQuestions);
|
||||
//looping each questions indise question group and attach it to group items node
|
||||
for (gquestion in tempGroupQuestions) {
|
||||
var singleGQuestion = tempGroupQuestions[gquestion];
|
||||
@ -183,24 +191,22 @@ function json2xml() {
|
||||
for (section in questionPaper['sections']) {
|
||||
//create section related xml nodes
|
||||
var tempSection = questionPaper['sections'][section];
|
||||
var sectionNumber = parseInt(section);
|
||||
sectionNumber++
|
||||
|
||||
// console.log(tempSection);
|
||||
|
||||
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
|
||||
// 'xsi:type': 'QuestionPaperSection',
|
||||
'xsi:type': 'QuestionPaperSection',
|
||||
'Id': tempSection['section_uuid'],
|
||||
'Type': 'Section',
|
||||
'No': sectionNumber,
|
||||
'DisplayMarks':(tempSection['section_display_marks'] === true ? 'true' : 'false'),
|
||||
...(tempSection['section_attempt_any'] !== '' ? {'AttemptAny': tempSection['section_attempt_any']} : {}),
|
||||
'No': tempSection['section_title'],
|
||||
'Order': 0
|
||||
});
|
||||
|
||||
var sectionTitle = createElementWithText(xmlDoc, sectionElement, 'Text', tempSection['section_title']);
|
||||
var sectionDesc = createElementWithText(xmlDoc, sectionElement, 'Subtext', tempSection['section_description']);
|
||||
var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'Marks', tempSection['section_marks']);
|
||||
// var sectionDisplayMark = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false'));
|
||||
// var sectionAttempAny = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']);
|
||||
var sectionDisplayMark = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false'));
|
||||
var sectionAttempAny = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']);
|
||||
var sectionItemElement = createElementWithText(xmlDoc, sectionElement, 'Items', '', );
|
||||
|
||||
|
||||
|
||||
6
main.js
@ -35,8 +35,6 @@ async function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
icon: path.join(__dirname, 'assets', 'images', 'Nexa_Author Icon.png'),
|
||||
title: 'Nexa Author',
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
@ -54,7 +52,6 @@ async function createWindow() {
|
||||
// mainWindow.removeMenu()
|
||||
mainWindow.loadFile('dashboard.html'); // Create an HTML file for your interface
|
||||
|
||||
|
||||
|
||||
|
||||
// if(process.env.ENABLE_DEV_TOOLS === 'TRUE')
|
||||
@ -90,9 +87,6 @@ async function createWindow() {
|
||||
// // Store the editors in an object or an array if you need to access them later
|
||||
// editors[divId] = editor;
|
||||
// });
|
||||
// mainWindow.setTitle(require('./package.json').name);
|
||||
mainWindow.setTitle('Nexa Author');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
241
nav_pane.js
@ -1,7 +1,4 @@
|
||||
// const { css } = require("jquery");
|
||||
// const mathJaxPath = require.resolve('./node_modules/mathjax/es5/latest.js');
|
||||
// require(mathJaxPath);
|
||||
const takeNumberOnly = require('./assets/js/takeNumberOnly/takeNumberOnly')
|
||||
const { css } = require("jquery");
|
||||
|
||||
// Initialize an array to store the expanded section data-ids
|
||||
const expandedSections = [];
|
||||
@ -26,7 +23,7 @@ function navpane() {
|
||||
|
||||
var html = html.replace(/<[^>]*>/g, '');
|
||||
if (html.length >= 30) {
|
||||
html=html.slice(0,24 ) + ''; // ...
|
||||
html=html.slice(0,30 ) + '...';
|
||||
}
|
||||
return html
|
||||
|
||||
@ -56,9 +53,9 @@ function navpane() {
|
||||
|
||||
// Truncate the content
|
||||
var truncatedContent = "";
|
||||
if(textContent.length > 24)
|
||||
if(textContent.length > 30)
|
||||
{
|
||||
truncatedContent = textContent.substring(0, maxLength) + ''; // ...
|
||||
truncatedContent = textContent.substring(0, maxLength) + '...';
|
||||
}
|
||||
else{
|
||||
truncatedContent = textContent;
|
||||
@ -68,7 +65,6 @@ function navpane() {
|
||||
}
|
||||
|
||||
function createTreeWithHeading(data, container) {
|
||||
|
||||
const treeTitle = removeParagraphTags(data.question_paper_title);
|
||||
const heading = document.createElement('a');
|
||||
heading.style.color = '#1D3557';
|
||||
@ -90,13 +86,6 @@ function navpane() {
|
||||
const sectionId = section.section_id;;
|
||||
sectionDiv.setAttribute('data-id', sectionId);
|
||||
sectionDiv.className = 'section main-heading';
|
||||
sectionDiv.setAttribute('id', `nav_section_title_${sectionId.match(/\d+/)[0]}`)
|
||||
// sectionDiv.setAttribute('draggable', 'true');
|
||||
sectionDiv.setAttribute("ondragstart" , "dragStart(this,event)");
|
||||
sectionDiv.setAttribute("ondragend" , "dragEnd(this,event)");
|
||||
sectionDiv.setAttribute("ondragover" , "dragOver(this,event)");
|
||||
sectionDiv.setAttribute("ondrop" , "dragDrop(this,event)");
|
||||
sectionDiv.setAttribute("ondragleave" ,"dragLeave(this,event)");
|
||||
|
||||
// console.log(section);
|
||||
// console.log(typeof sectionDiv);
|
||||
@ -226,8 +215,8 @@ function navpane() {
|
||||
sectionDiv.style.backgroundColor ='#fcdddd';
|
||||
// sectionDiv.style.border = '5px solid #fcdddd';
|
||||
sectionDiv.style.color ='black';
|
||||
// sectionDiv.style.marginLeft ='-67px';
|
||||
// sectionDiv.style.paddingLeft='67px';
|
||||
sectionDiv.style.marginLeft ='-67px';
|
||||
sectionDiv.style.paddingLeft='67px';
|
||||
sectionDiv.style.marginRight= '-75px'
|
||||
currentlyHighlightedElement = sectionLink;
|
||||
|
||||
@ -265,8 +254,8 @@ function navpane() {
|
||||
// sectionDiv.style.border = '5px solid #fcdddd';
|
||||
sectionDiv.style.borderRadius = '5px';
|
||||
sectionDiv.style.color ='black';
|
||||
// sectionDiv.style.marginLeft ='-67px';
|
||||
// sectionDiv.style.paddingLeft='67px';
|
||||
sectionDiv.style.marginLeft ='-67px';
|
||||
sectionDiv.style.paddingLeft='67px';
|
||||
sectionDiv.style.marginRight= '-75px'
|
||||
sectionLink.style.fontWeight = '100';
|
||||
|
||||
@ -295,7 +284,6 @@ function navpane() {
|
||||
sectionDiv.appendChild(sectionLink);
|
||||
|
||||
section.questions.forEach(question => {
|
||||
// console.log(question);
|
||||
createTreeNode(question, contentDiv);
|
||||
});
|
||||
|
||||
@ -305,31 +293,19 @@ function navpane() {
|
||||
|
||||
function createTreeNode(nodeData, parentNode) {
|
||||
const nodeDiv = document.createElement('div');
|
||||
const nodeDivChildForIconAlgin = document.createElement('div');
|
||||
nodeDiv.className = "navContain";
|
||||
nodeDiv.classList.add('navDrag');
|
||||
nodeDiv.appendChild(nodeDivChildForIconAlgin)
|
||||
|
||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
const nodeSerialNo = nodeData.serial_Number;
|
||||
const nodeDataId = nodeData.question_Id
|
||||
const nodeDataType = nodeData.question_type
|
||||
// console.log('nodeDataType:',nodeDataType);
|
||||
|
||||
if (nodeDataId) {
|
||||
var navPaneQuestionId = takeNumberOnly.takeNumberOnly(nodeDataId)
|
||||
}
|
||||
|
||||
parentNode.appendChild(nodeDiv);
|
||||
|
||||
|
||||
var bulletPoint = "";
|
||||
var dragIcon = "";
|
||||
dragIcon = document.createElement('i');
|
||||
dragIcon.className = 'fas fa-grip-horizontal';
|
||||
dragIcon.style.position = '';
|
||||
dragIcon.style.right = '1260px';
|
||||
if (nodeData.question) {
|
||||
parentNode.appendChild(nodeDiv);
|
||||
|
||||
|
||||
var RawID = "";
|
||||
if(nodeDataType == 'text')
|
||||
{
|
||||
@ -340,16 +316,9 @@ function navpane() {
|
||||
bulletPoint.style.fontWeight = 'bold';
|
||||
bulletPoint.style.color = '#00aaff';
|
||||
// bulletPoint.textContent = '\u2022';
|
||||
// bulletPoint.setAttribute("title", "Descriptive");
|
||||
nodeDivChildForIconAlgin.appendChild(bulletPoint);
|
||||
nodeDiv.id =`nav_removeAndCloneTextQuestion_${navPaneQuestionId}`;
|
||||
nodeDiv.setAttribute('draggable', 'true');
|
||||
nodeDiv.setAttribute("ondragstart" , "dragStart(this,event)");
|
||||
nodeDiv.setAttribute("ondragend" , "dragEnd(this,event)");
|
||||
nodeDiv.setAttribute("ondragover" , "dragOver(this,event)");
|
||||
nodeDiv.setAttribute("ondrop" , "dragDrop(this,event)");
|
||||
nodeDiv.setAttribute("ondragleave" , "dragLeave(this , event)");
|
||||
|
||||
bulletPoint.setAttribute("title", "Descriptive");
|
||||
nodeDiv.appendChild(bulletPoint);
|
||||
|
||||
var splitedId = nodeDataId.split("_")[1];
|
||||
RawID = 'removeAndCloneTextQuestion_'+splitedId;
|
||||
|
||||
@ -364,18 +333,11 @@ function navpane() {
|
||||
bulletPoint.style.color = '#00aaff';
|
||||
bulletPoint.setAttribute("title", "MCQ");
|
||||
// bulletPoint.textContent = '\u2022';
|
||||
nodeDiv.id =`nav_removeAndCloneQroupQuestion_${navPaneQuestionId}`;
|
||||
nodeDiv.setAttribute('draggable', 'true');
|
||||
nodeDiv.setAttribute("ondragstart" , "dragStart(this,event)");
|
||||
nodeDiv.setAttribute("ondragend" , "dragEnd(this,event)");
|
||||
nodeDiv.setAttribute("ondragover" , "dragOver(this,event)");
|
||||
nodeDiv.setAttribute("ondrop" , "dragDrop(this,event)");
|
||||
nodeDiv.setAttribute("ondragleave" , "dragLeave(this , event)");
|
||||
// nodeDiv.style.justifyContent= 'space-between'
|
||||
nodeDivChildForIconAlgin.appendChild(bulletPoint);
|
||||
nodeDiv.appendChild(bulletPoint);
|
||||
|
||||
var splitedId = nodeDataId.split("_")[1];
|
||||
RawID = 'removeAndCloneQroupQuestion_'+splitedId;
|
||||
|
||||
}
|
||||
|
||||
var QuestionID = document.getElementById(RawID)
|
||||
@ -400,13 +362,13 @@ function navpane() {
|
||||
questionLink.style.maxWidth = '190px';
|
||||
questionLink.style.fontWeight = '100';
|
||||
|
||||
// if(nodeDataType == 'text')
|
||||
// {
|
||||
// questionLink.setAttribute("title", "DescriptiveQuestion");
|
||||
// }else if(nodeDataType == 'group'){
|
||||
// questionLink.setAttribute("title", "MultiChoiceQuestion");
|
||||
if(nodeDataType == 'text')
|
||||
{
|
||||
questionLink.setAttribute("title", "Descriptive");
|
||||
}else if(nodeDataType == 'text'){
|
||||
questionLink.setAttribute("title", "MCQ");
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// QuestionID.addEventListener('click', function () {
|
||||
// if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||
@ -436,10 +398,9 @@ function navpane() {
|
||||
// nodeDiv.style.border = '5px solid #fcdddd';
|
||||
nodeDiv.style.borderRadius = '5px';
|
||||
nodeDiv.style.color ='black';
|
||||
// nodeDiv.style.marginLeft ='-67px';
|
||||
// nodeDiv.style.paddingLeft='67px';
|
||||
// nodeDiv.style.marginRight= '-75px';
|
||||
// nodeDiv.style.justifyContent= 'space-between';
|
||||
nodeDiv.style.marginLeft ='-67px';
|
||||
nodeDiv.style.paddingLeft='67px';
|
||||
nodeDiv.style.marginRight= '-75px'
|
||||
QuestionID.style.fontWeight = '100';
|
||||
currentlyHighlightedElement = nodeDiv;
|
||||
// nodeDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
@ -467,7 +428,6 @@ function navpane() {
|
||||
nodeDiv.style.color = ' black';
|
||||
nodeDiv.style.marginLeft ='0px';
|
||||
nodeDiv.style.paddingLeft='0px';
|
||||
// nodeDiv.style.justifyContent= 'space-between'
|
||||
currentlyHighlightedElement =null
|
||||
// nodeDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
|
||||
@ -506,11 +466,10 @@ function navpane() {
|
||||
nodeDiv.style.borderRadius = '5px';
|
||||
// nodeDiv.style.color = ' rgb(255 255 255)';
|
||||
nodeDiv.style.color ='black';
|
||||
// nodeDiv.style.marginLeft ='-67px';
|
||||
// nodeDiv.style.paddingLeft='67px';
|
||||
// nodeDiv.style.marginRight= '-75px';
|
||||
nodeDiv.style.marginLeft ='-67px';
|
||||
nodeDiv.style.paddingLeft='67px';
|
||||
nodeDiv.style.marginRight= '-75px';
|
||||
nodeDiv.style.borderLeftWidth= '-75px';
|
||||
// nodeDiv.style.justifyContent= 'space-between';
|
||||
currentlyHighlightedElement = questionLink;
|
||||
});
|
||||
questionLink.addEventListener('mouseout', function () {
|
||||
@ -527,7 +486,6 @@ function navpane() {
|
||||
nodeDiv.style.color = ' black';
|
||||
nodeDiv.style.marginLeft ='0px';
|
||||
nodeDiv.style.paddingLeft='0px';
|
||||
// nodeDiv.style.justifyContent= 'space-between';
|
||||
currentlyHighlightedElement =null
|
||||
});
|
||||
|
||||
@ -541,45 +499,19 @@ function navpane() {
|
||||
// questionLink.innerHTML = removeParagraphTags(nodeData.question);
|
||||
// }
|
||||
|
||||
|
||||
var htmlTagRemovedQuestionTitle = removeTagsAndTruncate(nodeData.serial_Number, 25);
|
||||
var Latex = convertToLatex(htmlTagRemovedQuestionTitle);
|
||||
|
||||
var data = ''
|
||||
if(nodeData.isMathEnabled){
|
||||
data = Latex;
|
||||
}else{
|
||||
data = htmlTagRemovedQuestionTitle;
|
||||
}
|
||||
|
||||
questionLink.innerHTML = data;
|
||||
|
||||
questionLink.innerHTML = removeTagsAndTruncate(nodeData.question, 25);
|
||||
|
||||
|
||||
// console.log('questionLink : ', questionLink)
|
||||
|
||||
|
||||
nodeDivChildForIconAlgin.appendChild(questionLink);
|
||||
nodeDiv.appendChild(dragIcon)
|
||||
nodeDiv.appendChild(questionLink);
|
||||
} else if (nodeData.group_title) {
|
||||
const groupTitleDiv = document.createElement('div');
|
||||
// const gripIcon = document.createElement('i');
|
||||
// gripIcon.className = 'fas fa-grip-horizontal';
|
||||
// gripIcon.style.position = 'fixed';
|
||||
// gripIcon.style.right = '1260px';
|
||||
|
||||
// groupTitleDiv.appendChild(gripIcon);
|
||||
|
||||
const groupTitleId = nodeData.question_group_id;
|
||||
const getNumberOnlyGroupTitleId = takeNumberOnly.takeNumberOnly(groupTitleId)
|
||||
groupTitleDiv.setAttribute('data-id', groupTitleId);
|
||||
groupTitleDiv.setAttribute('id', `nav_draggedGroup_${getNumberOnlyGroupTitleId}`);
|
||||
groupTitleDiv.className = 'question-group';
|
||||
groupTitleDiv.setAttribute('draggable', 'true');
|
||||
groupTitleDiv.setAttribute("ondragstart" , "dragStart(this,event)");
|
||||
groupTitleDiv.setAttribute("ondragend" , "dragEnd(this , event)");
|
||||
groupTitleDiv.setAttribute("ondragover" , "dragOver(this,event)");
|
||||
groupTitleDiv.setAttribute("ondragleave" , "dragLeave(this , event)")
|
||||
groupTitleDiv.setAttribute("ondrop" , "dragDrop(this , event)");
|
||||
|
||||
|
||||
// console.log(groupTitleId);
|
||||
|
||||
@ -595,11 +527,13 @@ function navpane() {
|
||||
} else {
|
||||
groupTitleDiv.classList.add('collapsed');
|
||||
}
|
||||
|
||||
if(editPage == 1 || editPage == null){
|
||||
|
||||
groupTitleDiv.classList.add('collapsed');
|
||||
|
||||
}
|
||||
|
||||
parentNode.appendChild(groupTitleDiv);
|
||||
|
||||
const groupTitleArrow = document.createElement('span');
|
||||
@ -618,7 +552,7 @@ function navpane() {
|
||||
groupTitleArrow.className = 'arrow-down';
|
||||
groupQuestionsDiv.classList.add('visible');
|
||||
}
|
||||
|
||||
|
||||
groupTitleArrow.addEventListener('click', () => {
|
||||
groupQuestionsDiv.classList.toggle('visible');
|
||||
groupTitleDiv.classList.toggle('collapsed');
|
||||
@ -662,7 +596,7 @@ function navpane() {
|
||||
|
||||
const groupQuestionLink = document.createElement('a');
|
||||
groupQuestionLink.href = '#' + groupTitleId;
|
||||
|
||||
|
||||
// Attach the scroll function to the hyperlinks
|
||||
groupQuestionLink.addEventListener('click', function(e) {
|
||||
e.preventDefault(); // Prevent the default behavior of the link
|
||||
@ -717,11 +651,11 @@ function navpane() {
|
||||
groupTitleDiv.style.fontWeight = '100';
|
||||
// groupTitleDiv.style.border = '5px solid #fcdddd';
|
||||
groupTitleDiv.style.borderRadius = '5px';
|
||||
groupTitleDiv.style.backgroundColor = '#fcdddd';
|
||||
// groupTitleDiv.style.marginLeft ='-67px';
|
||||
// groupTitleDiv.style.paddingLeft='67px';
|
||||
groupTitleDiv.style.marginRight= '-75px';
|
||||
groupTitleDiv.style.borderLeftWidth= '-75px';
|
||||
groupTitleDiv.style.backgroundColor = '#fcdddd';
|
||||
groupTitleDiv.style.marginLeft ='-67px';
|
||||
groupTitleDiv.style.paddingLeft='67px';
|
||||
groupTitleDiv.style.marginRight= '-75px';
|
||||
groupTitleDiv.style.borderLeftWidth= '-75px';
|
||||
|
||||
currentlyHighlightedElement = groupQuestionLink;
|
||||
|
||||
@ -819,12 +753,12 @@ function navpane() {
|
||||
groupTitleDiv.style.fontWeight = '400';
|
||||
groupTitleDiv.style.border = '5px solid #fcdddd';
|
||||
groupTitleDiv.style.borderRadius = '5px';
|
||||
groupTitleDiv.style.backgroundColor = '#fcdddd';
|
||||
groupQuestionLink.style.color= 'black';
|
||||
// groupTitleDiv.style.marginLeft ='-67px';
|
||||
// groupTitleDiv.style.paddingLeft='67px';
|
||||
groupTitleDiv.style.marginRight= '-75px';
|
||||
groupTitleDiv.style.borderLeftWidth= '-75px';
|
||||
groupTitleDiv.style.backgroundColor = '#fcdddd';
|
||||
groupQuestionLink.style.color= 'black';
|
||||
groupTitleDiv.style.marginLeft ='-67px';
|
||||
groupTitleDiv.style.paddingLeft='67px';
|
||||
groupTitleDiv.style.marginRight= '-75px';
|
||||
groupTitleDiv.style.borderLeftWidth= '-75px';
|
||||
GroupBoxID.style.fontWeight = 'normal';
|
||||
currentlyHighlightedElement = groupQuestionLink;
|
||||
// groupTitleDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
@ -834,10 +768,10 @@ function navpane() {
|
||||
|
||||
if (nodeData.group_title.length > 20) {
|
||||
// groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.serial_Number);
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title);
|
||||
|
||||
} else {
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.serial_Number);
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title);
|
||||
}
|
||||
groupTitleDiv.appendChild(groupQuestionLink);
|
||||
|
||||
@ -847,7 +781,6 @@ function navpane() {
|
||||
});
|
||||
parentNode.appendChild(groupQuestionsDiv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var questionPaperContainer = document.getElementById('questionPaper');
|
||||
@ -886,58 +819,38 @@ 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 = ''
|
||||
if(getMathFieldId == 'textQuestiontitleMath_'){
|
||||
focus = element
|
||||
}
|
||||
else{
|
||||
focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg');
|
||||
}
|
||||
if (element) {
|
||||
focus.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
}
|
||||
}
|
||||
|
||||
function convertToLatex(text, mathstatus) {
|
||||
// Parse mathstatus into a boolean
|
||||
const mathStatusBoolean = true;
|
||||
|
||||
// Check if the text contains <p> tags
|
||||
if (!/<p>|<\/p>/i.test(text)) {
|
||||
// Use MathJax to convert the text to LaTeX if mathStatusBoolean is true
|
||||
var val = mathStatusBoolean ? MathJax.tex2chtml(text).outerHTML : text;
|
||||
return convertMathJaxToLatex(val)
|
||||
} else {
|
||||
// Use MathJax to convert the text to LaTeX if it contains <p> tags
|
||||
var val2 = MathJax.tex2chtml(text).outerHTML;
|
||||
return convertMathJaxToLatex(val2)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
let draggedItemGroup = null;
|
||||
let draggedItemQuestion = null;
|
||||
let dropTarget = null;
|
||||
|
||||
|
||||
|
||||
// Event listener for .drag-handle elements within questions
|
||||
document.addEventListener('mousedown', function (e) {
|
||||
|
||||
const dragHandle = e.target.closest('.content visible');
|
||||
// alert(dragHandle);
|
||||
if (dragHandle) {
|
||||
// If the click is inside a drag handle, find the corresponding .question
|
||||
const questionElement = dragHandle.closest('.navDrag');
|
||||
|
||||
if (questionElement) {
|
||||
// console.log("draggHandle:",dragHandle);
|
||||
// Initiate the drag operation for the .question
|
||||
draggedItemQuestion = questionElement;
|
||||
|
||||
// Add a dragStart event listener to set data
|
||||
draggedItemQuestion.addEventListener('dragstart', function (e) {
|
||||
e.dataTransfer.setData('text/plain', draggedItemQuestion.id);
|
||||
// console.log(draggedItemQuestion.id);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
4
package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "Nexa Author",
|
||||
"name": "projectb",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "Nexa Author",
|
||||
"name": "projectb",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
14
package.json
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "Nexa Author",
|
||||
"name": "projectb",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "start",
|
||||
"start": "electron .",
|
||||
"build": "cross-env NODE_ENV=production electron-packager . NexaAuthor --platform=win32 --arch=x64",
|
||||
"build": "cross-env NODE_ENV=production electron-packager . ProjectB --platform=win32 --arch=x64",
|
||||
"convertEnvBase64": "node envConvertBasetoString.js"
|
||||
},
|
||||
"author": "VenbaInfoTech",
|
||||
"author": "venkatesh",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"electron": "^26.1.0",
|
||||
@ -44,6 +44,14 @@
|
||||
"mathjax-node": "^2.1.1",
|
||||
"mathlive": "^0.95.5",
|
||||
"os": "^0.1.2",
|
||||
"quill": "^1.3.7",
|
||||
"quill-better-table": "^1.1.0",
|
||||
"quill-better-table-picker": "^1.0.2",
|
||||
"quill-image-resize": "^3.0.9",
|
||||
"quill-image-resize-module": "^3.0.0",
|
||||
"quill-resize-module": "^1.2.4",
|
||||
"quill-table": "^1.0.0",
|
||||
"quill1-table": "^1.7.2",
|
||||
"sweetalert": "^2.1.2",
|
||||
"sweetalert2": "^11.6.13",
|
||||
"tippy.js": "^6.3.7",
|
||||
|
||||
@ -2,13 +2,11 @@ function rtc_hide_and_show(rtcid) {
|
||||
|
||||
var id = localStorage.getItem('rtc');
|
||||
var hideid = document.getElementById(id);
|
||||
// console.log('hideid : ', hideid);
|
||||
// console.log('hide id :' + id)
|
||||
$(hideid).hide();
|
||||
// console.log('hide id :' + id);
|
||||
var showid = document.getElementById(rtcid);
|
||||
console.log('hide id :' + id)
|
||||
$(showid).show();
|
||||
// console.log('Show id :' + rtcid)
|
||||
localStorage.setItem('rtc',rtcid);
|
||||
|
||||
};
|
||||
|
||||
@ -89,8 +89,6 @@ files.forEach((file) => {
|
||||
if(reorder){
|
||||
window.location.reload();
|
||||
}else{
|
||||
|
||||
console.log('addform.html?filename=' + xmlfilename);
|
||||
window.location.href = 'addform.html?filename=' + xmlfilename;
|
||||
// window.location.reload();
|
||||
|
||||
@ -100,10 +98,12 @@ files.forEach((file) => {
|
||||
|
||||
|
||||
function savexml(UserFilename,reorder=false) {
|
||||
// console.log("reorder",reorder);
|
||||
console.log("reorder",reorder);
|
||||
// Get the XML string from localStorage
|
||||
var xmlString = localStorage.getItem("xml");
|
||||
var jsonString = localStorage.getItem("Correct_Answer_Json");
|
||||
console.log('save json : ', jsonString);
|
||||
console.log('save xml : ', xmlString);
|
||||
|
||||
//check Encrypted or not
|
||||
var enc = "";
|
||||
|
||||
@ -3331,8 +3331,8 @@ a.main_sticky {
|
||||
position: fixed;
|
||||
top: 70px;
|
||||
left: 0;
|
||||
max-height: 750px;
|
||||
/* max-height: 532px; */
|
||||
|
||||
max-height: 532px;
|
||||
padding: 0 10px 20px;
|
||||
width: 235px;
|
||||
height: -webkit-fill-available;
|
||||
@ -3612,7 +3612,6 @@ font-size: 14px;
|
||||
display: flex;
|
||||
/* display: contents; */
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
}
|
||||
|
||||
@ -3820,5 +3819,3 @@ font-size: 14px;
|
||||
.is-hide{
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
3441
style_old.css
Normal file
1
xml/Sample.xml
Normal file
96
xml2json.js
@ -7,9 +7,7 @@ var jsonDecodeData = localStorage.getItem('json_Decode_Data_For_Mcq_Crt_Ans');
|
||||
// console.log(jsonDecodeData);
|
||||
|
||||
function getAttributesOfXMLNode(node)
|
||||
{
|
||||
// console.log('xmal attributes');
|
||||
// console.log(node);
|
||||
{
|
||||
// Get attributes of the node (if any)
|
||||
attributes = {};
|
||||
if (node.attributes.length > 0) {
|
||||
@ -22,22 +20,6 @@ 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(type);
|
||||
@ -45,35 +27,33 @@ function getQuestionsNodes(questionNode,type)
|
||||
if(type == 1)
|
||||
{
|
||||
// console.log(questionNode);
|
||||
// questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].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_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "" ;
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].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[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
// questionObj['display_marks'] = questionNode.childNodes[4].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;
|
||||
// console.log(questionObj);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].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_id'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
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['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
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['answers'] = [];
|
||||
questionObj['correct_answer'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[4].childNodes;
|
||||
var choiceList = questionNode.childNodes[7].childNodes;
|
||||
// console.log(questionNode);
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
@ -83,8 +63,8 @@ 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'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
|
||||
// console.log(tempChoiceobj);
|
||||
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
}
|
||||
}
|
||||
@ -126,24 +106,27 @@ function getQuestionsNodes(questionNode,type)
|
||||
function getQuestionGroupNodes(questionGroup)
|
||||
{
|
||||
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['question_id'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
||||
questionGroupObj['group_title'] = 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'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[3].childNodes;
|
||||
var questionList = questionGroup.childNodes[6].childNodes;
|
||||
// console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("Type");
|
||||
if(questionType == 'Descriptive')
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
// console.log(questionList[q]);
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
}
|
||||
else if(questionType == 'MCQ')
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
// console.log(questionList[q]);
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
|
||||
@ -170,11 +153,9 @@ const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const jsonObj = {};
|
||||
|
||||
// jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue || ' ';
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0] && xmlDoc.getElementsByTagName("Title")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue : '';// console.log('question_paper_description');
|
||||
// console.log(xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue)
|
||||
// jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue || ' ';
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0] && xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue : null;//get attributes of root/question paper element
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue;
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue;
|
||||
//get attributes of root/question paper element
|
||||
jsonObj['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
|
||||
jsonObj['sections'] = [];
|
||||
|
||||
@ -189,15 +170,15 @@ jsonObj['sections'] = [];
|
||||
|
||||
// console.log('Section :' + i + '-' + sectionsList[i].childNodes[0]);
|
||||
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_description'] = 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 !== null ? 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['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[3].childNodes;
|
||||
var questionList = sectionsList[i].childNodes[5].childNodes;
|
||||
// console.log('No of quetions:' + questionList.length);
|
||||
// console.log(questionList);
|
||||
for(let j = 0; j < questionList.length ;j++)
|
||||
@ -205,13 +186,13 @@ jsonObj['sections'] = [];
|
||||
//check weather quesiotn or question grup
|
||||
// console.log('QUESTION :' + j );
|
||||
// console.log(questionList[j]);
|
||||
var questionType = questionList[j].getAttribute("Type");
|
||||
var questionType = questionList[j].getAttribute("xsi:type");
|
||||
// console.log(questionType);
|
||||
if(questionType == 'Descriptive')
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
|
||||
}
|
||||
else if(questionType == 'MCQ')
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
|
||||
}
|
||||
@ -224,11 +205,10 @@ jsonObj['sections'] = [];
|
||||
}
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
jsonToHtml(jsonObj);
|
||||
|
||||
// console.log('Xml to Json Conversion ');
|
||||
// console.log('jsonData : ', jsonData);
|
||||
// console.log(jsonObj);
|
||||
jsonToHtml(jsonObj);
|
||||
// console.log(jsonToHtml(jsonObj))
|
||||
// localStorage.removeItem('json_Decode_Data_For_Mcq_Crt_Ans');
|
||||
|
||||
|
||||
@ -18,52 +18,37 @@ 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['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['questionId'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].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[2].firstChild !== null ? questionNode.childNodes[2].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;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
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['questionId'] = questionNode.childNodes[0].firstChild.nodeValue;
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
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['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['answers'] = [];
|
||||
questionObj['correct_answer'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[4].childNodes;
|
||||
|
||||
var choiceList = questionNode.childNodes[7].childNodes;
|
||||
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
@ -73,7 +58,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'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
|
||||
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
|
||||
@ -86,25 +71,29 @@ function getQuestionsNodes(questionNode,type)
|
||||
|
||||
function getQuestionGroupNodes(questionGroup)
|
||||
{
|
||||
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'] = [];
|
||||
var questionGroupObj = {};
|
||||
questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
|
||||
|
||||
questionGroupObj['group_title'] = 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'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[3].childNodes;
|
||||
var questionList = questionGroup.childNodes[6].childNodes;
|
||||
// console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("Type");
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
console.log(questionType);
|
||||
if(questionType == 'Descriptive')
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
}
|
||||
else if(questionType == 'MCQ')
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
|
||||
}
|
||||
@ -120,21 +109,20 @@ function getQuestionGroupNodes(questionGroup)
|
||||
|
||||
|
||||
//busi logic start
|
||||
console.log(xmlData);
|
||||
var xmlString = xmlData;
|
||||
const parser = new DOMParser();
|
||||
const parser = new DOMParser();
|
||||
|
||||
// Parse the XML string into an XML document
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const jsonObj = {};
|
||||
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0] && xmlDoc.getElementsByTagName("Title")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue : null;
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0] && xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue : null;
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue;
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue;
|
||||
//get attributes of root/question paper element
|
||||
jsonObj['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
|
||||
jsonObj['sections'] = [];
|
||||
|
||||
|
||||
|
||||
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
||||
// console.log(sectionsList);
|
||||
// console.log('no of sections:'+sectionsList.length);
|
||||
@ -142,15 +130,17 @@ jsonObj['sections'] = [];
|
||||
var tempObj = {};
|
||||
|
||||
// console.log('Section :' + i + '-' + sectionsList[i].childNodes[0].firstChild.nodeValue);
|
||||
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_title'] = sectionsList[i].childNodes[0].firstChild.nodeValue;
|
||||
tempObj['section_description'] = 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[3].childNodes;
|
||||
var questionList = sectionsList[i].childNodes[5].childNodes;
|
||||
// console.log('No of quetions:' + questionList.length);
|
||||
// console.log("Question List")
|
||||
// console.log(questionList);
|
||||
@ -159,13 +149,13 @@ jsonObj['sections'] = [];
|
||||
//check weather quesiotn or question grup
|
||||
// console.log('QUESTION :' + j );
|
||||
// console.log(questionList[j]);
|
||||
var questionType = questionList[j].getAttribute("Type");
|
||||
var questionType = questionList[j].getAttribute("xsi:type");
|
||||
// console.log(questionType);
|
||||
if(questionType == 'Descriptive')
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
|
||||
}
|
||||
else if(questionType == 'MCQ')
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
|
||||
}
|
||||
@ -179,7 +169,7 @@ jsonObj['sections'] = [];
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
localStorage.setItem('pjsonData', jsonData );
|
||||
console.log('xml2json_for_questionpaper : ',jsonData);
|
||||
// console.log(jsonData);
|
||||
QuestionPaperPreview(jsonObj);
|
||||
|
||||
}
|
||||
|
||||
157
xml2json_old.js
Normal file
@ -0,0 +1,157 @@
|
||||
|
||||
function xml2json(xmlData) {
|
||||
// console.clear();
|
||||
console.log('xml to json converstion');
|
||||
console.log(xmlData);
|
||||
|
||||
function getAttributesOfXMLNode(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.nodeName] = attribute.nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
function getQuestionsNodes(questionNode,type)
|
||||
{
|
||||
// console.log(questionNode);
|
||||
var questionObj = {};
|
||||
if(type == 1)
|
||||
{
|
||||
questionObj['question'] = 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['question_sub_type'] = 'false';
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
questionObj['question'] = 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[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['answers'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[5].childNodes;
|
||||
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
for (let k = 0; k < choiceList.length ;k++)
|
||||
{
|
||||
var tempChoiceobj = {};
|
||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
||||
tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue;
|
||||
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return questionObj;
|
||||
|
||||
}
|
||||
|
||||
function getQuestionGroupNodes(questionGroup)
|
||||
{
|
||||
var questionGroupObj = {};
|
||||
|
||||
questionGroupObj['group_title'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
||||
questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[3].childNodes;
|
||||
console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
|
||||
}
|
||||
|
||||
}
|
||||
return questionGroupObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//busi logic start
|
||||
var xmlString = xmlData;
|
||||
const parser = new DOMParser();
|
||||
|
||||
// Parse the XML string into an XML document
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const jsonObj = {};
|
||||
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue;
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue;
|
||||
//get attributes of root/question paper element
|
||||
jsonObj['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
|
||||
jsonObj['sections'] = [];
|
||||
|
||||
|
||||
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
||||
console.log(sectionsList);
|
||||
console.log('no of sections:'+sectionsList.length);
|
||||
for (let i = 0; i < sectionsList.length ;i++) {
|
||||
var tempObj = {};
|
||||
|
||||
console.log('Section :' + i + '-' + sectionsList[i].childNodes[0].firstChild.nodeValue);
|
||||
tempObj['section_title'] = sectionsList[i].childNodes[0].firstChild.nodeValue;
|
||||
tempObj['section_description'] = sectionsList[i].childNodes[1].firstChild.nodeValue;
|
||||
tempObj['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
|
||||
tempObj['questions'] = [];
|
||||
|
||||
//handle questions
|
||||
var questionList = sectionsList[i].childNodes[3].childNodes;
|
||||
console.log('No of quetions:' + questionList.length);
|
||||
// console.log(questionList[2]);
|
||||
for(let j = 0; j < questionList.length ;j++)
|
||||
{
|
||||
//check weather quesiotn or question grup
|
||||
console.log('QUESTION :' + j );
|
||||
// console.log(questionList[j].getAttribute("xsi:type"));
|
||||
var questionType = questionList[j].getAttribute("xsi:type");
|
||||
console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
|
||||
}
|
||||
else if(questionType == 'QuestionGroup')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionGroupNodes(questionList[j]));
|
||||
}
|
||||
}
|
||||
jsonObj['sections'].push(tempObj);
|
||||
}
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
console.log('Xml to Json Conversion ');
|
||||
console.log(jsonData);
|
||||
console.log(jsonObj);
|
||||
jsonToHtml(jsonObj);
|
||||
}
|
||||
|
||||
|
||||