INITIAL_COMMIT : RV

This commit is contained in:
VENKATESHWARAN 2024-01-06 11:31:15 +05:30
parent 34740eb09d
commit 64dc8a7133
6 changed files with 655 additions and 7201 deletions

View File

@ -27,3 +27,10 @@ This README would normally document whatever steps are necessary to get your app
* Repo owner or admin * 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

View File

@ -4,12 +4,12 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <title>Project-</title> -->
<title id="dynamicTitle"></title> <title id="dynamicTitle"></title>
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS STYLE -->
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" type="image/png" sizes="56x56" href="assets/images/fav-icon/v.png"> <link rel="icon" type="image/png" sizes="56x56" href="assets/images/fav-icon/v.png">
<!-- bootstrap CSS --> <!-- bootstrap CSS -->
@ -45,16 +45,17 @@
<link rel="stylesheet" href="./node_modules/quill/dist/quill.snow.css" type="text/css" media="all" /> <link rel="stylesheet" href="./node_modules/quill/dist/quill.snow.css" type="text/css" media="all" />
<!-- CortexJs MathLive JS and CSS --> <!-- CortexJs MathLive JS and CSS -->
<link rel="stylesheet" href="./node_modules/mathlive/dist/mathlive-static.css" /> <link rel="stylesheet" href="./node_modules/mathlive/dist/mathlive-static.css" />
<script defer src="./node_modules/mathlive/dist/mathlive.min.js"></script>
<!-- JS SCRIPTS -->
<!-- modernizr js --> <!-- modernizr js -->
<script src="assets/js/vendor/modernizr-3.5.0.min.js"></script> <script src="assets/js/vendor/modernizr-3.5.0.min.js"></script>
<!-- cortex js MathLive js -->
<script defer src="./node_modules/mathlive/dist/mathlive.min.js"></script>
<!-- QuestionPaper Preview js -->
<script src="QuestionPaperPreview.js"></script> <script src="QuestionPaperPreview.js"></script>
<!-- MathJax js -->
<!-- <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
<script id="MathJax-script" async src="./node_modules/mathjax/es5/tex-mml-chtml.js"></script> <script id="MathJax-script" async src="./node_modules/mathjax/es5/tex-mml-chtml.js"></script>
<link rel="stylesheet" href="assets/css/quillTable.css" type="text/css" media="all" />
<style> <style>
@ -74,21 +75,12 @@
.ql-picker.ql-table:nth-of-type(1) .ql-picker-options { .ql-picker.ql-table:nth-of-type(1) .ql-picker-options {
width: 310px !important; width: 310px !important;
} }
/* End custom css for table icon options in RTE editor */
/* start custom css for Alignment icon options in RTE editor */ /* start custom css for Alignment icon options in RTE editor */
.ql-icon-picker .ql-picker-item{ .ql-icon-picker .ql-picker-item{
width: 24px !important; width: 24px !important;
} }
/* End custom css for Alignment icon options in RTE editor */
/* [data-value="remove-table"] {
border: 1px solid black !important;
} */
/* .ql-picker-options{
width: 310px !important;
} */
.ql-picker-item{ .ql-picker-item{
width: 95px !important; width: 95px !important;
} }
@ -107,30 +99,30 @@
overflow-x: hidden; overflow-x: hidden;
transition: 0.5s; transition: 0.5s;
padding-top: 60px; padding-top: 60px;
z-index: 2; /* Increase z-index to make the sidebar overlap */ z-index: 2;
} }
.chat-box { .chat-box {
padding: 20px; padding: 20px;
color: white; color: white;
height: 100%; /* Set height to 100% to fill the sidebar */ height: 100%;
display: flex; display: flex;
flex-direction: column; /* Stack child elements vertically */ flex-direction: column;
justify-content: space-between; /* Push child elements to the top and bottom */ justify-content: space-between;
} }
#messages { #messages {
max-height: calc(100% - 60px); /* Adjusted to leave space for the input box */ max-height: calc(100% - 60px);
overflow-y: auto; overflow-y: auto;
margin-bottom: 10px; margin-bottom: 10px;
} }
#messageForm { #messageForm {
margin-top: auto; /* Push the form to the bottom */ margin-top: auto;
} }
textarea { textarea {
height: 40px; /* Adjust the height of the textarea as needed */ height: 40px;
} }
input { input {
@ -149,20 +141,18 @@
right: 20px; right: 20px;
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
z-index: 0; /* Ensure the button appears above the sidebar */ z-index: 0;
} }
.content { .content {
margin-right: 0; /* Initially, no margin to accommodate the sidebar width */ margin-right: 0;
transition: margin-right 0.5s; transition: margin-right 0.5s;
} }
.sidebar-open .content { .sidebar-open .content {
margin-right: 250px; /* Push content to the right when the sidebar is open */ margin-right: 250px;
} }
</style>
<style>
div:empty:not(:focus):before { div:empty:not(:focus):before {
content: attr(data-text); content: attr(data-text);
color: #999999; color: #999999;
@ -188,14 +178,7 @@
margin-top: 100px; margin-top: 100px;
} }
/* body { */
/* Ensure the body takes the full height of the viewport */
/* height: 100vh; */
/* Apply smooth transition for the zoom effect */
/* transition: transform 0.3s ease-in-out; */
/* Set transform origin to the top left corner to prevent content shifting */
/* transform-origin: top left; */
/* } */
.ql-align.ql-picker.ql-icon-picker{ .ql-align.ql-picker.ql-icon-picker{
margin-top: -10px; margin-top: -10px;
@ -245,25 +228,17 @@
padding-left: 10px; padding-left: 10px;
} }
</style>
<style>
.highlight { .highlight {
border: 2px dashed blue; /* Change the border style as needed */ border: 2px dashed blue;
} }
/* Initially hide the icon */ /* Initially hide the icon */
.drag-handle { .drag-handle {
/* display: none; */
color: transparent; color: transparent;
} }
/* Show the icon when hovering over the parent element with .hidedrag */ /* Show the icon when hovering over the parent element with .hidedrag */
.element:hover .drag-handle { .element:hover .drag-handle {
/* color: blueviolet; */
color: #BF303B; color: #BF303B;
} }
@ -285,7 +260,7 @@
/* Define the transition for the animation */ /* Define the transition for the animation */
.highlight { .highlight {
transition: background-color 0.3s ease; /* Adjust the duration and easing as needed */ transition: background-color 0.3s ease;
} }
/* Style for the placeholder element with a slow animation */ /* Style for the placeholder element with a slow animation */
@ -312,9 +287,7 @@
} }
</style>
<style>
.arrow-down::before { .arrow-down::before {
/* content: '\25BC'; */ /* content: '\25BC'; */
content: '⮟'; content: '⮟';
@ -335,7 +308,7 @@
} }
.menu-symbol1::before { .menu-symbol1::before {
content: '\2630'; /* Unicode character for the menu symbol (☰) */ content: '\2630'; /* Unicode character for the menu symbol (☰) */
font-size: 24px; /* Adjust the font size as needed */ font-size: 24px;
} }
a{ a{
white-space: nowrap !important; white-space: nowrap !important;
@ -444,7 +417,6 @@
} }
/* Reset default margin and padding for body and the wrapper */ /* Reset default margin and padding for body and the wrapper */
body, #wrapper { body, #wrapper {
margin: 0; margin: 0;
@ -457,16 +429,14 @@
} }
/* Style the sidebar */ /* Style the sidebar */
.sidebar-content { .sidebar-content {
padding: 10px; /* Add padding to your content */ padding: 10px; /* Add padding to your content */
} }
/* Style the main content area */ /* Style the main content area */
.main-content { .main-content {
flex-grow: 1; /* Allow the main content to grow and fill the remaining space */ flex-grow: 1;
overflow-y: auto; /* Enable vertical scrolling for the main content */ overflow-y: auto;
}
.qP-style{ .qP-style{
left:-300px!important; left:-300px!important;
@ -479,8 +449,8 @@
top:81px; top:81px;
left: 10px; left: 10px;
border: none; border: none;
border-radius: 15%; /* Make the button round */ border-radius: 15%;
width: 40px; /* Set the width and height of the button */ width: 40px;
height: 40px; height: 40px;
transition: box-shadow 0.3s, background-color 0.3s; transition: box-shadow 0.3s, background-color 0.3s;
color: #bf303b; color: #bf303b;
@ -492,8 +462,8 @@
top:81px; top:81px;
right: 10px; right: 10px;
border: none; border: none;
border-radius: 15%; /* Make the button round */ border-radius: 15%;
width: 40px; /* Set the width and height of the button */ width: 40px;
height: 40px; height: 40px;
transition: box-shadow 0.3s, background-color 0.3s; transition: box-shadow 0.3s, background-color 0.3s;
color: #bf303b; color: #bf303b;
@ -549,9 +519,6 @@
} */ } */
</style>
<style>
/* Styles for the overlay background */ /* Styles for the overlay background */
.overlay { .overlay {
display: none; display: none;
@ -560,8 +527,8 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgba(0, 0, 0, 0); /* Initial opacity set to 0 */ background-color: rgba(0, 0, 0, 0);
transition: background-color 0.3s; /* Add a transition effect for smooth opacity change */ transition: background-color 0.3s;
z-index: 1; z-index: 1;
} }
@ -572,6 +539,7 @@
li.popupbox span{ li.popupbox span{
color: #BF303B !important; color: #BF303B !important;
} }
/* Styles for the popup container */ /* Styles for the popup container */
.popup { .popup {
display: none; display: none;
@ -623,8 +591,7 @@
border: 1px solid #e6e6e6; border: 1px solid #e6e6e6;
box-shadow: 0 0 5px rgb(0 0 0 / 10%); box-shadow: 0 0 5px rgb(0 0 0 / 10%);
} }
</style>
<style>
.dropdown { .dropdown {
position: relative; position: relative;
display: inline-block; display: inline-block;
@ -686,9 +653,6 @@ filter: invert(23%) sepia(67%) saturate(2476%) hue-rotate(335deg) brightness(89%
position: relative !important; position: relative !important;
right: -15px !important; right: -15px !important;
} }
/* a .addPageMenu:hover {.buttons
} */
h1.title{ h1.title{
font-size: 20px; font-size: 20px;
@ -697,8 +661,7 @@ h1.title{
color: #1d3557; color: #1d3557;
padding-bottom: 10px; padding-bottom: 10px;
} }
</style>
<style>
body { body {
margin: 0; margin: 0;
font-family: 'Arial', sans-serif; font-family: 'Arial', sans-serif;
@ -777,7 +740,7 @@ h1.title{
} }
.sidebar::before { .sidebar::before {
content: '\2BC7'; /* Unicode character for the close arrow (adjust as needed) */ content: '\2BC7';
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 10px; left: 10px;
@ -786,7 +749,7 @@ h1.title{
} }
.work-area::before { .work-area::before {
content: '\2BC7'; /* Unicode character for the open arrow (adjust as needed) */ content: '\2BC7';
font-size: 24px; font-size: 24px;
} }
@ -818,20 +781,10 @@ h1.title{
/* margin-right: 15px; */ /* margin-right: 15px; */
width: 85px; width: 85px;
} }
</style> </style>
<script>
</script>
</head> </head>
<body> <body>
<!-- loder -->
<!-- <div class="loader-wrapper" id="loaderWrapper">
<div class="loader"></div>
<div class="loder-section left-section"></div>
<div class="loder-section right-section"></div>
</div> -->
<div id="overlay"> <div id="overlay">
<div class="cv-spinner"> <div class="cv-spinner">
@ -864,8 +817,10 @@ h1.title{
<button class="menu-symbol1" id="sidebarToggle1"></button> <button class="menu-symbol1" id="sidebarToggle1"></button>
<button class="work-area"id="sidebarToggle2"></button> <button class="work-area"id="sidebarToggle2"></button>
<!-- QuestionPapper Container start --> <!-- QuestionPapper Container start -->
<div class="d-flex" id="wrapper"> <div class="d-flex" id="wrapper">
<!-- Sidebar--> <!-- Sidebar-->
<div class="border-end bg-white" id="sidebar-wrapper"> <div class="border-end bg-white" id="sidebar-wrapper">
<div class="sidebar-fixed"> <div class="sidebar-fixed">
@ -874,6 +829,8 @@ h1.title{
</div> </div>
</div> </div>
<!-- sidebar end --> <!-- sidebar end -->
<script> <script>

File diff suppressed because it is too large Load Diff

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})));
}

File diff suppressed because it is too large Load Diff

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);
}