MARK CALCULATION COMPLETE : RV
This commit is contained in:
parent
f0149750cc
commit
8aadd1f308
125
addform.html
125
addform.html
@ -541,7 +541,7 @@
|
||||
<script src="decode.js"></script>
|
||||
|
||||
<!-- Mark Calculation Script -->
|
||||
<!-- <script src="mark_calc.js"></script> -->
|
||||
<script src="mark_calc.js"></script>
|
||||
|
||||
|
||||
<!-- nave pane -->
|
||||
@ -648,8 +648,8 @@ function loadXML(xmlFileName) {
|
||||
} else{
|
||||
decodeData = data;
|
||||
}
|
||||
resolve(decodeData)
|
||||
xml2json(decodeData)
|
||||
resolve(data);
|
||||
xml2json(data);
|
||||
// json2nav();
|
||||
// clearSidebarWrapper();
|
||||
// navpane();
|
||||
@ -1043,10 +1043,10 @@ function addSection(title = false, description = false, random_no = false, secti
|
||||
|
||||
//mark calculation code for section
|
||||
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
|
||||
|
||||
// $('#'+Section_Marks_raw_Id).prop("disabled", true);
|
||||
$('#'+Section_Marks_raw_Id).prop("disabled", true);
|
||||
|
||||
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
@ -1083,7 +1083,7 @@ $('#'+Section_Marks_raw_Id).keyup(function() {
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1424,6 +1424,7 @@ $('#'+Question_Attempt_Any_Fields).keyup(function() {
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
markCalculation()
|
||||
|
||||
}
|
||||
|
||||
@ -2018,6 +2019,8 @@ $('#'+choiceQuestionMarkField).keyup(function() {
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
markCalculation();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -2174,6 +2177,7 @@ function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, choiceDes
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
}
|
||||
|
||||
//Function for Create a New Text Question in the Section and Question Group
|
||||
@ -2427,113 +2431,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
});
|
||||
|
||||
|
||||
//mark calculation in TextQuestion
|
||||
|
||||
// var textQuestionMarkField = 'Text_Question_Marks_Id_'+ addTextQuestionId
|
||||
|
||||
// var sectionRandomID = localStorage.getItem('sectionId');
|
||||
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
|
||||
|
||||
|
||||
// var QuestionGroup_ID = localStorage.getItem('QuestionGroupId');
|
||||
// var Question_Attempt_Any_Fields = 'Question_Attempt_Any_Id_' + QuestionGroup_ID;
|
||||
// var Question_Group_Marks_Field = 'Question_Group_Marks_Id_' + QuestionGroup_ID;
|
||||
|
||||
|
||||
// //These lines are execute only the 'textQuestion()' function call
|
||||
// var QGinputValue = $('#'+Section_Attempt_Any_raw_Id).val();
|
||||
// var InMarkValue = $('#'+Section_Marks_raw_Id).val();
|
||||
// // alert(InMarkValue);
|
||||
|
||||
// if(QGinputValue == ""){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('text question enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(InMarkValue);
|
||||
// // alert('text question disabled');
|
||||
// }
|
||||
// //end of the lines
|
||||
|
||||
|
||||
// // These lines are working only the Section function to change anything AtemptAny field
|
||||
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// var MarkValue = $('#'+Section_Marks_raw_Id).val();
|
||||
|
||||
// // alert(MarkValue);
|
||||
|
||||
// if(inputValue == "" && section_id){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('sectionRandomID text enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// // alert('sectionRandomID text disabled');
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
// $('#'+Section_Marks_raw_Id).keyup(function() {
|
||||
// var MarksinputValue = $(this).val();
|
||||
|
||||
// if(MarksinputValue !== "" && section_id){
|
||||
// $('#'+textQuestionMarkField).val(MarksinputValue);
|
||||
// }
|
||||
// });
|
||||
// //end of the line
|
||||
|
||||
|
||||
// //These lines are execute only the 'textQuestion()' function call
|
||||
// var QG_AttemptAny_inputValue = $('#'+Question_Attempt_Any_Fields).val();
|
||||
// var QG_Marks_inputValue = $('#'+Question_Group_Marks_Field).val();
|
||||
// // alert(InMarkValue);
|
||||
|
||||
// if(QG_AttemptAny_inputValue == ""){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('text question enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(QG_Marks_inputValue);
|
||||
// // alert('text question disabled');
|
||||
// }
|
||||
// //end of the lines
|
||||
|
||||
|
||||
|
||||
// // These Function are working only the QuestionGroup to change anything AtemptAny field
|
||||
// $('#'+Question_Attempt_Any_Fields).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// var QG_Marks_inputValues = $('#'+Question_Group_Marks_Field).val();
|
||||
|
||||
// if(inputValue == "" && group_question_area_id){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('QuestionGroup_ID text enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(QG_Marks_inputValues);
|
||||
// // alert('QuestionGroup_ID text disabled');
|
||||
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
// $('#'+Question_Group_Marks_Field).keyup(function() {
|
||||
// var MarksinputValue = $(this).val();
|
||||
|
||||
// if(MarksinputValue !== "" && group_question_area_id){
|
||||
// $('#'+textQuestionMarkField).val(MarksinputValue);
|
||||
// }
|
||||
// });
|
||||
// // end of the lines
|
||||
|
||||
|
||||
//end of mark calculation in textquestion
|
||||
|
||||
|
||||
|
||||
var AddButtons_Raw = 'AddButtons_'+addTextQuestionId;
|
||||
var AddButtons_Raw = 'AddButtons_'+addTextQuestionId;
|
||||
var overallAddButtons_Raw = 'overallAddButtons_'+addTextQuestionId;
|
||||
var QuestionGroupAddButtons_Raw = 'QuestionGRoupAddButtons_'+addTextQuestionId;
|
||||
var overallQuestionGroupAddButtons_Raw = 'overallQuestionGRoupAddButtons_'+addTextQuestionId;
|
||||
@ -2679,6 +2577,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
markCalculation();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -88,8 +88,6 @@ function jsonToHtml(jsonData) {
|
||||
else if (questionType == 'group')
|
||||
{
|
||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, Choice, questionAreaId, false, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
||||
// groupQuestion(false, false, false, question_Title, question_Description, mathEnabled, Choice, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
||||
|
||||
|
||||
Choice = Choice.slice(1);
|
||||
Choice.forEach(function(choicenames, index) {
|
||||
@ -159,7 +157,7 @@ function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||
else if(group_question_Type == 'group')
|
||||
{
|
||||
// console.log('child ggroup'+group_question_Title)
|
||||
groupQuestion(false, false, false, group_question_Title, group_question_Description, mathEnabled, Choice, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
||||
groupQuestion(false, false, false, group_question_Title, group_question_Description, mathEnabled, Choice, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_uuid, group_question_marks, false, group_question_Display_Marks);
|
||||
|
||||
|
||||
Choice = Choice.slice(1);
|
||||
|
||||
10
json2xml.js
10
json2xml.js
@ -114,8 +114,8 @@ function json2xml() {
|
||||
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 groupQuestionMarks = createElementWithText(doc, element, 'DisplayMarks', (singleQuestion['group_display_marks'] === true ? 'true' : 'false' ));
|
||||
var groupQuestionMarks = createElementWithText(doc, element, 'AttemptAny', singleQuestion['group_attempt_any']);
|
||||
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
|
||||
@ -175,6 +175,8 @@ function json2xml() {
|
||||
//create section related xml nodes
|
||||
var tempSection = questionPaper['sections'][section];
|
||||
|
||||
console.log(tempSection);
|
||||
|
||||
var sectionElement = createElementWithText(xmlDoc, rootItemsElement, 'Question', '', {
|
||||
'xsi:type': 'QuestionPaperSection',
|
||||
'Id': tempSection['section_uuid'],
|
||||
@ -186,8 +188,8 @@ function json2xml() {
|
||||
var sectionTitle = createElementWithText(xmlDoc, sectionElement, 'Text', tempSection['section_title']);
|
||||
var sectionDesc = createElementWithText(xmlDoc, sectionElement, 'Subtext', tempSection['section_description']);
|
||||
var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'Marks', tempSection['section_marks']);
|
||||
var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false'));
|
||||
var sectionMarks = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']);
|
||||
var sectionDisplayMark = createElementWithText(xmlDoc, sectionElement, 'DisplayMarks', (tempSection['section_display_marks'] === true ? 'true' : 'false'));
|
||||
var sectionAttempAny = createElementWithText(xmlDoc, sectionElement, 'AttemptAny', tempSection['section_attempt_any']);
|
||||
var sectionItemElement = createElementWithText(xmlDoc, sectionElement, 'Items', '', );
|
||||
|
||||
|
||||
|
||||
279
mark_calc.js
279
mark_calc.js
@ -4,34 +4,54 @@ function markCalculation() {
|
||||
|
||||
// Get jsonData from the Localstorage
|
||||
var jsonString = localStorage.getItem('JSON_FOR_NAV');
|
||||
console.log('jsonData markCalculation');
|
||||
// console.log('jsonData markCalculation');
|
||||
const jsonData = JSON.parse(jsonString);
|
||||
console.log(jsonData);
|
||||
// console.log(jsonData);
|
||||
|
||||
|
||||
//Section Level foreach
|
||||
jsonData.sections.forEach(function(section, index) {
|
||||
|
||||
const random_no = Date.now();
|
||||
var sectionMarks = section.section_marks;
|
||||
var sectionAttemptAny = section.section_attempt_any;
|
||||
var section_id = section.section_id;
|
||||
|
||||
console.log('sectionMarks : ' + sectionMarks);
|
||||
console.log('sectionAttemptAny : ' + sectionAttemptAny);
|
||||
console.log('section_id : ' + section_id);
|
||||
// console.log('sectionMarks : ', sectionMarks);
|
||||
// console.log('sectionAttemptAny : ', sectionAttemptAny);
|
||||
// console.log('#########################################################################');
|
||||
|
||||
//send a object for generateSingleQuestions() function using foreach and mark calc
|
||||
var QuestionObjects = {
|
||||
|
||||
'sectionData': section,
|
||||
'sectionRandomNo': random_no,
|
||||
'sectionMarks': sectionMarks,
|
||||
'sectionAttemptAny': sectionAttemptAny,
|
||||
|
||||
var sectionRandomID = section_id.split("_")[3];
|
||||
var Section_Marks = document.getElementById('Section_Marks_Id_'+ sectionRandomID);
|
||||
|
||||
//condition for disable and enable Section Marks field
|
||||
if(sectionAttemptAny == "")
|
||||
{
|
||||
Section_Marks.disabled = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Section_Marks.disabled = false;
|
||||
}
|
||||
|
||||
// generateSingleQuestions(section,random_no);
|
||||
generateSingleQuestions(QuestionObjects);
|
||||
|
||||
//send a object for generateSingleQuestions() function using foreach and mark calc
|
||||
var ParentObjects = {
|
||||
|
||||
'questionData' : section,
|
||||
'parentMarks' : sectionMarks,
|
||||
'parentAttemptAny' : sectionAttemptAny,
|
||||
}
|
||||
|
||||
var returnvalue = generateSingleQuestions(ParentObjects);
|
||||
console.log('returnvalue of child sum in section : ' , returnvalue);
|
||||
|
||||
if(sectionAttemptAny == "")
|
||||
{
|
||||
Section_Marks.value = returnvalue;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -40,33 +60,21 @@ function markCalculation() {
|
||||
|
||||
|
||||
//Function for Question Level foreach
|
||||
// function generateSingleQuestions(section, random_no)
|
||||
function generateSingleQuestions(QuestionObjects)
|
||||
function generateSingleQuestions(ParentObjects)
|
||||
{
|
||||
//set default value for reciveing questionObjects
|
||||
var section = false;
|
||||
var random_no = false;
|
||||
|
||||
//end of set default value for reciveing questionObjects
|
||||
|
||||
var questionData = false; //set default value for reciveing questionObjects
|
||||
|
||||
//set values from QuestionObjects param if exists
|
||||
|
||||
if(QuestionObjects.hasOwnProperty('sectionData'))
|
||||
if(ParentObjects.hasOwnProperty('questionData'))
|
||||
{
|
||||
section = QuestionObjects.sectionData;
|
||||
}
|
||||
else if(QuestionObjects.hasOwnProperty('sectionRandomNo'))
|
||||
{
|
||||
random_no = QuestionObjects.sectionRandomNo;
|
||||
questionData = ParentObjects.questionData;
|
||||
}
|
||||
|
||||
var childMarks = 0;
|
||||
|
||||
//end of set values from QuestionObjects param if exists
|
||||
|
||||
|
||||
section.questions.forEach(function(Question, index) {
|
||||
//Questions Foreach Start
|
||||
questionData.questions.forEach(function(Question, index) {
|
||||
|
||||
const questionRandomNo = Date.now();
|
||||
var questionTypeFormets = "";
|
||||
if(Question.question_type)
|
||||
{
|
||||
@ -82,91 +90,97 @@ function generateSingleQuestions(QuestionObjects)
|
||||
var questionMarks = Question.marks;
|
||||
var question_Id = Question.question_Id;
|
||||
|
||||
// section mark divided by section attempt any
|
||||
console.log('questionType : ' , questionType);
|
||||
console.log('questionMarks : ' , questionMarks);
|
||||
console.log('##########################################################');
|
||||
|
||||
|
||||
var parentMarks = ParentObjects.parentMarks;
|
||||
var parentAttemptAny = ParentObjects.parentAttemptAny;
|
||||
var MarkDivideValue = parentMarks / parentAttemptAny;
|
||||
|
||||
// console.log('parentMarks : ', parentMarks);
|
||||
// console.log('new_parentAttemptAny : ', parentAttemptAny);
|
||||
// console.log('new_Child_Mark_DivideValue : ', MarkDivideValue);
|
||||
// console.log('################################################################################');
|
||||
|
||||
var sectionMarks = QuestionObjects.sectionMarks;
|
||||
var sectionAttemptAny = QuestionObjects.sectionAttemptAny;
|
||||
var sectionMarkDivideVale = sectionMarks / sectionAttemptAny;
|
||||
|
||||
//end of section mark divided by section attempt any
|
||||
var QuestionMarkField = "";
|
||||
|
||||
|
||||
var questionAreaId = 'question_area_'+random_no;
|
||||
if(questionType == 'text')
|
||||
{
|
||||
//this part for Text question only
|
||||
var addTextQuestionId = question_Id.split("_")[1];
|
||||
var textQuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ addTextQuestionId);
|
||||
|
||||
if(QuestionObjects.sectionAttemptAny !== "")
|
||||
{
|
||||
textQuestionMarkField.value = sectionMarkDivideVale;
|
||||
}
|
||||
else
|
||||
{
|
||||
textQuestionMarkField.value = "";
|
||||
}
|
||||
|
||||
var QuestionId = question_Id.split("_")[1];
|
||||
QuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ QuestionId);
|
||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||
var questionMarksINT = parseInt(onlyQuestionMarks, 10);
|
||||
childMarks = childMarks + questionMarksINT;
|
||||
}
|
||||
else if (questionType == 'group')
|
||||
{
|
||||
//this part for Choice question only
|
||||
var addChoiceAreaId = question_Id.split("_")[1];
|
||||
var choiceQuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + addChoiceAreaId);
|
||||
|
||||
if(QuestionObjects.sectionAttemptAny !== "")
|
||||
{
|
||||
console.log(choiceQuestionMarkField);
|
||||
choiceQuestionMarkField.value = sectionMarkDivideVale;
|
||||
choiceQuestionMarkField.disable = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
choiceQuestionMarkField.value = "";
|
||||
}
|
||||
|
||||
|
||||
else if(questionType == 'group')
|
||||
{
|
||||
var QuestionId = question_Id.split("_")[1];
|
||||
QuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + QuestionId);
|
||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||
var questionMarksINT = parseInt(onlyQuestionMarks, 10);
|
||||
childMarks = childMarks + questionMarksINT;
|
||||
}
|
||||
else if (questionType == 'question_group')
|
||||
|
||||
|
||||
if (questionType == 'question_group')
|
||||
{
|
||||
|
||||
//the objects contain QuestionGroup Data for send generateGroupQuestion()
|
||||
//the objects contain QuestionGroup Data for send generateGroupQuestions()
|
||||
var QuestionGroupObjects = {
|
||||
|
||||
'questionGroupData': Question,
|
||||
'sectionMarks': sectionMarkDivideVale,
|
||||
'sectionAttemptAny': QuestionObjects.sectionAttemptAny,
|
||||
'parentMarks' : MarkDivideValue,
|
||||
'parentAttemptAny' : ParentObjects.parentAttemptAny,
|
||||
|
||||
}
|
||||
|
||||
generateGroupQuestion(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
||||
|
||||
var returnValue = generateGroupQuestions(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
||||
onlyQuestionMarks = returnValue !== undefined && returnValue !== "" ? returnValue : 0;
|
||||
var questionGroupMarksINT = parseInt(onlyQuestionMarks, 10);
|
||||
childMarks = childMarks + questionGroupMarksINT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ParentObjects.parentAttemptAny !== "")
|
||||
{
|
||||
QuestionMarkField.value = MarkDivideValue;
|
||||
QuestionMarkField.disabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QuestionMarkField.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//sum the child marks to set parent
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
//End of Questions Foreach
|
||||
|
||||
console.log('ChildMarks sum in Questions: ', childMarks);
|
||||
return childMarks;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// function for QuestionGroups and QuestionGroup questions Level Foreach
|
||||
// function generateGroupQuestion(Question, questionRandomNo)
|
||||
function generateGroupQuestion(QuestionGroupObjects)
|
||||
function generateGroupQuestions(QuestionGroupObjects)
|
||||
{
|
||||
|
||||
|
||||
//set default value for reciveing questionObjects
|
||||
var Question = false;
|
||||
|
||||
//end of set default value for reciveing questionObjects
|
||||
|
||||
|
||||
//set values from QuestionObjects param if exists
|
||||
|
||||
if(QuestionGroupObjects.hasOwnProperty('questionGroupData'))
|
||||
{
|
||||
Question = QuestionGroupObjects.questionGroupData;
|
||||
@ -179,59 +193,68 @@ function generateGroupQuestion(QuestionGroupObjects)
|
||||
var group_marks = Question.group_marks;
|
||||
var group_attempt_any = Question.group_attempt_any;
|
||||
var question_group_id = Question.question_group_id;
|
||||
//end of QuestionGroup Variables
|
||||
|
||||
// console.log('old_group_marks : ', group_marks);
|
||||
// console.log('old_group_attempt_any : ', group_attempt_any);
|
||||
// console.log('################################################################################');
|
||||
|
||||
|
||||
|
||||
console.log(question_group_id);
|
||||
|
||||
|
||||
//Section AttemptAny for first level QuestionGroup
|
||||
var QuestionGroup_ID = question_group_id.split("_")[3];
|
||||
var Question_Group_Marks_Field = document.getElementById('Question_Group_Marks_Id_' + QuestionGroup_ID);
|
||||
console.log(Question_Group_Marks_Field);
|
||||
|
||||
if(QuestionGroupObjects.sectionAttemptAny !== "")
|
||||
if(QuestionGroupObjects.parentAttemptAny !== "" )
|
||||
{
|
||||
// alert(QuestionGroupObjects.sectionMarks)
|
||||
Question_Group_Marks_Field.value = QuestionGroupObjects.sectionMarks;
|
||||
Question_Group_Marks_Field.value = QuestionGroupObjects.parentMarks !== undefined ? QuestionGroupObjects.parentMarks : '';
|
||||
group_marks= QuestionGroupObjects.parentMarks !== undefined ? QuestionGroupObjects.parentMarks : ''; //set the new value of group-marks using the divided value of parent marks
|
||||
Question_Group_Marks_Field.disabled = true;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Question_Group_Marks_Field.value = "";
|
||||
Question_Group_Marks_Field.disabled = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
console.log('group_marks : ' + group_marks);
|
||||
console.log('group_attempt_any : ' + group_attempt_any);
|
||||
console.log('question_group_id : ' + question_group_id);
|
||||
//condition for disable and enable QuestionGroup Marks field
|
||||
if(group_attempt_any == "")
|
||||
{
|
||||
Question_Group_Marks_Field.disabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Question_Group_Marks_Field.disabled = false;
|
||||
}
|
||||
|
||||
|
||||
// QuestionGroup question Level Foreach
|
||||
Question.questions.forEach(function(GroupQuestions, index) {
|
||||
|
||||
const QuestionGroupRandomNo = Date.now();
|
||||
|
||||
//QuestionGroup Questions Variables
|
||||
var group_question_Type = GroupQuestions.question_type;
|
||||
var group_question_marks = GroupQuestions.marks;
|
||||
var group_question_id = GroupQuestions.question_Id;
|
||||
|
||||
// var questionGroupId = 'group_question_area_'+questionRandomNo;
|
||||
|
||||
if(group_question_Type == 'text')
|
||||
{
|
||||
console.log('group_question_Type : ' + group_question_Type);
|
||||
console.log('group_question_marks : ' + group_question_marks);
|
||||
console.log('group_question_id : ' + group_question_id);
|
||||
}
|
||||
else if(group_question_Type == 'group')
|
||||
{
|
||||
console.log('group_question_Type : ' + group_question_Type);
|
||||
console.log('group_question_marks : ' + group_question_marks);
|
||||
console.log('group_question_id : ' + group_question_id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
generateGroupQuestion(GroupQuestions, questionGroupId, QuestionGroupRandomNo); // function for 4 level QuestionGroup Handle
|
||||
}
|
||||
var QuestionGroupObjects = {
|
||||
|
||||
});
|
||||
'questionData' : Question,
|
||||
'parentMarks' : group_marks,
|
||||
'parentAttemptAny': group_attempt_any,
|
||||
|
||||
}
|
||||
|
||||
|
||||
var returnvalue = generateSingleQuestions(QuestionGroupObjects);
|
||||
console.log('ReturnValue of child sum in questionGroup: ' , returnvalue);
|
||||
|
||||
if(returnvalue)
|
||||
{
|
||||
if(group_attempt_any == "")
|
||||
{
|
||||
Question_Group_Marks_Field.value = returnvalue;
|
||||
group_marks = returnvalue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return group_marks;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ function navpane() {
|
||||
|
||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
const nodeDataId = nodeData.question_Id
|
||||
console.log('nodeDataId:',nodeDataId);
|
||||
// console.log('nodeDataId:',nodeDataId);
|
||||
|
||||
|
||||
|
||||
@ -241,8 +241,8 @@ function navpane() {
|
||||
|
||||
createTreeWithHeading(jsonData, questionPaperContainer);
|
||||
localStorage.setItem("collapse", JSON.stringify((expandedSections)));
|
||||
console.log('expandedSections:',expandedSections);
|
||||
console.log('questionPaperContainer:',questionPaperContainer);
|
||||
// console.log('expandedSections:',expandedSections);
|
||||
// console.log('questionPaperContainer:',questionPaperContainer);
|
||||
|
||||
window.addEventListener('DOMContentLoaded', event => {
|
||||
// Toggle the side navigation
|
||||
|
||||
21
xml2json.js
21
xml2json.js
@ -29,7 +29,7 @@ function getQuestionsNodes(questionNode,type)
|
||||
questionObj['question_type'] = 'text';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = 'false';
|
||||
questionObj['marks'] = questionNode.childNodes[2].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;
|
||||
|
||||
@ -41,7 +41,7 @@ function getQuestionsNodes(questionNode,type)
|
||||
questionObj['question_type'] = 'group';
|
||||
questionObj['attributes'] = getAttributesOfXMLNode(questionNode);
|
||||
questionObj['question_sub_type'] = questionNode.childNodes[5].firstChild.nodeValue;
|
||||
questionObj['marks'] = questionNode.childNodes[2].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['answers'] = [];
|
||||
@ -72,9 +72,9 @@ function getQuestionGroupNodes(questionGroup)
|
||||
|
||||
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.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.nodeValue;
|
||||
questionGroupObj['group_attempt_any'] = (questionGroup.childNodes[4].firstChild !== null ? questionGroup.childNodes[4].firstChild.nodeValue : "");
|
||||
questionGroupObj['attributes'] = getAttributesOfXMLNode(questionGroup);
|
||||
questionGroupObj['questions'] = [];
|
||||
//handle questions
|
||||
@ -120,17 +120,18 @@ jsonObj['sections'] = [];
|
||||
|
||||
|
||||
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
||||
// console.log(sectionsList);
|
||||
// console.log('no of sections:'+sectionsList.length);
|
||||
for (let i = 0; i < sectionsList.length ;i++) {
|
||||
console.log(sectionsList);
|
||||
console.log('no of sections:'+sectionsList.length);
|
||||
//return false;
|
||||
for (let i = 0; i < (sectionsList.length) ;i++) {
|
||||
var tempObj = {};
|
||||
|
||||
// console.log('Section :' + i + '-' + sectionsList[i].childNodes[0].firstChild.nodeValue);
|
||||
console.log('Section :' + i + '-' + sectionsList[i].childNodes[0]);
|
||||
tempObj['section_title'] = sectionsList[i].childNodes[0].firstChild.nodeValue;
|
||||
tempObj['section_description'] = sectionsList[i].childNodes[1].firstChild.nodeValue;
|
||||
tempObj['section_marks'] = 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_attempt_any'] = sectionsList[i].childNodes[4].firstChild.nodeValue;
|
||||
tempObj['section_attempt_any'] = (sectionsList[i].childNodes[4].firstChild !== null && sectionsList[i].childNodes[4].firstChild !== undefined ? sectionsList[i].childNodes[4].firstChild.nodeValue : "");
|
||||
tempObj['attributes'] = getAttributesOfXMLNode(sectionsList[i]);
|
||||
tempObj['questions'] = [];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user