diff --git a/QuestionPaperPreview.js b/QuestionPaperPreview.js index e497d96..1153849 100644 --- a/QuestionPaperPreview.js +++ b/QuestionPaperPreview.js @@ -101,6 +101,25 @@ function QuestionPaperPreview(jsonData){ var sectionMark = `

Marks: ${section.section_marks}

`; } + + var displayMarks = section.section_display_marks; + if (displayMarks === 'false') { + var parser = new DOMParser(); + var doc = parser.parseFromString(sectionMark, 'text/html'); + var questionMarkElement = doc.body.firstChild; + questionMarkElement.setAttribute('hidden', 'hidden'); + sectionMark =questionMarkElement.outerHTML + + + var doc = parser.parseFromString(sectionAttempt, 'text/html'); + var questionMarkElement = doc.body.firstChild; + questionMarkElement.style.marginRight = '106px'; + console.log(questionMarkElement); + sectionAttempt =questionMarkElement.outerHTML + + } + + const sectionDescriptio = section.section_description; const sectionDescription = sectionDescriptio.replaceAll('

', '

'); // const questions = section.questions; @@ -127,6 +146,8 @@ function QuestionPaperPreview(jsonData){ var questionIndentation = " ".repeat(depth2); var dataa =data.questions; dataa.forEach((question, index) =>{ + + var currentSno = parentSno + (index + 1) + '.'; var temp_sno= currentSno.slice(0,-1) @@ -147,7 +168,6 @@ function QuestionPaperPreview(jsonData){ var GroupQuestionTilteAlign = 0; if (question.group_title) { - // console.log(question); let cleanedTex = question.question_id.replace(/\s+/g, ' ').trim(); let cleanedText=cleanedTex.replace('

','').replace('

','') var question_id_length =cleanedText.length; @@ -173,7 +193,6 @@ function QuestionPaperPreview(jsonData){ // const questionId =`

${cleanedText})

` const questionId =cleanedText - // console.log(questionId); const questionGroupSetP = `${question.group_title}`; const questionGroupmodify =questionGroupSetP.replaceAll('

', `

`) @@ -190,6 +209,17 @@ function QuestionPaperPreview(jsonData){ var questionGroupMark = `

Marks : ${question.group_marks}

` } + var displayMarks = question.group_display_marks; + if (displayMarks === 'false') { + var parser = new DOMParser(); + var doc = parser.parseFromString(questionGroupMark, 'text/html'); + var questionMarkElement = doc.body.firstChild; + questionMarkElement.setAttribute('hidden', 'hidden'); + questionGroupMark =questionMarkElement.outerHTML + + } + + const questionGroupDescriptio = question.group_description; const questionGroupDescription = questionGroupDescriptio.replaceAll('

', '

') @@ -209,7 +239,7 @@ function QuestionPaperPreview(jsonData){ questionPaper += `

${questionGroupDescription}
`; depth2++ } else if (question.question) { - console.log(question); + let cleanedTex = question.questionId.replace(/\s+/g, ' ').trim(); let cleanedText=cleanedTex.replace('

','').replace('

','') var question_id_length =cleanedText.length; @@ -240,12 +270,21 @@ function QuestionPaperPreview(jsonData){ const questionDescriptio = question.question_description; const questionDescription = questionDescriptio.replaceAll('

', '

') const mathstatus = question.is_math_enabled; - if (question.marks == 0 || question.marks == '') { + if (question.marks == 0 || question.marks == '' ) { var questionMark = `

`; } else { var questionMark = `

Marks :${question.marks}

