Compare commits

..

25 Commits
dev ... jodit

Author SHA1 Message Date
aadhavan valli
ef7d32bdea GROUPQUESTIONMANDTORYCHECKISSUE : AADHAVAN 2024-02-17 08:31:07 +05:30
aadhavan valli
86427dbb3f GROUPQUESTIONDESCRIPTIONMANDATORY : AADHAVAN 2024-02-16 14:57:00 +05:30
aadhavan valli
6cdf19d212 PASTEAFTERMANDATORYISSUE : AADHAVAN 2024-02-15 14:21:16 +05:30
aadhavan valli
87e10fe685 ASETTINGWORKAREA : AADHAVAN 2024-02-14 14:24:46 +05:30
aadhavan valli
254a0a1ae0 TABINDEX : AADHAVAN 2024-02-13 11:26:56 +05:30
aadhavan valli
92aa201002 LEFTNAVCSS : AADHAVAN 2024-02-12 17:22:11 +05:30
aadhavan valli
84e5110f78 CSSISSUE : AADHAVAN 2024-02-10 15:56:52 +05:30
aadhavan valli
ace083b56c APPSETTINGISSUE : AADHAVAN 2024-02-10 11:41:36 +05:30
aadhavan valli
3a5087d1a2 APPSETTINGISSUE : AADHAVAN 2024-02-10 11:31:10 +05:30
aadhavan valli
f8bf6bf965 DUPLICATEQUESTIONPAPER APPSETTING : AADHAVAN 2024-02-10 10:12:33 +05:30
85526f8bbd Fix_Spelling_Mistake : RV 2024-01-29 14:12:24 +05:30
e0944e65ba change_logo_and_other : RV 2024-01-29 13:28:07 +05:30
567694928a repush : RV 2024-01-25 16:07:26 +05:30
702e74496b QuestionPaperTitle_Mandatory : RV 2024-01-25 12:54:24 +05:30
ba5ef4b437 NavPane_Latex_Issue_Fix : RV 2024-01-24 16:18:34 +05:30
cc9f3650fe Tracker_Issue_Fix : RV 2024-01-24 14:22:57 +05:30
40aa6fe055 Fix_Empty_Drag_and_Drop_Issue : RV 2024-01-23 17:32:20 +05:30
072126a2f2 Fix_Section_Display_Marks : RV 2024-01-23 14:36:49 +05:30
b59e46713c XML_CHANGES : RV 2024-01-22 16:51:42 +05:30
3ef12dc65a PREVIEW_ISSUES_FIXES : RV 2024-01-20 17:37:48 +05:30
c63b2062b4 JSON2XML->XML2JSON->JSON2HTML Changes : RV 2024-01-19 12:09:01 +05:30
aadhavan valli
ce6d38d329 SECTIONDELETEFUNCTION CHOICEQUESTIONPREVIEW: AADHAVAN 2024-01-19 09:41:05 +05:30
aadhavan valli
a580c841f6 DRAGANDDROP : AADHAVAN 2024-01-12 11:15:53 +05:30
9797075e88 CHANGE_QUILL_TO_JODIT_COMPLETE_FLOW : RV 2024-01-11 11:17:15 +05:30
64dc8a7133 INITIAL_COMMIT : RV 2024-01-06 11:31:15 +05:30
40 changed files with 5506 additions and 9820 deletions

View File

