JSON2XML->XML2JSON->JSON2HTML Changes : RV

This commit is contained in:
VENKATESHWARAN 2024-01-19 12:09:01 +05:30
parent ce6d38d329
commit c63b2062b4
4 changed files with 75 additions and 67 deletions

View File

@ -430,7 +430,8 @@
overflow-x: clip; overflow-x: clip;
max-height: 532px; max-height: 532px;
padding:0 10px 20px; padding:0 10px 20px;
width: 314px; /* width: 314px; */
width: 285px;
height: -webkit-fill-available; height: -webkit-fill-available;
} }
@ -1471,7 +1472,7 @@ $("#overlay").show();
$('#workarea_math').click(function(){ $('#workarea_math').click(function(){
// console.log('called'); // console.log('called');
$('#workarea_math').css('margin-bottom', '350px'); $('#workarea_math').css('margin-bottom', '300px');
localStorage.setItem('workAreaMath', true); localStorage.setItem('workAreaMath', true);
}); });
@ -2249,8 +2250,8 @@ function addSection(title = false, description = false, random_no = false, secti
innerDivElement.addEventListener("keyup", function(event) { innerDivElement.addEventListener("keyup", function(event) {
<!-- console.log('JoditworkPlaceId : ', event.target.id) --> // <!-- console.log('JoditworkPlaceId : ', event.target.id) -->
<!-- console.log('content : ',document.getElementById(sectionID).innerHTML) --> // <!-- console.log('content : ',document.getElementById(sectionID).innerHTML)
json2nav(); json2nav();
clearSidebarWrapper(); clearSidebarWrapper();
@ -2352,7 +2353,7 @@ function addQuestionGroup(idObj)
// console.log(idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_title : ""); // console.log(idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_title : "");
var sectionRandomID = localStorage.getItem('sectionId'); var sectionRandomID = localStorage.getItem('sectionId');
var group_question_i = `${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.question_id : ""}` var group_question_i = `${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.attributes.No : ""}`
var group_question_id = (group_question_i.replace('<p>','').replace('</p>','').replace('<br>','')) var group_question_id = (group_question_i.replace('<p>','').replace('</p>','').replace('<br>',''))
// console.log(group_question_i);subSection_title_text_1 // console.log(group_question_i);subSection_title_text_1
// console.log(group_question_id); // console.log(group_question_id);
@ -2420,7 +2421,7 @@ function addQuestionGroup(idObj)
<div class="col-lg-4 col-md-4 hideondrag text" > <div class="col-lg-4 col-md-4 hideondrag text" >
<div class="form_box justify-content-end"> <div class="form_box justify-content-end">
<div style="margin-right:10px;"> Attempt Any : </div> <div style="margin-right:10px;"> Attempt Any : </div>
<input type="text" id="Question_Attempt_Any_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_attempt_any : ''}"> <input type="text" id="Question_Attempt_Any_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.attributes.AttemptAny : ''}">
</div> </div>
</div> </div>
@ -2636,7 +2637,7 @@ function addQuestionGroup(idObj)
var displayMArks = "" var displayMArks = ""
if(idObj.hasOwnProperty('question_group_obj')) if(idObj.hasOwnProperty('question_group_obj'))
{ {
displayMArks = idObj.question_group_obj.group_display_marks; displayMArks = idObj.question_group_obj.attributes.DisplayMarks;
} }
else else
{ {
@ -3330,7 +3331,7 @@ fileInput3.addEventListener("change", () => {
if(choice_mathEnabled === 'true') if(choice_mathEnabled === 'Math')
{ {
$(ChoiceFieldMathSwitchId).prop('checked', true); $(ChoiceFieldMathSwitchId).prop('checked', true);
$(choiceElements).hide(); $(choiceElements).hide();
@ -3713,7 +3714,7 @@ $(newChoiceDeleteButtonId).on('click', function() {
const titleElements = newChoiceTextField.previousElementSibling; const titleElements = newChoiceTextField.previousElementSibling;
ChoiceMathSwitchId.checked = false; ChoiceMathSwitchId.checked = false;
if(choice_mathEnabled === "true") if(choice_mathEnabled === "Math")
{ {
ChoiceMathSwitchId.checked = true; ChoiceMathSwitchId.checked = true;
$(titleElements).hide(); $(titleElements).hide();

View File

@ -71,8 +71,8 @@ function jsonToHtml(jsonData) {
'sectionDescription' :section.section_description, 'sectionDescription' :section.section_description,
'sectionMarks' :section.section_marks, 'sectionMarks' :section.section_marks,
'sectionUUID' :section.attributes.Id, 'sectionUUID' :section.attributes.Id,
'sectionDispalyMarks':section.section_display_marks, 'sectionDispalyMarks':section.attributes.DisplayMarks,
'sectionAttemptAny' :section.section_attempt_any, 'sectionAttemptAny' :section.attributes.AttemptAny,
} }
// addSection(SectionObj); //call the addSection() function and send the sectionObject to that function // addSection(SectionObj); //call the addSection() function and send the sectionObject to that function
@ -108,7 +108,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
{ {
questionTypeFormets ='question_group'; questionTypeFormets ='question_group';
} }
var questionId = Question.question_id var questionId = Question.attributes.No
var questionTitle = Question.question; var questionTitle = Question.question;
var questionDescription = Question.question_description; var questionDescription = Question.question_description;
var questionType = questionTypeFormets; var questionType = questionTypeFormets;
@ -118,7 +118,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
var descriptionMath = Question.descriptionMath; var descriptionMath = Question.descriptionMath;
var questionMarks = Question.marks; var questionMarks = Question.marks;
var questionUUID = Question.attributes.Id; var questionUUID = Question.attributes.Id;
var questionDisplayMarks = Question.display_marks; var questionDisplayMarks = Question.attributes.DisplayMarks;
var Choice = Question.answers; var Choice = Question.answers;
var CorrectAnswer = Question.correct_answer; var CorrectAnswer = Question.correct_answer;
@ -128,7 +128,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
"question_area_id" :questionAreaId, "question_area_id" :questionAreaId,
'questionRandomNo' :questionRandomNo, 'questionRandomNo' :questionRandomNo,
'questionId' :Question.question_id, 'questionId' :Question.attributes.No,
'questionTitle' :Question.question, 'questionTitle' :Question.question,
'questionDescription' :Question.question_description, 'questionDescription' :Question.question_description,
'questionType' :questionTypeFormets, 'questionType' :questionTypeFormets,
@ -137,7 +137,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
'descriptionMath' :Question.descriptionMath, 'descriptionMath' :Question.descriptionMath,
'questionMarks' :Question.marks, 'questionMarks' :Question.marks,
'questionUUID' :Question.attributes.Id, 'questionUUID' :Question.attributes.Id,
'questionDisplayMarks' :Question.display_marks, 'questionDisplayMarks' :Question.attributes.DisplayMarks,
'Choice' :Question.answers, 'Choice' :Question.answers,
'CorrectAnswer' :Question.correct_answer 'CorrectAnswer' :Question.correct_answer
} }
@ -173,7 +173,11 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo,index){
//function for Generate QuestionGroup //function for Generate QuestionGroup
function generateGroupQuestion(Question, questionAreaId, questionRandomNo) 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); addQuestionGroup(idObj);
Question.questions.forEach(function(GroupQuestions, index) { Question.questions.forEach(function(GroupQuestions, index) {

View File

@ -64,16 +64,18 @@ function json2xml() {
} = createStandaloneXMLNode('Question', { } = 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']), '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) { // if (question['question_id'] !== undefined) {
var questionChoiceId =createElementWithText(doc, element, 'Text', question['question_id']) // var questionChoiceId =createElementWithText(doc, element, 'Text', question['question_id'])
} else { // } else {
// If question['question_id'] is undefined, create a new variable // // If question['question_id'] is undefined, create a new variable
var questionIdSet = createElementWithText(doc, element , 'Text', question['questionChoiceId']) // var questionIdSet = createElementWithText(doc, element , 'Text', question['questionChoiceId'])
} // }
var questionTitle = createElementWithText(doc, element, 'Text', question['question']); var questionTitle = createElementWithText(doc, element, 'Text', question['question']);
@ -81,8 +83,7 @@ function json2xml() {
var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']); var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
questionDesc.setAttribute('xsi:type',(question['is_math_enabled'] === true ? 'Math' : '')); questionDesc.setAttribute('xsi:type',(question['is_math_enabled'] === true ? 'Math' : ''));
var marks = createElementWithText(doc, element, 'Marks', question['marks']); var marks = createElementWithText(doc, element, 'Marks', question['marks']);
var display_marks = createElementWithText(doc, element, 'DispalyMarks', (question['display_marks'] === true ? 'true' : 'false'), {}); // 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') { if (question['question_type'] == 'group') {
// console.log(question); // console.log(question);
@ -95,7 +96,6 @@ function json2xml() {
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {}); var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {});
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_name'], {}); var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_name'], {});
text.setAttribute('xsi:type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : 'Text')); text.setAttribute('xsi:type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : 'Text'));
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
} }
// choicesElement.appendChild(); // choicesElement.appendChild();
@ -116,8 +116,10 @@ function json2xml() {
'xsi:type': 'QuestionGroup', 'xsi:type': 'QuestionGroup',
'Id': singleQuestion['group_uuid'], 'Id': singleQuestion['group_uuid'],
'Type': 'QuestionGroup', 'Type': 'QuestionGroup',
'No': '', 'No': (singleQuestion['question_id'] ? singleQuestion['question_id'] : '' ),
'Order': 0 'Order': 0,
'DisplayMarks':(singleQuestion['group_display_marks'] === true ? 'true' : 'false' ),
'AttemptAny':(singleQuestion['group_attempt_any'] ? singleQuestion['group_attempt_any'] : '' ),
}, ''); }, '');
@ -128,12 +130,12 @@ function json2xml() {
// 'No': singleQuestion['group_title'], // 'No': singleQuestion['group_title'],
// 'Order': 0 // 'Order': 0
// }); // });
var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['question_id']); // var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['question_id']);
var groupQuestionTitle = createElementWithText(doc, element, 'Text', singleQuestion['group_title']); var groupQuestionTitle = createElementWithText(doc, element, 'Text', singleQuestion['group_title']);
var groupQuestionDesc = createElementWithText(doc, element, 'Subtext', singleQuestion['group_description']); var groupQuestionDesc = createElementWithText(doc, element, 'Subtext', singleQuestion['group_description']);
var groupQuestionMarks = createElementWithText(doc, element, 'Marks', singleQuestion['group_marks']); var groupQuestionMarks = createElementWithText(doc, element, 'Marks', singleQuestion['group_marks']);
var groupQuestionDisplayMarks = createElementWithText(doc, element, 'DisplayMarks', (singleQuestion['group_display_marks'] === true ? 'true' : 'false' )); // var groupQuestionDisplayMarks = createElementWithText(doc, element, 'DisplayMarks', (singleQuestion['group_display_marks'] === true ? 'true' : 'false' ));
var groupQuestionAttemptAny = createElementWithText(doc, element, 'AttemptAny', singleQuestion['group_attempt_any'] ); // var groupQuestionAttemptAny = createElementWithText(doc, element, 'AttemptAny', singleQuestion['group_attempt_any'] );
var groupQuestionItemsElement = createElementWithText(doc, element, 'Items', ''); var groupQuestionItemsElement = createElementWithText(doc, element, 'Items', '');
//gather questions data inside question group //gather questions data inside question group
@ -194,22 +196,26 @@ function json2xml() {
for (section in questionPaper['sections']) { for (section in questionPaper['sections']) {
//create section related xml nodes //create section related xml nodes
var tempSection = questionPaper['sections'][section]; var tempSection = questionPaper['sections'][section];
var sectionNumber = parseInt(section);
sectionNumber++
// console.log(tempSection); // console.log(tempSection);
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', { var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
'xsi:type': 'QuestionPaperSection', 'xsi:type': 'QuestionPaperSection',
'Id': tempSection['section_uuid'], 'Id': tempSection['section_uuid'],
'Type': 'Section', 'Type': 'Section',
'No': '', 'No': sectionNumber,
'Order': 0 'Order': 0,
'DisplayMarks':(tempSection['section_display_marks'] === true ? 'true' : 'false'),
'AttemptAny':(tempSection['section_attempt_any'] ? tempSection['section_attempt_any'] : '' ),
}); });
var sectionTitle = createElementWithText(xmlDoc, sectionElement, 'Text', tempSection['section_title']); var sectionTitle = createElementWithText(xmlDoc, sectionElement, 'Text', tempSection['section_title']);
var sectionDesc = createElementWithText(xmlDoc, sectionElement, 'Subtext', tempSection['section_description']); var sectionDesc = createElementWithText(xmlDoc, sectionElement, 'Subtext', tempSection['section_description']);
var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'Marks', tempSection['section_marks']); var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'Marks', tempSection['section_marks']);
var sectionDisplayMark = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false')); // var sectionDisplayMark = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false'));
var sectionAttempAny = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']); // var sectionAttempAny = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']);
var sectionItemElement = createElementWithText(xmlDoc, sectionElement, 'Items', '', ); var sectionItemElement = createElementWithText(xmlDoc, sectionElement, 'Items', '', );

