diff --git a/addform.html b/addform.html index 62f50c0..09e02b2 100644 --- a/addform.html +++ b/addform.html @@ -327,6 +327,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; +} */ + + + @@ -581,7 +600,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(); } @@ -705,9 +724,7 @@ function loadXML(xmlFileName) { // Function for Save the XML File function saveFile() { - console.log("html2json"); html2json(); - console.log("json2xml"); json2xml(); if(FileName == "" || FileName == null ){ @@ -824,6 +841,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(); @@ -861,16 +880,16 @@ function addSection(title = false, description = false, random_no = false, secti
@@ -891,26 +910,26 @@ function addSection(title = false, description = false, random_no = false, secti - +
Display Marks - -
-
-
-
Attempt Any :
+
+ +
+
+
Attempt Any :
-
-
-
-
Marks :
- + +
+
+
Marks :
+
@@ -1420,7 +1439,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({ @@ -1431,45 +1450,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 = ""; @@ -1480,28 +1470,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 = ""; @@ -1512,18 +1491,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'); @@ -1543,16 +1519,16 @@ function groupQuestion( question_id = false, section_id = false , group_question
@@ -1593,6 +1569,7 @@ function groupQuestion( question_id = false, section_id = false , group_question
${questionDescription ? questionDescription : ''}
${mathEnabled == 'true' ? questionDescription : ''} + MATH 
@@ -1600,19 +1577,15 @@ function groupQuestion( question_id = false, section_id = false , group_question
-
+
${Choice ? Choice[0].choice_name : ""}
${Choice ? Choice[0].choice_name : ""}
-         +   MATH
-
- -
- -
+
@@ -1622,36 +1595,31 @@ function groupQuestion( question_id = false, section_id = false , group_question
-
-
+
+ + +
+
Marks :
- - +
`; @@ -1668,13 +1636,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) { @@ -1700,6 +1661,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; @@ -1707,6 +1669,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) @@ -1716,24 +1679,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(); } @@ -1741,54 +1721,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(); }) + + @@ -1869,77 +1834,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', @@ -2007,13 +1901,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); @@ -2029,8 +1928,8 @@ $(inputElement).keyup(function(event) { var choiceQuestionMarkField = 'Choice_Question_Marks_Id_' + addChoiceAreaId; $('#'+choiceQuestionMarkField).keyup(function() { - json2nav() - markCalculation() + json2nav(); + markCalculation(); }); @@ -2044,9 +1943,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 = ""; @@ -2058,550 +1956,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 @@ -2628,9 +2451,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); } @@ -2643,8 +2470,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 { @@ -2729,7 +2558,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 c848ff0..9a1060e 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/xml2json.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);