@ -1,4 +1,3 @@
function QuestionPaperPreview(jsonData){
// The provided JSON data
// console.log(jsonData)
@ -40,24 +39,46 @@ function QuestionPaperPreview(jsonData){
function convertToLatex(text, mathstatus) {
// console.log(text);
// Parse mathstatus into a boolean
const mathStatusBoolean = JSON.parse(mathstatus);
// console.log('convertToLatex : ', mathstatus);
// console.log('convertToLatex text : ', text);
// const mathStatusBoolean = JSON.parse(mathstatus);
// Check if the text contains <p> tags
if (!/<p>|<\/p>/i.test(text)) {
if (mathStatusBoolean) {
if (mathstatus === 'Math') {
// Use MathJax to convert the text to LaTeX
const cov = MathJax.tex2chtml(text).outerHTML;
return cov;
// console.log('Latex Full : ', cov);
const onlyMath = convertMathJaxToLatex(cov)
// console.log('Latex small : ', onlyMath);
return onlyMath;
} else {
// Return the text as-is
return text;
}
} else {
// Return the text as-is
return text;
}
}
function convertMathJaxToLatex(mathJaxCode) {
// Replace MathJax-specific tags and attributes
let latexCode = mathJaxCode
.replace(/<mjx-container[^>]*>/g, '')
.replace(/<\/mjx-container>/g, '')
.replace(/<mjx-math[^>]*>/g, '')
.replace(/<\/mjx-math>/g, '')
.replace(/<mjx-mi[^>]*>/g, '')
.replace(/<\/mjx-mi>/g, '')
.replace(/<mjx-c[^>]*>/g, '')
.replace(/<\/mjx-c>/g, '')
.replace(/<mjx-assistive-mml[^>]*>/g, '')
.replace(/<\/mjx-assistive-mml>/g, '')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>');
return latexCode;
}
// Initialize the formatted question paper string
let questionPaper = "";
@ -69,9 +90,22 @@ function QuestionPaperPreview(jsonData){
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex , questionIndex = 1) {
const sections = data.sections;
const questionPaperTitle = data.question_paper_title;
const questionPaperDescription = data.question_paper_description;
var title = removeHtmlTags(questionPaperTitle)
var questionPaperDescription = data.question_paper_description;
var title = '';
if(questionPaperTitle == '' || questionPaperTitle == '<p><br></p>' || questionPaperTitle == null){
var title = 'Untitled'
}else{
title = removeHtmlTags(questionPaperTitle);
}
if(questionPaperDescription == '' || questionPaperDescription == '<p><br></p>' || questionPaperDescription == null){
var questionPaperDescription = ''
}else{
questionPaperDescription = data.question_paper_description;
}
console.log('questionPaperDescription : ', questionPaperDescription)
// Wrap the heading elements in <div> elements with CSS for centering
questionPaper += `<div style="text-align: center; font-weight: bolder; "><h1>${title}</h1></div>`;
@ -88,8 +122,8 @@ function QuestionPaperPreview(jsonData){
const sectionTitle = section.section_title;
const modifiedSectionTitle = sectionTitle.replaceAll('<p>', '<p id="sectionTitle">');//add the id for Section Title
// console.log(section.section_attempt_any);
if (section.section_attempt_any) {
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.section_attempt_any}</p>`;
if (section.attributes.AttemptAny) {
var sectionAttempt = `<p id="sectionAttempt">Attempt Any : ${section.attributes.AttemptAny}</p>`;
} else {
var sectionAttempt = `<p id="sectionAttempt"> </p>`;
@ -102,7 +136,8 @@ function QuestionPaperPreview(jsonData){
}
var displayMarks = section.section_display_marks;
var displayMarks = section.attributes.DisplayMarks;
// console.log('displayMarks : ', displayMarks)
if (displayMarks === 'false') {
var parser = new DOMParser();
var doc = parser.parseFromString(sectionMark, 'text/html');
@ -114,7 +149,7 @@ function QuestionPaperPreview(jsonData){
var doc = parser.parseFromString(sectionAttempt, 'text/html');
var questionMarkElement = doc.body.firstChild;
questionMarkElement.style.marginRight = '106px';
console.log(questionMarkElement);
// console.log(questionMarkElement);
sectionAttempt =questionMarkElement.outerHTML
}
@ -144,18 +179,22 @@ function QuestionPaperPreview(jsonData){
var description_align =25;
function displayQuestions(data,parentSno =''){
var questionIndentation = " ".repeat(depth2);
console.log(data)
var dataa =data.questions;
dataa.forEach((question, index) =>{
console.log(question.descriptionMath);
var currentSno = parentSno + (index + 1) + '.';
console.log('currentSno : ', currentSno);
var temp_sno= currentSno.slice(0,-1)
var currentSno_length =currentSno.length-(currentSno.length/2)
console.log('currentSno_length : ', currentSno_length);
if (currentSno_length == 1) {
description_align =27
} else if (currentSno_length == 2) {
description_align =33
description_align =20
}else if(currentSno_length == 3){
description_align =48
}else if(currentSno_length == 4) {
@ -165,11 +204,15 @@ function QuestionPaperPreview(jsonData){
description_align =78
}
if(question.descriptionMath == 'Math'){
description_align = -364
}
var GroupQuestionTilteAlign = 0;
if (question.group_title) {
let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim();
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','');
var question_id_length =cleanedText.length;
if (question_id_length == 1) {
@ -196,9 +239,8 @@ function QuestionPaperPreview(jsonData){
const questionGroupSetP = `${question.group_title}`;
const questionGroupmodify =questionGroupSetP.replaceAll('<p>', `<p id="question-Group-Id" style="padding-left:${GroupQuestionTilteAlign}px">`)
if (question.group_attempt_any) {
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.group_attempt_any} </p>`
if (question.attributes.AttemptAny) {
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.attributes.AttemptAny} </p>`
}else{
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny"> </p>`
@ -209,7 +251,7 @@ function QuestionPaperPreview(jsonData){
var questionGroupMark = `<p id="group_marks">Marks : ${question.group_marks} </p>`
}
var displayMarks = question.group_display_marks;
var displayMarks = question.attributes.DisplayMarks;
if (displayMarks === 'false') {
var parser = new DOMParser();
var doc = parser.parseFromString(questionGroupMark, 'text/html');
@ -231,16 +273,16 @@ function QuestionPaperPreview(jsonData){
// questionGroupMark = questionGroupMark.replace('<p id="group_marks">', '<p id="group_marks" hidden>')
// }
questionPaper += `<div class="text-group-align" style="margin-left:0px;">${questionId})${questionGroupmodify}</div>`
questionPaper += `<div class="textGroup"><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>`;
questionPaper += `<div class="group-descrip" style="margin-left:${description_align}px">${questionGroupDescription}</div></div>`;
depth2++
} else if (question.question) {
let cleanedTex = question.questionId.replace(/\s+/g, ' ').trim();
// console.log('serial no : ', question.attributes.No);
let cleanedTex = question.attributes.No.replace(/\s+/g, ' ').trim();
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
var question_id_length =cleanedText.length;
if (question_id_length == 1) {
@ -262,6 +304,7 @@ function QuestionPaperPreview(jsonData){
// console.log(question);
// const questionId =`<p class="questionId">${cleanedText})</p>`;
const questionI =cleanedText;
// console.log('cleanedText : ', questionI);
var questionId = questionI.replace('<p>', '<p class="questionId">');
const questionTex = question.question;
@ -269,21 +312,23 @@ function QuestionPaperPreview(jsonData){
// console.log(questionText);
const questionDescriptio = question.question_description;
const questionDescription = questionDescriptio.replaceAll('<p>', '<p class="question-Description">')
const mathstatus = question.is_math_enabled;
const mathstatus = question.descriptionMath;
const titlemathstatus = question.titleMath;
console.log('questionText : ', questionText)
console.log('titlemathstatus : ', titlemathstatus)
if (question.marks == 0 || question.marks == '' ) {
var questionMark = `<p id="question-mark"> </p>`;
} else {
var questionMark = `<p id="question-mark">Marks :${question.marks}</p>`;
}
var displayMarks =question.display_marks
var displayMarks =question.attributes.DisplayMarks
if (displayMarks === 'false') {
var parser = new DOMParser();
var doc = parser.parseFromString(questionMark, 'text/html');
var questionMarkElement = doc.body.firstChild;
questionMarkElement.setAttribute('hidden', 'hidden');
questionMark =questionMarkElement.outerHTML
questionMark =questionMarkElement.outerHTML;
}
// console.log(questionMark);
@ -292,25 +337,23 @@ function QuestionPaperPreview(jsonData){
questionMark = questionMark.replace('<p id="question-mark">', '<p id="question-mark" hidden>')
}
// questionPaper += `<div id="parent" class="text-qus-align">${temp_sno})${convertToLatex(questionText, mathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px">${convertToLatex(questionDescription, mathstatus)}</div>`;
questionPaper += `<div id="parent" class="text-qus-align">${questionId})${convertToLatex(questionText, mathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px">${convertToLatex(questionDescription, mathstatus)}</div>`;
//
questionPaper += `<div id="parent" class="text-qus-align">${questionId})${convertToLatex(questionText, titlemathstatus)}</div>${questionMark}<div class="text-des align-right" style="margin-left:${description_align}px;">${convertToLatex(questionDescription, mathstatus)}</div>`;
if (question.question_type === "group") {
var answers = question.answers;
var answerId =question.question_id;
console.log('choice answers math: ', question.answers)
var choisealgin =25
// var currentSno_length1 =currentSno.length-(currentSno.length/2)
var currentSno_length1 =question_id_length
console.log(answerId);
// console.log(answerId);
// console.log(currentSno_length1);
if (currentSno_length1 == 1) {
choisealgin =26
// choisealgin =26
choisealgin =52
} else if (currentSno_length1 == 2) {
choisealgin =25
choisealgin = 52
}else if(currentSno_length1 == 3){
choisealgin =33
}else if(currentSno_length1 == 4) {
@ -328,19 +371,29 @@ 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="text-option-align" style="margin-left:${choisealgin}px"><input type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
questionPaper += `<div class="${choiceClass}" style="margin-left:${choisealgin}px;"><input class="optionSelectArea" type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
}else{
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input type="checkbox" name="answer" value="A"> <p class="ChoiceOption"> ${answerA.padEnd(10)}</p></div>`;
questionPaper += `<div class="${choiceClass}" style="margin-left:${choisealgin}px;"><input class="optionSelectArea" type="checkbox" name="answer" value="A"> <p class="ChoiceOptionMultiple">${answerA.padEnd(10)}</p></div>`;
}
}
}
@ -365,17 +418,6 @@ function QuestionPaperPreview(jsonData){
function removeHtmlTags(inputString) {
const cheerio = require('cheerio');
@ -385,33 +427,33 @@ function removeHtmlTags(inputString) {
return text;
}
function convertToLatex(text, mathstatus) {
// Parse mathstatus into a boolean
const mathStatusBoolean = true
// Check if the text contains <p> tags
console.log(text);
// console.log("ff")
if (!/<p>|<\/p>/i.test(text)) {
// console.log('text:' , text)
if (mathStatusBoolean) {
// console.log('text1:' , text)
// Use MathJax to convert the text to LaTeX
const cov = MathJax.tex2chtml(text).outerHTML;
console.log('cov:' , cov)
// function convertToLatex(text, mathstatus) {
// // Parse mathstatus into a boolean
// const mathStatusBoolean = true
// // Check if the text contains <p> tags
// console.log(text);
// // console.log("ff")
// if (!/<p>|<\/p>/i.test(text)) {
// // console.log('text:' , text)
// if (mathStatusBoolean) {
// // console.log('text1:' , text)
// // Use MathJax to convert the text to LaTeX
// const cov = MathJax.tex2chtml(text).outerHTML;
// console.log('cov:' , cov)
return cov;
} else {
// Return the text as-is
// return cov;
// } else {
// // Return the text as-is
return text;
}
} else {
console.log("pq")
const cov = MathJax.tex2chtml(text).outerHTML;
console.log('cov:' , cov)
// return text;
// }
// } else {
// console.log("pq")
// const cov = MathJax.tex2chtml(text).outerHTML;
// console.log('cov:' , cov)
return cov;
// Return the text as-is
return text;
}
}
// return cov;
// // Return the text as-is
// return text;
// }style="margin-left:27px;position: absolute;right: 546px;bottom: 10px;"
// }

View File

@ -3,10 +3,8 @@
<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 -->
@ -53,8 +51,29 @@
<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: 25px;
margin-top: 30px;
margin-bottom: 15px;
}
@ -66,9 +85,22 @@
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;
@ -202,6 +234,7 @@
margin-right: 10px;
float: right;
margin-top:-27px;
margin-top:-41px;
}
/* Section SectionAttempt SectionMark */
@ -253,11 +286,44 @@
.MathJax.CtxtMenu_Attached_0{
display: contents !important;
}
.text-qus-align{padding-right: 62px; }
.text-qus-align{
padding-right: 62px;
/* margin-top: 37px; */
inline-size: 790px;
display:table-footer-group;
/* position: relative; */
/* top:30px */
}
.text-qus-align p{ margin:0; }
.text-des{ margin-left: 20px;margin-top: 0px;} /* Change there aadhavan top-6px*/
.text-option-align{display:flex;margin-top: 0%;margin-left: 45px;} /* Change there aadhavan 10px*/
.text-option-align p{ margin:0; text-wrap: balance;}
.text-des{
margin-left: 20px;
margin-top: 23px;
inline-size: 790px;
} /* Change there aadhavan top-6px*/
.text-option-align{
display:flow-root;
margin-top: -2%;
margin-left: 45px;
inline-size: 790px;
position: relative;
bottom: 13px;
} /* Change there aadhavan 10px*/
.text-option-align p{
margin:0;
text-wrap: balance;
}
.text-option-align2{
display:flow-root;
margin-top: 20px;
margin-left: 45px;
inline-size: 790px;
position: relative;
bottom: 50px;
} /* Change there aadhavan 10px*/
.text-option-align2 p{
margin:0;
text-wrap: balance;
}
/* #sectionTitle {border-top: 2px solid gray
; width:99%;} */
/* #sectionTitle:first-of-type {border:none;} */
@ -291,11 +357,13 @@
.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-right: 10px; */
/* margin-bottom: -40px; */
margin-bottom: 10px;
}
.question-Description{
inline-size: 660px;
@ -303,7 +371,11 @@
}
.question-Group-Description{
inline-size: 660px;
text-wrap: wrap;
text-wrap: wrap;
position: relative;
bottom: 30px;
right: 12px;
margin-bottom: 15px;
}
.text-group-align{
/* display: flex; */
@ -314,11 +386,14 @@
margin-top: -54px;
float: right;
display:inline;
position: relative;
left: 10px;
}
.group-descrip{
position: relative;
top: -21px;
margin-bottom: -20px;
top: 8px;
margin-bottom: -26px;
inline-size: 790px;
}
/* p.question_Text:not(:first-of-type) {
margin-left: 34px;
@ -373,6 +448,12 @@ color: #1d3557 !important;
color: #1d3557 !important;
}
math {
position: relative;
bottom: 24px;
left: 21px;
}
</style>
</head>
@ -400,7 +481,7 @@ color: #1d3557 !important;
<div class="col-lg-12">
<div class="nav-menu">
<div class="header-logo">
<a href="dashboard.html" ><img class="logo-d" src="assets/images/project-b-logo.png" alt=""></a>
<a href="dashboard.html" ><img class="logo-d" src="assets/images/Nexa_Author Logo.png" alt="" style="position: relative !important; bottom: 11px !important;"></a>
</div>
<div class="heder-menu">
<ul>
@ -426,12 +507,13 @@ color: #1d3557 !important;
<div class="copy-right-area">
<div class="copy-left">
<span style="color: #1D3557;">© 2023 Project-B. All rights reserved.</span>
<span id="copyright" style="color: #1D3557;"></span>
</div>
</div>
<!-- jquery js -->
<script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
<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> -->
<!-- mathjax -->
<script src="./node_modules/mathjax/es5/tex-chtml-full.js"></script>
<!-- bootstrap js -->
@ -455,7 +537,7 @@ color: #1d3557 !important;
<!-- 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 -->
@ -475,6 +557,17 @@ color: #1d3557 !important;
<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');
@ -522,6 +615,7 @@ 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);
@ -724,7 +818,7 @@ try {
<!-- Start this is Add TItle Dynamic -->
<script>
var dynamicTitleValue = configObject.TITLE;
var dynamicTitleValue = 'Nexa Author';
document.getElementById("dynamicTitle").innerText = dynamicTitleValue;
</script>
<!-- End this is Add TItle Dynamic -->

View File

@ -26,4 +26,11 @@ 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
* 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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
{"AppSetting":["WorkArea,MathCheckbox,TextQuestionButton,MCQQuestionButton"]}

View File

@ -0,0 +1 @@
{"AppSetting":["SubTitle"]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

1
assets/images/close.svg Normal file
View File

@ -0,0 +1 @@
<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>

After

Width:  |  Height:  |  Size: 332 B

View File

@ -0,0 +1,3 @@
<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>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1 @@
<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>

After

Width:  |  Height:  |  Size: 667 B

BIN
assets/images/paper.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
assets/images/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,4 @@
var a =document.

View File

@ -0,0 +1,328 @@
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" });
}
}

View File

@ -0,0 +1,72 @@
/* .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; */
}

View File

@ -0,0 +1,10 @@
module.exports.takeNumberOnly = function (text) {
let number = text.match(/\d+/)[0];
return number
}

View File

@ -4,7 +4,6 @@
<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">
@ -45,12 +44,99 @@
<!-- <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 */
@ -227,12 +313,13 @@ 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/project-b-logo.png" alt=""></a>
<a href="dashboard.html"><img class="logo-d" src="assets/images/Nexa_Author 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>
@ -269,11 +356,11 @@ margin-left: -16px;
</div>
</div>
<div class="copy-right-area">
<div class="copy-left">
<span style="color: #1D3557;">© 2023 Project-B. All rights reserved.</span>
</div>
</div>
<div class="copy-right-area">
<div class="copy-left">
<span id="copyright" style="color: #1D3557;"></span>
</div>
</div>
<!-- jquery js -->
<script src="assets/js/vendor/jquery-3.2.1.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
@ -319,7 +406,18 @@ 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();
@ -598,6 +696,186 @@ 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 {
@ -649,12 +927,216 @@ function copyFile(sourceFilePath, destinationFilePath) {
<!-- Start this is Add TItle Dynamic -->
<script>
var dynamicTitleValue = configObject.TITLE;
var dynamicTitleValue = 'Nexa Author';
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>

View File

@ -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;

View File

@ -3,21 +3,34 @@ 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 = "";
if(isMathEnabled == true)
{
//for Descriptive question Description math check
if(isMathEnabled == true){
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
}else{
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).innerHTML;
}
else
{
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').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;
}
var questionType = document.getElementById('question_type_' + element_id).value;
// var questionSubType = document.getElementById('longAnswer_' + element_id).checked;
var questionSubType = 'false';
@ -28,6 +41,7 @@ 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,
@ -37,24 +51,37 @@ function html2json() {
$.fn.getChoiceQuestion = function(element_id) {
var questionChoiceId = document.getElementById('QuestionChoiceId_' + element_id).value;
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
var questionTitle = document.getElementById('textQuestionName_' + element_id).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).querySelector('.ql-editor').innerHTML;
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).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;
@ -71,7 +98,7 @@ function html2json() {
}
else
{
choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML;
choice_name = document.getElementById('choiceTextField_' + element_id).innerHTML;
}
var choice_group_fixed_uuid = document.getElementById('Choice_Group_Fixed_UUID_ID_' + element_id).value;
answers.push({
@ -113,7 +140,7 @@ function html2json() {
}
else
{
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML;
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).innerHTML;
}
// console.log('choice_description id in the html to json script');
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
@ -142,6 +169,7 @@ 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,
@ -215,8 +243,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.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_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_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);
@ -246,8 +274,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.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_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_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);
@ -265,8 +293,8 @@ function html2json() {
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;
var question_paper_title = document.getElementById('Question_title').innerHTML;
var question_paper_description = document.getElementById('Question_description').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;
@ -303,10 +331,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})));
}

View File

@ -2,35 +2,83 @@ function json2nav() {
// console.clear();
$.fn.getTextQuestion = function(element_id) {
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
var textQuestionId = 'textQuestionName_' + element_id;
// 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 questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
var choiceQuestionId = 'textQuestionName_' + element_id;
// var choiceQuestionId = 'textQuestionName_' + element_id;
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
// var questionType = 'Group';
var questionType = document.getElementById('question_type_' + element_id).value;
var isMathEnabled = document.getElementById('titlemath_' + element_id).checked;
var questionTitle = "";
var choiceQuestionId = "";
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
}
}
@ -85,11 +133,19 @@ function json2nav() {
// console.log(rand_id);
// console.log('section_title_text_'+rand_id);
var groupQuestion = {}
var group_title = document.getElementById('subSection_title_text_' + rand_id);
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_attempt_any = document.getElementById('Question_Attempt_Any_Id_' + rand_id);
var group_marks = document.getElementById('Question_Group_Marks_Id_' + rand_id);
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.querySelector('.ql-editor').innerHTML : null) : null);
groupQuestion['serial_Number'] = serial_Number
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title : 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);
@ -105,18 +161,23 @@ 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 = {}
var section_title = document.getElementById('section_title_text_' + rand_id);
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_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.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_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_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);
@ -133,7 +194,24 @@ function json2nav() {
var formData = {};
var question_paper_title = document.getElementById('Question_title').querySelector('.ql-editor').innerHTML;
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;
formData['question_paper_title'] = question_paper_title;
formData['Question_title_id'] = 'Question_title';
formData['sections'] = [];

View File

@ -1,224 +0,0 @@
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})));
}

