XML_CHANGES : RV
This commit is contained in:
parent
3ef12dc65a
commit
b59e46713c
50
addform.html
50
addform.html
@ -1139,7 +1139,7 @@ async function convertToLatex(text, mathstatus) {
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="form_box">
|
||||
<label class="titleSpace">Max Marks:</label>
|
||||
<input class="MetaData" id="Max_Marks" >
|
||||
<input class="MetaData" placeholder="" id="Max_Marks" onkeypress = "return matchnum(event)" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3">
|
||||
@ -1451,8 +1451,8 @@ var inputElement2 = document.getElementById('questionTitleValue');
|
||||
var innerDivElement = inputElement2.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg');
|
||||
innerDivElement.addEventListener("keyup", function(event) {
|
||||
|
||||
console.log('JoditworkPlaceId : ', event.target.id);
|
||||
console.log('content : ',innerDivElement.innerHTML);
|
||||
// console.log('JoditworkPlaceId : ', event.target.id);
|
||||
// console.log('content : ',innerDivElement.innerHTML);
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
@ -1468,6 +1468,27 @@ html2json();
|
||||
})
|
||||
|
||||
|
||||
function matchnum(event){
|
||||
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if(charcode>= 48 && charcode <= 57)return true; //only numbers
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
let innerDivElement = document.getElementById('Max_Marks');
|
||||
console.log(innerDivElement)
|
||||
innerDivElement.addEventListener("keyup", function(event) {
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
check_Remove_Empty_Question('Max_Marks');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1898,6 +1919,14 @@ var checkchoicequestona= 0;
|
||||
var questionIncrement = 1;
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
array_of_Id.push('Max_Marks')
|
||||
console.log(array_of_Id);
|
||||
const arrayString = JSON.stringify(array_of_Id);
|
||||
collect_Empty_Question_Id(arrayString, 'Max_Marks');
|
||||
})
|
||||
|
||||
|
||||
|
||||
//Function for Create a New Section in the Question Paper
|
||||
function addSection(title = false, description = false, random_no = false, section_uuid = false, section_marks = false, sectionDispalyMarks = false, sectionAttemptAny = false, scrollval = false)
|
||||
@ -2429,7 +2458,7 @@ function addQuestionGroup(idObj)
|
||||
<div class="col-lg-4 col-md-4 hideondrag text" >
|
||||
<div class="form_box justify-content-end">
|
||||
<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.attributes.AttemptAny : ''}">
|
||||
<input type="text" id="Question_Attempt_Any_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') && idObj.question_group_obj.attributes.AttemptAny !== undefined ? idObj.question_group_obj.attributes.AttemptAny : ''}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -4475,8 +4504,13 @@ function collect_Empty_Question_Id(arrayString, ID) {
|
||||
if(input_text_value !== null)
|
||||
{
|
||||
// console.log("ikl");
|
||||
if (input_text_value.className == 'QuestionTextIdSet') {
|
||||
attrId =input_text_value.innerHTML;
|
||||
if (input_text_value.className == 'QuestionTextIdSet' || ID == 'Max_Marks') {
|
||||
|
||||
if(ID == 'Max_Marks'){
|
||||
attrId =input_text_value.innerHTML;
|
||||
}else{
|
||||
attrId =input_text_value.value;
|
||||
}
|
||||
// console.log('attrId QuestionTextIdSet : ', attrId);
|
||||
} else {
|
||||
const previousElement = input_text_value.previousElementSibling;
|
||||
@ -4549,7 +4583,7 @@ function check_Empty_Question()
|
||||
attrId =elementid;
|
||||
} else {
|
||||
var value = ''
|
||||
if(getMathFiled == 'textQuestiontitleMath_'){
|
||||
if(getMathFiled == 'textQuestiontitleMath_' || Id == "Max_Marks"){
|
||||
value = elementid.value;
|
||||
}else{
|
||||
value = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
|
||||
@ -4617,7 +4651,7 @@ function check_Remove_Empty_Question(IdToRemove , DeleteElement=0) {
|
||||
if (newVariableWithoutNumbers == 'removeAndCloneQroupQuestion_') {
|
||||
attrId= 'choice';
|
||||
} else if(DeleteElement != 1){
|
||||
if(newVariableWithoutNumbers == 'QuestionTextIdSet_' || newVariableWithoutNumbers == 'QuestionChoiceId_' || newVariableWithoutNumbers == 'Questions_Group_id_' || newVariableWithoutNumbers == 'textQuestiontitleMath_'){
|
||||
if(newVariableWithoutNumbers == 'QuestionTextIdSet_' || newVariableWithoutNumbers == 'QuestionChoiceId_' || newVariableWithoutNumbers == 'Questions_Group_id_' || newVariableWithoutNumbers == 'textQuestiontitleMath_' || IdToRemove == "Max_Marks"){
|
||||
attrId = input_text_value.value;
|
||||
}else{
|
||||
const previousElement = input_text_value.previousElementSibling;
|
||||
|
||||
@ -62,7 +62,7 @@ function jsonToHtml(jsonData) {
|
||||
var sectionMarks = section.section_marks;
|
||||
var sectionUUID = section.attributes.Id;
|
||||
var sectionDispalyMarks = section.section_display_marks;
|
||||
var sectionAttemptAny = section.section_attempt_any;
|
||||
var sectionAttemptAny = section.attributes.AttemptAny;
|
||||
|
||||
|
||||
var SectionObj = {
|
||||
|
||||
47
json2xml.js
47
json2xml.js
@ -62,28 +62,24 @@ function json2xml() {
|
||||
doc,
|
||||
element
|
||||
} = createStandaloneXMLNode('Question', {
|
||||
"xsi:type": (question['question_type'] == 'text' ? 'DescriptiveQuestion' : 'MultiChoiceQuestion'),
|
||||
// "xsi:type": (question['question_type'] == 'text' ? 'DescriptiveQuestion' : 'MultiChoiceQuestion'),
|
||||
'Id': (question['question_type'] == 'text' ? question['text_question_uuid'] : question['choice_question_uuid']),
|
||||
'type': (question['question_type'] == 'text' ? 'Descriptive' : 'Mcq'),
|
||||
'Type': (question['question_type'] == 'text' ? 'Descriptive' : 'MCQ'),
|
||||
'No': (question['question_id'] ? question['question_id'] : question['questionChoiceId']),
|
||||
'DisplayMarks': (question['display_marks'] === true ? 'true' : 'false'),
|
||||
|
||||
}, '');
|
||||
|
||||
// if (question['question_id'] !== undefined) {
|
||||
// var questionChoiceId =createElementWithText(doc, element, 'Text', question['question_id'])
|
||||
// } else {
|
||||
// // If question['question_id'] is undefined, create a new variable
|
||||
// var questionIdSet = createElementWithText(doc, element , 'Text', question['questionChoiceId'])
|
||||
// }
|
||||
|
||||
|
||||
var questionTitle = createElementWithText(doc, element, 'Text', question['question']);
|
||||
questionTitle.setAttribute('xsi:type',(question['is_math_enabled2'] === true ? 'Math' : ''));
|
||||
if(question['is_math_enabled2'] === true){
|
||||
questionTitle.setAttribute('Type',(question['is_math_enabled2'] === true ? 'Math' : ''));
|
||||
}
|
||||
var questionDesc = createElementWithText(doc, element, 'Subtext', question['question_description']);
|
||||
questionDesc.setAttribute('xsi:type',(question['is_math_enabled'] === true ? 'Math' : ''));
|
||||
if(question['is_math_enabled'] === true){
|
||||
questionDesc.setAttribute('Type',(question['is_math_enabled'] === true ? 'Math' : ''));
|
||||
}
|
||||
var marks = createElementWithText(doc, element, 'Marks', question['marks']);
|
||||
// var display_marks = createElementWithText(doc, element, 'DispalyMarks', (question['display_marks'] === true ? 'true' : 'false'), {});
|
||||
|
||||
if (question['question_type'] == 'group') {
|
||||
// console.log(question);
|
||||
@ -95,7 +91,9 @@ function json2xml() {
|
||||
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
||||
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {});
|
||||
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_name'], {});
|
||||
text.setAttribute('xsi:type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : 'Text'));
|
||||
if(question['answers'][choice]['is_math_enabled'] === true){
|
||||
text.setAttribute('Type',(question['answers'][choice]['is_math_enabled'] === true ? 'Math' : ''));
|
||||
}
|
||||
|
||||
}
|
||||
// choicesElement.appendChild();
|
||||
@ -113,35 +111,24 @@ function json2xml() {
|
||||
doc,
|
||||
element
|
||||
} = createStandaloneXMLNode('Question', {
|
||||
'xsi:type': 'QuestionGroup',
|
||||
// 'xsi:type': 'QuestionGroup',
|
||||
'Id': singleQuestion['group_uuid'],
|
||||
'Type': 'QuestionGroup',
|
||||
'No': (singleQuestion['question_id'] ? singleQuestion['question_id'] : '' ),
|
||||
'Order': 0,
|
||||
'DisplayMarks':(singleQuestion['group_display_marks'] === true ? 'true' : 'false' ),
|
||||
'AttemptAny':(singleQuestion['group_attempt_any'] ? singleQuestion['group_attempt_any'] : '' ),
|
||||
...(singleQuestion['group_attempt_any'] !== '' ? {'AttemptAny': singleQuestion['group_attempt_any']} : {})
|
||||
}, '');
|
||||
|
||||
|
||||
// var groupQuestionElement = createElementWithText(xmlDoc, sectionElement, 'Question', '', {
|
||||
// 'xsi:type': 'QuestionGroup',
|
||||
// 'Id': singleQuestion['group_uuid'],
|
||||
// 'Type': 'QuestionGroup',
|
||||
// 'No': singleQuestion['group_title'],
|
||||
// 'Order': 0
|
||||
// });
|
||||
// var groupQuestionId = createElementWithText(doc, element, 'Text', singleQuestion['question_id']);
|
||||
var groupQuestionTitle = createElementWithText(doc, element, 'Text', singleQuestion['group_title']);
|
||||
var groupQuestionDesc = createElementWithText(doc, element, 'Subtext', singleQuestion['group_description']);
|
||||
var groupQuestionMarks = createElementWithText(doc, element, 'Marks', singleQuestion['group_marks']);
|
||||
// var groupQuestionDisplayMarks = createElementWithText(doc, element, 'DisplayMarks', (singleQuestion['group_display_marks'] === true ? 'true' : 'false' ));
|
||||
// var groupQuestionAttemptAny = createElementWithText(doc, element, 'AttemptAny', singleQuestion['group_attempt_any'] );
|
||||
var groupQuestionItemsElement = createElementWithText(doc, element, 'Items', '');
|
||||
|
||||
//gather questions data inside question group
|
||||
if (singleQuestion['questions'].length != 0) {
|
||||
var tempGroupQuestions = singleQuestion['questions'];
|
||||
console.log(tempGroupQuestions);
|
||||
// console.log(tempGroupQuestions);
|
||||
//looping each questions indise question group and attach it to group items node
|
||||
for (gquestion in tempGroupQuestions) {
|
||||
var singleGQuestion = tempGroupQuestions[gquestion];
|
||||
@ -201,14 +188,12 @@ function json2xml() {
|
||||
// console.log(tempSection);
|
||||
|
||||
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
|
||||
'xsi:type': 'QuestionPaperSection',
|
||||
// 'xsi:type': 'QuestionPaperSection',
|
||||
'Id': tempSection['section_uuid'],
|
||||
'Type': 'Section',
|
||||
'No': sectionNumber,
|
||||
'Order': 0,
|
||||
'DisplayMarks':(tempSection['section_display_marks'] === true ? 'true' : 'false'),
|
||||
'AttemptAny':(tempSection['section_attempt_any'] ? tempSection['section_attempt_any'] : '' ),
|
||||
|
||||
...(tempSection['section_attempt_any'] !== '' ? {'AttemptAny': tempSection['section_attempt_any']} : {}),
|
||||
});
|
||||
|
||||
var sectionTitle = createElementWithText(xmlDoc, sectionElement, 'Text', tempSection['section_title']);
|
||||
|
||||
22
xml2json.js
22
xml2json.js
@ -126,12 +126,9 @@ function getQuestionsNodes(questionNode,type)
|
||||
function getQuestionGroupNodes(questionGroup)
|
||||
{
|
||||
var questionGroupObj = {};
|
||||
// questionGroupObj['question_id'] = (questionGroup.childNodes[0].firstChild !== null ? questionGroup.childNodes[0].firstChild.nodeValue : "");
|
||||
questionGroupObj['group_title'] = (questionGroup.childNodes[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_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
|
||||
@ -140,13 +137,13 @@ function getQuestionGroupNodes(questionGroup)
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
var questionType = questionList[q].getAttribute("Type");
|
||||
if(questionType == 'Descriptive')
|
||||
{
|
||||
// console.log(questionList[q]);
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
else if(questionType == 'MCQ')
|
||||
{
|
||||
// console.log(questionList[q]);
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
|
||||
@ -208,13 +205,13 @@ jsonObj['sections'] = [];
|
||||
//check weather quesiotn or question grup
|
||||
// console.log('QUESTION :' + j );
|
||||
// console.log(questionList[j]);
|
||||
var questionType = questionList[j].getAttribute("xsi:type");
|
||||
var questionType = questionList[j].getAttribute("Type");
|
||||
// console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
if(questionType == 'Descriptive')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
else if(questionType == 'MCQ')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
|
||||
}
|
||||
@ -227,10 +224,11 @@ jsonObj['sections'] = [];
|
||||
}
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
// console.log('Xml to Json Conversion ');
|
||||
console.log('jsonData : ', jsonData);
|
||||
// console.log(jsonObj);
|
||||
jsonToHtml(jsonObj);
|
||||
|
||||
// console.log('Xml to Json Conversion ');
|
||||
// console.log('jsonData : ', jsonData);
|
||||
// console.log(jsonObj);
|
||||
// console.log(jsonToHtml(jsonObj))
|
||||
// localStorage.removeItem('json_Decode_Data_For_Mcq_Crt_Ans');
|
||||
|
||||
|
||||
@ -98,13 +98,13 @@ function getQuestionGroupNodes(questionGroup)
|
||||
for(let q = 0; q < questionList.length ;q++)
|
||||
{
|
||||
|
||||
var questionType = questionList[q].getAttribute("xsi:type");
|
||||
var questionType = questionList[q].getAttribute("Type");
|
||||
console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
if(questionType == 'Descriptive')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
else if(questionType == 'MCQ')
|
||||
{
|
||||
questionGroupObj['questions'].push(getQuestionsNodes(questionList[q],2));
|
||||
}
|
||||
@ -121,7 +121,7 @@ function getQuestionGroupNodes(questionGroup)
|
||||
|
||||
//busi logic start
|
||||
var xmlString = xmlData;
|
||||
const parser = new DOMParser();
|
||||
const parser = new DOMParser();
|
||||
|
||||
// Parse the XML string into an XML document
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
@ -129,7 +129,6 @@ const jsonObj = {};
|
||||
|
||||
jsonObj['question_paper_title'] = xmlDoc.getElementsByTagName("Title")[0] && xmlDoc.getElementsByTagName("Title")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Title")[0].childNodes[0].nodeValue : null;
|
||||
jsonObj['question_paper_description'] = xmlDoc.getElementsByTagName("Subtitle")[0] && xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0] ? xmlDoc.getElementsByTagName("Subtitle")[0].childNodes[0].nodeValue : null;
|
||||
//get attributes of root/question paper element
|
||||
jsonObj['attributes'] = getAttributesOfXMLNode(xmlDoc.documentElement);
|
||||
jsonObj['sections'] = [];
|
||||
|
||||
@ -158,13 +157,13 @@ jsonObj['sections'] = [];
|
||||
//check weather quesiotn or question grup
|
||||
// console.log('QUESTION :' + j );
|
||||
// console.log(questionList[j]);
|
||||
var questionType = questionList[j].getAttribute("xsi:type");
|
||||
var questionType = questionList[j].getAttribute("Type");
|
||||
// console.log(questionType);
|
||||
if(questionType == 'DescriptiveQuestion')
|
||||
if(questionType == 'Descriptive')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],1));
|
||||
}
|
||||
else if(questionType == 'MultiChoiceQuestion')
|
||||
else if(questionType == 'MCQ')
|
||||
{
|
||||
tempObj['questions'].push(getQuestionsNodes(questionList[j],2));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user