SAVEEMPTYFOCUS SERIALNO : AADHAVAN
This commit is contained in:
parent
0d655d7898
commit
81a095cd7d
@ -39,6 +39,7 @@ function QuestionPaperPreview(jsonData){
|
|||||||
|
|
||||||
|
|
||||||
function convertToLatex(text, mathstatus) {
|
function convertToLatex(text, mathstatus) {
|
||||||
|
// console.log(text);
|
||||||
// Parse mathstatus into a boolean
|
// Parse mathstatus into a boolean
|
||||||
const mathStatusBoolean = JSON.parse(mathstatus);
|
const mathStatusBoolean = JSON.parse(mathstatus);
|
||||||
// Check if the text contains <p> tags
|
// Check if the text contains <p> tags
|
||||||
@ -130,21 +131,48 @@ function QuestionPaperPreview(jsonData){
|
|||||||
|
|
||||||
var currentSno_length =currentSno.length-(currentSno.length/2)
|
var currentSno_length =currentSno.length-(currentSno.length/2)
|
||||||
if (currentSno_length == 1) {
|
if (currentSno_length == 1) {
|
||||||
description_align =17
|
description_align =27
|
||||||
} else if (currentSno_length == 2) {
|
} else if (currentSno_length == 2) {
|
||||||
description_align =33
|
description_align =33
|
||||||
}else if(currentSno_length == 3){
|
}else if(currentSno_length == 3){
|
||||||
description_align =48
|
description_align =48
|
||||||
}else if(currentSno_length == 4) {
|
}else if(currentSno_length == 4) {
|
||||||
description_align =64
|
description_align =62
|
||||||
}
|
}
|
||||||
else if(currentSno_length == 5) {
|
else if(currentSno_length == 5) {
|
||||||
description_align =78
|
description_align =78
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var GroupQuestionTilteAlign = 0;
|
||||||
if (question.group_title) {
|
if (question.group_title) {
|
||||||
|
// console.log(question);
|
||||||
|
let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim();
|
||||||
|
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||||
|
var question_id_length =cleanedText.length;
|
||||||
|
if (question_id_length == 1) {
|
||||||
|
GroupQuestionTilteAlign =15
|
||||||
|
} else if (question_id_length == 3) {
|
||||||
|
GroupQuestionTilteAlign =33
|
||||||
|
}else if(question_id_length == 5){
|
||||||
|
GroupQuestionTilteAlign =47
|
||||||
|
}else if(question_id_length == 7) {
|
||||||
|
GroupQuestionTilteAlign =63
|
||||||
|
}else if(question_id_length == 4) {
|
||||||
|
GroupQuestionTilteAlign =40
|
||||||
|
}else if(question_id_length == 6) {
|
||||||
|
GroupQuestionTilteAlign =54
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const questionId =`<p class="GroupQuestionId">${cleanedText})</p>`
|
||||||
|
|
||||||
|
const questionId =cleanedText
|
||||||
|
console.log(questionId);
|
||||||
|
|
||||||
const questionGroupSetP = `${question.group_title}`;
|
const questionGroupSetP = `${question.group_title}`;
|
||||||
const questionGroupmodify =questionGroupSetP.replaceAll('<p>', `<p id="question-Group-Id" style="padding-left:${description_align}px">`)
|
const questionGroupmodify =questionGroupSetP.replaceAll('<p>', `<p id="question-Group-Id" style="padding-left:${GroupQuestionTilteAlign}px">`)
|
||||||
if (question.group_attempt_any) {
|
if (question.group_attempt_any) {
|
||||||
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.group_attempt_any} </p>`
|
var questionGroupAttempt = `<p id="group_attempt_any" class="GroupAttempAny">Attempt Any : ${question.group_attempt_any} </p>`
|
||||||
|
|
||||||
@ -169,7 +197,7 @@ function QuestionPaperPreview(jsonData){
|
|||||||
// questionGroupMark = questionGroupMark.replace('<p id="group_marks">', '<p id="group_marks" hidden>')
|
// questionGroupMark = questionGroupMark.replace('<p id="group_marks">', '<p id="group_marks" hidden>')
|
||||||
// }
|
// }
|
||||||
|
|
||||||
questionPaper += `<div class="text-group-align" style="margin-left:-1px;">${temp_sno})${questionGroupmodify}</div>`
|
questionPaper += `<div class="text-group-align" style="margin-left:-1px;">${questionId})${questionGroupmodify}</div>`
|
||||||
|
|
||||||
questionPaper += `<div class="group_marks_attmpt">${questionGroupAttempt}${questionGroupMark}</div>`;
|
questionPaper += `<div class="group_marks_attmpt">${questionGroupAttempt}${questionGroupMark}</div>`;
|
||||||
// questionPaper += `<div class="group_attempt_any">${questionGroupAttempt}</div>`;
|
// questionPaper += `<div class="group_attempt_any">${questionGroupAttempt}</div>`;
|
||||||
@ -177,8 +205,34 @@ function QuestionPaperPreview(jsonData){
|
|||||||
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>`;
|
||||||
depth2++
|
depth2++
|
||||||
} else if (question.question) {
|
} else if (question.question) {
|
||||||
|
let cleanedTex = question.questionId.replace(/\s+/g, ' ').trim();
|
||||||
|
let cleanedText=cleanedTex.replace('<p>','').replace('</p>','')
|
||||||
|
|
||||||
|
var question_id_length =cleanedText.length;
|
||||||
|
console.log(question_id_length);
|
||||||
|
if (question_id_length == 1) {
|
||||||
|
GroupQuestionTilteAlign =14
|
||||||
|
} else if (question_id_length == 3) {
|
||||||
|
GroupQuestionTilteAlign =26
|
||||||
|
}else if(question_id_length == 5){
|
||||||
|
GroupQuestionTilteAlign =41
|
||||||
|
}else if(question_id_length == 7) {
|
||||||
|
GroupQuestionTilteAlign =54
|
||||||
|
}else if(question_id_length == 2) {
|
||||||
|
GroupQuestionTilteAlign =25
|
||||||
|
}else if(question_id_length == 4) {
|
||||||
|
GroupQuestionTilteAlign =42
|
||||||
|
}else if(question_id_length == 6) {
|
||||||
|
GroupQuestionTilteAlign =58
|
||||||
|
}
|
||||||
|
// console.log(question);
|
||||||
|
// const questionId =`<p class="questionId">${cleanedText})</p>`;
|
||||||
|
const questionI =cleanedText;
|
||||||
|
var questionId = questionI.replace('<p>', '<p class="questionId">');
|
||||||
|
console.log(questionId);
|
||||||
|
|
||||||
const questionTex = question.question;
|
const questionTex = question.question;
|
||||||
const questionText = questionTex.replaceAll('<p>', `<p class="question_Text" style="margin-left:${description_align}px">`);
|
const questionText = questionTex.replaceAll('<p>', `<p class="question_Text" style="margin-left:${GroupQuestionTilteAlign}px">`);
|
||||||
// console.log(questionText);
|
// console.log(questionText);
|
||||||
const questionDescriptio = question.question_description;
|
const questionDescriptio = question.question_description;
|
||||||
const questionDescription = questionDescriptio.replaceAll('<p>', '<p class="question-Description">')
|
const questionDescription = questionDescriptio.replaceAll('<p>', '<p class="question-Description">')
|
||||||
@ -198,8 +252,11 @@ function QuestionPaperPreview(jsonData){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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">${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>`;
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
if (question.question_type === "group") {
|
if (question.question_type === "group") {
|
||||||
var answers = question.answers;
|
var answers = question.answers;
|
||||||
var choisealgin =25
|
var choisealgin =25
|
||||||
@ -250,6 +307,8 @@ function QuestionPaperPreview(jsonData){
|
|||||||
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
|
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function removeHtmlTags(inputString) {
|
function removeHtmlTags(inputString) {
|
||||||
|
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
@ -257,4 +316,35 @@ function removeHtmlTags(inputString) {
|
|||||||
const text = $.text();
|
const text = $.text();
|
||||||
|
|
||||||
return text;
|
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)
|
||||||
|
|
||||||
|
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 cov;
|
||||||
|
// Return the text as-is
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -49,8 +49,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.question-Group-Description{
|
||||||
|
margin-top: -14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GroupQuestionId{
|
||||||
|
margin-left: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
/* strong{
|
/* strong{
|
||||||
margin-left: -51px !important;
|
margin-left: -51px !important;
|
||||||
@ -75,6 +80,7 @@
|
|||||||
/* overflow-wrap: break-word;
|
/* overflow-wrap: break-word;
|
||||||
hyphens: manual; */
|
hyphens: manual; */
|
||||||
text-wrap: wrap;
|
text-wrap: wrap;
|
||||||
|
margin-top: -27px !important;
|
||||||
|
|
||||||
/* width: 700px; */
|
/* width: 700px; */
|
||||||
/* inline-size: 150px; */
|
/* inline-size: 150px; */
|
||||||
@ -137,7 +143,7 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
float: right;
|
float: right;
|
||||||
margin-top:-25px;
|
margin-top:-27px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Section SectionAttempt SectionMark */
|
/* Section SectionAttempt SectionMark */
|
||||||
|
|||||||
796
addform.html
796
addform.html
File diff suppressed because it is too large
Load Diff
33
html2json.js
33
html2json.js
@ -2,6 +2,7 @@ function html2json() {
|
|||||||
// console.clear();
|
// console.clear();
|
||||||
|
|
||||||
$.fn.getTextQuestion = function(element_id) {
|
$.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 questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||||
var questionUUID = document.getElementById('Text_Question_UUID_ID_' + element_id).value;
|
var questionUUID = document.getElementById('Text_Question_UUID_ID_' + element_id).value;
|
||||||
@ -21,6 +22,7 @@ function html2json() {
|
|||||||
var questionSubType = 'false';
|
var questionSubType = 'false';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"question_id":questionTitleIdSet,
|
||||||
"question": questionTitle,
|
"question": questionTitle,
|
||||||
"question_description": questionSubTitle,
|
"question_description": questionSubTitle,
|
||||||
"question_type": questionType,
|
"question_type": questionType,
|
||||||
@ -34,12 +36,18 @@ function html2json() {
|
|||||||
|
|
||||||
$.fn.getChoiceQuestion = function(element_id) {
|
$.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).querySelector('.ql-editor').innerHTML;
|
||||||
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
||||||
var questionUUID = document.getElementById('Choice_Question_UUID_ID_' + element_id).value;
|
var questionUUID = document.getElementById('Choice_Question_UUID_ID_' + element_id).value;
|
||||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||||
var displayMarks = document.getElementById('Choice_Question_Display_Marks_Id_' + element_id).checked;
|
var displayMarks = document.getElementById('Choice_Question_Display_Marks_Id_' + element_id).checked;
|
||||||
var questionSubTitle = "";
|
var questionSubTitle = "";
|
||||||
|
// var choiceQuestiondiv = document.getElementById('removeAndCloneQroupQuestion_' + element_id)
|
||||||
|
var choiceQuestioncheckInput = document.getElementById('ChoiceCorrectAnswer_' + element_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isMathEnabled == true)
|
if(isMathEnabled == true)
|
||||||
{
|
{
|
||||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||||
@ -52,7 +60,7 @@ function html2json() {
|
|||||||
// console.log(questionType);
|
// console.log(questionType);
|
||||||
var questionSubType = document.getElementById('multipleAnswer_' + element_id).checked;
|
var questionSubType = document.getElementById('multipleAnswer_' + element_id).checked;
|
||||||
var answers = [];
|
var answers = [];
|
||||||
|
var correct_answers =[];
|
||||||
//get choice group
|
//get choice group
|
||||||
|
|
||||||
//get default choice details
|
//get default choice details
|
||||||
@ -74,6 +82,12 @@ function html2json() {
|
|||||||
"no": 'a'
|
"no": 'a'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (choiceQuestioncheckInput.checked) {
|
||||||
|
correct_answers.push([
|
||||||
|
choiceQuestioncheckInput.value
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('before group');
|
// console.log('before group');
|
||||||
//get dynamically added choice detailscolor: #999;
|
//get dynamically added choice detailscolor: #999;
|
||||||
const alphabets = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
const alphabets = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
||||||
@ -84,7 +98,7 @@ function html2json() {
|
|||||||
|
|
||||||
var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[0];
|
var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[0];
|
||||||
var individualChoiceId = (element.id).split('.').slice(-1)[0];
|
var individualChoiceId = (element.id).split('.').slice(-1)[0];
|
||||||
console.log('newChoiceTextField_'+groupChoiceId+'.'+individualChoiceId);
|
// console.log('newChoiceTextField_'+groupChoiceId+'.'+individualChoiceId);
|
||||||
|
|
||||||
var choice_math_Enabled = document.getElementById('choice_math_' + groupChoiceId + '.' + individualChoiceId).checked;
|
var choice_math_Enabled = document.getElementById('choice_math_' + groupChoiceId + '.' + individualChoiceId).checked;
|
||||||
var choice_name = "";
|
var choice_name = "";
|
||||||
@ -100,6 +114,7 @@ function html2json() {
|
|||||||
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
||||||
var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value;
|
var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||||
|
|
||||||
|
choiceQuestioncheckInput = document.getElementById('ChoiceCorrectAnswer_'+groupChoiceId + '.' + individualChoiceId)
|
||||||
answers.push({
|
answers.push({
|
||||||
"choice_name": choice_name,
|
"choice_name": choice_name,
|
||||||
"is_math_enabled": choice_math_Enabled,
|
"is_math_enabled": choice_math_Enabled,
|
||||||
@ -107,11 +122,18 @@ function html2json() {
|
|||||||
"no":letter
|
"no":letter
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (choiceQuestioncheckInput.checked) {
|
||||||
|
correct_answers.push([
|
||||||
|
choiceQuestioncheckInput.value
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"questionChoiceId" : questionChoiceId,
|
||||||
"question": questionTitle,
|
"question": questionTitle,
|
||||||
"question_description": questionSubTitle,
|
"question_description": questionSubTitle,
|
||||||
"question_type": questionType,
|
"question_type": questionType,
|
||||||
@ -120,7 +142,8 @@ function html2json() {
|
|||||||
"display_marks": displayMarks,
|
"display_marks": displayMarks,
|
||||||
"marks":marks,
|
"marks":marks,
|
||||||
"choice_question_uuid":questionUUID,
|
"choice_question_uuid":questionUUID,
|
||||||
"answers": answers
|
"answers": answers,
|
||||||
|
"correct_answer": correct_answers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +202,16 @@ function html2json() {
|
|||||||
// console.log(rand_id);
|
// console.log(rand_id);
|
||||||
// console.log('section_title_text_'+rand_id);
|
// console.log('section_title_text_'+rand_id);
|
||||||
var groupQuestion = {}
|
var groupQuestion = {}
|
||||||
|
// console.log(document.getElementById('Questions_Group_id_' + rand_id).value);
|
||||||
|
var question_id = document.getElementById('Questions_Group_id_' + rand_id);
|
||||||
var group_title = document.getElementById('subSection_title_text_' + rand_id);
|
var group_title = document.getElementById('subSection_title_text_' + rand_id);
|
||||||
var group_description = document.getElementById('subSection_description_text_' + rand_id);
|
var group_description = document.getElementById('subSection_description_text_' + rand_id);
|
||||||
var group_marks = document.getElementById('Question_Group_Marks_Id_' + rand_id);
|
var group_marks = document.getElementById('Question_Group_Marks_Id_' + rand_id);
|
||||||
var group_uuid = document.getElementById('Question_Group_UUID_ID_' + rand_id);
|
var group_uuid = document.getElementById('Question_Group_UUID_ID_' + rand_id);
|
||||||
var group_display_marks = document.getElementById('Question_Group_Display_Marks_Id_' + rand_id);
|
var group_display_marks = document.getElementById('Question_Group_Display_Marks_Id_' + rand_id);
|
||||||
var group_attempt_any = document.getElementById('Question_Attempt_Any_Id_' + rand_id);
|
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_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_description'] = ((typeof group_description !== null && group_description !== 'undefined') ? (group_description !== null ? group_description.querySelector('.ql-editor').innerHTML : null) : null);
|
||||||
groupQuestion['group_marks'] = ((typeof group_marks !== null && group_marks !== 'undefined') ? (group_marks !== null ? group_marks.value : null) : null);
|
groupQuestion['group_marks'] = ((typeof group_marks !== null && group_marks !== 'undefined') ? (group_marks !== null ? group_marks.value : null) : null);
|
||||||
|
|||||||
1
imageresize.min.js
vendored
Normal file
1
imageresize.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
18
json2html.js
18
json2html.js
@ -12,7 +12,6 @@ function jsonToHtml(jsonData) {
|
|||||||
|
|
||||||
if(jsonData == "" || jsonData == null)
|
if(jsonData == "" || jsonData == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = "";
|
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = "";
|
||||||
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = "";
|
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = "";
|
||||||
document.getElementById('Max_Marks').value = "";
|
document.getElementById('Max_Marks').value = "";
|
||||||
@ -92,6 +91,7 @@ function jsonToHtml(jsonData) {
|
|||||||
|
|
||||||
function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||||
|
|
||||||
|
// console.log(Question);
|
||||||
var questionTypeFormets = "";
|
var questionTypeFormets = "";
|
||||||
if(Question.question_type)
|
if(Question.question_type)
|
||||||
{
|
{
|
||||||
@ -101,6 +101,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
{
|
{
|
||||||
questionTypeFormets ='question_group';
|
questionTypeFormets ='question_group';
|
||||||
}
|
}
|
||||||
|
var questionId = Question.question_id
|
||||||
var questionTitle = Question.question;
|
var questionTitle = Question.question;
|
||||||
var questionDescription = Question.question_description;
|
var questionDescription = Question.question_description;
|
||||||
var questionType = questionTypeFormets;
|
var questionType = questionTypeFormets;
|
||||||
@ -110,12 +111,13 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
var questionUUID = Question.attributes.Id;
|
var questionUUID = Question.attributes.Id;
|
||||||
var questionDisplayMarks = Question.display_marks;
|
var questionDisplayMarks = Question.display_marks;
|
||||||
var Choice = Question.answers;
|
var Choice = Question.answers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var QuestionObj = {
|
var QuestionObj = {
|
||||||
"question_area_id" :questionAreaId,
|
"question_area_id" :questionAreaId,
|
||||||
'questionRandomNo' :questionRandomNo,
|
'questionRandomNo' :questionRandomNo,
|
||||||
|
|
||||||
|
'questionId' :Question.question_id,
|
||||||
'questionTitle' :Question.question,
|
'questionTitle' :Question.question,
|
||||||
'questionDescription' :Question.question_description,
|
'questionDescription' :Question.question_description,
|
||||||
'questionType' :questionTypeFormets,
|
'questionType' :questionTypeFormets,
|
||||||
@ -125,7 +127,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
'questionUUID' :Question.attributes.Id,
|
'questionUUID' :Question.attributes.Id,
|
||||||
'questionDisplayMarks' :Question.display_marks,
|
'questionDisplayMarks' :Question.display_marks,
|
||||||
'Choice' :Question.answers,
|
'Choice' :Question.answers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(questionType == 'text')
|
if(questionType == 'text')
|
||||||
@ -134,10 +136,9 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
// textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks);
|
// textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks);
|
||||||
}
|
}
|
||||||
else if (questionType == 'group')
|
else if (questionType == 'group')
|
||||||
{
|
{
|
||||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,);
|
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId);
|
||||||
// groupQuestion(QuestionObj);
|
// groupQuestion(QuestionObj);
|
||||||
|
|
||||||
Choice = Choice.slice(1);
|
Choice = Choice.slice(1);
|
||||||
Choice.forEach(function(choicenames, index) {
|
Choice.forEach(function(choicenames, index) {
|
||||||
var choiceName = choicenames.choice_name;
|
var choiceName = choicenames.choice_name;
|
||||||
@ -150,7 +151,6 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
}
|
}
|
||||||
else if (questionType == 'question_group')
|
else if (questionType == 'question_group')
|
||||||
{
|
{
|
||||||
|
|
||||||
generateGroupQuestion(Question, questionAreaId, questionRandomNo);
|
generateGroupQuestion(Question, questionAreaId, questionRandomNo);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -161,12 +161,12 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
|||||||
//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) {
|
||||||
|
// Question.forEach(function(GroupQuestions, index) {
|
||||||
|
|
||||||
const QuestionGroupRandomNo = Date.now();
|
const QuestionGroupRandomNo = Date.now();
|
||||||
var questionGroupAreaId = 'group_question_area_'+questionRandomNo;
|
var questionGroupAreaId = 'group_question_area_'+questionRandomNo;
|
||||||
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
|
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
|
||||||
|
|||||||
29
json2xml.js
29
json2xml.js
@ -1,8 +1,7 @@
|
|||||||
function json2xml() {
|
function json2xml() {
|
||||||
// console.clear();
|
// console.clear();
|
||||||
var obj = localStorage.getItem("json");
|
var obj = localStorage.getItem("json");
|
||||||
// console.log(obj);
|
// console.log('***********************************************************');
|
||||||
// console.log('***********************************************************');
|
|
||||||
|
|
||||||
function createXMLDocument(namespace = null) {
|
function createXMLDocument(namespace = null) {
|
||||||
if (typeof document.implementation.createDocument === 'function') {
|
if (typeof document.implementation.createDocument === 'function') {
|
||||||
@ -66,6 +65,15 @@ function json2xml() {
|
|||||||
'type': (question['question_type'] == 'text' ? 'Descriptive' : 'Mcq')
|
'type': (question['question_type'] == 'text' ? 'Descriptive' : 'Mcq')
|
||||||
|
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
|
if (question['question_id'] !== undefined) {
|
||||||
|
var questionChoiceId =createElementWithText(doc, element, 'Text', question['question_id'])
|
||||||
|
} else {
|
||||||
|
// If question['question_id'] is undefined, create a new variable
|
||||||
|
var questionIdSet = createElementWithText(doc, element , 'Text', question['questionChoiceId'])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var questionTitle = createElementWithText(doc, element, 'Text', question['question']);
|
var questionTitle = createElementWithText(doc, element, 'Text', question['question']);
|
||||||
var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
|
var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
|
||||||
var marks = createElementWithText(doc, element, 'Marks', question['marks']);
|
var marks = createElementWithText(doc, element, 'Marks', question['marks']);
|
||||||
@ -75,14 +83,14 @@ function json2xml() {
|
|||||||
if (question['question_type'] == 'group') {
|
if (question['question_type'] == 'group') {
|
||||||
var hasMultipleAnswers = createElementWithText(doc, element, 'HasMultipleAnswers', (question['question_sub_type'] === true ? 'true' : 'false'), {});
|
var hasMultipleAnswers = createElementWithText(doc, element, 'HasMultipleAnswers', (question['question_sub_type'] === true ? 'true' : 'false'), {});
|
||||||
var choicesElement = createElementWithText(doc, element, 'Choices', '', {});
|
var choicesElement = createElementWithText(doc, element, 'Choices', '', {});
|
||||||
for (choice in question['answers']) {
|
for (choice in question['answers']) {
|
||||||
var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {});
|
var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {});
|
||||||
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
||||||
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'], {});
|
||||||
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
|
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
|
||||||
|
|
||||||
}
|
}
|
||||||
// choicesElement.appendChild();
|
// choicesElement.appendChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +120,7 @@ function json2xml() {
|
|||||||
// 'No': singleQuestion['group_title'],
|
// 'No': singleQuestion['group_title'],
|
||||||
// 'Order': 0
|
// 'Order': 0
|
||||||
// });
|
// });
|
||||||
|
var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['group_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']);
|
||||||
@ -151,6 +159,7 @@ function json2xml() {
|
|||||||
|
|
||||||
//start of the busi logic
|
//start of the busi logic
|
||||||
questionPaper = JSON.parse(obj);
|
questionPaper = JSON.parse(obj);
|
||||||
|
// console.log(questionPaper);
|
||||||
var ns1 = 'http://www.w3.org/2001/XMLSchema';
|
var ns1 = 'http://www.w3.org/2001/XMLSchema';
|
||||||
var xmlDoc = createXMLDocument(namespace = ns1);
|
var xmlDoc = createXMLDocument(namespace = ns1);
|
||||||
var rootElement = xmlDoc.createElement('QuestionPaper');
|
var rootElement = xmlDoc.createElement('QuestionPaper');
|
||||||
@ -177,7 +186,7 @@ function json2xml() {
|
|||||||
//create section related xml nodes
|
//create section related xml nodes
|
||||||
var tempSection = questionPaper['sections'][section];
|
var tempSection = questionPaper['sections'][section];
|
||||||
|
|
||||||
console.log(tempSection);
|
// console.log(tempSection);
|
||||||
|
|
||||||
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
|
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
|
||||||
'xsi:type': 'QuestionPaperSection',
|
'xsi:type': 'QuestionPaperSection',
|
||||||
@ -199,15 +208,15 @@ function json2xml() {
|
|||||||
if (tempSection['questions'].length != 0) {
|
if (tempSection['questions'].length != 0) {
|
||||||
for (question in tempSection['questions']) {
|
for (question in tempSection['questions']) {
|
||||||
var singleQuestion = tempSection['questions'][question];
|
var singleQuestion = tempSection['questions'][question];
|
||||||
if (singleQuestion.hasOwnProperty('question_type')) // normal questions
|
if (singleQuestion.hasOwnProperty('question_type')) // normal questions
|
||||||
{
|
{
|
||||||
var singleQuestionElement = getXMLNodesOfQuestionData(singleQuestion);
|
var singleQuestionElement = getXMLNodesOfQuestionData(singleQuestion);
|
||||||
//attach each single question into section item node
|
//attach each single question into section item node
|
||||||
sectionItemElement.appendChild(singleQuestionElement);
|
sectionItemElement.appendChild(singleQuestionElement);
|
||||||
} else // handle question group
|
} else // handle question group
|
||||||
{
|
{
|
||||||
var groupQuestionElement = getXMLNodesOfGroupQuestionData(singleQuestion);
|
var groupQuestionElement = getXMLNodesOfGroupQuestionData(singleQuestion);
|
||||||
sectionItemElement.appendChild(groupQuestionElement);
|
sectionItemElement.appendChild(groupQuestionElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap-icons": "^1.11.1",
|
"bootstrap-icons": "^1.11.1",
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
|
"cropperjs": "^1.6.1",
|
||||||
"desandro-matches-selector": "^2.0.2",
|
"desandro-matches-selector": "^2.0.2",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"electron-context-menu": "^3.6.1",
|
"electron-context-menu": "^3.6.1",
|
||||||
@ -769,6 +770,11 @@
|
|||||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/cropperjs": {
|
||||||
|
"version": "1.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/cropperjs/-/cropperjs-1.6.1.tgz",
|
||||||
|
"integrity": "sha512-F4wsi+XkDHCOMrHMYjrTEE4QBOrsHHN5/2VsVAaRq8P7E5z7xQpT75S+f/9WikmBEailas3+yo+6zPIomW+NOA=="
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap-icons": "^1.11.1",
|
"bootstrap-icons": "^1.11.1",
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
|
"cropperjs": "^1.6.1",
|
||||||
"desandro-matches-selector": "^2.0.2",
|
"desandro-matches-selector": "^2.0.2",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"electron-context-menu": "^3.6.1",
|
"electron-context-menu": "^3.6.1",
|
||||||
|
|||||||
@ -3760,4 +3760,9 @@ width:85px;
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
font-style: normal !important;
|
font-style: normal !important;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
.correctAnswer{
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
46
xml2json.js
46
xml2json.js
@ -24,40 +24,44 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
var questionObj = {};
|
var questionObj = {};
|
||||||
if(type == 1)
|
if(type == 1)
|
||||||
{
|
{
|
||||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
questionObj['question_id'] = 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'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||||
|
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionObj['question_type'] = 'text';
|
questionObj['question_type'] = 'text';
|
||||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||||
questionObj['question_sub_type'] = 'false';
|
questionObj['question_sub_type'] = 'false';
|
||||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||||
|
// console.log(questionObj);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
questionObj['question_id'] = 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'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||||
|
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionObj['question_type'] = 'group';
|
questionObj['question_type'] = 'group';
|
||||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||||
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
questionObj['is_math_enabled'] = questionNode.childNodes[6].firstChild.nodeValue;
|
||||||
questionObj['answers'] = [];
|
questionObj['answers'] = [];
|
||||||
|
|
||||||
var choiceList = questionNode.childNodes[6].childNodes;
|
var choiceList = questionNode.childNodes[7].childNodes;
|
||||||
|
|
||||||
if(choiceList.length > 0)
|
if(choiceList.length > 0)
|
||||||
{
|
{
|
||||||
for (let k = 0; k < choiceList.length ;k++)
|
for (let k = 0; k < choiceList.length ;k++)
|
||||||
{
|
{
|
||||||
var tempChoiceobj = {};
|
var tempChoiceobj = {};
|
||||||
|
console.log(choiceList)
|
||||||
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'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
|
||||||
// console.log(tempChoiceobj);
|
// console.log(tempChoiceobj);
|
||||||
questionObj['answers'].push(tempChoiceobj);
|
questionObj['answers'].push(tempChoiceobj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,16 +73,16 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
function getQuestionGroupNodes(questionGroup)
|
function getQuestionGroupNodes(questionGroup)
|
||||||
{
|
{
|
||||||
var questionGroupObj = {};
|
var questionGroupObj = {};
|
||||||
|
questionGroupObj['question_id'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
||||||
questionGroupObj['group_title'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
questionGroupObj['group_title'] = questionGroup.childNodes[1].firstChild.nodeValue;
|
||||||
questionGroupObj['group_description'] = (questionGroup.childNodes[1].firstChild !== null ? questionGroup.childNodes[1].firstChild.nodeValue : "");
|
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionGroupObj['group_marks'] = (questionGroup.childNodes[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[3].firstChild.nodeValue;
|
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].firstChild.nodeValue;
|
||||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[4].firstChild !== null ? questionGroup.childNodes[4].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[5].childNodes;
|
var questionList = questionGroup.childNodes[6].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++)
|
||||||
{
|
{
|
||||||
@ -128,7 +132,7 @@ jsonObj['sections'] = [];
|
|||||||
var tempObj = {};
|
var tempObj = {};
|
||||||
|
|
||||||
// console.log('Section :' + i + '-' + sectionsList[i].childNodes[0]);
|
// console.log('Section :' + i + '-' + sectionsList[i].childNodes[0]);
|
||||||
tempObj['section_title'] = 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.nodeValue;
|
tempObj['section_description'] = sectionsList[i].childNodes[1].firstChild.nodeValue;
|
||||||
tempObj['section_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
|
tempObj['section_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_display_marks'] = sectionsList[i].childNodes[3].firstChild.nodeValue;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
function xml2json(xmlData) {
|
function xml2json(xmlData) {
|
||||||
// console.clear();
|
// console.clear();
|
||||||
console.log('xml to json converstion');
|
console.log('xml to json converstion');
|
||||||
// console.log(xmlData);
|
// console.log(xmlData);z
|
||||||
|
|
||||||
function getAttributesOfXMLNode(node)
|
function getAttributesOfXMLNode(node)
|
||||||
{
|
{
|
||||||
@ -24,29 +24,31 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
var questionObj = {};
|
var questionObj = {};
|
||||||
if(type == 1)
|
if(type == 1)
|
||||||
{
|
{
|
||||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
questionObj['questionId'] = 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'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||||
|
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionObj['question_type'] = 'text';
|
questionObj['question_type'] = 'text';
|
||||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||||
questionObj['question_sub_type'] = 'false';
|
questionObj['question_sub_type'] = 'false';
|
||||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
questionObj['questionId'] = questionNode.childNodes[0].firstChild.nodeValue;
|
||||||
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||||
|
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionObj['question_type'] = 'group';
|
questionObj['question_type'] = 'group';
|
||||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||||
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue;
|
||||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||||
questionObj['answers'] = [];
|
questionObj['answers'] = [];
|
||||||
|
|
||||||
var choiceList = questionNode.childNodes[6].childNodes;
|
var choiceList = questionNode.childNodes[7].childNodes;
|
||||||
|
|
||||||
if(choiceList.length > 0)
|
if(choiceList.length > 0)
|
||||||
{
|
{
|
||||||
@ -70,20 +72,23 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
function getQuestionGroupNodes(questionGroup)
|
function getQuestionGroupNodes(questionGroup)
|
||||||
{
|
{
|
||||||
var questionGroupObj = {};
|
var questionGroupObj = {};
|
||||||
questionGroupObj['group_title'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
questionGroupObj['question_id'] = (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['group_title'] = questionGroup.childNodes[1].firstChild.nodeValue;
|
||||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[3].firstChild.nodeValue;
|
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[4].firstChild !== null ? questionGroup.childNodes[4].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['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||||
questionGroupObj['questions'] = [];
|
questionGroupObj['questions'] = [];
|
||||||
//handle questions
|
//handle questions
|
||||||
var questionList = questionGroup.childNodes[5].childNodes;
|
var questionList = questionGroup.childNodes[6].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++)
|
||||||
{
|
{
|
||||||
|
|
||||||
var questionType = questionList[q].getAttribute("xsi:type");
|
var questionType = questionList[q].getAttribute("xsi:type");
|
||||||
|
console.log(questionType);
|
||||||
if(questionType == 'DescriptiveQuestion')
|
if(questionType == 'DescriptiveQuestion')
|
||||||
{
|
{
|
||||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user