View File

@ -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 dynamicId = `download-button-${Date.now()}`;
const dynamicIdDownload = `download-button-${Date.now()}`;
const dynamicIdDuplicate = `duplicate-button-${Date.now()}`
// Handle list view
const html_for_list = `
@ -75,9 +75,12 @@ 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="${dynamicId}" data-filename="${xmlFile}" title="Download">
<a class="icons" href="#" id="${dynamicIdDownload}" 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">
@ -90,12 +93,19 @@ async function loadMultipleXMLs() {
$('#list').append(html_for_list);
// Add event listener for download buttons
$('#'+dynamicId).on('click',function (event) {
$('#'+dynamicIdDownload).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);
}

View File

@ -12,8 +12,8 @@ function jsonToHtml(jsonData) {
if(jsonData == "" || jsonData == null)
{
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = "";
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = "";
document.getElementById('Question_title').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = "";
document.getElementById('Question_description').querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML = "";
document.getElementById('Max_Marks').value = "";
document.getElementById('Course_ID').value = "";
document.getElementById('Course_Code').value = "";
@ -37,8 +37,10 @@ function jsonToHtml(jsonData) {
var paper_No = jsonData.attributes.PaperNo;
var subject_Name = jsonData.attributes.SubjectName;
var sub_Paper_Prefix = jsonData.attributes.SubPaperPrefix;
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = title;
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = description;
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('Max_Marks').value = max_marks;
document.getElementById('Course_ID').value = course_ID;
document.getElementById('Course_Code').value = course_Code;
@ -59,8 +61,8 @@ function jsonToHtml(jsonData) {
var sectionDescription = section.section_description;
var sectionMarks = section.section_marks;
var sectionUUID = section.attributes.Id;
var sectionDispalyMarks = section.section_display_marks;
var sectionAttemptAny = section.section_attempt_any;
var sectionDispalyMarks = section.attributes.DisplayMarks;
var sectionAttemptAny = section.attributes.AttemptAny;
var SectionObj = {
@ -69,8 +71,8 @@ function jsonToHtml(jsonData) {
'sectionDescription' :section.section_description,
'sectionMarks' :section.section_marks,
'sectionUUID' :section.attributes.Id,
'sectionDispalyMarks':section.section_display_marks,
'sectionAttemptAny' :section.section_attempt_any,
'sectionDispalyMarks':section.attributes.DisplayMarks,
'sectionAttemptAny' :section.attributes.AttemptAny,
}
// addSection(SectionObj); //call the addSection() function and send the sectionObject to that function
@ -106,15 +108,17 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
{
questionTypeFormets ='question_group';
}
var questionId = Question.question_id
var questionId = Question.attributes.No
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.display_marks;
var questionDisplayMarks = Question.attributes.DisplayMarks;
var Choice = Question.answers;
var CorrectAnswer = Question.correct_answer;
@ -124,15 +128,16 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
"question_area_id" :questionAreaId,
'questionRandomNo' :questionRandomNo,
'questionId' :Question.question_id,
'questionId' :Question.attributes.No,
'questionTitle' :Question.question,
'questionDescription' :Question.question_description,
'questionType' :questionTypeFormets,
'questionSubType' :Question.question_sub_type,
'mathEnabled' :Question.is_math_enabled,
'titleMath' :Question.titleMath,
'descriptionMath' :Question.descriptionMath,
'questionMarks' :Question.marks,
'questionUUID' :Question.attributes.Id,
'questionDisplayMarks' :Question.display_marks,
'questionDisplayMarks' :Question.attributes.DisplayMarks,
'Choice' :Question.answers,
'CorrectAnswer' :Question.correct_answer
}
@ -145,7 +150,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
}
else if (questionType == 'group')
{
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId,CorrectAnswer[0]);
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, descriptionMath, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId,CorrectAnswer[0], titleMath);
Choice = Choice.slice(1);
Choice.forEach(function(choicenames, indexs) {
var choiceName = choicenames.choice_name;
@ -168,7 +173,11 @@ 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) {

View File

@ -62,25 +62,24 @@ 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')
'Type': (question['question_type'] == 'text' ? 'Descriptive' : 'MCQ'),
'No': (question['question_id'] ? question['question_id'] : question['questionChoiceId']),
'DisplayMarks': (question['display_marks'] === true ? 'true' : 'false'),
}, '');
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);
@ -92,7 +91,9 @@ 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'], {});
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
if(question['answers'][choice]['is_math_enabled'] === true){
text.setAttribute('Type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : ''));
}
}
// choicesElement.appendChild();
@ -110,33 +111,24 @@ function json2xml() {
doc,
element
} = createStandaloneXMLNode('Question', {
'xsi:type': 'QuestionGroup',
// 'xsi:type': 'QuestionGroup',
'Id': singleQuestion['group_uuid'],
'Type': 'QuestionGroup',
'No': singleQuestion['group_title'],
'Order': 0
'No': (singleQuestion['question_id'] ? singleQuestion['question_id'] : '' ),
'DisplayMarks':(singleQuestion['group_display_marks'] === true ? 'true' : 'false' ),
...(singleQuestion['group_attempt_any'] !== '' ? {'AttemptAny': singleQuestion['group_attempt_any']} : {})
}, '');
// 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];
@ -191,22 +183,24 @@ 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': tempSection['section_title'],
'Order': 0
'No': sectionNumber,
'DisplayMarks':(tempSection['section_display_marks'] === true ? 'true' : 'false'),
...(tempSection['section_attempt_any'] !== '' ? {'AttemptAny': tempSection['section_attempt_any']} : {}),
});
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', '', );

View File

@ -35,6 +35,8 @@ 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,
@ -52,6 +54,7 @@ async function createWindow() {
// mainWindow.removeMenu()
mainWindow.loadFile('dashboard.html'); // Create an HTML file for your interface
// if(process.env.ENABLE_DEV_TOOLS === 'TRUE')
@ -87,6 +90,9 @@ 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');
}

View File

@ -1,4 +1,7 @@
const { css } = require("jquery");
// const { css } = require("jquery");
// const mathJaxPath = require.resolve('./node_modules/mathjax/es5/latest.js');
// require(mathJaxPath);
const takeNumberOnly = require('./assets/js/takeNumberOnly/takeNumberOnly')
// Initialize an array to store the expanded section data-ids
const expandedSections = [];
@ -23,7 +26,7 @@ function navpane() {
var html = html.replace(/<[^>]*>/g, '');
if (html.length >= 30) {
html=html.slice(0,30 ) + '...';
html=html.slice(0,24 ) + ''; // ...
}
return html
@ -53,9 +56,9 @@ function navpane() {
// Truncate the content
var truncatedContent = "";
if(textContent.length > 30)
if(textContent.length > 24)
{
truncatedContent = textContent.substring(0, maxLength) + '...';
truncatedContent = textContent.substring(0, maxLength) + ''; // ...
}
else{
truncatedContent = textContent;
@ -65,6 +68,7 @@ function navpane() {
}
function createTreeWithHeading(data, container) {
const treeTitle = removeParagraphTags(data.question_paper_title);
const heading = document.createElement('a');
heading.style.color = '#1D3557';
@ -86,6 +90,13 @@ 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);
@ -215,8 +226,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;
@ -254,8 +265,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';
@ -284,6 +295,7 @@ function navpane() {
sectionDiv.appendChild(sectionLink);
section.questions.forEach(question => {
// console.log(question);
createTreeNode(question, contentDiv);
});
@ -293,19 +305,31 @@ 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);
parentNode.appendChild(nodeDiv);
if (nodeDataId) {
var navPaneQuestionId = takeNumberOnly.takeNumberOnly(nodeDataId)
}
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')
{
@ -316,9 +340,16 @@ function navpane() {
bulletPoint.style.fontWeight = 'bold';
bulletPoint.style.color = '#00aaff';
// bulletPoint.textContent = '\u2022';
bulletPoint.setAttribute("title", "Descriptive");
nodeDiv.appendChild(bulletPoint);
// 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)");
var splitedId = nodeDataId.split("_")[1];
RawID = 'removeAndCloneTextQuestion_'+splitedId;
@ -333,11 +364,18 @@ function navpane() {
bulletPoint.style.color = '#00aaff';
bulletPoint.setAttribute("title", "MCQ");
// bulletPoint.textContent = '\u2022';
nodeDiv.appendChild(bulletPoint);
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);
var splitedId = nodeDataId.split("_")[1];
RawID = 'removeAndCloneQroupQuestion_'+splitedId;
}
var QuestionID = document.getElementById(RawID)
@ -362,13 +400,13 @@ function navpane() {
questionLink.style.maxWidth = '190px';
questionLink.style.fontWeight = '100';
if(nodeDataType == 'text')
{
questionLink.setAttribute("title", "Descriptive");
}else if(nodeDataType == 'text'){
questionLink.setAttribute("title", "MCQ");
// if(nodeDataType == 'text')
// {
// questionLink.setAttribute("title", "DescriptiveQuestion");
// }else if(nodeDataType == 'group'){
// questionLink.setAttribute("title", "MultiChoiceQuestion");
}
// }
// QuestionID.addEventListener('click', function () {
// if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
@ -398,9 +436,10 @@ 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.marginLeft ='-67px';
// nodeDiv.style.paddingLeft='67px';
// nodeDiv.style.marginRight= '-75px';
// nodeDiv.style.justifyContent= 'space-between';
QuestionID.style.fontWeight = '100';
currentlyHighlightedElement = nodeDiv;
// nodeDiv.scrollIntoView({ behavior: 'smooth', block: 'start' });
@ -428,6 +467,7 @@ 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' });
@ -466,10 +506,11 @@ 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 () {
@ -486,6 +527,7 @@ function navpane() {
nodeDiv.style.color = ' black';
nodeDiv.style.marginLeft ='0px';
nodeDiv.style.paddingLeft='0px';
// nodeDiv.style.justifyContent= 'space-between';
currentlyHighlightedElement =null
});
@ -499,19 +541,45 @@ function navpane() {
// questionLink.innerHTML = removeParagraphTags(nodeData.question);
// }
questionLink.innerHTML = removeTagsAndTruncate(nodeData.question, 25);
var htmlTagRemovedQuestionTitle = removeTagsAndTruncate(nodeData.serial_Number, 25);
var Latex = convertToLatex(htmlTagRemovedQuestionTitle);
var data = ''
if(nodeData.isMathEnabled){
data = Latex;
}else{
data = htmlTagRemovedQuestionTitle;
}
questionLink.innerHTML = data;
// console.log('questionLink : ', questionLink)
nodeDiv.appendChild(questionLink);
nodeDivChildForIconAlgin.appendChild(questionLink);
nodeDiv.appendChild(dragIcon)
} 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);
@ -527,13 +595,11 @@ function navpane() {
} else {
groupTitleDiv.classList.add('collapsed');
}
if(editPage == 1 || editPage == null){
groupTitleDiv.classList.add('collapsed');
}
parentNode.appendChild(groupTitleDiv);
const groupTitleArrow = document.createElement('span');
@ -552,7 +618,7 @@ function navpane() {
groupTitleArrow.className = 'arrow-down';
groupQuestionsDiv.classList.add('visible');
}
groupTitleArrow.addEventListener('click', () => {
groupQuestionsDiv.classList.toggle('visible');
groupTitleDiv.classList.toggle('collapsed');
@ -596,7 +662,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
@ -651,11 +717,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;
@ -753,12 +819,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' });
@ -768,10 +834,10 @@ function navpane() {
if (nodeData.group_title.length > 20) {
// groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title);
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.serial_Number);
} else {
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title);
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.serial_Number);
}
groupTitleDiv.appendChild(groupQuestionLink);
@ -781,6 +847,7 @@ function navpane() {
});
parentNode.appendChild(groupQuestionsDiv);
}
}
var questionPaperContainer = document.getElementById('questionPaper');
@ -819,38 +886,58 @@ 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) {
element.scrollIntoView({ behavior: "smooth", block: "center" });
focus.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)
}
}
let draggedItemGroup = null;
let draggedItemQuestion = null;
let dropTarget = null;
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(/&lt;/g, '<')
.replace(/&gt;/g, '>');
return latexCode;
}
// 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
View File

@ -1,11 +1,11 @@
{
"name": "projectb",
"name": "Nexa Author",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "projectb",
"name": "Nexa Author",
"version": "1.0.0",
"license": "MIT",
"dependencies": {

View File

@ -1,15 +1,15 @@
{
"name": "projectb",
"name": "Nexa Author",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "start",
"start": "electron .",
"build": "cross-env NODE_ENV=production electron-packager . ProjectB --platform=win32 --arch=x64",
"build": "cross-env NODE_ENV=production electron-packager . NexaAuthor --platform=win32 --arch=x64",
"convertEnvBase64": "node envConvertBasetoString.js"
},
"author": "venkatesh",
"author": "VenbaInfoTech",
"license": "MIT",
"devDependencies": {
"electron": "^26.1.0",
@ -44,14 +44,6 @@
"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",

View File

@ -2,11 +2,13 @@ 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);
};

View File

@ -89,6 +89,8 @@ 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();
@ -98,12 +100,10 @@ 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 = "";

View File

@ -3331,8 +3331,8 @@ a.main_sticky {
position: fixed;
top: 70px;
left: 0;
max-height: 532px;
max-height: 750px;
/* max-height: 532px; */
padding: 0 10px 20px;
width: 235px;
height: -webkit-fill-available;
@ -3612,6 +3612,7 @@ font-size: 14px;
display: flex;
/* display: contents; */
align-items: center;
justify-content: space-between;
}
@ -3819,3 +3820,5 @@ font-size: 14px;
.is-hide{
display:none;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,9 @@ 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) {
@ -20,6 +22,22 @@ 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);
@ -27,33 +45,35 @@ 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[1].firstChild.nodeValue;
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
// 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_type'] = 'text';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = 'false';
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
// questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
// console.log(questionObj);
}
else
{
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_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_type'] = 'group';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = questionNode.childNodes[3].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
// questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['answers'] = [];
questionObj['correct_answer'] = [];
var choiceList = questionNode.childNodes[7].childNodes;
var choiceList = questionNode.childNodes[4].childNodes;
// console.log(questionNode);
if(choiceList.length > 0)
{
@ -63,8 +83,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'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
// console.log(tempChoiceobj);
tempChoiceobj['is_math_enabled'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
// console.log(tempChoiceobj);
questionObj['answers'].push(tempChoiceobj);
}
}
@ -106,27 +126,24 @@ function getQuestionsNodes(questionNode,type)
function getQuestionGroupNodes(questionGroup)
{
var questionGroupObj = {};
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['group_title'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
questionGroupObj['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
questionGroupObj['questions'] = [];
//handle questions
var questionList = questionGroup.childNodes[6].childNodes;
var questionList = questionGroup.childNodes[3].childNodes;
// console.log('No of quetions in GQ:' + questionList.length);
for(let q = 0; q < questionList.length ;q++)
{
var questionType = questionList[q].getAttribute("xsi:type");
if(questionType == 'DescriptiveQuestion')
var questionType = questionList[q].getAttribute("Type");
if(questionType == 'Descriptive')
{
// console.log(questionList[q]);
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
}
else if(questionType == 'MultiChoiceQuestion')
else if(questionType == 'MCQ')
{
// console.log(questionList[q]);
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
@ -153,9 +170,11 @@ 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_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue;
//get attributes of root/question paper element
// 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['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
jsonObj['sections'] = [];
@ -170,15 +189,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.nodeValue;
tempObj['section_description'] = (sectionsList[i].childNodes[1].firstChild !== null ? sectionsList[i].childNodes[1].firstChild.nodeValue : "");
tempObj['section_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
tempObj['section_display_marks'] = sectionsList[i].childNodes[3].firstChild.nodeValue;
tempObj['section_attempt_any'] = (sectionsList[i].childNodes[4].firstChild !== null && sectionsList[i].childNodes[4].firstChild !== undefined ? sectionsList[i].childNodes[4].firstChild.nodeValue : "");
// tempObj['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['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
tempObj['questions'] = [];
//handle questions
var questionList = sectionsList[i].childNodes[5].childNodes;
var questionList = sectionsList[i].childNodes[3].childNodes;
// console.log('No of quetions:' + questionList.length);
// console.log(questionList);
for(let j = 0; j < questionList.length ;j++)
@ -186,13 +205,13 @@ jsonObj['sections'] = [];
//check weather quesiotn or question grup
// console.log('QUESTION :' + j );
// console.log(questionList[j]);
var questionType = questionList[j].getAttribute("xsi:type");
var questionType = questionList[j].getAttribute("Type");
// console.log(questionType);
if(questionType == 'DescriptiveQuestion')
if(questionType == 'Descriptive')
{
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
}
else if(questionType == 'MultiChoiceQuestion')
else if(questionType == 'MCQ')
{
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
}
@ -205,10 +224,11 @@ 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');

View File

@ -18,37 +18,52 @@ function getAttributesOfXMLNode(node)
return attributes;
}
function getAttributesOfXMLNodeWithoutArray(node)
{
// console.log('xmal attributes');
// console.log(node);
// Get attributes of the node (if any)
attributes = {};
if (node.attributes.length > 0) {
for (let i = 0; i < node.attributes.length; i++) {
const attribute = node.attributes[i];
attributes = attribute.nodeValue;
}
}
return attributes;
}
function getQuestionsNodes(questionNode,type)
{
// console.log(questionNode);
var questionObj = {};
if(type == 1)
{
questionObj['questionId'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
questionObj['question_type'] = 'text';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = 'false';
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
}
else
{
questionObj['questionId'] = questionNode.childNodes[0].firstChild.nodeValue;
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
questionObj['question_type'] = 'group';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = questionNode.childNodes[3].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
questionObj['answers'] = [];
var choiceList = questionNode.childNodes[7].childNodes;
questionObj['correct_answer'] = [];
var choiceList = questionNode.childNodes[4].childNodes;
if(choiceList.length > 0)
{
@ -58,7 +73,7 @@ function getQuestionsNodes(questionNode,type)
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
tempChoiceobj['is_math_enabled'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
// console.log(tempChoiceobj);
questionObj['answers'].push(tempChoiceobj);
@ -71,29 +86,25 @@ function getQuestionsNodes(questionNode,type)
function getQuestionGroupNodes(questionGroup)
{
var questionGroupObj = {};
questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
questionGroupObj['group_title'] = questionGroup.childNodes[1].firstChild.nodeValue;
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
questionGroupObj['group_marks'] = (questionGroup.childNodes[3].firstChild !== null ? questionGroup.childNodes[3].firstChild.nodeValue : "");
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].firstChild.nodeValue;
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[5].firstChild !== null ? questionGroup.childNodes[5].firstChild.nodeValue : "");
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
questionGroupObj['questions'] = [];
var questionGroupObj = {};
questionGroupObj['group_title'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
questionGroupObj['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
questionGroupObj['questions'] = [];
//handle questions
var questionList = questionGroup.childNodes[6].childNodes;
var questionList = questionGroup.childNodes[3].childNodes;
// console.log('No of quetions in GQ:' + questionList.length);
for(let q = 0; q < questionList.length ;q++)
{
var questionType = questionList[q].getAttribute("xsi:type");
var questionType = questionList[q].getAttribute("Type");
console.log(questionType);
if(questionType == 'DescriptiveQuestion')
if(questionType == 'Descriptive')
{
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
}
else if(questionType == 'MultiChoiceQuestion')
else if(questionType == 'MCQ')
{
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
}
@ -109,20 +120,21 @@ 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].childNodes[0].nodeValue;
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue;
//get attributes of root/question paper element
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['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
jsonObj['sections'] = [];
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
// console.log(sectionsList);
// console.log('no of sections:'+sectionsList.length);
@ -130,17 +142,15 @@ jsonObj['sections'] = [];
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['section_title'] = (sectionsList[i].childNodes[0].firstChild !== null ? sectionsList[i].childNodes[0].firstChild.nodeValue : "");
tempObj['section_description'] = (sectionsList[i].childNodes[1].firstChild !== null ? sectionsList[i].childNodes[1].firstChild.nodeValue : "");
tempObj['section_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
tempObj['section_display_marks'] = sectionsList[i].childNodes[3].firstChild.nodeValue;
tempObj['section_attempt_any'] = (sectionsList[i].childNodes[4].firstChild !== null && sectionsList[i].childNodes[4].firstChild !== undefined ? sectionsList[i].childNodes[4].firstChild.nodeValue : "");
tempObj['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
tempObj['questions'] = [];
//handle questions
var questionList = sectionsList[i].childNodes[5].childNodes;
var questionList = sectionsList[i].childNodes[3].childNodes;
// console.log('No of quetions:' + questionList.length);
// console.log("Question List")
// console.log(questionList);
@ -149,13 +159,13 @@ jsonObj['sections'] = [];
//check weather quesiotn or question grup
// console.log('QUESTION :' + j );
// console.log(questionList[j]);
var questionType = questionList[j].getAttribute("xsi:type");
var questionType = questionList[j].getAttribute("Type");
// console.log(questionType);
if(questionType == 'DescriptiveQuestion')
if(questionType == 'Descriptive')
{
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
}
else if(questionType == 'MultiChoiceQuestion')
else if(questionType == 'MCQ')
{
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
}
@ -169,7 +179,7 @@ jsonObj['sections'] = [];
var jsonData = JSON.stringify(jsonObj);
localStorage.setItem('pjsonData', jsonData );
// console.log(jsonData);
console.log('xml2json_for_questionpaper : ',jsonData);
QuestionPaperPreview(jsonObj);
}

View File

@ -1,157 +0,0 @@
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);
}