SECTIONDELETEFUNCTION CHOICEQUESTIONPREVIEW: AADHAVAN

This commit is contained in:
aadhavan valli 2024-01-19 09:41:05 +05:30
parent a580c841f6
commit ce6d38d329
6 changed files with 97 additions and 63 deletions

View File

@ -341,7 +341,7 @@ function QuestionPaperPreview(jsonData){
if (multipleAnswer == 'false') {
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input class="optionSelectArea" type="radio" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
}else{
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input class="optionSelectArea" type="checkbox" name="answer" value="A"> <p class="ChoiceOption">${answerA.padEnd(10)}</p></div>`;
questionPaper += `<div class="text-option-align" style="margin-left:${choisealgin}px"><input class="optionSelectArea" type="checkbox" name="answer" value="A"> <p class="ChoiceOptionMultiple">${answerA.padEnd(10)}</p></div>`;
}
}
}

View File

@ -53,6 +53,9 @@
<style>
.textGroup{
margin-top:30px;
}
/* .ChoiceOption{
position: absolute;
margin-top: 28px !important;
@ -83,6 +86,14 @@
margin-top: 22px;
display: flex;
}
.ChoiceOptionMultiple{
align-items: center;
display: inline;
/* margin-left: -6px !important; */
position: absolute;
margin-top: 28px !important;
margin-left: -30px !important;
}
.ChoiceOption{
/* display: flex; */
align-items: center;
@ -275,9 +286,18 @@
.MathJax.CtxtMenu_Attached_0{
display: contents !important;
}
.text-qus-align{padding-right: 62px; margin-top: 37px; inline-size: 790px;}
.text-qus-align{
padding-right: 62px;
/* margin-top: 37px; */
inline-size: 790px;
display:table-footer-group;
/* position: relative; */
/* top:30px */
}
.text-qus-align p{ margin:0; }
.text-des{ margin-left: 20px;margin-top: 10px; inline-size: 790px;} /* Change there aadhavan top-6px*/
.text-des{ margin-left: 20px;
/* margin-top: 23px; */
inline-size: 790px;} /* Change there aadhavan top-6px*/
.text-option-align{display:flow-root;margin-top: -2%;margin-left: 45px; inline-size: 790px; } /* Change there aadhavan 10px*/
.text-option-align p{ margin:0; text-wrap: balance;}
/* #sectionTitle {border-top: 2px solid gray
@ -318,6 +338,7 @@
text-wrap: wrap;
/* display: inline-flex; */
/* margin-right: 10px; */
margin-bottom: -40px;
}
.question-Description{
inline-size: 660px;
@ -339,8 +360,8 @@
}
.group-descrip{
position: relative;
top: 15px;
margin-bottom: -20px;
top: 8px;
margin-bottom: -26px;
inline-size: 790px;
}
/* p.question_Text:not(:first-of-type) {

View File

@ -1298,27 +1298,16 @@ $(document).ready(function(){
var toolbar = "bold,italic,underline,strikethrough,|,superscript,subscript,|,table,align,";
var toolbar2 = "bold,italic,underline,strikethrough,|,superscript,subscript,|,align,";
const editor = Jodit.make("#Question_title", {
buttons:toolbar,
buttons:toolbar2,
showPlaceholder: false,
toolbarButtonSize: 'small',
showPlaceholder: false,
toolbarAdaptive:false,
saveHeightInStorage: true,
minHeight: 40,
extraButtons: [
{
name: 'info',
iconURL: 'assets/images/image-solid.svg', // Replace with the actual icon URL
tooltip: 'Insert Image',
exec: function (editor) {
const fileInput = document.getElementById("Question_title_fileInput");
fileInput.click();
},
},
],
});
var chat_Div = $('#Question_title');
@ -1342,24 +1331,14 @@ fileInput.addEventListener("change", () => {
const editor2 = Jodit.make("#Question_description", {
buttons: toolbar,
buttons: toolbar2,
showPlaceholder: false,
toolbarButtonSize: 'small',
showPlaceholder: false,
toolbarAdaptive:false,
saveHeightInStorage: true,
minHeight: 40,
extraButtons: [
{
name: 'info',
iconURL: 'assets/images/image-solid.svg', // Replace with the actual icon URL
exec: function (editor2) {
const fileInput2 = document.getElementById("Question_description_fileInput");
fileInput2.click();
},
},
],
});
@ -1492,7 +1471,7 @@ $("#overlay").show();
$('#workarea_math').click(function(){
// console.log('called');
$('#workarea_math').css('margin-bottom', '240px');
$('#workarea_math').css('margin-bottom', '350px');
localStorage.setItem('workAreaMath', true);
});
@ -1588,7 +1567,6 @@ function clearSidebarWrapper() {
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);
if (swalButton) {
swalButton.click();
}
@ -1821,7 +1799,6 @@ function loadXML(xmlFileName) {
// Function for Save the XML File
function saveFile(flag=0) {
// console.log("flag = ", flag);
console.log("SaveFile");
var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION');
console.log('JSON_FOR_EMPTY_QUESTION', title_id);
@ -1830,7 +1807,7 @@ function saveFile(flag=0) {
{
var parsedArray = JSON.parse(title_id);
var count = parsedArray.length;
console.log('count - ' + count)
// console.log('count - ' + count)
}
else
{
@ -1851,11 +1828,9 @@ function saveFile(flag=0) {
const newFileName = FileName.split(".")[0];
//if 1 it is used for re-order and redirect to the qn paper itself
if (flag==1){
// alert("reorder True")
savexml(newFileName,reorder=true);
//if 0 it is used as nrml save which will redierect to dashboard
}else{
// alert("reorder Flase")
savexml(newFileName);
}
@ -2274,8 +2249,8 @@ function addSection(title = false, description = false, random_no = false, secti
innerDivElement.addEventListener("keyup", function(event) {
console.log('JoditworkPlaceId : ', event.target.id)
console.log('content : ',document.getElementById(sectionID).innerHTML)
<!-- console.log('JoditworkPlaceId : ', event.target.id) -->
<!-- console.log('content : ',document.getElementById(sectionID).innerHTML) -->
json2nav();
clearSidebarWrapper();
@ -4498,7 +4473,7 @@ function collect_Empty_Question_Id(arrayString, ID) {
//find the empty question
function check_Empty_Question()
{
console.log("Check Empty Enter");
// console.log("Check Empty Enter");
var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION');
// console.log('check_Empty_Question JSON_FOR_EMPTY_QUESTION', title_id);
if (title_id) {
@ -4507,9 +4482,14 @@ function check_Empty_Question()
parsedArray.forEach(function(Id, index,array) {
if (index === array.length - 1) {
var idclass= document.getElementById(Id).className;
var idclass= document.getElementById(Id);
// console.log(idclass == "QuestionTextIdSet SerialNo");
if ( idclass === 'QuestionTextIdSet SerialNo' || idclass === 'QuestionsGroupIdset SerialNo' || idclass === 'QuestionChoiceId SerialNo' ) {
if (idclass == '' || idclass == null) {
check_Remove_Empty_Question(Id,1)
attrId ="1";
} else if ( idclass === 'QuestionTextIdSet SerialNo' || idclass === 'QuestionsGroupIdset SerialNo' || idclass === 'QuestionChoiceId SerialNo' ) {
attrId = document.getElementById(Id).innerHTML
}else if(idclass === 'multipleAnswerorNot'){
attrId ="";
@ -4517,9 +4497,17 @@ function check_Empty_Question()
Id ='ChoiceCorrectAnswer_'+remove;
}else {
var elementid = document.getElementById(Id);
const previousElement = elementid.previousElementSibling;
var focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
attrId = focus;
if(elementid.tagName == 'INPUT'){
}else{
const previousElement = elementid.previousElementSibling;
if (previousElement == null) {
attrId =elementid;
} else {
var focus = previousElement.querySelector('.jodit-workplace').querySelector('.jodit-wysiwyg').innerHTML;
attrId = focus;
}
}
}
if(attrId === '<p><br></p>')
{
@ -4531,14 +4519,22 @@ function check_Empty_Question()
// console.log("Check empty else if");
scrollToElementWithoutLink(Id);
document.getElementById(Id).focus();
}else if(attrId == '1'){
var anchorElement = document.getElementById("editPreview");
if (anchorElement) {
anchorElement.click();
// saveButton.click();
}
}
else{
// console.log("Check empty Last else");
scrollToElementWithoutLink(Id);
document.getElementById(Id).focus();
}
var ele = document.getElementById(Id)
ele.scrollIntoView({ behavior: "smooth", block: "center" });
var element = document.getElementById(Id)
if (element != null) {
element.scrollIntoView({ behavior: "smooth", block: "center" });
}
}
});
}
@ -4962,9 +4958,7 @@ function removeSection(RandomId, IndexValue) {
var element = document.getElementById('reorder_'+ RandomId);
var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV'));
var count = jsonData.sections.length;
// console.log(`Count of sections: ${count}`);
var count = jsonData.sections.length;
if(count > 1)
{
Swal.fire({
@ -4980,6 +4974,30 @@ function removeSection(RandomId, IndexValue) {
if (element) {
var sectionTitle= 'section_title_text_'+RandomId;
// jsonData.sections.forEach(function (section) {
// if (section.section_id == sectionTitle) {
// section.questions.forEach(function (question){
// if(question.question_Id){
// check_Remove_Empty_Question(question.question_Id,1)
// }else{
// groupQuestionLoop(question)
// }
// function groupQuestionLoop(groupQuestions){
// groupQuestions.questions.forEach(function(questionn){
// if(questionn.question_Id){
// check_Remove_Empty_Question(questionn.question_Id,1)
// }else{
// groupQuestionLoop(questionn)
// }
// })
// }
// })
// }
// })
check_Remove_Empty_Question(sectionTitle,1);
@ -5778,5 +5796,8 @@ setInterval(removeNonExistentIdseveryTime, 1000)
</body>
</html>

View File

@ -133,37 +133,28 @@ var draggedItem = null;
} else {
dragDropElementNextElement = dragDropElement.nextElementSibling;
dragDropElementNextElement.appendChild(dragStartElement);
insertElement(dragStartElement , dragDropElement)
insertElement(dragStartElement , dragDropElement, "after")
}
}
}
//Check Drop Element is Section
else if(dragDropElement.id.replace(/\d+/g, '') == "nav_section_title_"){
var dragDropElementChild = dragDropElement.nextElementSibling.firstChild;
if (dragDropElementChild) {
dragDropElementChild.parentNode.insertBefore(dragStartElement , dragDropElementChild);
insertElement(dragStartElement, dragDropElement);
} else {
if (dragStartElement.id.replace(/\d+/g, '') == "nav_draggedGroup_") {
var firstChild = dragStartElement.nextElementSibling;
dragDropElementChild = dragDropElement.nextElementSibling;
dragDropElementChild.appendChild(dragStartElement);
dragDropElementChild.appendChild(firstChild)
} else {
dragDropElementChild = dragDropElement.nextElementSibling;
dragDropElementChild.appendChild(dragStartElement);
insertElement(dragStartElement, dragDropElement);
}
}
}
//THis Entered in Text and Choice Question
else {
@ -189,7 +180,6 @@ var draggedItem = null;
}
}
//THis function is Replicate the Nav Pane Change
function insertElement(dragStartElement, dragDropElement, position){
var mainpaneSection = document.getElementById('addNewSection')
@ -250,7 +240,10 @@ var draggedItem = null;
groupQuestionAddTextChoice.parentNode.insertBefore(maindragStartElement , groupQuestionAddTextChoice)
} else {
var groupQuestionAdd = maindragDropElement.querySelector('.nested-sortable')
etest.appendChild(maindragStartElement)
console.log(groupQuestionAdd);
groupQuestionAdd.appendChild(maindragStartElement)
console.log(groupQuestionAdd);
alert("111")
// test.parentNode.insertBefore(maindragStartElement , test)
}
}

View File

@ -569,7 +569,6 @@ function navpane() {
// groupTitleDiv.appendChild(gripIcon);
const groupTitleId = nodeData.question_group_id;
console.log(groupTitleId);
const getNumberOnlyGroupTitleId = takeNumberOnly.takeNumberOnly(groupTitleId)
groupTitleDiv.setAttribute('data-id', groupTitleId);
groupTitleDiv.setAttribute('id', `nav_draggedGroup_${getNumberOnlyGroupTitleId}`);

View File

@ -15,7 +15,7 @@ function rtc_hide_and_show(rtcid) {
function add_button_hide_and_show(BtnID){
// console.log('show id :'+BtnID)
console.log('show id :'+BtnID)
var id = localStorage.getItem('btn');
var hideid = document.getElementById(id);
// console.log('hide id :' + id);