View File

@ -45,37 +45,35 @@ function getQuestionsNodes(questionNode,type)
if(type == 1) if(type == 1)
{ {
// console.log(questionNode); // console.log(questionNode);
questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "" ; // questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "" ;
questionObj['question'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : ""); questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : ""); questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
questionObj['question_type'] = 'text'; questionObj['question_type'] = 'text';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode); questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]); questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[2]); questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = 'false'; questionObj['question_sub_type'] = 'false';
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? 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['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
// console.log(questionObj); // console.log(questionObj);
} }
else else
{ {
questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : ""; // questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
questionObj['question'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : ""); questionObj['question'] = (questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "");
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : ""); questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
questionObj['question_type'] = 'group'; questionObj['question_type'] = 'group';
questionObj['attributes'] = getAttributesOfXMLNode(questionNode); questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]); questionObj['titleMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[0]);
questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[2]); questionObj['descriptionMath'] = getAttributesOfXMLNodeWithoutArray(questionNode.childNodes[1]);
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue; questionObj['question_sub_type'] = questionNode.childNodes[3].firstChild.nodeValue;
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? 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['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
questionObj['answers'] = []; questionObj['answers'] = [];
questionObj['correct_answer'] = []; questionObj['correct_answer'] = [];
var choiceList = questionNode.childNodes[7].childNodes; var choiceList = questionNode.childNodes[4].childNodes;
// console.log(questionNode); // console.log(questionNode);
if(choiceList.length > 0) if(choiceList.length > 0)
{ {
@ -85,8 +83,7 @@ function getQuestionsNodes(questionNode,type)
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue; tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : ""); tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : ""); tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : ""); tempChoiceobj['is_math_enabled'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
tempChoiceobj['ChoiceMath'] = getAttributesOfXMLNodeWithoutArray(choiceList[k].childNodes[2]);
// console.log(tempChoiceobj); // console.log(tempChoiceobj);
questionObj['answers'].push(tempChoiceobj); questionObj['answers'].push(tempChoiceobj);
} }
@ -129,16 +126,16 @@ function getQuestionsNodes(questionNode,type)
function getQuestionGroupNodes(questionGroup) function getQuestionGroupNodes(questionGroup)
{ {
var questionGroupObj = {}; var questionGroupObj = {};
questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : ""); // questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
questionGroupObj['group_title'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : ""); questionGroupObj['group_title'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : ""); questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
questionGroupObj['group_marks'] = (questionGroup.childNodes[3].firstChild !== null ? questionGroup.childNodes[3].firstChild.nodeValue : ""); questionGroupObj['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].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_attempt_any'] = (questionGroup.childNodes[5].firstChild !== null ? questionGroup.childNodes[5].firstChild.nodeValue : "");
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup); questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
questionGroupObj['questions'] = []; questionGroupObj['questions'] = [];
//handle questions //handle questions
var questionList = questionGroup.childNodes[6].childNodes; var questionList = questionGroup.childNodes[3].childNodes;
// console.log('No of quetions in GQ:' + questionList.length); // console.log('No of quetions in GQ:' + questionList.length);
for(let q = 0; q < questionList.length ;q++) for(let q = 0; q < questionList.length ;q++)
{ {
@ -197,13 +194,13 @@ jsonObj['sections'] = [];
tempObj['section_title'] = (sectionsList[i].childNodes[0].firstChild !== null ? sectionsList[i].childNodes[0].firstChild.nodeValue : ""); tempObj['section_title'] = (sectionsList[i].childNodes[0].firstChild !== null ? sectionsList[i].childNodes[0].firstChild.nodeValue : "");
tempObj['section_description'] = (sectionsList[i].childNodes[1].firstChild !== null ? sectionsList[i].childNodes[1].firstChild.nodeValue : ""); tempObj['section_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_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
tempObj['section_display_marks'] = (sectionsList[i].childNodes[3].firstChild !== null ? sectionsList[i].childNodes[3].firstChild.nodeValue : ""); // tempObj['section_display_marks'] = (sectionsList[i].childNodes[3].firstChild !== null ? sectionsList[i].childNodes[3].firstChild.nodeValue : "");
tempObj['section_attempt_any'] = (sectionsList[i].childNodes[4].firstChild !== null && sectionsList[i].childNodes[4].firstChild !== undefined ? sectionsList[i].childNodes[4].firstChild.nodeValue : ""); // tempObj['section_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['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
tempObj['questions'] = []; tempObj['questions'] = [];
//handle 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('No of quetions:' + questionList.length);
// console.log(questionList); // console.log(questionList);
for(let j = 0; j < questionList.length ;j++) for(let j = 0; j < questionList.length ;j++)
@ -231,7 +228,7 @@ jsonObj['sections'] = [];
var jsonData = JSON.stringify(jsonObj); var jsonData = JSON.stringify(jsonObj);
// console.log('Xml to Json Conversion '); // console.log('Xml to Json Conversion ');
// console.log('jsonData : ', jsonData); console.log('jsonData : ', jsonData);
// console.log(jsonObj); // console.log(jsonObj);
jsonToHtml(jsonObj); jsonToHtml(jsonObj);
// console.log(jsonToHtml(jsonObj)) // console.log(jsonToHtml(jsonObj))