codeMerage : RV
This commit is contained in:
commit
1310c0efcd
@ -39,6 +39,7 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
|
||||
function convertToLatex(text, mathstatus) {
|
||||
// console.log(text);
|
||||
// Parse mathstatus into a boolean
|
||||
const mathStatusBoolean = JSON.parse(mathstatus);
|
||||
// Check if the text contains <p> tags
|
||||
@ -130,21 +131,48 @@ function QuestionPaperPreview(jsonData){
|
||||
|
||||
var currentSno_length =currentSno.length-(currentSno.length/2)
|
||||
if (currentSno_length == 1) {
|
||||
description_align =17
|
||||
description_align =27
|
||||
} else if (currentSno_length == 2) {
|
||||
description_align =33
|
||||
}else if(currentSno_length == 3){
|
||||
description_align =48
|
||||
}else if(currentSno_length == 4) {
|
||||
description_align =64
|
||||
description_align =62
|
||||
}
|
||||
else if(currentSno_length == 5) {
|
||||
description_align =78
|
||||
}
|
||||
|
||||
|
||||
var GroupQuestionTilteAlign = 0;
|
||||
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 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) {
|
||||
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>')
|
||||
// }
|
||||
|
||||
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_attempt_any">${questionGroupAttempt}</div>`;
|
||||
@ -177,8 +205,34 @@ function QuestionPaperPreview(jsonData){
|
||||
questionPaper += `<div class="group-descrip" style="margin-left:${description_align}px">${questionGroupDescription}</div>`;
|
||||
depth2++
|
||||
} 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 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);
|
||||
const questionDescriptio = question.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") {
|
||||
var answers = question.answers;
|
||||
var choisealgin =25
|
||||
@ -250,6 +307,8 @@ function QuestionPaperPreview(jsonData){
|
||||
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
|
||||
}
|
||||
|
||||
|
||||
|
||||
function removeHtmlTags(inputString) {
|
||||
|
||||
const cheerio = require('cheerio');
|
||||
@ -257,4 +316,35 @@ function removeHtmlTags(inputString) {
|
||||
const text = $.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>
|
||||
|
||||
|
||||
.question-Group-Description{
|
||||
margin-top: -14px;
|
||||
}
|
||||
|
||||
.GroupQuestionId{
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
/* strong{
|
||||
margin-left: -51px !important;
|
||||
@ -75,6 +80,7 @@
|
||||
/* overflow-wrap: break-word;
|
||||
hyphens: manual; */
|
||||
text-wrap: wrap;
|
||||
margin-top: -27px !important;
|
||||
|
||||
/* width: 700px; */
|
||||
/* inline-size: 150px; */
|
||||
@ -137,7 +143,7 @@
|
||||
display: inline-flex;
|
||||
margin-right: 10px;
|
||||
float: right;
|
||||
margin-top:-25px;
|
||||
margin-top:-27px;
|
||||
}
|
||||
|
||||
/* Section SectionAttempt SectionMark */
|
||||
|
||||
656
addform.html
656
addform.html
File diff suppressed because it is too large
Load Diff
31
html2json.js
31
html2json.js
@ -2,6 +2,7 @@ function html2json() {
|
||||
// console.clear();
|
||||
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
var questionTitleIdSet = document.getElementById('QuestionTextIdSet_'+element_id).value;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||
var questionUUID = document.getElementById('Text_Question_UUID_ID_' + element_id).value;
|
||||
@ -21,6 +22,7 @@ function html2json() {
|
||||
var questionSubType = 'false';
|
||||
|
||||
return {
|
||||
"question_id":questionTitleIdSet,
|
||||
"question": questionTitle,
|
||||
"question_description": questionSubTitle,
|
||||
"question_type": questionType,
|
||||
@ -34,12 +36,18 @@ function html2json() {
|
||||
|
||||
$.fn.getChoiceQuestion = function(element_id) {
|
||||
|
||||
var questionChoiceId = document.getElementById('QuestionChoiceId_' + element_id).value;
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
||||
var questionUUID = document.getElementById('Choice_Question_UUID_ID_' + element_id).value;
|
||||
var isMathEnabled = document.getElementById('math_' + element_id).checked;
|
||||
var displayMarks = document.getElementById('Choice_Question_Display_Marks_Id_' + element_id).checked;
|
||||
var questionSubTitle = "";
|
||||
// var choiceQuestiondiv = document.getElementById('removeAndCloneQroupQuestion_' + element_id)
|
||||
var choiceQuestioncheckInput = document.getElementById('ChoiceCorrectAnswer_' + element_id)
|
||||
|
||||
|
||||
|
||||
if(isMathEnabled == true)
|
||||
{
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_math_' + element_id).value;
|
||||
@ -52,7 +60,7 @@ function html2json() {
|
||||
// console.log(questionType);
|
||||
var questionSubType = document.getElementById('multipleAnswer_' + element_id).checked;
|
||||
var answers = [];
|
||||
|
||||
var correct_answers =[];
|
||||
//get choice group
|
||||
|
||||
//get default choice details
|
||||
@ -74,6 +82,12 @@ function html2json() {
|
||||
"no": 'a'
|
||||
});
|
||||
|
||||
if (choiceQuestioncheckInput.checked) {
|
||||
correct_answers.push([
|
||||
choiceQuestioncheckInput.value
|
||||
])
|
||||
}
|
||||
|
||||
// console.log('before group');
|
||||
//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'];
|
||||
@ -100,6 +114,7 @@ function html2json() {
|
||||
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
||||
var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
|
||||
choiceQuestioncheckInput = document.getElementById('ChoiceCorrectAnswer_'+groupChoiceId + '.' + individualChoiceId)
|
||||
answers.push({
|
||||
"choice_name": choice_name,
|
||||
"is_math_enabled": choice_math_Enabled,
|
||||
@ -107,11 +122,18 @@ function html2json() {
|
||||
"no":letter
|
||||
});
|
||||
|
||||
if (choiceQuestioncheckInput.checked) {
|
||||
correct_answers.push([
|
||||
choiceQuestioncheckInput.value
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
"questionChoiceId" : questionChoiceId,
|
||||
"question": questionTitle,
|
||||
"question_description": questionSubTitle,
|
||||
"question_type": questionType,
|
||||
@ -120,7 +142,8 @@ function html2json() {
|
||||
"display_marks": displayMarks,
|
||||
"marks":marks,
|
||||
"choice_question_uuid":questionUUID,
|
||||
"answers": answers
|
||||
"answers": answers,
|
||||
"correct_answer": correct_answers
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,12 +202,16 @@ function html2json() {
|
||||
// console.log(rand_id);
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
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_description = document.getElementById('subSection_description_text_' + 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_display_marks = document.getElementById('Question_Group_Display_Marks_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_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);
|
||||
|
||||
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
@ -13,7 +13,6 @@ function jsonToHtml(jsonData) {
|
||||
|
||||
if(jsonData == "" || jsonData == null)
|
||||
{
|
||||
|
||||
document.getElementById('Question_title').querySelector('.ql-editor').innerHTML = "";
|
||||
document.getElementById('Question_description').querySelector('.ql-editor').innerHTML = "";
|
||||
document.getElementById('Max_Marks').value = "";
|
||||
@ -93,6 +92,7 @@ function jsonToHtml(jsonData) {
|
||||
|
||||
function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
|
||||
// console.log(Question);
|
||||
var questionTypeFormets = "";
|
||||
if(Question.question_type)
|
||||
{
|
||||
@ -102,6 +102,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
{
|
||||
questionTypeFormets ='question_group';
|
||||
}
|
||||
var questionId = Question.question_id
|
||||
var questionTitle = Question.question;
|
||||
var questionDescription = Question.question_description;
|
||||
var questionType = questionTypeFormets;
|
||||
@ -111,12 +112,13 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
var questionUUID = Question.attributes.Id;
|
||||
var questionDisplayMarks = Question.display_marks;
|
||||
var Choice = Question.answers;
|
||||
|
||||
|
||||
|
||||
var QuestionObj = {
|
||||
"question_area_id" :questionAreaId,
|
||||
'questionRandomNo' :questionRandomNo,
|
||||
|
||||
'questionId' :Question.question_id,
|
||||
'questionTitle' :Question.question,
|
||||
'questionDescription' :Question.question_description,
|
||||
'questionType' :questionTypeFormets,
|
||||
@ -126,7 +128,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
'questionUUID' :Question.attributes.Id,
|
||||
'questionDisplayMarks' :Question.display_marks,
|
||||
'Choice' :Question.answers,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(questionType == 'text')
|
||||
@ -135,11 +137,10 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
// textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks);
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
Choice = Choice.slice(1);
|
||||
Choice.forEach(function(choicenames, index) {
|
||||
var choiceName = choicenames.choice_name;
|
||||
@ -152,7 +153,6 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
}
|
||||
else if (questionType == 'question_group')
|
||||
{
|
||||
|
||||
generateGroupQuestion(Question, questionAreaId, questionRandomNo);
|
||||
|
||||
}
|
||||
@ -163,12 +163,12 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||
//function for Generate QuestionGroup
|
||||
function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||
{
|
||||
|
||||
var idObj = {"section_question_area_id":questionAreaId, 'question_group_obj': Question, 'questions_randon_id':questionRandomNo};
|
||||
|
||||
addQuestionGroup(idObj);
|
||||
|
||||
Question.questions.forEach(function(GroupQuestions, index) {
|
||||
// Question.forEach(function(GroupQuestions, index) {
|
||||
|
||||
const QuestionGroupRandomNo = Date.now();
|
||||
var questionGroupAreaId = 'group_question_area_'+questionRandomNo;
|
||||
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
|
||||
|
||||
24
json2xml.js
24
json2xml.js
@ -1,6 +1,7 @@
|
||||
function json2xml() {
|
||||
// console.clear();
|
||||
var obj = localStorage.getItem("json");
|
||||
|
||||
// var obj = `{
|
||||
// "question_paper_title": "<p><br></p>",
|
||||
// "question_paper_description": "<p><br></p>",
|
||||
@ -203,6 +204,15 @@ function json2xml() {
|
||||
'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 questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
|
||||
var marks = createElementWithText(doc, element, 'Marks', question['marks']);
|
||||
@ -212,14 +222,14 @@ function json2xml() {
|
||||
if (question['question_type'] == 'group') {
|
||||
var hasMultipleAnswers = createElementWithText(doc, element, 'HasMultipleAnswers', (question['question_sub_type'] === true ? 'true' : 'false'), {});
|
||||
var choicesElement = createElementWithText(doc, element, 'Choices', '', {});
|
||||
for (choice in question['answers']) {
|
||||
for (choice in question['answers']) {
|
||||
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 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'), {});
|
||||
|
||||
}
|
||||
}
|
||||
// choicesElement.appendChild();
|
||||
}
|
||||
|
||||
@ -249,7 +259,7 @@ function json2xml() {
|
||||
// 'No': singleQuestion['group_title'],
|
||||
// 'Order': 0
|
||||
// });
|
||||
|
||||
var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['group_id']);
|
||||
var groupQuestionTitle = createElementWithText(doc, element, 'Text', singleQuestion['group_title']);
|
||||
var groupQuestionDesc = createElementWithText(doc, element, 'Subtext', singleQuestion['group_description']);
|
||||
var groupQuestionMarks = createElementWithText(doc, element, 'Marks', singleQuestion['group_marks']);
|
||||
@ -288,6 +298,7 @@ function json2xml() {
|
||||
|
||||
//start of the busi logic
|
||||
questionPaper = JSON.parse(obj);
|
||||
// console.log(questionPaper);
|
||||
var ns1 = 'http://www.w3.org/2001/XMLSchema';
|
||||
var xmlDoc = createXMLDocument(namespace = ns1);
|
||||
var rootElement = xmlDoc.createElement('QuestionPaper');
|
||||
@ -336,6 +347,7 @@ function json2xml() {
|
||||
if (tempSection['questions'].length != 0) {
|
||||
for (question in tempSection['questions']) {
|
||||
var singleQuestion = tempSection['questions'][question];
|
||||
|
||||
|
||||
//for Separate Correct Answer From MCQ
|
||||
if(singleQuestion.question_type == 'group'){
|
||||
@ -347,12 +359,12 @@ function json2xml() {
|
||||
if (singleQuestion.hasOwnProperty('question_type')) // normal questions
|
||||
{
|
||||
var singleQuestionElement = getXMLNodesOfQuestionData(singleQuestion);
|
||||
//attach each single question into section item node
|
||||
//attach each single question into section item node
|
||||
sectionItemElement.appendChild(singleQuestionElement);
|
||||
} else // handle question group
|
||||
{
|
||||
var groupQuestionElement = getXMLNodesOfGroupQuestionData(singleQuestion);
|
||||
sectionItemElement.appendChild(groupQuestionElement);
|
||||
sectionItemElement.appendChild(groupQuestionElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
"dependencies": {
|
||||
"bootstrap-icons": "^1.11.1",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"cropperjs": "^1.6.1",
|
||||
"desandro-matches-selector": "^2.0.2",
|
||||
"dotenv": "^16.3.1",
|
||||
"electron-dl": "^3.5.1",
|
||||
|
||||
13
style.css
13
style.css
@ -3768,4 +3768,15 @@ width:85px;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* #questionPaper {
|
||||
font-size:small;
|
||||
text-decoration: none;
|
||||
font-weight: 100;
|
||||
font-style: normal !important;
|
||||
} */
|
||||
|
||||
.correctAnswer{
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
46
xml2json.js
46
xml2json.js
@ -26,41 +26,45 @@ function getQuestionsNodes(questionNode,type)
|
||||
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_id'] = questionNode.childNodes[0].firstChild !== null? questionNode.childNodes[0].firstChild.nodeValue : "" ;
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'text';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = 'false';
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
// console.log(questionObj);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['question_id'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[6].firstChild.nodeValue;
|
||||
questionObj['answers'] = [];
|
||||
questionObj['correct_answer'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[6].childNodes;
|
||||
|
||||
var choiceList = questionNode.childNodes[7].childNodes;
|
||||
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
for (let k = 0; k < choiceList.length ;k++)
|
||||
{
|
||||
var tempChoiceobj = {};
|
||||
console.log(choiceList)
|
||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
||||
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
|
||||
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
||||
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
|
||||
// console.log(tempChoiceobj);
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
}
|
||||
}
|
||||
@ -102,16 +106,16 @@ function getQuestionsNodes(questionNode,type)
|
||||
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['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[3].firstChild.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[4].firstChild !== null ? questionGroup.childNodes[4].firstChild.nodeValue : "");
|
||||
questionGroupObj['question_id'] = questionGroup.childNodes[0].firstChild.nodeValue;
|
||||
questionGroupObj['group_title'] = questionGroup.childNodes[1].firstChild.nodeValue;
|
||||
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_marks'] = (questionGroup.childNodes[3].firstChild !== null ? questionGroup.childNodes[3].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].firstChild.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[5].firstChild !== null ? questionGroup.childNodes[5].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[5].childNodes;
|
||||
var questionList = questionGroup.childNodes[6].childNodes;
|
||||
// console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
@ -161,7 +165,7 @@ jsonObj['sections'] = [];
|
||||
var tempObj = {};
|
||||
|
||||
// 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_marks'] = (sectionsList[i].childNodes[2].firstChild !== null ? sectionsList[i].childNodes[2].firstChild.nodeValue : "");
|
||||
tempObj['section_display_marks'] = sectionsList[i].childNodes[3].firstChild.nodeValue;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
function xml2json(xmlData) {
|
||||
// console.clear();
|
||||
console.log('xml to json converstion');
|
||||
// console.log(xmlData);
|
||||
// console.log(xmlData);z
|
||||
|
||||
function getAttributesOfXMLNode(node)
|
||||
{
|
||||
@ -24,29 +24,31 @@ function getQuestionsNodes(questionNode,type)
|
||||
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['questionId'] = questionNode.childNodes[0].firstChild !== null ? questionNode.childNodes[0].firstChild.nodeValue : "";
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'text';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = 'false';
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
questionObj['question'] = questionNode.childNodes[0].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[1].firstChild !== null? questionNode.childNodes[1].firstChild.nodeValue : "");
|
||||
questionObj['questionId'] = questionNode.childNodes[0].firstChild.nodeValue;
|
||||
questionObj['question'] = questionNode.childNodes[1].firstChild.nodeValue;
|
||||
questionObj['question_description'] = (questionNode.childNodes[2].firstChild !== null? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[6].firstChild.nodeValue;
|
||||
questionObj['marks'] = (questionNode.childNodes[3].firstChild !== null ? questionNode.childNodes[3].firstChild.nodeValue : "");
|
||||
questionObj['display_marks'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||
questionObj['is_math_enabled'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
questionObj['answers'] = [];
|
||||
|
||||
var choiceList = questionNode.childNodes[6].childNodes;
|
||||
var choiceList = questionNode.childNodes[7].childNodes;
|
||||
|
||||
if(choiceList.length > 0)
|
||||
{
|
||||
@ -70,20 +72,23 @@ function getQuestionsNodes(questionNode,type)
|
||||
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['group_marks'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[3].firstChild.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[4].firstChild !== null ? questionGroup.childNodes[4].firstChild.nodeValue : "");
|
||||
questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
|
||||
|
||||
questionGroupObj['group_title'] = questionGroup.childNodes[1].firstChild.nodeValue;
|
||||
questionGroupObj['group_description'] = (questionGroup.childNodes[2].firstChild !== null ? questionGroup.childNodes[2].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_marks'] = (questionGroup.childNodes[3].firstChild !== null ? questionGroup.childNodes[3].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_display_marks'] = questionGroup.childNodes[4].firstChild.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[5].firstChild !== null ? questionGroup.childNodes[5].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
//handle questions
|
||||
var questionList = questionGroup.childNodes[5].childNodes;
|
||||
var questionList = questionGroup.childNodes[6].childNodes;
|
||||
// console.log('No of quetions in GQ:' + questionList.length);
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user