`; } + var displayMarks =question.display_marks + + if (displayMarks === 'false') { + var parser = new DOMParser(); + var doc = parser.parseFromString(questionMark, 'text/html'); + var questionMarkElement = doc.body.firstChild; + questionMarkElement.setAttribute('hidden', 'hidden'); + questionMark =questionMarkElement.outerHTML + } // console.log(questionMark); const multipleAnswer =question.question_sub_type; @@ -262,19 +301,29 @@ function QuestionPaperPreview(jsonData){ if (question.question_type === "group") { var answers = question.answers; + var answerId =question.question_id; var choisealgin =25 - var currentSno_length1 =currentSno.length-(currentSno.length/2) + // var currentSno_length1 =currentSno.length-(currentSno.length/2) + var currentSno_length1 =question_id_length + console.log(answerId); + // console.log(currentSno_length1); if (currentSno_length1 == 1) { choisealgin =26 } else if (currentSno_length1 == 2) { - choisealgin =40 + choisealgin =25 }else if(currentSno_length1 == 3){ - choisealgin =55 + choisealgin =33 }else if(currentSno_length1 == 4) { - choisealgin =70 + choisealgin =41 } else if(currentSno_length1 == 5) { - choisealgin =84 + choisealgin =46 + }else if(currentSno_length1 == 6) { + choisealgin =46 + }else if(currentSno_length1 == 7) { + choisealgin =46 + }else if(currentSno_length1 == 8) { + choisealgin =68 } const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options diff --git a/QuestionPreview.html b/QuestionPreview.html index 84398e9..e369721 100644 --- a/QuestionPreview.html +++ b/QuestionPreview.html @@ -209,7 +209,7 @@ } #sectionAttempt{ display: inline-flex; - margin-right: 40px; + margin-right: 15px; float: right; margin-top:-27px; } diff --git a/addform.html b/addform.html index da06f47..e759839 100644 --- a/addform.html +++ b/addform.html @@ -377,7 +377,8 @@ width: 15rem; } #questionPaper{ - margin-top:65px; + /* margin-top:65px; */ + margin-top: 16px; overflow-y: auto; overflow-x: clip; max-height: 532px; @@ -1275,7 +1276,7 @@ var toolbarOptions = [ - + @@ -1529,7 +1530,9 @@ var previewbutton = document.getElementById("editPreview"); if (submitButton) { submitButton.addEventListener("click", function() { FileName = popupInput.value; - FileName += ".xml" + if (FileName) { + FileName += ".xml" + } if(FileName){ var anchorElement = document.getElementById("editPreview"); if (anchorElement) { @@ -1657,7 +1660,6 @@ function saveFile(flag=0) { json2xml(); if(FileName == "" || FileName == null ){ setTimeout(promptBox, 1000); - }else{ const newFileName = FileName.split(".")[0]; @@ -1761,30 +1763,67 @@ var toolbarOptions2 = [ ['image'], ]; -var quill = new Quill('#Question_title', { - theme: 'snow', - modules: { - imageResize:{ - displaySize:true, - modules: [ 'Resize', 'DisplaySize', 'Toolbar' ], - }, - toolbar: { - container: toolbarOptions, - handlers: { - table: function () { - // this.quill.getModule('table').insert(); - this.quill.getModule('table').insert(); - }, - }, - }, - table: { - cellSelectionOnClick: true, - // Other options for quill1-table module... - }, - keyboard: keyboardOptions, - }, -}); +class CustomQuill { + constructor(elementId) { + this.quillElement = document.getElementById(elementId); + this.initializeQuill(); + } + + initializeQuill() { + this.quill = new Quill('#' + this.quillElement.id , { + theme: 'snow', + modules: { + imageResize:{ + displaySize:true, + modules: [ 'Resize', 'DisplaySize', 'Toolbar' ], + }, + toolbar: { + container: toolbarOptions, + handlers: { + table: function () { + this.quill.getModule('table').insert(); + }, + }, + }, + table: { + cellSelectionOnClick: true, + }, + keyboard: keyboardOptions, + }, + }); + } +} + +var customQuill = new CustomQuill('Question_title'); + + + + +// var quill = new Quill('#Question_title', { +// theme: 'snow', +// modules: { +// imageResize:{ +// displaySize:true, +// modules: [ 'Resize', 'DisplaySize', 'Toolbar' ], +// }, +// toolbar: { +// container: toolbarOptions, +// handlers: { +// table: function () { +// // this.quill.getModule('table').insert(); + +// this.quill.getModule('table').insert(); +// }, +// }, +// }, +// table: { +// cellSelectionOnClick: true, +// // Other options for quill1-table module... +// }, +// keyboard: keyboardOptions, +// }, +// }); @@ -2882,10 +2921,10 @@ function groupQuestion(question_id = false, section_id = false , group_question_