From c138aeca338217a2793ddefd2a215451bd7c0441 Mon Sep 17 00:00:00 2001 From: venkateswaran ubuntu Date: Wed, 18 Oct 2023 19:30:27 +0530 Subject: [PATCH] NAVPAN CHANGES & MATH TOGGLE FOR INDV : RV --- addform.html | 1323 +++++++++++-------------- html2json.js | 35 +- html2json_for_navigation.js | 2 +- json2html.js | 140 ++- json2xml.js | 6 +- mark_calc.js | 8 +- nav_pane.js | 148 ++- style.css | 16 +- xml2/Monthly Question Paper.xml | 1 - xml2json.js | 16 +- xml2json_for_Questionpaper_preview.js | 2 +- 11 files changed, 822 insertions(+), 875 deletions(-) delete mode 100644 xml2/Monthly Question Paper.xml diff --git a/addform.html b/addform.html index 02e73b4..f63bee1 100644 --- a/addform.html +++ b/addform.html @@ -319,6 +319,25 @@ background-color: #e4d3f8b4; } + /* @media not (pointer: coarse) { + math-field::part(virtual-keyboard-toggle) { + display: none; + } + +} */ + +/* body { + --keycap-height: 24px; + --keycap-font-size: 16px; + --keycap-shift-font-size: 9px; + --keycap-small-font-size: 9px; + --keycap-extra-small-font-size: 9px; + --keyboard-toolbar-font-size: 16px; + --keycap-gap: 1px; +} */ + + + @@ -573,7 +592,7 @@ await new Promise(resolve => setTimeout(resolve, 1000)); const swalButton = document.querySelector('.swal2-confirm.swal2-styled'); var AutoSaveFileName = document.querySelector('.swal2-input').value; - console.log('AutoSaveFileName : ' , AutoSaveFileName); + // console.log('AutoSaveFileName : ' , AutoSaveFileName); if (swalButton) { swalButton.click(); } @@ -672,9 +691,7 @@ function loadXML(xmlFileName) { // Function for Save the XML File function saveFile() { - console.log("html2json"); html2json(); - console.log("json2xml"); json2xml(); if(FileName == "" || FileName == null ){ @@ -791,6 +808,8 @@ var i = 0; //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) { + + const Section_UUID = uuidv4(); var addsection = ""; const text_field_created_time = Date.now(); @@ -828,16 +847,16 @@ function addSection(title = false, description = false, random_no = false, secti
@@ -858,26 +877,26 @@ function addSection(title = false, description = false, random_no = false, secti - +
Display Marks - -
-
-
-
Attempt Any :
+
+ +
+
+
Attempt Any :
-
-
-
-
Marks :
- + +
+
+
Marks :
+
@@ -1387,7 +1406,7 @@ const value = localStorage.getItem('JSON_FOR_NAV') var element = document.getElementById(`${finalString}`); if (classes < 5) { - console.log("Div not found."); + // console.log("Div not found."); } else { const Swal = require('sweetalert2'); Swal.fire({ @@ -1398,45 +1417,16 @@ const value = localStorage.getItem('JSON_FOR_NAV') }); element.parentNode.removeChild(element); - console.log("Div removed successfully."); + // console.log("Div removed successfully."); } // end of find QG level script } //Function for Create a New Choice Question in the Section and Question Group // function groupQuestion( question_id = false, section_id = false , group_question_area_id = false, questionTitle = false, questionDescription = false, questionSubType = false, mathEnabled = false, Choice = false, questionAreaId = false, questionGroupId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false) -function groupQuestion( question_id = false, section_id = false , group_question_area_id = false, questionTitle = false, questionDescription = false, questionType = false, questionSubType = false, mathEnabled = false, Choice = false, questionGroupId = false, questionAreaId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false) - - +function groupQuestion(question_id = false, section_id = false , group_question_area_id = false, questionTitle = false, questionDescription = false, questionType = false, questionSubType = false, mathEnabled = false, Choice = false, questionAreaId = false, questionRandomNo = false, questionMarks = false, questionUUID = false, questionDisplayMarks = false) { - console.log(Choice) - // console.log('===========================================================================================================================================') - // console.log("group_question_area_id : "+group_question_area_id, 'questionGroupId : '+ questionGroupId, 'questionAreaId : '+questionAreaId) - // console.log('===========================================================================================================================================') - - - - // console.log( - // 'question_id : '+question_id, - // 'section_id : ' + section_id, - // 'group_question_area_id : ' + group_question_area_id, - // 'questionTitle : '+ questionTitle, - // 'questionDescription : ' + questionDescription, - // 'questionSubType : ' + questionSubType, - // 'mathEnabled : ' + mathEnabled, - // Choice, - // 'questionAreaId : ' + questionAreaId, - // 'questionGroupId : ' + questionGroupId, - // 'questionRandomNo : ' + questionRandomNo, - // 'QuestionGroupRandomNo : ' + QuestionGroupRandomNo, - // 'questionMarks : ' + questionMarks, - // 'questionUUID : ' + questionUUID, - // 'group_question_marks : ' + group_question_marks, - // 'group_question_uuid : ' + group_question_uuid, - // 'questionDisplayMarks : ' + questionDisplayMarks, - // 'group_question_Display_Marks : ' + group_question_Display_Marks) - const ChoiceGroupFixed_UUID = uuidv4(); var groupQuestion = ""; @@ -1447,28 +1437,17 @@ function groupQuestion( question_id = false, section_id = false , group_question if(questionRandomNo) { addChoiceAreaId = questionRandomNo; - } - else if(QuestionGroupRandomNo) - { - addChoiceAreaId = QuestionGroupRandomNo; - } - else - { + }else{ addChoiceAreaId = text_field_created_time; } - localStorage.setItem('ChoiceId', addChoiceAreaId) - localStorage.setItem('mathEnabled', mathEnabled); + localStorage.setItem('ChoiceId', addChoiceAreaId); var marks = "" if(questionMarks) { marks = questionMarks; } - else if(group_question_marks) - { - marks = group_question_marks; - } else { marks = ""; @@ -1479,18 +1458,15 @@ function groupQuestion( question_id = false, section_id = false , group_question { UUID = questionUUID; } - else if(group_question_marks) - { - UUID = group_question_uuid; - } else { const ChoiceQuestion_UUID = uuidv4(); UUID = ChoiceQuestion_UUID; } - var sectionRandomID = localStorage.getItem('sectionId'); + + var sectionRandomID = localStorage.getItem('sectionId'); var QuestionGroup_ID = localStorage.getItem('QuestionGroupId'); @@ -1510,16 +1486,16 @@ function groupQuestion( question_id = false, section_id = false , group_question
@@ -1560,6 +1536,7 @@ function groupQuestion( question_id = false, section_id = false , group_question
${questionDescription ? questionDescription : ''}
${mathEnabled == 'true' ? questionDescription : ''} + MATH 
@@ -1567,19 +1544,15 @@ function groupQuestion( question_id = false, section_id = false , group_question
-
+
${Choice ? Choice[0].choice_name : ""}
${Choice ? Choice[0].choice_name : ""}
-         +   MATH
-
- -
- -
+
@@ -1589,36 +1562,31 @@ function groupQuestion( question_id = false, section_id = false , group_question
-
-
+
+ + +
+
Marks :
- - +
`; @@ -1635,13 +1603,6 @@ function groupQuestion( question_id = false, section_id = false , group_question var sectionDiv = document.getElementById(section_id); sectionDiv.insertAdjacentHTML('beforeend', groupQuestion); - } - else if(questionGroupId) - { - - var sectionDiv = document.getElementById(questionGroupId); - sectionDiv.insertAdjacentHTML('beforeend', textQuestion); - } else if(questionAreaId) { @@ -1667,6 +1628,7 @@ function groupQuestion( question_id = false, section_id = false , group_question var ChoiceMathSwitch = 'math_'+addChoiceAreaId; + var ChoiceFieldMathSwitch = 'Choicemath_'+addChoiceAreaId; var textQuestionSubtitle_math = 'textQuestionSubtitle_math_'+addChoiceAreaId; var textQuestionSubtitle = 'textQuestionSubtitle_'+addChoiceAreaId; var choiceTextField_math = 'choiceTextField_math_'+addChoiceAreaId; @@ -1674,6 +1636,7 @@ function groupQuestion( question_id = false, section_id = false , group_question var choicecommentFielddelete = 'newChoiceGroup_'+addChoiceAreaId; var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch); + var ChoiceFieldMathSwitchId = document.getElementById(ChoiceFieldMathSwitch); var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math) var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle) var choiceTextField_math_Id = document.getElementById(choiceTextField_math) @@ -1683,24 +1646,41 @@ function groupQuestion( question_id = false, section_id = false , group_question if (mathEnabled === 'true') { - ChoiceMathSwitchId.checked = true; $(textQuestionSubtitleId).hide(); $(textQuestionSubtitle_previousDiv).hide(); $(textQuestionSubtitle_mathId).show(); - $(choiceTextFieldId).hide(); - $(choiceTextField_previousDiv).hide(); - $(choiceTextField_math_Id).show(); - } else { - $(ChoiceMathSwitchId).checked = false; $(textQuestionSubtitleId).show(); $(textQuestionSubtitle_mathId).hide(); + } + + //for default choice field mathenabled + var choice_mathEnabled = ""; + if(Choice !== false) + { + choice_mathEnabled = Choice[0].is_math_enabled; + } + else{ + choice_mathEnabled = 'false' + } + + + + if(choice_mathEnabled === 'true') + { + $(ChoiceFieldMathSwitchId).prop('checked', true); + $(choiceTextFieldId).hide(); + $(choiceTextField_math_Id).show(); + } + else + { + $(ChoiceFieldMathSwitchId).prop('checked', false); $(choiceTextFieldId).show(); - $(choiceTextField_math_Id).hide(); + $(choiceTextField_math_Id).hide(); } @@ -1708,54 +1688,39 @@ function groupQuestion( question_id = false, section_id = false , group_question $(ChoiceMathSwitchId).change(function() { if (ChoiceMathSwitchId.checked) { + $(textQuestionSubtitle_mathId).show(); $(textQuestionSubtitleId).hide(); $(textQuestionSubtitle_previousDiv).hide(); - $(choiceTextFieldId).hide(); - $(choiceTextField_previousDiv).hide(); - $(choiceTextField_math_Id).show(); + } else { $(textQuestionSubtitleId).show(); $(textQuestionSubtitle_mathId).hide(); - $(choiceTextFieldId).show(); - $(choiceTextField_math_Id).hide(); - } + } }); + $(ChoiceFieldMathSwitchId).change(function() { + + if (ChoiceFieldMathSwitchId.checked) { + + $(choiceTextFieldId).hide(); + $(choiceTextField_previousDiv).hide(); + $(choiceTextField_math_Id).show(); + + } else { + $(choiceTextFieldId).show(); + $(choiceTextField_math_Id).hide(); + } + }); + - - if(Choice) - { - if(Choice[0].choice_description !== 'undefined' && Choice[0].choice_description !== '' && Choice[0].choice_description !== 'null' && Choice[0].choice_description !== 'false') - { - - $('#'+commentFieldId).css('display', 'block'); - - }else { - - $('#'+commentFieldId).css('display', 'none'); - - } - } - - - - $('#'+commentButtonId).on('click', function() { - - $('#'+commentFieldId).toggle(); - - }) - - $('#'+imageButtonId).on('click', function() { - - $('#'+imageInputId).click(); - - }) $('#'+deleteButtonId).on('click', function() { $('#'+choicecommentFielddelete).remove(); }) + + @@ -1836,77 +1801,6 @@ function groupQuestion( question_id = false, section_id = false , group_question -//mark calculation in Choice Question - -// var choiceQuestionMarkField = 'Choice_Question_Marks_Id_' + addChoiceAreaId; - -// 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 InMarkValue = $('#'+Section_Marks_raw_Id).val(); -// // alert(InMarkValue); - -// var QuestionGroup_ID = localStorage.getItem('QuestionGroupId'); -// var Question_Attempt_Any_Fields = 'Question_Attempt_Any_Id_' + QuestionGroup_ID; - - -// //these lines are work only the 'ChoiceQuestion()(groupQuestion)' function calls -// var QGinputValue = $('#'+Section_Attempt_Any_raw_Id).val(); - -// if(QGinputValue == ""){ -// $('#'+choiceQuestionMarkField).prop("disabled", false); -// // alert('enable'); -// }else{ -// $('#'+choiceQuestionMarkField).prop("disabled", true); -// $('#'+choiceQuestionMarkField).val(InMarkValue); -// // alert('disabled'); -// } -// //end of the lines - - - -// $('#'+Section_Attempt_Any_raw_Id).keyup(function() { -// var inputValue = $(this).val(); -// if(inputValue == ""){ -// $('#'+choiceQuestionMarkField).prop("disabled", false); -// // alert('enable'); -// }else{ -// $('#'+choiceQuestionMarkField).prop("disabled", true); -// // alert('disabled'); - -// } -// json2nav(); -// }); - -// $('#'+Section_Marks_raw_Id).keyup(function() { -// var MarksinputValue = $(this).val(); - -// if(MarksinputValue !== ""){ -// $('#'+choiceQuestionMarkField).val(MarksinputValue); -// }else{ -// $('#'+choiceQuestionMarkField).val(""); -// } -// }); - - -// $('#'+Question_Attempt_Any_Fields).keyup(function() { -// var inputValue = $(this).val(); -// if(inputValue == ""){ -// $('#'+choiceQuestionMarkField).prop("disabled", false); -// // alert('enable') -// }else{ -// $('#'+choiceQuestionMarkField).prop("disabled", true); -// // alert('disabled'); - -// } -// json2nav(); -// }); - -//end of mark calculation in Choice Question - - - var typetwoQuestionName = 'textQuestionName_' + addChoiceAreaId; var quill = new Quill('#'+typetwoQuestionName, { theme: 'snow', @@ -1974,13 +1868,18 @@ var DisplayMark_ID = document.getElementById(DisplayMark_RawID) if(questionDisplayMarks === 'true'){ - DisplayMark_ID.checked = true; -}else if(group_question_Display_Marks === 'true'){ DisplayMark_ID.checked = true; }else{ DisplayMark_ID.checked = false; } +var multipleAnswer = 'multipleAnswer_'+addChoiceAreaId; +if (questionSubType === 'true') { + $('#'+multipleAnswer).prop('checked', true); +} else { + $('#'+multipleAnswer).prop('checked', false); +} + var choiceid = 'textQuestionName_'+ addChoiceAreaId; var inputElement = document.getElementById(choiceid); @@ -1996,8 +1895,8 @@ $(inputElement).keyup(function(event) { var choiceQuestionMarkField = 'Choice_Question_Marks_Id_' + addChoiceAreaId; $('#'+choiceQuestionMarkField).keyup(function() { - json2nav() - markCalculation() + json2nav(); + markCalculation(); }); @@ -2011,9 +1910,8 @@ markCalculation(); } //Function for Create a New Choice Field in a Choice Question -function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, choiceDescription = false, questionRandomNo = false, QuestionGroupRandomNo = false, choiceID = false, mathEnabled= false) +function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, questionRandomNo = false, choiceID = false, choice_mathEnabled= false) { - const Choice_Group_Dynamic_UUID = uuidv4(); addChoice = ""; @@ -2025,550 +1923,475 @@ function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, choiceDes
-
-
${choiceName ? choiceName : ""}
+
+
${choiceName ? choiceName : ""}
${choiceName ? choiceName : ""}
-
-     +
    +   MATH
- -
- -
` - if(questionRandomNo) - { - var addChoiceAreaId = 'addChoiceArea_'+questionRandomNo; - var addChoiceAreaId2 = document.getElementById(addChoiceAreaId); - addChoiceAreaId2.insertAdjacentHTML('beforeend', addChoice); - } - else if(QuestionGroupRandomNo) - { - var addChoiceAreaRandomNo = 'addChoiceArea_'+QuestionGroupRandomNo; - var addChoiceAreaId = document.getElementById(addChoiceAreaRandomNo); - addChoiceAreaId.insertAdjacentHTML('beforeend', addChoice); - } - else if(NewaddChoiceAreaId) - { - NewaddChoiceAreaId.insertAdjacentHTML('beforeend', addChoice); - } - - - var newChoiceCommentButtonId = document.getElementById('newChoiceCommentButton_'+text_field_created_time+rnd_no); - var newChoiceCommentFieldId = document.getElementById('newChoiceCommentField_'+text_field_created_time+rnd_no); - var newChoiceCommentFieldDeleteId = document.getElementById('newChoiceGroup_'+text_field_created_time+rnd_no); - var newChoiceDeleteButtonId = document.getElementById('newChoiceDeleteButton_'+text_field_created_time+rnd_no); - var newDeleteChoiceId = document.getElementById('newDeleteChoice_'+text_field_created_time+rnd_no); - - var formbox = document.getElementById('delete_'+text_field_created_time+rnd_no); - - - var choiceid = localStorage.getItem('ChoiceId'); - var ChoiceMathSwitch = 'math_'+choiceid; - - var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch) - var newchoiceTextField_math_Id = document.getElementById('newchoiceTextField_math_'+text_field_created_time+rnd_no); - var newchoiceTextFieldId = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no); - - - $(newchoiceTextField_math_Id).hide(); - ChoiceMathSwitchId.addEventListener("change", function() { - - if (ChoiceMathSwitchId.checked) { - - $(newchoiceTextFieldId).hide(); - $(newchoiceTextField_math_Id).show(); - - } else { - - $(newchoiceTextFieldId).show(); - $(newchoiceTextField_math_Id).hide(); - } - }); - - if (ChoiceMathSwitchId.checked) { - - $(newchoiceTextFieldId).hide(); - $(newchoiceTextField_math_Id).show(); - - } else { - - $(newchoiceTextFieldId).show(); - $(newchoiceTextField_math_Id).hide(); - } - - + if(questionRandomNo) + { + var addChoiceAreaId = 'addChoiceArea_'+questionRandomNo; + var addChoiceAreaId2 = document.getElementById(addChoiceAreaId); + addChoiceAreaId2.insertAdjacentHTML('beforeend', addChoice); + } + else if(NewaddChoiceAreaId) + { + NewaddChoiceAreaId.insertAdjacentHTML('beforeend', addChoice); + } - $(newChoiceCommentButtonId).on('click', function() { - $(newChoiceCommentFieldId).toggle(); + var newChoiceCommentButtonId = document.getElementById('newChoiceCommentButton_'+text_field_created_time+rnd_no); + var newChoiceCommentFieldId = document.getElementById('newChoiceCommentField_'+text_field_created_time+rnd_no); + var newChoiceCommentFieldDeleteId = document.getElementById('newChoiceGroup_'+text_field_created_time+rnd_no); + var newChoiceDeleteButtonId = document.getElementById('newChoiceDeleteButton_'+text_field_created_time+rnd_no); + var newDeleteChoiceId = document.getElementById('newDeleteChoice_'+text_field_created_time+rnd_no); - }) + var formbox = document.getElementById('delete_'+text_field_created_time+rnd_no); + - $(newChoiceDeleteButtonId).on('click', function() { +//function for delete the choice field +$(newChoiceDeleteButtonId).on('click', function() { - $(newChoiceCommentFieldDeleteId).remove(); - }) - - if(choiceDescription !== 'undefined' && choiceDescription !== '' && choiceDescription !== null && choiceDescription !== false){ - - $(newChoiceCommentFieldId).css('display', 'block'); - - - }else { - - $(newChoiceCommentFieldId).css('display', 'none'); - - - } - + $(newChoiceCommentFieldDeleteId).remove(); +}) - var newChoiceTextField = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no); - var quill = new Quill(newChoiceTextField, { - theme: 'snow', - modules: { - toolbar: toolbarOptions2 - }, - placeholder: 'Enter Choice', - }); + var newChoiceTextField = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no); + var quill = new Quill(newChoiceTextField, { + theme: 'snow', + modules: { + toolbar: toolbarOptions2 + }, + placeholder: 'Enter Choice', + }); - var newchoiceFieldId = 'newChoiceTextField_'+text_field_created_time+rnd_no; - var newchoiceTextField_Div = document.getElementById(newchoiceFieldId); - var newchoiceTextField_previousDiv = $(newchoiceTextField_Div).prev(); - var newChoiceTextNewRTEId = "newChoiceTextField_rtc_"+text_field_created_time+rnd_no; - newchoiceTextField_previousDiv.attr("id", newChoiceTextNewRTEId); - + var newchoiceFieldId = 'newChoiceTextField_'+text_field_created_time+rnd_no; + var newchoiceTextField_Div = document.getElementById(newchoiceFieldId); + var newchoiceTextField_previousDiv = $(newchoiceTextField_Div).prev(); + var newChoiceTextNewRTEId = "newChoiceTextField_rtc_"+text_field_created_time+rnd_no; + newchoiceTextField_previousDiv.attr("id", newChoiceTextNewRTEId); + + + newchoiceTextField_Div.addEventListener('click', function() { - newchoiceTextField_Div.addEventListener('click', function() { - - var id = localStorage.getItem('rtc'); - var hideid = document.getElementById(id); - // console.log('hide id :' + hideid) - $(hideid).hide(); - $(newchoiceTextField_previousDiv).show(); - // console.log('show id :'+newchoiceTextField_previousDiv) - localStorage.setItem('rtc',newChoiceTextNewRTEId); + var id = localStorage.getItem('rtc'); + var hideid = document.getElementById(id); + // console.log('hide id :' + hideid) + $(hideid).hide(); + $(newchoiceTextField_previousDiv).show(); + // console.log('show id :'+newchoiceTextField_previousDiv) + localStorage.setItem('rtc',newChoiceTextNewRTEId); - }); - $(newchoiceTextField_previousDiv).hide(); + }); + $(newchoiceTextField_previousDiv).hide(); - json2nav(); - clearSidebarWrapper(); - navpane(); + + var choiceid = localStorage.getItem('ChoiceId'); + var ChoiceMathSwitch = 'choice_math_'+text_field_created_time+rnd_no; + + + var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch) + var newchoiceTextField_math_Id = document.getElementById('newchoiceTextField_math_'+text_field_created_time+rnd_no); + var newchoiceTextFieldId = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no); + + + if(choice_mathEnabled === "true") + { + ChoiceMathSwitchId.checked = true; + $(newchoiceTextFieldId).hide(); + $(newchoiceTextField_previousDiv).hide(); + $(newchoiceTextField_math_Id).show(); + } + else{ + ChoiceMathSwitchId.checked = false; + $(newchoiceTextFieldId).hide(); + $(newchoiceTextField_math_Id).show(); + } + + ChoiceMathSwitchId.addEventListener("change", function() { + if (ChoiceMathSwitchId.checked) { + + $(newchoiceTextFieldId).hide(); + $(newchoiceTextField_previousDiv).hide(); + $(newchoiceTextField_math_Id).show(); + + } else { + + $(newchoiceTextFieldId).show(); + $(newchoiceTextField_math_Id).hide(); + } + }); + + if (ChoiceMathSwitchId.checked) { + + $(newchoiceTextFieldId).hide(); + $(newchoiceTextField_previousDiv).hide(); + $(newchoiceTextField_math_Id).show(); + + } else { + + $(newchoiceTextFieldId).show(); + $(newchoiceTextField_math_Id).hide(); + } + + + + + + + + + + + json2nav(); + clearSidebarWrapper(); + navpane(); } //Function for Create a New Text Question in the Section and Question Group -function textQuestion(question_id = false, section_id = false, group_question_area_id = false, questionTitle = false, questionDescription = false, questionSubType = false, mathEnabled = false, questionGroupId = false, questionAreaId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false) +function textQuestion(QuestionObj) { - // console.log('===========================================================================================================================================') - // console.log("group_question_area_id : "+group_question_area_id, 'questionGroupId : '+ questionGroupId, 'questionAreaId : '+questionAreaId) - // console.log('===========================================================================================================================================') + var textQuestion = ""; - const Text_Question_UUID = uuidv4(); +const Text_Question_UUID = uuidv4(); +const text_field_created_time = Date.now(); - var textQuestion = ""; - const text_field_created_time = Date.now(); - - var addTextQuestionId = "" - if(questionRandomNo) - { - addTextQuestionId = questionRandomNo; - } - else if(QuestionGroupRandomNo) - { - addTextQuestionId = QuestionGroupRandomNo; - } - else - { - addTextQuestionId = text_field_created_time; - } - localStorage.setItem('questionsId', addTextQuestionId); - - - - var marks = "" - if(questionMarks) - { - marks = questionMarks; - } - else if(group_question_marks) - { - marks = group_question_marks; - } - else - { - marks = ""; - } - - - var UUID = ""; - if(questionUUID) - { - UUID = questionUUID; - } - else if(group_question_marks) - { - UUID = group_question_uuid; - } - else - { - UUID = Text_Question_UUID; - } - - var sectionRandomID = localStorage.getItem('sectionId'); - var QuestionGroup_ID = localStorage.getItem('QuestionGroupId'); - - textQuestion += - `
-
- -
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- - -
- -
- -
${questionTitle ? questionTitle : ''}
-
-
-
-
- -
${questionDescription ? questionDescription : ''}
- ${mathEnabled == 'true' ? questionDescription : ''} -
-
-
-
- -
-
-
-
- -
-
-
- -
-
-
Marks :
- -
-
- - -
`; - - - if(question_id && !section_id) - { - var questionDiv = document.getElementById(question_id); - questionDiv.insertAdjacentHTML('afterend', textQuestion); - } - else if(section_id) - { - var sectionDiv = document.getElementById(section_id); - sectionDiv.insertAdjacentHTML('beforeend', textQuestion); - } - else if(questionGroupId) - { - var sectionDiv = document.getElementById(questionGroupId); - sectionDiv.insertAdjacentHTML('beforeend', textQuestion); - } - else if(questionAreaId) - { - var sectionDiv = document.getElementById(questionAreaId); - sectionDiv.insertAdjacentHTML('beforeend', textQuestion); - } - else if(group_question_area_id !== 0) - { - var sectionDiv = document.getElementById(group_question_area_id); - sectionDiv.insertAdjacentHTML('beforeend', textQuestion); - } - - - var longAnswerRandomId = 'longAnswer_' + addTextQuestionId; - var textareaRandomId = 'textarea_' + addTextQuestionId; - var textFieldRandomId = 'textField_' + addTextQuestionId; - - var longAnswerId = document.getElementById(longAnswerRandomId); - var textareaId = document.getElementById(textareaRandomId); - var textFieldId = document.getElementById(textFieldRandomId); - - // Hide and show of text and textare using switch long answer - $(textareaId).hide(); - $(longAnswerId).on("change", function() { - if (longAnswerId.checked) { - $(textareaId).show(); - $(textFieldId).hide(); - } else { - $(textareaId).hide(); - $(textFieldId).show(); - } - }); - - - var ChoiceMathSwitch ='math_' + addTextQuestionId; - var textQuestionSubtitle_math = 'textQuestionSubtitle_math_' + addTextQuestionId; - var textQuestionSubtitle = 'textQuestionSubtitle_' + addTextQuestionId; - - var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch); - var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math); - var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle); - - - if (mathEnabled === 'true') - { - - ChoiceMathSwitchId.checked = true; - $(textQuestionSubtitleId).hide(); - $(textQuestionSubtitle_previousDiv).hide(); - $(textQuestionSubtitle_mathId).show(); - } - else - { - - ChoiceMathSwitchId.checked = false; - $(textQuestionSubtitleId).show(); - $(textQuestionSubtitle_mathId).hide(); - } - - - ChoiceMathSwitchId.addEventListener("change", function() { - - if (ChoiceMathSwitchId.checked) { - $(textQuestionSubtitle_mathId).show(); - $(textQuestionSubtitleId).hide(); - $(textQuestionSubtitle_previousDiv).hide(); - } else { - $(textQuestionSubtitleId).show(); - $(textQuestionSubtitle_mathId).hide(); - } - }); - - - var AddButtons_Raw = 'AddButtons_'+addTextQuestionId; - var overallAddButtons_Raw = 'overallAddButtons_'+addTextQuestionId; - var QuestionGroupAddButtons_Raw = 'QuestionGRoupAddButtons_'+addTextQuestionId; - var overallQuestionGroupAddButtons_Raw = 'overallQuestionGRoupAddButtons_'+addTextQuestionId; - - var AddButtons_ID = document.getElementById(AddButtons_Raw) - var QuestionGroupAddButtons_ID = document.getElementById(QuestionGroupAddButtons_Raw) - var removeAndCloneTextQuestion_ID = document.getElementById(removeAndCloneTextQuestion_Raw); - - - if(group_question_area_id !== false )//questionGroupId - { - // alert('three') - // three button group - $('#'+overallQuestionGroupAddButtons_Raw).show(); - $('#'+overallAddButtons_Raw).hide(); - - } - else{ - - // alert('four') - // four button group - - if(questionAreaId !== false) - { - $('#'+overallQuestionGroupAddButtons_Raw).show(); - $('#'+overallAddButtons_Raw).hide(); - } - else - { - $('#'+overallQuestionGroupAddButtons_Raw).hide(); - $('#'+overallAddButtons_Raw).show(); - } - - // $('#'+overallQuestionGroupAddButtons_Raw).hide(); - // $('#'+overallAddButtons_Raw).show(); - } - - - var removeAndCloneTextQuestion_Raw = 'removeAndCloneTextQuestion_'+addTextQuestionId; - var AddButtons_Raw = 'AddButtons_'+addTextQuestionId; - $('#'+removeAndCloneTextQuestion_Raw).mouseenter(function(){ - - - if(group_question_area_id !== false) - { - add_button_hide_and_show(QuestionGroupAddButtons_Raw); - } - else - { - if(questionAreaId !== false) - { - add_button_hide_and_show(QuestionGroupAddButtons_Raw); - } - else - { - add_button_hide_and_show(AddButtons_Raw); - } - } - - }) - $('#'+AddButtons_Raw).hide(); - $('#'+QuestionGroupAddButtons_Raw).hide(); - - - - var typeOneQuestionName = 'textQuestionName_' + addTextQuestionId; - var quill = new Quill('#'+typeOneQuestionName, { - theme: 'snow', - modules: { - toolbar: toolbarOptions - }, - - }); - - var typeOneQuestionSubtitle = 'textQuestionSubtitle_' + addTextQuestionId; - var quill = new Quill('#'+typeOneQuestionSubtitle, { - theme: 'snow', - modules: { - toolbar: toolbarOptions - }, - }); - - - var textQuestionName_Div = 'textQuestionName_' + addTextQuestionId; - var textQuestionNewRTEId = 'typeOnetextQuestionName_rtc_' + addTextQuestionId; - var textQuestionName_previousDiv = $('#'+textQuestionName_Div).prev(); - textQuestionName_previousDiv.attr("id", textQuestionNewRTEId); - $('#'+textQuestionName_Div).click(function() { - - rtc_hide_and_show(textQuestionNewRTEId); - }); - - - var textQuestionSubtitle_Div = 'textQuestionSubtitle_' + addTextQuestionId; - var textQuestionSubtitleNewRTEId = 'typeOnetextQuestionSubtitle_rtc_' + addTextQuestionId; - var textQuestionSubtitle_previousDiv = $('#'+textQuestionSubtitle_Div).prev(); - textQuestionSubtitle_previousDiv.attr("id", textQuestionSubtitleNewRTEId); - $('#'+textQuestionSubtitle_Div).click(function() { - - rtc_hide_and_show(textQuestionSubtitleNewRTEId); - - }); - - $(textQuestionName_previousDiv).hide(); - $(textQuestionSubtitle_previousDiv).hide(); - - - var DisplayMark_RawID = "Text_Question_Display_Marks_Id_" + addTextQuestionId; - var DisplayMark_ID = document.getElementById(DisplayMark_RawID) - - if(questionDisplayMarks === 'true'){ - - DisplayMark_ID.checked = true; - - }else if(group_question_Display_Marks === 'true' && group_question_Display_Marks !== null){ - - DisplayMark_ID.checked = true; - - }else{ - DisplayMark_ID.checked = false; - } - - - - var Textid = 'textQuestionName_'+ addTextQuestionId; - var inputElement = document.getElementById(Textid); - - $(inputElement).keyup(function(event) { - json2nav(); - clearSidebarWrapper(); - navpane(); - }); - - // function for calling html2json using Mark Calculation - var textQuestionMarkField = 'Text_Question_Marks_Id_'+ addTextQuestionId - $('#'+textQuestionMarkField).keyup(function() { - - json2nav() - markCalculation() - - }); - - json2nav(); - clearSidebarWrapper(); - navpane(); - markCalculation(); +var addTextQuestionId = "" +if(QuestionObj.hasOwnProperty('questionRandomNo')) { + addTextQuestionId = QuestionObj.questionRandomNo; +} else{ + addTextQuestionId = text_field_created_time; } +var mathEnabled = ""; +if(QuestionObj.hasOwnProperty('mathEnabled')) +{ + mathEnabled = QuestionObj.mathEnabled; +} +else +{ + mathEnabled = 'false'; +} + + +var sectionRandomID = localStorage.getItem('sectionId'); +var QuestionGroup_ID = localStorage.getItem('QuestionGroupId'); + +textQuestion += +`
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + +
+ +
+ +
${QuestionObj.hasOwnProperty('questionTitle') ? QuestionObj.questionTitle : ''}
+
+
+
+
+ +
${QuestionObj.hasOwnProperty('questionDescription') ? QuestionObj.questionDescription : '' }
+ ${mathEnabled == 'true' ? QuestionObj.questionDescription : ''} + MATH  +
+
+ + +
+
+ +
+
+
Marks :
+ +
+
+
`; + + +if(QuestionObj.hasOwnProperty('clone_question_id')) +{ + var questionDiv = document.getElementById(QuestionObj.clone_question_id); + questionDiv.insertAdjacentHTML('afterend', textQuestion); +} +else if(QuestionObj.hasOwnProperty('section_question_id')) +{ + var sectionDiv = document.getElementById(QuestionObj.section_question_id); + sectionDiv.insertAdjacentHTML('beforeend', textQuestion); +} + +else if(QuestionObj.hasOwnProperty('question_area_id')) +{ + var sectionDiv = document.getElementById(QuestionObj.question_area_id); + sectionDiv.insertAdjacentHTML('beforeend', textQuestion); +} +else if(QuestionObj.hasOwnProperty('group_question_area_id')) +{ + var sectionDiv = document.getElementById(QuestionObj.group_question_area_id); + sectionDiv.insertAdjacentHTML('beforeend', textQuestion); +} + + +var ChoiceMathSwitch ='math_' + addTextQuestionId; +var textQuestionSubtitle_math = 'textQuestionSubtitle_math_' + addTextQuestionId; +var textQuestionSubtitle = 'textQuestionSubtitle_' + addTextQuestionId; + +var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch); +var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math); +var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle); + + +if (mathEnabled === 'true') +{ + + ChoiceMathSwitchId.checked = true; + $(textQuestionSubtitleId).hide(); + $(textQuestionSubtitle_previousDiv).hide(); + $(textQuestionSubtitle_mathId).show(); +} +else +{ + + ChoiceMathSwitchId.checked = false; + $(textQuestionSubtitleId).show(); + $(textQuestionSubtitle_mathId).hide(); +} + + +ChoiceMathSwitchId.addEventListener("change", function() { + +if (ChoiceMathSwitchId.checked) { + $(textQuestionSubtitle_mathId).show(); + $(textQuestionSubtitleId).hide(); + $(textQuestionSubtitle_previousDiv).hide(); +} else { + $(textQuestionSubtitleId).show(); + $(textQuestionSubtitle_mathId).hide(); +} +}); + + +var AddButtons_Raw = 'AddButtons_'+addTextQuestionId; +var overallAddButtons_Raw = 'overallAddButtons_'+addTextQuestionId; +var QuestionGroupAddButtons_Raw = 'QuestionGRoupAddButtons_'+addTextQuestionId; +var overallQuestionGroupAddButtons_Raw = 'overallQuestionGRoupAddButtons_'+addTextQuestionId; + +var AddButtons_ID = document.getElementById(AddButtons_Raw) +var QuestionGroupAddButtons_ID = document.getElementById(QuestionGroupAddButtons_Raw) +var removeAndCloneTextQuestion_ID = document.getElementById(removeAndCloneTextQuestion_Raw); + +var questionAreaType = ""; +if(QuestionObj.hasOwnProperty('question_area_id')){ +questionAreaID = QuestionObj.question_area_id; +questionAreaType = questionAreaID.split("_")[0]; +} + +var questionGroupID = "" +if(QuestionObj.hasOwnProperty('group_question_area_id')) +{ +questionGroupID = QuestionObj.group_question_area_id; +} + + +if(questionGroupID !== "")//Three button for QuestionGroup +{ +$('#'+overallQuestionGroupAddButtons_Raw).show(); +$('#'+overallAddButtons_Raw).hide(); +}else{ + +// four button group +if(questionAreaType === 'group') +{ + $('#'+overallQuestionGroupAddButtons_Raw).show(); + $('#'+overallAddButtons_Raw).hide(); +} +else +{ + $('#'+overallQuestionGroupAddButtons_Raw).hide(); + $('#'+overallAddButtons_Raw).show(); +} + +} + + + var removeAndCloneTextQuestion_Raw = 'removeAndCloneTextQuestion_'+addTextQuestionId; + var AddButtons_Raw = 'AddButtons_'+addTextQuestionId; + $('#'+removeAndCloneTextQuestion_Raw).mouseenter(function(){ + + + if(questionGroupID !== "") + { + add_button_hide_and_show(QuestionGroupAddButtons_Raw); + } + else + { + if(questionAreaType === 'group') + { + add_button_hide_and_show(QuestionGroupAddButtons_Raw); + } + else + { + add_button_hide_and_show(AddButtons_Raw); + } + } + + }) + $('#'+AddButtons_Raw).hide(); + $('#'+QuestionGroupAddButtons_Raw).hide(); + + + + var typeOneQuestionName = 'textQuestionName_' + addTextQuestionId; + var quill = new Quill('#'+typeOneQuestionName, { + theme: 'snow', + modules: { + toolbar: toolbarOptions + }, + + }); + + var typeOneQuestionSubtitle = 'textQuestionSubtitle_' + addTextQuestionId; + var quill = new Quill('#'+typeOneQuestionSubtitle, { + theme: 'snow', + modules: { + toolbar: toolbarOptions + }, + }); + + + var textQuestionName_Div = 'textQuestionName_' + addTextQuestionId; + var textQuestionNewRTEId = 'typeOnetextQuestionName_rtc_' + addTextQuestionId; + var textQuestionName_previousDiv = $('#'+textQuestionName_Div).prev(); + textQuestionName_previousDiv.attr("id", textQuestionNewRTEId); + $('#'+textQuestionName_Div).click(function() { + + rtc_hide_and_show(textQuestionNewRTEId); + }); + + + var textQuestionSubtitle_Div = 'textQuestionSubtitle_' + addTextQuestionId; + var textQuestionSubtitleNewRTEId = 'typeOnetextQuestionSubtitle_rtc_' + addTextQuestionId; + var textQuestionSubtitle_previousDiv = $('#'+textQuestionSubtitle_Div).prev(); + textQuestionSubtitle_previousDiv.attr("id", textQuestionSubtitleNewRTEId); + $('#'+textQuestionSubtitle_Div).click(function() { + + rtc_hide_and_show(textQuestionSubtitleNewRTEId); + + }); + + $(textQuestionName_previousDiv).hide(); + $(textQuestionSubtitle_previousDiv).hide(); + + var displayMArks = "" + if(QuestionObj.hasOwnProperty('questionDisplayMarks')) + { + displayMArks = QuestionObj.questionDisplayMarks; + } + else + { + displayMArks = 'false'; + } + + + var DisplayMark_RawID = "Text_Question_Display_Marks_Id_" + addTextQuestionId; + var DisplayMark_ID = document.getElementById(DisplayMark_RawID) + + if(displayMArks === 'true'){ + + DisplayMark_ID.checked = true; + + }else{ + DisplayMark_ID.checked = false; + } + + + +var Textid = 'textQuestionName_'+ addTextQuestionId; +var inputElement = document.getElementById(Textid); + + $(inputElement).keyup(function(event) { + json2nav(); + clearSidebarWrapper(); + navpane(); + }); + + // function for calling html2json using Mark Calculation + var textQuestionMarkField = 'Text_Question_Marks_Id_'+ addTextQuestionId + $('#'+textQuestionMarkField).keyup(function() { + + json2nav() + markCalculation() + + }); + + json2nav(); + clearSidebarWrapper(); + navpane(); + markCalculation(); +} //Function for Add Group Question inside the Group QUestion Like Question @@ -2595,9 +2418,13 @@ function addNewQuestions(e, type) clone_id_time = e.target.id; var clone_id = clone_id_time.split("_")[1]; var section_id = 'question_area_'+clone_id; + + var sectionQuestionAreaObject = { + 'section_question_id':section_id + } if(type == 1){ - textQuestion(false, section_id); + textQuestion(sectionQuestionAreaObject); }else if(type == 2){ groupQuestion(false, section_id); } @@ -2610,8 +2437,10 @@ function addNewGroupQuestions(e, type) var clone_id = clone_id_time.split("_")[1]; var group_question_area_id = 'group_question_area_'+clone_id; + var group_question_area_id_obj = {'group_question_area_id' : group_question_area_id} + if(type == 1){ - textQuestion(false, false, group_question_area_id); + textQuestion(group_question_area_id_obj); }else if(type == 2){ groupQuestion(false, false, group_question_area_id); }else { @@ -2696,7 +2525,7 @@ function removeClonedQroupQuestion(index) // Add a dragStart event listener to set data draggedItemGroup.addEventListener('dragstart', function (e) { e.dataTransfer.setData('text/plain', draggedItemGroup.id); - console.log(draggedItemGroup.id); + // console.log(draggedItemGroup.id); // Hide all elements with class "hideondrag" richTextElements = document.querySelectorAll('.hideondrag'); richTextElements.forEach((element) => { diff --git a/html2json.js b/html2json.js index 463f2a5..8e9a63a 100644 --- a/html2json.js +++ b/html2json.js @@ -17,8 +17,8 @@ function html2json() { questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML; } var questionType = document.getElementById('question_type_' + element_id).value; - // console.log(questionType); - var questionSubType = document.getElementById('longAnswer_' + element_id).checked; + // var questionSubType = document.getElementById('longAnswer_' + element_id).checked; + var questionSubType = 'false'; return { "question": questionTitle, @@ -56,8 +56,9 @@ function html2json() { //get choice group //get default choice details + var default_choice_math_Enabled = document.getElementById('Choicemath_' + element_id).checked; var choice_name = ""; - if(isMathEnabled == true) + if(default_choice_math_Enabled == true) { choice_name = document.getElementById('choiceTextField_math_' + element_id).value; } @@ -65,47 +66,45 @@ function html2json() { { choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML; } - var choice_description = document.getElementById('commentField_' + element_id).value; var choice_group_fixed_uuid = document.getElementById('Choice_Group_Fixed_UUID_ID_' + element_id).value; - // var choice_image = document.getElementById('imageInput_' + element_id).value; answers.push({ "choice_name": choice_name, - "choice_description": choice_description, + "is_math_enabled": default_choice_math_Enabled, "choice_uuid": choice_group_fixed_uuid, + "no": 'a' }); // 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']; var $newlyAddedChoices = $('#addChoiceArea_' + element_id); $newlyAddedChoices.children().each(function(index, element) { + var letter = alphabets[index]; //for choice field key[no] value + var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[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_name = ""; - if(isMathEnabled == true) + if(choice_math_Enabled == true) { choice_name = document.getElementById('newchoiceTextField_math_' + groupChoiceId + '.' + individualChoiceId).value; } else { choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML; - // console.log('choice_name'); - // console.log(choice_name) } - // console.log('choice_description id in the html to json script'); var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId); - // console.log(id); - var choice_description = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId).value; var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value; - - // var choice_image = document.getElementById('newChoiceImageInput_' + groupChoiceId + '.' + individualChoiceId).value; - + answers.push({ "choice_name": choice_name, - "choice_description": choice_description, + "is_math_enabled": choice_math_Enabled, "choice_uuid": choice_group_dynamic_uuid, + "no":letter }); @@ -277,6 +276,6 @@ function html2json() { // console.log((formData)); // console.log(JSON.stringify(formData, null, 1)); localStorage.setItem("json", JSON.stringify((formData))); - // console.log(JSON.stringify(formData)); + console.log(JSON.stringify(formData)); // console.log(OBJtoXML(({'question_paper' : formData}))); } diff --git a/html2json_for_navigation.js b/html2json_for_navigation.js index e95b7cf..dac6a1f 100644 --- a/html2json_for_navigation.js +++ b/html2json_for_navigation.js @@ -157,7 +157,7 @@ function json2nav() { localStorage.setItem("JSON_FOR_NAV", JSON.stringify((formData))); // console.log('JSON_FOR_NAV'); // console.log('*********************************************************************************'); - console.log(JSON.stringify(formData)); + // console.log(JSON.stringify(formData)); // console.log('*********************************************************************************'); // console.log(OBJtoXML(({'question_paper' : formData}))); diff --git a/json2html.js b/json2html.js index 04373db..335e651 100644 --- a/json2html.js +++ b/json2html.js @@ -1,6 +1,6 @@ function jsonToHtml(jsonData) { - console.log(jsonData); + // console.log(jsonData); if(jsonData == "" || jsonData == null) { @@ -46,6 +46,8 @@ function jsonToHtml(jsonData) { jsonData.sections.forEach(function(section, index) { const random_no = Date.now(); + var questionAreaId = 'question_area_'+random_no; //Add section to this id of the question paper + var sectionTitle = section.section_title; var sectionDescription = section.section_description; var sectionMarks = section.section_marks; @@ -53,12 +55,34 @@ function jsonToHtml(jsonData) { var sectionDispalyMarks = section.section_display_marks; var sectionAttemptAny = section.section_attempt_any; - + + var SectionObj = { + 'random_no' :random_no, + 'sectionTitle' :section.section_title, + 'sectionDescription' :section.section_description, + 'sectionMarks' :section.section_marks, + 'sectionUUID' :section.attributes.Id, + 'sectionDispalyMarks':section.section_display_marks, + 'sectionAttemptAny' :section.section_attempt_any, + } + + // addSection(SectionObj); //call the addSection() function and send the sectionObject to that function addSection(sectionTitle, sectionDescription, random_no, sectionUUID, sectionMarks, sectionDispalyMarks, sectionAttemptAny); section.questions.forEach(function(Question, index) { - - const questionRandomNo = Date.now(); + + const questionRandomNo = Date.now(); + QuestionsForEach(Question, questionAreaId, questionRandomNo) + + }) + + }) + +} + + +function QuestionsForEach(Question, questionAreaId, questionRandomNo){ + var questionTypeFormets = ""; if(Question.question_type) { @@ -68,36 +92,50 @@ function jsonToHtml(jsonData) { { questionTypeFormets ='question_group'; } - var questionTitle = Question.question; - var questionDescription = Question.question_description; - var questionType = questionTypeFormets; - var questionSubType = Question.question_sub_type; - var mathEnabled = Question.is_math_enabled; - var questionMarks = Question.marks; - var questionUUID = Question.attributes.Id; + var questionTitle = Question.question; + var questionDescription = Question.question_description; + var questionType = questionTypeFormets; + var questionSubType = Question.question_sub_type; + var mathEnabled = Question.is_math_enabled; + var questionMarks = Question.marks; + var questionUUID = Question.attributes.Id; var questionDisplayMarks = Question.display_marks; - var Choice = Question.answers; + var Choice = Question.answers; - var questionAreaId = 'question_area_'+random_no; + + var QuestionObj = { + "question_area_id" :questionAreaId, + 'questionRandomNo' :questionRandomNo, + + 'questionTitle' :Question.question, + 'questionDescription' :Question.question_description, + 'questionType' :questionTypeFormets, + 'questionSubType' :Question.question_sub_type, + 'mathEnabled' :Question.is_math_enabled, + 'questionMarks' :Question.marks, + 'questionUUID' :Question.attributes.Id, + 'questionDisplayMarks' :Question.display_marks, + 'Choice' :Question.answers, + } if(questionType == 'text') { - textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, false, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false); + textQuestion(QuestionObj) + // textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks); } 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, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, false, questionAreaId, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false); + groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,); + // groupQuestion(QuestionObj); - Choice = Choice.slice(1); Choice.forEach(function(choicenames, index) { var choiceName = choicenames.choice_name; - var choiceDescription = choicenames.choice_description; var choiceID = choicenames.id; + var choice_mathEnabled = choicenames.is_math_enabled; - addNewChoice(false , choiceName, choiceDescription, questionRandomNo, false, choiceID, mathEnabled); + addNewChoice(false , choiceName, questionRandomNo, choiceID, choice_mathEnabled); }); } @@ -108,76 +146,20 @@ function jsonToHtml(jsonData) { } - -}) - - }) - } +//function for Generate QuestionGroup 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); Question.questions.forEach(function(GroupQuestions, index) { - const QuestionGroupRandomNo = Date.now(); - - console.log(GroupQuestions); - console.log("**********************************"); - - // question level variables - var group_question_Title = GroupQuestions.question; - var group_question_Description = GroupQuestions.question_description; - var group_question_Type = GroupQuestions.question_type; - var group_questionSubType = GroupQuestions.question_sub_type; - var mathEnabled = GroupQuestions.is_math_enabled; - var group_question_marks = GroupQuestions.marks; - var group_question_uuid = GroupQuestions.attributes.Id; - var group_question_Display_Marks = GroupQuestions.display_marks; - - // - - var Choice = GroupQuestions.answers; - var questionGroupId = 'group_question_area_'+questionRandomNo; - // console.log('questionGroupId :' + questionGroupId) - - if(group_question_Type == 'text') - { - // console.log('child gtext' + group_question_Title) - textQuestion(false, false, false, group_question_Title, group_question_Description, group_questionSubType, mathEnabled, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks); - - } - 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, group_question_Type, group_questionSubType, 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) { - var choiceName = choicenames.choice_name; - var choiceDescription = choicenames.choice_description; - var choiceID = choicenames.id; - - addNewChoice(false , choiceName, choiceDescription, false, QuestionGroupRandomNo, choiceID, mathEnabled) - }); - - } - else - { - generateGroupQuestion(GroupQuestions, questionGroupId, QuestionGroupRandomNo); - // console.log('child group question'+group_question_Title) - } - + var questionGroupAreaId = 'group_question_area_'+questionRandomNo; + QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo); }); } diff --git a/json2xml.js b/json2xml.js index aa543b4..5ace446 100644 --- a/json2xml.js +++ b/json2xml.js @@ -78,8 +78,10 @@ function json2xml() { for (choice in question['answers']) { var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {}); var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {}); - var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['choice_name'], {}); - var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_description'], {}); + 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(); } diff --git a/mark_calc.js b/mark_calc.js index e3c4a33..002d27c 100644 --- a/mark_calc.js +++ b/mark_calc.js @@ -111,7 +111,7 @@ function generateSingleQuestions(ParentObjects) var QuestionId = question_Id.split("_")[1]; QuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ QuestionId); onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0; - var questionMarksINT = parseFloat(onlyQuestionMarks); + var questionMarksINT = parseFloat(onlyQuestionMarks, 2); childMarks = childMarks + questionMarksINT; } else if(questionType == 'group') @@ -119,7 +119,7 @@ function generateSingleQuestions(ParentObjects) var QuestionId = question_Id.split("_")[1]; QuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + QuestionId); onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0; - var questionMarksINT = parseFloat(onlyQuestionMarks); + var questionMarksINT = parseFloat(onlyQuestionMarks, 2); childMarks = childMarks + questionMarksINT; } @@ -138,8 +138,8 @@ function generateSingleQuestions(ParentObjects) var returnValue = generateGroupQuestions(QuestionGroupObjects); //function for forEach QuestionGroups and Questions onlyQuestionMarks = returnValue !== undefined && returnValue !== "" ? returnValue : 0; - var questionGroupMarksINT = parseFloat(onlyQuestionMarks); - childMarks = childMarks + questionGroupMarksINT; + var questionGroupMarksINT = parseFloat(onlyQuestionMarks, 2); + childMarks = childMarks + questionGroupMarksINT; } else { diff --git a/nav_pane.js b/nav_pane.js index ddc5a72..d57d05b 100644 --- a/nav_pane.js +++ b/nav_pane.js @@ -6,6 +6,7 @@ function navpane() { let currentlyHighlightedElement = null; // Track the currently highlighted element // console.log('navpane called'); var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV')); + console.log(jsonData); // var arr = JSON.parse( localStorage.getItem('memoriesdata') ); // var jsonData2 = JSON.parse(jsonData); // console.log(typeof jsonData); @@ -30,10 +31,16 @@ function navpane() { function createTree(data, container) { data.sections.forEach(section => { const sectionDiv = document.createElement('div'); - const sectionId = section.section_id; + const sectionId = section.section_id;; sectionDiv.setAttribute('data-id', sectionId); sectionDiv.className = 'section main-heading'; - + + var splitedSectionId = sectionId.split("_")[3]; + var SectionBox_RawID = 'SectionBox_'+splitedSectionId; + var SectionBoxID = document.getElementById(SectionBox_RawID) + console.log(SectionBoxID); + + // Check if the section should be initially expanded based on expandedSections if (expandedSections.includes(sectionId)) { sectionDiv.classList.remove('collapsed'); @@ -77,12 +84,21 @@ function navpane() { sectionArrow.classList.add('arrow-down'); } }); - + const sectionLink = document.createElement('a'); sectionLink.href = '#' + section.section_id; + + // Attach the scroll function to the hyperlinks + sectionLink.addEventListener('click', function(e) { + e.preventDefault(); // Prevent the default behavior of the link + const targetId = this.getAttribute('href').substring(1); // Get the target element's ID + scrollToElement(targetId); + }); + + sectionLink.style.color = '#740fd6'; - // Add a click event listener to toggle highlighting and boldness + //click event listener to toggle highlighting and boldness if click the Section sectionLink.addEventListener('click', function () { if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) { currentlyHighlightedElement.style.fontWeight = 'normal'; @@ -95,6 +111,19 @@ function navpane() { currentlyHighlightedElement = sectionLink; } }); + + SectionBoxID.addEventListener('click', function() { + if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) { + currentlyHighlightedElement.style.fontWeight = 'normal'; + } + + if (currentlyHighlightedElement === sectionLink) { + sectionLink.style.fontWeight = sectionLink.style.fontWeight === 'bold' ? 'normal' : 'bold'; + } else { + sectionLink.style.fontWeight = 'bold'; + currentlyHighlightedElement = sectionLink; + } + }); if (section.section_title == null || typeof section.section_title === 'undefined') { section.section_title = "sampletitle"; @@ -116,25 +145,83 @@ function navpane() { // nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id; const nodeDataId = nodeData.question_Id - // console.log('nodeDataId:',nodeDataId); + const nodeDataType = nodeData.question_type + console.log('nodeDataType:',nodeDataType); parentNode.appendChild(nodeDiv); - + if (nodeData.question) { - const bulletPoint = document.createElement('span'); - bulletPoint.style.marginRight = '10px'; - bulletPoint.style.fontSize = '23px'; - bulletPoint.style.fontWeight = 'bold'; - bulletPoint.style.color = 'darkgray'; - bulletPoint.textContent = '\u2022'; - nodeDiv.appendChild(bulletPoint); + + var RawID = ""; + if(nodeDataType == 'text') + { + const bulletPoint = document.createElement('i'); + bulletPoint.className = "fa fa-text-width"; + bulletPoint.style.marginRight = '10px'; + bulletPoint.style.fontSize = '17px'; + bulletPoint.style.fontWeight = 'bold'; + bulletPoint.style.color = '#00aaff'; + // bulletPoint.textContent = '\u2022'; + bulletPoint.setAttribute("title", "Descriptive"); + nodeDiv.appendChild(bulletPoint); + + var splitedId = nodeDataId.split("_")[1]; + RawID = 'removeAndCloneTextQuestion_'+splitedId; + + + }else if(nodeDataType == 'group') + { + const bulletPoint = document.createElement('i'); + bulletPoint.className = "fa fa-check-circle-o"; + bulletPoint.style.marginRight = '10px'; + bulletPoint.style.fontSize = '17px'; + bulletPoint.style.fontWeight = 'bold'; + bulletPoint.style.color = '#00aaff'; + bulletPoint.setAttribute("title", "MCQ"); + // bulletPoint.textContent = '\u2022'; + nodeDiv.appendChild(bulletPoint); + + var splitedId = nodeDataId.split("_")[1]; + RawID = 'removeAndCloneQroupQuestion_'+splitedId; + } + + var QuestionID = document.getElementById(RawID) + console.log(QuestionID) + const questionLink = document.createElement('a'); questionLink.href = '#' + nodeDataId; + + // Attach the scroll function to the hyperlinks + questionLink.addEventListener('click', function(e) { + e.preventDefault(); // Prevent the default behavior of the link + const targetId = this.getAttribute('href').substring(1); // Get the target element's ID + scrollToElement(targetId); + }); questionLink.style.color = '#740fd6'; + + if(nodeDataType == 'text') + { + questionLink.setAttribute("title", "Descriptive"); + }else if(nodeDataType == 'text'){ + questionLink.setAttribute("title", "MCQ"); + + } + + QuestionID.addEventListener('click', function () { + if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) { + currentlyHighlightedElement.style.fontWeight = 'normal'; + } + if (currentlyHighlightedElement === questionLink) { + questionLink.style.fontWeight = questionLink.style.fontWeight === 'bold' ? 'normal' : 'bold'; + } else { + questionLink.style.fontWeight = 'bold'; + currentlyHighlightedElement = questionLink; + } + }); questionLink.addEventListener('click', function () { if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) { currentlyHighlightedElement.style.fontWeight = 'normal'; @@ -160,6 +247,14 @@ function navpane() { const groupTitleId = nodeData.question_group_id; groupTitleDiv.setAttribute('data-id', groupTitleId); groupTitleDiv.className = 'question-group'; + + console.log(groupTitleId); + + var splitedGroupId = groupTitleId.split("_")[3]; + var SplitedGroupRawID = 'QuestionGroupButtons_'+splitedGroupId; + var GroupBoxID = document.getElementById(SplitedGroupRawID); + console.log(GroupBoxID); + // Check if the group should be initially expanded based on expandedSections if (expandedSections.includes(groupTitleId)) { @@ -207,6 +302,13 @@ function navpane() { const groupQuestionLink = document.createElement('a'); groupQuestionLink.href = '#' + groupTitleId; + + // Attach the scroll function to the hyperlinks + groupQuestionLink.addEventListener('click', function(e) { + e.preventDefault(); // Prevent the default behavior of the link + const targetId = this.getAttribute('href').substring(1); // Get the target element's ID + scrollToElement(targetId); + }); groupQuestionLink.style.color = '#740fd6'; groupQuestionLink.addEventListener('click', function () { @@ -221,6 +323,18 @@ function navpane() { currentlyHighlightedElement = groupQuestionLink; } }); + GroupBoxID.addEventListener('click', function () { + if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== groupQuestionLink) { + currentlyHighlightedElement.style.fontWeight = 'normal'; + } + + if (currentlyHighlightedElement === groupQuestionLink) { + groupQuestionLink.style.fontWeight = groupQuestionLink.style.fontWeight === 'bold' ? 'normal' : 'bold'; + } else { + groupQuestionLink.style.fontWeight = 'bold'; + currentlyHighlightedElement = groupQuestionLink; + } + }); if (nodeData.group_title.length > 20) { groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..'); @@ -257,4 +371,12 @@ function navpane() { }); } }); + } + + // Function to scroll to the specified element with smooth behavior + function scrollToElement(elementId) { + const element = document.getElementById(elementId); + if (element) { + element.scrollIntoView({ behavior: "smooth", block: "center" }); + } } \ No newline at end of file diff --git a/style.css b/style.css index 2872b15..ae3d022 100644 --- a/style.css +++ b/style.css @@ -3325,7 +3325,7 @@ a.main_sticky { .type1-switch{ /* margin-left: 535px; */ - text-align: right; + text-align: left; width: 100%; position: relative; } @@ -3547,7 +3547,21 @@ input:disabled { cursor: pointer; } +.checkbox{ + width: 14px; + height: 14px; + float: right; + margin-right: 5px; + margin-top: 5px; +} +.math{ + font-weight: 500; +} +.mathQuestions{ + font-weight: 500; + float: right; +} diff --git a/xml2/Monthly Question Paper.xml b/xml2/Monthly Question Paper.xml deleted file mode 100644 index fa39abe..0000000 --- a/xml2/Monthly Question Paper.xml +++ /dev/null @@ -1 +0,0 @@ -75Fj5Ddz4Dp3sKeXGmtZ8w==Umm8RLUL1rO/tnNUIzzK+AzvH4qzEuRgO6ZiCTaggqs1nqsQRW5Om5R5Y2DavqVTOrUltHzFDMQqnD/kUN1yw4MsMUqqpXquvC2HC2VAYjbK3ti2MXm4Gc4+CpJWAY644VvJhLAqhuzNamTTcBzx2WkI6tpHdVhhIgZitq/hxlLIfVxNRunTzv5ck2aPWPop5ZHzz5bzZ/c8Sk5n2apSKJZtNBPs7YYYsR9J14KdcUT4WTYchNYCbW6PTtOZufszH9Hs0Cc+qY+JKaJsZyDpX5KZvAuryjESauAtPzvtm057M0YqYcCnPdblauOazakE2jOzCqja+LnJaS5kxq79WAdWlE8YFEKDxog0m8puT/PyjJaKkvrDBvkqmZBNIm5/c/VywpGW9jyAMEihCYMxzb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2json.js b/xml2json.js index 57d3e61..e8a7d6a 100644 --- a/xml2json.js +++ b/xml2json.js @@ -1,7 +1,7 @@ function xml2json(xmlData) { // console.clear(); -console.log('xml to json converstion'); +// console.log('xml to json converstion'); // console.log(xmlData); function getAttributesOfXMLNode(node) @@ -32,7 +32,7 @@ function getQuestionsNodes(questionNode,type) 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; - + } else { @@ -54,11 +54,11 @@ function getQuestionsNodes(questionNode,type) { var tempChoiceobj = {}; tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue; - tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue; - tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].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); questionObj['answers'].push(tempChoiceobj); - } } } @@ -120,8 +120,8 @@ jsonObj['sections'] = []; sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes; - console.log(sectionsList); - console.log('no of sections:'+sectionsList.length); + // console.log(sectionsList); + // console.log('no of sections:'+sectionsList.length); for (let i = 0; i < sectionsList.length ;i++) { @@ -164,7 +164,7 @@ jsonObj['sections'] = []; } var jsonData = JSON.stringify(jsonObj); - console.log('Xml to Json Conversion '); + // console.log('Xml to Json Conversion '); // console.log(jsonData); // console.log(jsonObj); jsonToHtml(jsonObj); diff --git a/xml2json_for_Questionpaper_preview.js b/xml2json_for_Questionpaper_preview.js index cc53c8d..bc7cada 100644 --- a/xml2json_for_Questionpaper_preview.js +++ b/xml2json_for_Questionpaper_preview.js @@ -54,7 +54,7 @@ function getQuestionsNodes(questionNode,type) { var tempChoiceobj = {}; tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue; - tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue; + tempChoiceobj['choice_name'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : ""); tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : ""); // console.log(tempChoiceobj); questionObj['answers'].push(tempChoiceobj);