SOLVED CONFLICT-SV

This commit is contained in:
Sharath 2023-10-20 16:03:55 +05:30
commit f3a5bf6440
9 changed files with 382 additions and 236 deletions

View File

@ -72,9 +72,13 @@ function CheakQnType(question, questionIndex, depth,nested) {
}
}
let count =0
var count =0
var count1 =0
var romanNumerals = ["", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"];
function processQuestion(question, questionIndex, depth,nested) {
// console.log('question Data')
// console.log(question);
const questionTex = question.question;
const questionText = questionTex.replace('<p>', '<p id="question_Text">');
const questionDescription = question.question_description;
@ -83,15 +87,23 @@ function processQuestion(question, questionIndex, depth,nested) {
const multipleAnswer =question.question_sub_type; // this gives true or false to chaeck multiple answers or not
// Add appropriate indentation for nested questions
const questionIndentation = " ".repeat(depth + 1);
console.log(questionIndentation)
if (nested == 1) {// this adds the inside the questionGroup
count1++
questionPaper += `<div class="text-qus-align">${questionIndentation}${count}.${count1}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
count1++;
var romanNumeral=romanNumerals[count1];
questionPaper += `<div class="text-qus-choice">${questionIndentation}${romanNumeral}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
} else {
count++
questionPaper += `<div class="text-qus-align">${questionIndentation}${count}) ${convertToLatex(questionText, mathstatus)}${questionIndentation}</div><p id="question-mark">Marks :${questionMark}</p><div class="text-des">${convertToLatex(questionDescription, mathstatus)}</div>`;
}
console.log(questionPaper);
// If it's an MCQ question, add choices
// If it's an MCquestionText
if (question.question_type === "group") {
const answers = question.answers;
const alphabetOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // Define the alphabet options
@ -138,7 +150,7 @@ function GroupQuestion(question, questionIndex, depth) {
// Function to recursively convert JSON to a formatted question paper
function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionIndex = 1) {
const sections = data.sections;
console.log(sections);
// console.log(sections);
// Extract the heading information
const questionPaperTitle = data.question_paper_title;
const questionPaperDescription = data.question_paper_description;
@ -164,7 +176,7 @@ function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionI
const indentation = " ".repeat(depth);
// questionPaper += `${indentation}${sectionTitle}${sectionAttempt}${sectionMark}${indentation}${sectionDescription}`;
questionPaper += `${indentation}${modifiedSectionTitle}${sectionMark}${sectionAttempt}${indentation}${sectionDescription}`;
questionPaper += `${indentation}<hr id="horizontal">${modifiedSectionTitle}${sectionMark}${sectionAttempt}${indentation}${sectionDescription}`;
// Process each question in the section
@ -183,6 +195,6 @@ function convertJSONToQuestionPaper(data, depth = 0, sectionIndex = 1, questionI
// Call the function and display the formatted question paper
const formattedQuestionPaper = convertJSONToQuestionPaper(jsonData, 0, 1, 1);
const questionPaperElement = document.getElementById("questionPaper");
console.log(questionPaperElement);
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
}

View File

@ -49,18 +49,33 @@
<style>
hr{
height: 2px;
}
#horizontal:first-of-type{
display: none;
}
p{
font-weight: 500;
}
/* Question Group Mark */
.text-qus-align{
/* .text-qus-align{
display: inline-flex;
}
} */
.group_attempt_any{
display: inline-flex;
float: right;
margin-right: 40px;
margin-right: 115px;
margin-top:-35px;
}
.group_marks{
display: inline-flex;
float: right;
margin-top:-35px;
margin-right: 4px;
}
@ -73,6 +88,7 @@
display: inline-block;
margin-right: 10px;
float: right;
margin-top:-25px;
}
/* Section SectionAttempt SectionMark */
@ -84,11 +100,13 @@
display: inline-block;
margin-right: 40px;
float: right;
/* margin-top:-27px; */
}
#sectionMark{
display: inline-block;
margin-right: 10px;
float: right;
/* margin-top:-27px; */
}
/* End the this */
@ -105,13 +123,14 @@
.MathJax.CtxtMenu_Attached_0{
display: contents !important;
}
.text-qus-align{margin-left: -16px;padding-right: 250px; }
.text-qus-align{margin-left: -16px;padding-right: 250px;display:flex; }
.text-qus-align p{ margin:0; }
.text-des{ margin-left: 20px;margin-top: 0px;} /* Change there aadhavan top-6px*/
.text-option-align{display:flex;margin-top: 0%;margin-left: 45px;} /* Change there aadhavan 10px*/
.text-option-align p{ margin:0; }
#sectionTitle {border-top: 2px solid gray; width: 100%;}
#sectionTitle:first-of-type {border:none;}
/* #sectionTitle {border-top: 2px solid gray
; width:99%;} */
/* #sectionTitle:first-of-type {border:none;} */
mjx-container[jax="CHTML"][display="true"] {
display: block;
text-align: center;
@ -292,7 +311,7 @@
//XmlPath get from .env
const xmlPathenv=process.env.XML_FILE_PATH;
const xmlPath =path.join(__dirname,xmlPathenv);
console.log(xmlFileName)
// console.log(xmlFileName)
return new Promise((resolve, reject) => {
fs.readFile(`${xmlPath}`+xmlFileName, 'utf8', (error, data) => {
if (error) {
@ -312,6 +331,9 @@
});
}
console.log()
</script>

View File

@ -48,6 +48,14 @@
<style>
#editPreview{
color: #7018d4;
}
#editPreview:hover {
color:#3399FF;
}
ul, #myUL {
list-style-type: none;
}
@ -384,10 +392,14 @@
.popup-save{
display: flex;
justify-content: flex-end;
}
.popup-save button{
border-radius: 5px;
border-color:#eee;
margin-right: 0px;
margin-top: 16px;
}
.popupbox q{
align-items: center;
@ -457,7 +469,7 @@
<ul>
<li><a href="dashboard.html"><i class="fa fa-home" aria-hidden="true" style="font-size: 24px;"></i>&nbsp;&nbsp;Home</a></li>
<li><a href="#" class="myBtn" onclick="saveFile()" id="SaveButton"><i class="fa fa-floppy-o" aria-hidden="true" style="font-size: 20px;"></i>&nbsp;&nbsp;Save</a></li>
<li><a id="editPreview" style="color: #730fd5;"><i class="fa fa-eye" aria-hidden="true" style="font-size: 24px;"></i>&nbsp;&nbsp;Preview</a></li>
<li><a id="editPreview" ><i class="fa fa-eye" aria-hidden="true" style="font-size: 24px;"></i>&nbsp;&nbsp;Preview</a></li>
</ul>
</div>
</div>
@ -497,7 +509,6 @@
<!-- QuestionPapper Title Start-->
<div class="question-papper-title element" style="border-top: solid; margin-bottom: 15px;">
<input type="hidden" id="QuestionPaper_UUID_ID">
<div class="col-lg-12 col-md-12">
@ -594,8 +605,8 @@
<div style="margin-bottom: 9px;">Reorder sections</div>
</ul>
<div class="popup-save">
<button onclick="saveFile()" id="closePopupButton">Save</button>
<div class="popup-save form-button">
<button onclick="saveFile(flag=1)" id="closePopupButton">Save</button>
</div>
<!-- <button id="closePopupButton">Close</button> -->
@ -709,7 +720,6 @@
const url = new URL(window.location.href);// Get the URL of the current page for JSON
const params = new URLSearchParams(url.search);// Create a URLSearchParams object from the query string
var FileName = params.get('filename');// Get the value of a specific parameter
var xmlPath ="" //get the xml filepath in .env file local variable
$(document).ready(function() {
@ -762,10 +772,28 @@ document.addEventListener('DOMContentLoaded', function () {
});
//EditPreview and Create Previe
//EditPreview and Create Preview
var previewbutton = document.getElementById("editPreview");
previewbutton.addEventListener("click", async () => {
if (FileName) {
const saveButton = document.getElementById('SaveButton');
if (saveButton) {
saveButton.click();
setTimeout(function() {
var popupInput = document.getElementById("swal2-input");
var submitButton = document.querySelector(".swal2-confirm.swal2-styled");
submitButton.addEventListener("click", function() {
FileName = popupInput.value;
FileName += ".xml"
if(FileName){
var anchorElement = document.getElementById("editPreview");
if (anchorElement) {
anchorElement.click();
}
}
});
}, 1000);
}
previewbutton.href = "QuestionPreview.html?filename=" + FileName;
} else {
const saveButton = document.getElementById('SaveButton');
@ -822,7 +850,7 @@ function loadXML(xmlFileName) {
function saveFile(flag=0) {
html2json();
json2xml();
console.log("flag",flag);
if(FileName == "" || FileName == null ){
setTimeout(promptBox, 1000);
@ -830,7 +858,7 @@ 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){
if (flag==1){
savexml(newFileName,reorder=true);
//if 0 it is used as nrml save which will redierect to dashboard
}else{
@ -918,6 +946,7 @@ navpane();
html2json();
// function for ONMOUSE HOVER to SHOW the side ADD BUTTONS
function showButtons(container) {
const buttons = container.querySelector('.buttons');
const onhover = container.querySelector('.onhover');
@ -929,6 +958,7 @@ function showButtons(container) {
}
// function for ONMOUSE HOVER to HIDE the side ADD BUTTONS
function hideButtons(container) {
const buttons = container.querySelector('.buttons');
const onhover = container.querySelector('.onhover');
@ -981,8 +1011,8 @@ function addSection(title = false, description = false, random_no = false, secti
<div class="items align-items-center hideondrag" style="display: block;">
<div class="dropdown " id="toggle-menu">
<i class="fa fa-ellipsis-v" style="font-size:20px" aria-hidden="true"></i>
<div class="dropdown-content">
<button id="popupid_${sectionRandomID}" class="showPopupButton">Move</button>
<div class="dropdown-content ">
<button id="popupid_${sectionRandomID}" class="showPopupButton ">Move</button>
</div>
</div>
</div>
@ -1026,7 +1056,7 @@ function addSection(title = false, description = false, random_no = false, secti
<div class="col-lg-5 col-md-5 mt-2">
<span>Display Marks</span>
<label class="switch">
<input type="checkbox" id="Section_Display_Marks_Id_${sectionRandomID}" checked>
<input type="checkbox" id="Section_Display_Marks_Id_${sectionRandomID}">
<span class="slider round"></span>
</label>
</div>
@ -1217,35 +1247,16 @@ function addSection(title = false, description = false, random_no = false, secti
var DisplayMark_RawID = 'Section_Display_Marks_Id_' + sectionRandomID
var DisplayMark_ID = document.getElementById(DisplayMark_RawID)
if(sectionDispalyMarks === 'true'){
DisplayMark_ID.checked = true;
}else{
if(sectionDispalyMarks === 'false'){
DisplayMark_ID.checked = false;
}else{
DisplayMark_ID.checked = true;
}
//mark calculation code for section
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
$('#'+Section_Marks_raw_Id).prop("disabled", true);
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
// var inputValue = $(this).val();
// if(inputValue == ""){
// $('#'+Section_Marks_raw_Id).prop("disabled", true);
// }else{
// $('#'+Section_Marks_raw_Id).prop("disabled", false);
// }
// json2nav();
// });
//end of mark calculation code for section
// function for calling html2json script using Mark Calculation
@ -1318,11 +1329,14 @@ function addQuestionGroup(idObj)
<input type="hidden" id="Question_Group_UUID_ID_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.attributes.Id : QuestionGroup_UUID}">
<div class="groupsection" draggable='true' id="group_question_${QuestionGroup_ID}">
<div class="sectionTitle" id="group_question_title_${QuestionGroup_ID}">
<div class="col-lg-12 col-md-12">
<div onmouseover="showButtons(this)" id="QuestionGroupButtons_${QuestionGroup_ID}" class="row question element" style="border-top: 10px solid #a658f3; border-radius:10px; margin-top:5px;">
<div class="items align-items-center">
<span onclick="ReArrangeQuestionsGroup(event)" id="forword_${QuestionGroup_ID}" class="fa fa-chevron-up up-icon"></span>&nbsp;&nbsp;
<span onclick="ReArrangeQuestionsGroup(event)" id="backword_${QuestionGroup_ID}" class="fa fa-chevron-down down-icon"></span>&nbsp;&nbsp;&nbsp;
</div>
<div class="row" style="text-align:right; width: 100%">
<div class="col-lg-10 col-md-12">
<div class=" button-group align-items-center">
@ -1340,20 +1354,19 @@ function addQuestionGroup(idObj)
</div>
</div>
</div>
<div id="dragHandle" class="drag-handle">
<i class="fas fa-grip-horizontal"></i>
</div>
<div class="col-lg-12 col-md-12">
<div class="form_box">
<label>Quesions Group:</label>
<label>Questions Group:</label>
<div class="richText" id="subSection_title_text_${QuestionGroup_ID}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_title : ""}</div>
</div>
</div>
<div class="col-lg-12 col-md-12 hideondrag">
<div class="form_box">
<label>Quesions Group Description:</label>
<label>Questions Group Description:</label>
<div class="richText" id="subSection_description_text_${QuestionGroup_ID}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_description : ""}</div>
</div>
</div>
@ -1499,18 +1512,17 @@ function addQuestionGroup(idObj)
}
else
{
displayMArks = 'false';
displayMArks = false;
}
var DisplayMark_RawID = "Question_Group_Display_Marks_Id_" + QuestionGroup_ID;
var DisplayMark_ID = document.getElementById(DisplayMark_RawID)
if(displayMArks === 'true'){
DisplayMark_ID.checked = true;
}else{
if(displayMArks === 'false'){
DisplayMark_ID.checked = false;
}else{
DisplayMark_ID.checked = true;
}
@ -1580,7 +1592,6 @@ const value = localStorage.getItem('JSON_FOR_NAV')
// 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, questionAreaId = false, questionRandomNo = false, questionMarks = false, questionUUID = false, questionDisplayMarks = false)
{
const ChoiceGroupFixed_UUID = uuidv4();
var groupQuestion = "";
@ -1630,8 +1641,9 @@ function groupQuestion(question_id = false, section_id = false , group_question_
<i class="fas fa-grip-horizontal"></i>
</div>
<div class="items hideondrag" style="display: none;">
<i onclick="ReArrangeQuestions(event)" class="fa fa-chevron-up up-icon"></i>&nbsp;&nbsp;
<i onclick="ReArrangeQuestions(event)" class="fa fa-chevron-down down-icon"></i>&nbsp;&nbsp;&nbsp;
<i class="fa fa-trash-o" onclick="removeClonedQroupQuestion(${addChoiceAreaId})" style="font-size:20px;"aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fa fa-clone" id="cloneId_${addChoiceAreaId}" onclick="cloneQuestion(event, 2)" style="font-size:20px;" aria-hidden="true"></i>
</div>
@ -1703,7 +1715,6 @@ function groupQuestion(question_id = false, section_id = false , group_question_
<math-field id="choiceTextField_math_${addChoiceAreaId}" style="width: 100%;" contenteditable="true">${Choice ? Choice[0].choice_name : ""}</math-field>
</div>
<div class="items2 col-lg-4">
<i class="fa fa-trash-o" style="font-size:20px;" aria-hidden="true" id="deleteButton_${addChoiceAreaId}"></i>&nbsp;&nbsp;&nbsp;
<input style="width:14px; height:14px" type="checkbox" id="Choicemath_${addChoiceAreaId}">&nbsp;&nbsp;<span class="math">MATH</span>
</div>
</div>
@ -2020,11 +2031,10 @@ $(choiceTextField_previousDiv).hide();
var DisplayMark_RawID = "Choice_Question_Display_Marks_Id_" + addChoiceAreaId;
var DisplayMark_ID = document.getElementById(DisplayMark_RawID)
if(questionDisplayMarks === 'true'){
DisplayMark_ID.checked = true;
}else{
if(questionDisplayMarks === 'false'){
DisplayMark_ID.checked = false;
}else{
DisplayMark_ID.checked = true;
}
var multipleAnswer = 'multipleAnswer_'+addChoiceAreaId;
@ -2082,8 +2092,8 @@ function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, questionR
<math-field id="newchoiceTextField_math_`+text_field_created_time+rnd_no+`" style="width: 100%;" contenteditable="true">${choiceName ? choiceName : ""}</math-field>
</div>
<div class="items2 col-lg-4">
<i class="fa fa-trash-o" style="font-size:20px;" aria-hidden="true" id="newChoiceDeleteButton_`+text_field_created_time+rnd_no+`"></i>&nbsp;&nbsp;&nbsp;
<input style="width:14px; height:14px" type="checkbox" id="choice_math_`+text_field_created_time+rnd_no+`">&nbsp;&nbsp;<span class="math">MATH</span>
<input style="width:14px; height:14px" type="checkbox" id="choice_math_`+text_field_created_time+rnd_no+`">&nbsp;&nbsp;<span class="math">MATH</span>&nbsp;&nbsp;&nbsp;
<i class="fa fa-trash-o" style="font-size:20px;" aria-hidden="true" id="newChoiceDeleteButton_`+text_field_created_time+rnd_no+`" title="Remove Choice"></i>
</div>
</div>
</div>`
@ -2286,8 +2296,9 @@ textQuestion +=
</div>
<div class="items align-items-center hideondrag" style="display: none;">
<i onclick="ReArrangeQuestions(event)" id="forword_${addTextQuestionId}" class="fa fa-chevron-up up-icon" ></i>&nbsp;&nbsp;
<i onclick="ReArrangeQuestions(event)" id="backword_${addTextQuestionId}" class="fa fa-chevron-down down-icon"></i>&nbsp;&nbsp;&nbsp;
<i class="fa fa-trash-o" onclick="removeClonedTextQuestion(${addTextQuestionId})" style="font-size:20px;"aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fa fa-clone" onclick="cloneQuestion(event, 1)" id="cloneId_${addTextQuestionId}" style="font-size:20px;" aria-hidden="true"></i>
</div>
<div class="col-lg-12 col-md-12 ">
<input type="hidden" id="Text_Question_UUID_ID_${addTextQuestionId}" value="${QuestionObj.hasOwnProperty('questionUUID') ? QuestionObj.questionUUID : Text_Question_UUID}">
@ -2506,20 +2517,18 @@ else
}
else
{
displayMArks = 'false';
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;
if(displayMArks === 'false'){
DisplayMark_ID.checked = false;
}else{
DisplayMark_ID.checked = false;
}
DisplayMark_ID.checked = true;
}
@ -2548,6 +2557,92 @@ var inputElement = document.getElementById(Textid);
}
//function for Questions REORDER in the SECTION Level
function ReArrangeQuestions(e){
var currentID= e.target.parentElement.parentElement.parentElement.id;
console.log(currentID)
var currentItemID = document.getElementById(currentID);
console.log('currentItemID');
console.log(currentItemID);
if (e.target.classList.contains('up-icon')) {
console.log('FORWORD');
const question_ListItem = e.target.parentElement.parentElement;
console.log('question_ListItem');
console.log(question_ListItem);
const question_PrevItem = question_ListItem.previousElementSibling;
console.log('question_PrevItem');
console.log(question_PrevItem );
if (question_PrevItem !== null) {
currentItemID.insertBefore(question_ListItem, question_PrevItem);
}
} else if (e.target.classList.contains('down-icon')) {
console.log('BACKWORD');
const question_ListItem = e.target.parentElement.parentElement;
console.log('question_ListItem');
console.log(question_ListItem);
const question_nextItem = question_ListItem.nextElementSibling;
console.log('question_nextItem');
console.log(question_nextItem );
if (question_nextItem) {
currentItemID.insertBefore(question_nextItem, question_ListItem);
}
}
json2nav();
clearSidebarWrapper();
navpane();
}
//function for REORDER the Question Group in the SECTION Level
function ReArrangeQuestionsGroup(e){
var currentID= e.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.id;
console.log(currentID)
var currentItemID = document.getElementById(currentID);
console.log('currentItemID');
console.log(currentItemID);
if (e.target.classList.contains('up-icon')) {
console.log('FORWORD');
const question_ListItem = e.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
console.log('question_ListItem');
console.log(question_ListItem);
const question_PrevItem = question_ListItem.previousElementSibling;
console.log('question_PrevItem');
console.log(question_PrevItem );
if (question_PrevItem !== null) {
currentItemID.insertBefore(question_ListItem, question_PrevItem);
}
} else if (e.target.classList.contains('down-icon')) {
console.log('BACKWORD');
const question_ListItem = e.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
console.log('question_ListItem');
console.log(question_ListItem);
const question_nextItem = question_ListItem.nextElementSibling;
console.log('question_nextItem');
console.log(question_nextItem );
if (question_nextItem) {
currentItemID.insertBefore(question_nextItem, question_ListItem);
}
}
json2nav();
clearSidebarWrapper();
navpane();
}
//Function for Add Group Question inside the Group QUestion Like Question
function MultiLevelQuestionGroup(e)
{
@ -2637,6 +2732,7 @@ function cloneQuestion(e,type)
// remove the cloned text type questions function
function removeClonedTextQuestion(index)
{
alert('hi text');
var element = document.getElementById('removeAndCloneTextQuestion_'+ index);
if (element) {
element.remove();
@ -2646,6 +2742,8 @@ function removeClonedTextQuestion(index)
// remove the cloned choice or group type questions function
function removeClonedQroupQuestion(index)
{
alert('hi choice');
var element = document.getElementById('removeAndCloneQroupQuestion_'+ index);
if (element) {
element.remove();
@ -2686,86 +2784,6 @@ function removeClonedQroupQuestion(index)
}
});
// document.addEventListener('mousedown', function (e) {
// const dragHandle = e.target.closest('.drag-handle');
// if (dragHandle) {
// // If the click is inside a drag handle, find the corresponding .question
// const questionElement = dragHandle.closest('.groupsection');
// if (questionElement) {
// console.log("draggHandle:",dragHandle);
// // Initiate the drag operation for the .question
// draggedItemQuestion = questionElement;
// // Add a dragStart event listener to set data
// draggedItemQuestion.addEventListener('dragstart', function (e) {
// e.dataTransfer.setData('text/plain', draggedItemQuestion.id);
// console.log(draggedItemQuestion.id);
// });
// }
// }
// });
// document.addEventListener('mousedown', function (e) {
// const dragHandle = e.target.closest('.drag-handle');
// if (dragHandle) {
// // If the click is inside a drag handle, find the corresponding .question
// const questionElement = dragHandle.closest('.groupsection>.question');
// if (questionElement) {
// console.log(questionElement);
// console.log("draggHandle:",dragHandle);
// // Initiate the drag operation for the .question
// draggedItemQuestion = questionElement;
// // Add a dragStart event listener to set data
// draggedItemQuestion.addEventListener('dragstart', function (e) {
// e.dataTransfer.setData('text/plain', draggedItemQuestion.id);
// console.log(draggedItemQuestion.id);
// });
// }
// }
// });
// // Event listener for .draggable-group elements
// document.addEventListener('mousedown', function (e) {
// const dragHandle = e.target.closest('.drag-handle');
// if(groupqnornot){
// if (dragHandle) {
// // If the click is inside a drag handle, find the corresponding .draggable-group
// const draggableGroup = dragHandle.closest('.draggable-group');
// console.log("draggableGroup:",draggableGroup);
// if (draggableGroup) {
// console.log("draggHandle:",dragHandle);
// // Initiate the drag operation for the .draggable-group
// draggedItemGroup = draggableGroup;
// // Add a dragStart event listener to set data
// draggedItemGroup.addEventListener('dragstart', function (e) {
// e.dataTransfer.setData('text/plain', draggedItemGroup.id);
// console.log(draggedItemGroup.id);
// // // Hide all elements with class "hideondrag" in the group
// // const richTextElements = document.querySelectorAll('.hideondrag');
// // richTextElements.forEach((element) => {
// // element.style.display = 'none';
// // });
// });
// }
// }
// }
// });
document.addEventListener('dragover', function (e) {
// groupqnornot = true;
// Hide all elements with class "hideondrag" in the question
@ -2842,6 +2860,9 @@ function removeClonedQroupQuestion(index)
}
draggedItemGroup = null;
dropTarget = null;
json2nav();
clearSidebarWrapper();
navpane();
} else if (draggedItemQuestion && dropTarget) {
e.preventDefault();
const rect = dropTarget.getBoundingClientRect();
@ -2854,10 +2875,14 @@ function removeClonedQroupQuestion(index)
}
draggedItemQuestion = null;
dropTarget = null;
json2nav();
clearSidebarWrapper();
navpane();
} else {
console.error('No dragged item or drop target found.');
}
});
</script>

View File

@ -22,7 +22,7 @@ body {
p {
font-weight: 500;/* Change this into 400 aadhavan */
font-weight: 400;/* Change this into 400 aadhavan */
font-style: normal;
font-family: 'Rubik', sans-serif;
color: #6d6d6d;

View File

@ -95,7 +95,10 @@ function generateSingleQuestions(ParentObjects)
var parentMarks = ParentObjects.parentMarks;
var parentAttemptAny = ParentObjects.parentAttemptAny;
var MarkDivideValue = parentMarks / parentAttemptAny;
var DivideValue = parentMarks / parentAttemptAny;
const twoDigitsAfterDecimal = DivideValue.toFixed(2);
var MarkDivideValue = parseFloat(twoDigitsAfterDecimal);
// console.log(MarkDivideValue)
// console.log('parentMarks : ', parentMarks);
// console.log('new_parentAttemptAny : ', parentAttemptAny);

View File

@ -6,7 +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);
// console.log(jsonData);
// var arr = JSON.parse( localStorage.getItem('memoriesdata') );
// var jsonData2 = JSON.parse(jsonData);
// console.log(typeof jsonData);
@ -38,7 +38,7 @@ function navpane() {
var splitedSectionId = sectionId.split("_")[3];
var SectionBox_RawID = 'SectionBox_'+splitedSectionId;
var SectionBoxID = document.getElementById(SectionBox_RawID)
console.log(SectionBoxID);
// console.log(SectionBoxID);
// Check if the section should be initially expanded based on expandedSections
@ -142,25 +142,26 @@ function navpane() {
function createTreeNode(nodeData, parentNode) {
const nodeDiv = document.createElement('div');
nodeDiv.className = "navContain";
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
const nodeDataId = nodeData.question_Id
const nodeDataType = nodeData.question_type
console.log('nodeDataType:',nodeDataType);
// console.log('nodeDataType:',nodeDataType);
parentNode.appendChild(nodeDiv);
var bulletPoint = "";
if (nodeData.question) {
var RawID = "";
if(nodeDataType == 'text')
{
const bulletPoint = document.createElement('i');
bulletPoint = document.createElement('span');
bulletPoint.className = "fa fa-text-width";
bulletPoint.style.marginRight = '10px';
bulletPoint.style.fontSize = '17px';
bulletPoint.style.marginRight = '5px';
bulletPoint.style.fontSize = '15px';
bulletPoint.style.fontWeight = 'bold';
bulletPoint.style.color = '#00aaff';
// bulletPoint.textContent = '\u2022';
@ -173,10 +174,10 @@ function navpane() {
}else if(nodeDataType == 'group')
{
const bulletPoint = document.createElement('i');
bulletPoint = document.createElement('span');
bulletPoint.className = "fa fa-check-circle-o";
bulletPoint.style.marginRight = '10px';
bulletPoint.style.fontSize = '17px';
bulletPoint.style.marginRight = '5px';
bulletPoint.style.fontSize = '15px';
bulletPoint.style.fontWeight = 'bold';
bulletPoint.style.color = '#00aaff';
bulletPoint.setAttribute("title", "MCQ");
@ -189,7 +190,7 @@ function navpane() {
}
var QuestionID = document.getElementById(RawID)
console.log(QuestionID)
// console.log(QuestionID)
const questionLink = document.createElement('a');
questionLink.href = '#' + nodeDataId;
@ -219,6 +220,7 @@ function navpane() {
questionLink.style.fontWeight = questionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
} else {
questionLink.style.fontWeight = 'bold';
QuestionID.style.fontWeight = 'normal';
currentlyHighlightedElement = questionLink;
}
});
@ -236,7 +238,7 @@ function navpane() {
});
if (nodeData.question.length > 20) {
questionLink.innerHTML = removeParagraphTags(nodeData.question.substring(0, 20) + '.....');
questionLink.innerHTML = removeParagraphTags(nodeData.question.substring(0, 20) + '...');
} else {
questionLink.innerHTML = removeParagraphTags(nodeData.question);
}
@ -248,12 +250,12 @@ function navpane() {
groupTitleDiv.setAttribute('data-id', groupTitleId);
groupTitleDiv.className = 'question-group';
console.log(groupTitleId);
// console.log(groupTitleId);
var splitedGroupId = groupTitleId.split("_")[3];
var SplitedGroupRawID = 'QuestionGroupButtons_'+splitedGroupId;
var GroupBoxID = document.getElementById(SplitedGroupRawID);
console.log(GroupBoxID);
// console.log(GroupBoxID);
// Check if the group should be initially expanded based on expandedSections
@ -332,6 +334,7 @@ function navpane() {
groupQuestionLink.style.fontWeight = groupQuestionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
} else {
groupQuestionLink.style.fontWeight = 'bold';
GroupBoxID.style.fontWeight = 'normal';
currentlyHighlightedElement = groupQuestionLink;
}
});

View File

@ -3,13 +3,40 @@ const cheerio = require('cheerio');
const Swal = require('sweetalert2')
const encode = require('./encode')
const path = require('path')
require('dotenv').config();
//Get the value from .env
const isEncrypted = process.env.ENCRYPTED;
// start the Autosave filename take the names in xml folder
////////
function getFilesInFolder(folderName) {
const xmlFilePath = path.join(__dirname, folderName);
try {
const fileNames = fs.readdirSync(xmlFilePath);
const xmlFiles = fileNames.filter((file) => file.endsWith('.xml'));
return xmlFiles;
} catch (error) {
console.error('Error reading folder:', error);
return [];
}
}
//XmlPath get from .env
const xmlPath_ = process.env.XML_FILE_PATH;
const folderName = `/${xmlPath_}`;
const filePaths = [];
const files = getFilesInFolder(folderName);
files.forEach((file) => {
const filePath = file;
filePaths.push(filePath);
});
////////
//end the autosave
function saveXmlToFile(xmlData, filePath,reorder=false) {
console.log(filePath);
// console.log(filePath);
// Check if the file path is provided
if (!filePath) {
console.error('File path is required.');
@ -31,82 +58,116 @@ function saveXmlToFile(xmlData, filePath,reorder=false) {
}
});
localStorage.clear();
if(reorder){
window.location.reload();
}else{
window.location.href = 'dashboard.html';
}
}
function savexml(UserFilename,reorder=false) {
// Get the XML string from localStorage
var xmlString = localStorage.getItem("xml");
//check Encrypted or not
var enc = "";
if (isEncrypted === 'YES') {
// Encrypt
enc = encode(xmlString);
}else{
enc = xmlString;
}
//XmlPath get from .env
const xmlPathenv=process.env.XML_FILE_PATH;
const xmlPath = path.join(__dirname, xmlPathenv)
// Get the json string from localStorage for set fileName
var jsonData = localStorage.getItem("json");
// Create a filename using on the subtitle
var xmlfilename = `${UserFilename}.xml`;
// var jsonfilename = `${UserFilename}.json`;
// file path where you want to save the XML file
// const xmlfilePath = process.cwd() + `/${xmlPath}` + xmlfilename;
const xmlfilePath = `${xmlPath}` + xmlfilename;
// const jsonfilePath = process.cwd() + '/xml/' + jsonfilename;
if(reorder){
saveXmlToFile(enc, xmlfilePath,reorder=true);
}else{
// Call the function to save the XML file
saveXmlToFile(enc, xmlfilePath);
}
if(reorder){
window.location.reload();
}else{
window.location.href = 'dashboard.html';
}
}
function promptBox(){
function savexml(UserFilename,reorder=false) {
console.log("reorder",reorder);
// Get the XML string from localStorage
var xmlString = localStorage.getItem("xml");
//check Encrypted or not
var enc = "";
if (isEncrypted === 'YES') {
// Encrypt
enc = encode(xmlString);
} else {
enc = xmlString;
}
//XmlPath get from .env
const xmlPathenv=process.env.XML_FILE_PATH;
const xmlPath = path.join(__dirname, xmlPathenv)
// Get the json string from localStorage for set fileName
var jsonData = localStorage.getItem("json");
// Create a filename using on the subtitle
var xmlfilename = `${UserFilename}.xml`;
// var jsonfilename = `${UserFilename}.json`;
// file path where you want to save the XML file
// const xmlfilePath = process.cwd() + `/${xmlPath}` + xmlfilename;
const xmlfilePath = `${xmlPath}` + xmlfilename;
// const jsonfilePath = process.cwd() + '/xml/' + jsonfilename;
if(reorder){
saveXmlToFile(enc, xmlfilePath,reorder=true);
}else{
// Call the function to save the XML file
saveXmlToFile(enc, xmlfilePath);
}
}
function promptBox() {
var jsonData = localStorage.getItem("json");
var jsonString = JSON.parse(jsonData);
var getTitle = jsonString.question_paper_title;
var RawFileName = removeHtmlTags(getTitle);
// console.log(RawFileName)
var jsonString = JSON.parse(jsonData);
var getTitle = jsonString.question_paper_title;
var RawFileNam = removeHtmlTags(getTitle);
var RawFileName;
if (RawFileNam === "" || RawFileNam === null) {
const currentDate = new Date();
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
const day = String(currentDate.getDate()).padStart(2, '0');
let hours = currentDate.getHours();
let ampm = 'AM';
if (hours > 12) {
hours -= 12;
ampm = 'PM';
}
hours = String(hours).padStart(2, '0');
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
// Create a formatted date-time string
const formattedDateTime = `${year}${month}${day}(${hours};${minutes}${ampm})`;
RawFileName = "untitled" +formattedDateTime;
} else {
RawFileName = RawFileNam
}
Swal.fire({
title: 'Enter Filename',
input: 'text',
inputValue: RawFileName,
showCancelButton: true,
showDenyButton: false,
denyButtonText: 'Overwrite',
confirmButtonText: 'Submit',
cancelButtonText: 'Cancel',
inputValidator: (value) => {
// console.log(value);
const entervalue =value+'.xml'
if (!value) {
return 'You need to enter Filename!'
}
else if (value){
const fileexist =fileexists(entervalue);
if(fileexist){
Swal.update({ showDenyButton: true });
return 'This file Name already exists'
}else {
Swal.update({ showDenyButton: false });
}
}
}
}).then((result) => {
// console.log(result);
if (result.isConfirmed) {
const inputValue = result.value
savexml(inputValue)
}else if(result.isDenied){
savexml(RawFileName)
}
})
@ -122,5 +183,15 @@ function removeHtmlTags(inputString) {
return text;
}
//check filename is already exists or not
function fileexists(enteredfilename) {
var nextFilename
for (const files of filePaths) {
nextFilename = files;
if (nextFilename === enteredfilename) {
return true;
}
}
}

View File

@ -3557,10 +3557,19 @@ input:disabled {
.math{
font-weight: 500;
font-size: 14px;
}
.mathQuestions{
font-weight: 500;
float: right;
font-size: 14px;
}
.navContain{
display: flex; /* Use a flex container to control spacing */
align-items: center; /* Vertically center the items */
}

View File

@ -54,8 +54,9 @@ function getQuestionsNodes(questionNode,type)
{
var tempChoiceobj = {};
tempChoiceobj['id'] = choiceList[k].childNodes[0].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 : "");
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);