From 702e74496be66f06571cf942a58e3168a9bb482d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 25 Jan 2024 12:54:24 +0530 Subject: [PATCH] QuestionPaperTitle_Mandatory : RV --- addform.html | 120 ++++++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 55 deletions(-) diff --git a/addform.html b/addform.html index f3d05d5..774c581 100644 --- a/addform.html +++ b/addform.html @@ -1473,13 +1473,10 @@ $('#Jodit_RTE_workarea').focus(function() { var inputElement2 = document.getElementById('questionTitleValue'); var innerDivElement = inputElement2.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg'); innerDivElement.addEventListener("keyup", function(event) { - - // console.log('JoditworkPlaceId : ', event.target.id); - // console.log('content : ',innerDivElement.innerHTML); - json2nav(); clearSidebarWrapper(); navpane(); +check_Remove_Empty_Question('Question_title'); }); @@ -1488,6 +1485,7 @@ clearSidebarWrapper(); navpane(); html2json(); + }) @@ -1515,6 +1513,8 @@ check_Remove_Empty_Question('Max_Marks'); + + //The Show function for LOADER $("#overlay").show(); @@ -1696,7 +1696,6 @@ document.addEventListener('DOMContentLoaded', function () { function editPreview() { var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION'); - console.log(title_id) var count = "";//XmlPath get from .env // const decode = require('./decode'); if(title_id !== '' && title_id !== null){ @@ -1944,9 +1943,10 @@ var questionIncrement = 1; $(document).ready(function(){ -array_of_Id.push('Max_Marks') +array_of_Id.push('Max_Marks'); +array_of_Id.push('Question_title') const arrayString = JSON.stringify(array_of_Id); -collect_Empty_Question_Id(arrayString, 'Max_Marks'); +collect_Empty_Question_Id(arrayString); }) @@ -2234,7 +2234,6 @@ function addSection(title = false, description = false, random_no = false, secti var fileInputId2 = 'fileInput2_' + sectionRandomID; const fileInput2 = document.getElementById(fileInputId2); - console.log(fileInput2) fileInput2.click(); }, }, @@ -2278,7 +2277,6 @@ function addSection(title = false, description = false, random_no = false, secti const idParts = event.target.id.split('_')[1]; const subSectionTitleRTCID = 'sectionTitleRtc_'+idParts - console.log(subSectionTitleRTCID); rtc_hide_and_show(subSectionTitleRTCID); }); @@ -2295,7 +2293,6 @@ function addSection(title = false, description = false, random_no = false, secti const idParts2 = event.target.id.split('_')[1]; const descriptionRTCID = 'sectionDescriptionRtc_'+idParts2 - console.log(descriptionRTCID); rtc_hide_and_show(descriptionRTCID); }); @@ -2627,7 +2624,6 @@ function addQuestionGroup(idObj) var fileInputId2 = 'fileInput2_' + QuestionGroup_ID; const fileInput2 = document.getElementById(fileInputId2); - console.log(fileInput2) fileInput2.click(); }, }, @@ -2670,7 +2666,6 @@ function addQuestionGroup(idObj) const idParts = event.target.id.split('_')[1]; const subSectionTitleRTCID = 'subSectionTitleRtc_'+idParts - console.log(subSectionTitleRTCID); rtc_hide_and_show(subSectionTitleRTCID); }); @@ -2687,7 +2682,6 @@ function addQuestionGroup(idObj) const idParts2 = event.target.id.split('_')[1]; const descriptionRTCID = 'subSectionDescriptionRtc_'+idParts2 - console.log(descriptionRTCID); rtc_hide_and_show(descriptionRTCID); }); @@ -3077,7 +3071,7 @@ function groupQuestion(question_id = false, section_id = false , group_question_ var idToAdd = 'textQuestiontitleMath_' + addChoiceAreaId; var arrayVal = JSON.parse(localStorage.getItem('JSON_FOR_EMPTY_QUESTION')) || []; - console.log('Original Array:', arrayVal); + // console.log('Original Array:', arrayVal); var newArray = arrayVal.filter(function(id) { return id !== idToRemove; @@ -3087,8 +3081,8 @@ function groupQuestion(question_id = false, section_id = false , group_question_ localStorage.setItem('JSON_FOR_EMPTY_QUESTION', JSON.stringify(newArray)); check_Remove_Empty_Question(idToAdd); - console.log('Modified Array:', newArray); - console.log('Updated local storage:', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); + // console.log('Modified Array:', newArray); + // console.log('Updated local storage:', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); // var id = 'textQuestiontitle_math_' + addChoiceAreaId; @@ -3102,7 +3096,7 @@ function groupQuestion(question_id = false, section_id = false , group_question_ var idToAdd2 = 'textQuestionName_' + addChoiceAreaId; var arrayVal2 = JSON.parse(localStorage.getItem('JSON_FOR_EMPTY_QUESTION')) || []; - console.log('Original Array:', arrayVal2); + // console.log('Original Array:', arrayVal2); var newArray2 = arrayVal2.filter(function(id) { return id !== idToRemove2; @@ -3112,8 +3106,8 @@ function groupQuestion(question_id = false, section_id = false , group_question_ localStorage.setItem('JSON_FOR_EMPTY_QUESTION', JSON.stringify(newArray2)); check_Remove_Empty_Question(idToAdd2); - console.log('Modified Array 2 :', newArray2); - console.log('Updated local storage 2 :', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); + // console.log('Modified Array 2 :', newArray2); + // console.log('Updated local storage 2 :', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); } }); @@ -3183,7 +3177,6 @@ const editor2 = Jodit.make("#"+typetwoQuestionSubtitle, { var fileInputId2 = 'fileInput2_' + addChoiceAreaId; const fileInput2 = document.getElementById(fileInputId2); - console.log(fileInput2) fileInput2.click(); }, }, @@ -3272,7 +3265,6 @@ fileInput3.addEventListener("change", () => { const idParts2 = event.target.id.split('_')[1]; const titleRTCID = 'MCQTitleRtc_'+idParts2 - console.log(titleRTCID); rtc_hide_and_show(titleRTCID); }); @@ -3287,9 +3279,9 @@ fileInput3.addEventListener("change", () => { $(Question_description_workarea).focus(function(event) { const idParts2 = event.target.id.split('_')[1]; - console.log(idParts2); + // console.log(idParts2); const descriptionRTCID = 'MCQDescriptionRtc_'+idParts2; - console.log(descriptionRTCID); + // console.log(descriptionRTCID); rtc_hide_and_show(descriptionRTCID); }); @@ -3307,7 +3299,7 @@ fileInput3.addEventListener("change", () => { const idParts2 = event.target.id.split('_')[1]; const choiceRTCID = 'fixedChoiceRtc_'+idParts2 - console.log(choiceRTCID); + // console.log(choiceRTCID); rtc_hide_and_show(choiceRTCID); }); @@ -3710,7 +3702,6 @@ $(newChoiceDeleteButtonId).on('click', function() { var fileInputId = 'fileInput_'+text_field_created_time+rnd_no; const fileInput = document.getElementById(fileInputId); - console.log(fileInput) fileInput.click(); }, }, @@ -3719,7 +3710,6 @@ $(newChoiceDeleteButtonId).on('click', function() { var chat_Div = $(newChoiceTextField); var chat_previousDiv = chat_Div.prev(); - console.log() var addChoiceValueId = 'addChoiceValue_'+text_field_created_time+rnd_no chat_previousDiv.attr("id", addChoiceValueId); @@ -3752,7 +3742,6 @@ $(newChoiceDeleteButtonId).on('click', function() { const idParts = event.target.id.split('_')[1]; const titleRTCID = 'newChoiceTextFieldToolbar_'+idParts - console.log(titleRTCID); rtc_hide_and_show(newchoiceFieldId); }); @@ -3761,7 +3750,6 @@ $(newChoiceDeleteButtonId).on('click', function() { var newChoiceId = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no); var choicePreviousDiv = document.getElementById(addChoiceValueId); - console.log(choicePreviousDiv) choiceWorkField = choicePreviousDiv.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg'); newChoiceId.style.setProperty('display', 'none', 'important'); if(focusval !== false) @@ -4050,7 +4038,7 @@ array_of_Id.push('textQuestionName_' + addTextQuestionId); var idToAdd = 'textQuestiontitleMath_' + addTextQuestionId; var arrayVal = JSON.parse(localStorage.getItem('JSON_FOR_EMPTY_QUESTION')) || []; - console.log('Original Array:', arrayVal); + // console.log('Original Array:', arrayVal); var newArray = arrayVal.filter(function(id) { return id !== idToRemove; @@ -4060,8 +4048,8 @@ array_of_Id.push('textQuestionName_' + addTextQuestionId); localStorage.setItem('JSON_FOR_EMPTY_QUESTION', JSON.stringify(newArray)); check_Remove_Empty_Question(idToAdd); - console.log('Modified Array:', newArray); - console.log('Updated local storage:', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); + // console.log('Modified Array:', newArray); + // console.log('Updated local storage:', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); } else { @@ -4069,7 +4057,7 @@ array_of_Id.push('textQuestionName_' + addTextQuestionId); var idToAdd2 = 'textQuestionName_' + addTextQuestionId; var arrayVal2 = JSON.parse(localStorage.getItem('JSON_FOR_EMPTY_QUESTION')) || []; - console.log('Original Array:', arrayVal2); + // console.log('Original Array:', arrayVal2); var newArray2 = arrayVal2.filter(function(id) { return id !== idToRemove2; @@ -4079,8 +4067,8 @@ array_of_Id.push('textQuestionName_' + addTextQuestionId); localStorage.setItem('JSON_FOR_EMPTY_QUESTION', JSON.stringify(newArray2)); check_Remove_Empty_Question(idToAdd2); - console.log('Modified Array 2 :', newArray2); - console.log('Updated local storage 2 :', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); + // console.log('Modified Array 2 :', newArray2); + // console.log('Updated local storage 2 :', localStorage.getItem('JSON_FOR_EMPTY_QUESTION')); } }); @@ -4196,7 +4184,6 @@ fileInput2.addEventListener("change", () => { const idParts = event.target.id.split('_')[1]; const titleRTCID = 'textTitleRtc_'+idParts - console.log(titleRTCID); rtc_hide_and_show(titleRTCID); }); @@ -4213,7 +4200,6 @@ fileInput2.addEventListener("change", () => { const idParts2 = event.target.id.split('_')[1]; const descriptionRTCID = 'textDescriptionRtc_'+idParts2 - console.log(descriptionRTCID); rtc_hide_and_show(descriptionRTCID); @@ -4394,7 +4380,6 @@ var tempQuestionTitle = inputElement.innerHTML; $(innerDivElement).keyup(function(event) { - console.log('1'); json2nav(); clearSidebarWrapper(); navpane(); @@ -4574,6 +4559,7 @@ function check_Empty_Question() var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION'); // console.log('check_Empty_Question JSON_FOR_EMPTY_QUESTION', title_id); var attrId = ''; + var questionpapertitleid = 'Question_title'; if (title_id) { var parsedArray = JSON.parse(title_id); // console.log(parsedArray); @@ -4615,11 +4601,17 @@ function check_Empty_Question() } } } - if(attrId === '


') + if(attrId === '


' || attrId === '



') { // console.log("Check empty if"); - scrollToElementWithoutLink(Id); - document.getElementById(Id).focus(); + if(Id === 'Question_title'){ + var elementID = document.getElementById('Question_title_workarea') + elementID.scrollIntoView({ behavior: "smooth", block: "center" }); + elementID.focus(); + }else{ + scrollToElementWithoutLink(Id); + document.getElementById(Id).focus(); + } } else if(attrId == ''){ // console.log("Check empty else if"); @@ -4634,8 +4626,14 @@ function check_Empty_Question() } else{ // console.log("Check empty Last else"); - scrollToElementWithoutLink(Id); - document.getElementById(Id).focus(); + if(Id === 'Question_title'){ + var elementID = document.getElementById('Question_title_workarea') + elementID.scrollIntoView({ behavior: "smooth", block: "center" }); + elementID.focus(); + }else{ + scrollToElementWithoutLink(Id); + document.getElementById(Id).focus(); + } } var element = document.getElementById(Id) if (element != null) { @@ -4682,24 +4680,36 @@ function check_Remove_Empty_Question(IdToRemove , DeleteElement=0) { attrId = focus; } } -// console.log('attrId : ', attrId); - var parsedArray = []; - if (count !== 0) { + // console.log('attrId : ', attrId); + + var parsedArray = []; + + if (count !== 0) { + + parsedArray = JSON.parse(title_id); + // console.log('attrId 2 : ', attrId); - // console.log(parsedArray); + if(attrId === '' || attrId === '



' || attrId === '


') { + + // alert('1'); + if (!parsedArray.includes(IdToRemove)) { + var newArray = parsedArray.push(IdToRemove); + } + const newArrayString = JSON.stringify(parsedArray); + collect_Empty_Question_Id(newArrayString); + + } else{ + + // alert('2'); for (let i = 0; i < parsedArray.length; i++) { const Id = parsedArray[i]; - const element = document.getElementById(Id); - // console.log(element); - if (element) { - // console.log("Check empty Last else"); + if (element) { if (DeleteElement != 1) { - const attrId = element.innerHTML; } @@ -4727,15 +4737,15 @@ function check_Remove_Empty_Question(IdToRemove , DeleteElement=0) { var newArray = parsedArray.push(IdToRemove); } const newArrayString = JSON.stringify(newArray); - // console.log('newArrayString : ', newArray) collect_Empty_Question_Id(newArrayString); } } } - const newArrayString = JSON.stringify(parsedArray); - collect_Empty_Question_Id(newArrayString); + const newArrayString = JSON.stringify(parsedArray); + collect_Empty_Question_Id(newArrayString); + } } - else if(attrId == '' || attrId == '


') { + else if(attrId === '' || attrId == '


') { // console.log('check empty question : ', attrId); if (!parsedArray.includes(IdToRemove)) { var newArray = parsedArray.push(IdToRemove);