loader and workarea changes : RV

This commit is contained in:
venkateswaran ubuntu 2023-11-29 18:16:25 +05:30
parent 1310c0efcd
commit b6cba02c6b
11 changed files with 440 additions and 347 deletions

View File

@ -2,6 +2,7 @@
function QuestionPaperPreview(jsonData){
// The provided JSON data
// console.log(jsonData)
// start Remove <p> tag
var jsonDat = jsonData;
@ -305,10 +306,25 @@ function QuestionPaperPreview(jsonData){
const formattedQuestionPaper = convertJSONToQuestionPaper(jsonData, 0, 1, 1);
const questionPaperElement = document.getElementById("questionPaper");
questionPaperElement.innerHTML = formattedQuestionPaper; // Use innerHTML here
$("#overlay").hide();
}
function removeHtmlTags(inputString) {
const cheerio = require('cheerio');

View File

@ -98,7 +98,7 @@
text-wrap: wrap;
/* display: inline-flex; */
/* flex-direction: column; */
text-decoration: underline;
/* text-decoration: underline; */
/* justify-content: flex-start; */
position: relative;
top: -27px;
@ -320,11 +320,17 @@ color: #1d3557 !important;
<!-- loder -->
<div class="loader-wrapper">
<!-- <div class="loader-wrapper">
<div class="loader"></div>
<div class="loder-section left-section"></div>
<div class="loder-section right-section"></div>
</div>
</div> -->
<div id="overlay">
<div class="cv-spinner">
<span class="spinner"></span>
</div>
</div>
<!-- main-header -->
@ -409,6 +415,7 @@ color: #1d3557 !important;
<script>
$("#overlay").show();
const fs = require('fs');
const path =require('path');

View File

@ -46,30 +46,12 @@
<script defer src="./node_modules/mathlive/dist/mathlive.min.js"></script>
<!-- modernizr js -->
<script src="assets/js/vendor/modernizr-3.5.0.min.js"></script>
<!-- <script src="./node_modules/quill-resize-module/dist/resize.js"></script> -->
<!-- <link rel="stylesheet" href="./node_modules/quill-resize-module/dist/resize.css"> -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/cropperjs/dist/cropper.min.css">
<!-- <script src="//cdn.quilljs.com/1.2.2/quill.min.js"></script> -->
<script src="./node_modules/quill/dist/quill.min.js"> </script>
<!-- <link href="//cdn.quilljs.com/1.2.2/quill.snow.css" rel="stylesheet"> -->
<!-- <script src="//cdn.quilljs.com/1.3.6/quill.min.js"></script> -->
<!-- <link href="//cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"> -->
<script src="./imageresize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.1/fabric.min.js"></script>
<script src="QuestionPaperPreview.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<!-- <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
<script id="MathJax-script" async src="./node_modules/mathjax/es5/tex-mml-chtml.js"></script>
<style>
body {
@ -129,7 +111,7 @@
right: 20px;
font-size: 20px;
cursor: pointer;
z-index: 3; /* Ensure the button appears above the sidebar */
z-index: 0; /* Ensure the button appears above the sidebar */
}
.content {
@ -797,19 +779,26 @@ h1.title{
/* margin-right: 15px; */
width: 85px;
}
</style>
</style>
<script>
</script>
</head>
<body>
<!-- loder -->
<div class="loader-wrapper">
<!-- <div class="loader-wrapper" id="loaderWrapper">
<div class="loader"></div>
<div class="loder-section left-section"></div>
<div class="loder-section right-section"></div>
</div>
<div class="loder-section left-section"></div>
<div class="loder-section right-section"></div>
</div> -->
<div id="overlay">
<div class="cv-spinner">
<span class="spinner"></span>
</div>
</div>
<!-- main-header -->
<div class="main-header">
@ -913,6 +902,7 @@ h1.title{
$('#messageInput_rtc').hide();
} else {
$(mathField).hide();
$(mathField).css('margin-bottom', '0');
$(richText).show();
$('#messageInput_rtc').hide();
@ -1023,7 +1013,7 @@ h1.title{
});
}
</script>
<div class="sidebar" id="rightSidebar">
@ -1042,7 +1032,6 @@ h1.title{
<div>
<math-field id="workarea_math" style="width: 100%; " contenteditable="true"></math-field>
</div>
</div>
<div class="col-6 items2" style="display: flex; align-items: center; position: relative; right: 40px;">
<input style="width:14px; height:14px; margin-right: 5px;" type="checkbox" id="Choicemath_messageInput"/>
@ -1263,12 +1252,27 @@ h1.title{
<!-- Main.js its used to trigger auto save when system online -->
<script src="main.js"></script>
<script src="checkParent.js"></script>
<script>
$("#overlay").show();
$('#workarea_math').click(function(){
console.log('called');
$('#workarea_math').css('margin-bottom', '190px');
localStorage.setItem('workAreaMath', true);
});
const { v4: uuidv4 } = require('uuid');
const Quill = require('quill');
const ImageResize = require('quill-image-resize').default;
var ids = document.getElementById('workarea_math')
console.log(ids)
function clearMessage() {
var val = document.getElementById('messages') ;
if(val !== null){
@ -1340,6 +1344,8 @@ $(document).ready(function() {
if(FileName == "" || FileName == null ) {
var random_no = Date.now();
addSection(false, false, random_no, false, false, false, false, 1); //Call the Default section on the QUestion paper
$("#overlay").hide();
}else {
loadXML(FileName); //send filename to read xml files to using this function
@ -1348,16 +1354,42 @@ $(document).ready(function() {
})
// $(document).on("click", function (event) {
// var questionPaperDiv = $(".QuestionPaperClass");
// alert('test')
// // Check if the click is outside the QuestionPaperClass and its descendants
// if (!questionPaperDiv.is(event.target) && questionPaperDiv.find(event.target).length === 0) {
// $('.ql-toolbar').hide();
// }
// });
$(document).on("click", function (event) {
var questionPaperDiv = $(".QuestionPaperClass");
var rightSidebar = $('.sidebar');
var qlToolbar = $('.ql-toolbar');
// Check if the click is outside the QuestionPaperClass and its descendants
if (!questionPaperDiv.is(event.target) && questionPaperDiv.find(event.target).length === 0) {
// $('#workarea_math').css('margin-bottom', '0px');
// Check if the click is within the rightSidebar or its descendants
if (!rightSidebar.is(event.target) && rightSidebar.find(event.target).length === 0) {
qlToolbar.hide();
}
}
});
$(document).on("click", function (event) {
console.log(event.target.id);
console.log(event.target.id == 'workarea_math' ? 'true' : 'false');
if(event.target.id !== 'workarea_math')
{
var element = $('.ML__virtual-keyboard-toggle');
console.log(element);
var value = localStorage.getItem('workAreaMath');
console.log('valeu : ', value);
console.log('type : ',typeof value);
if(value === 'true'){
$('#workarea_math').css('margin-bottom', '0px');
localStorage.removeItem('workAreaMath');
}
}
// localStorage.removeItem('workAreaMath');
});
document.addEventListener('DOMContentLoaded', function () {
const scrollToTopBtn = document.getElementById('SaveButton');
@ -1495,18 +1527,18 @@ function loadXML(xmlFileName) {
decodeData = data;
}
// console.log('jsonDecodeData : ', jsonDecodeData);
console.log('jsonDecodeData : ', jsonDecodeData);
resolve(decodeData);
xml2json(decodeData);
// json2nav();
// clearSidebarWrapper();
// navpane();
}
});
});
}
// Function for Save the XML File
@ -1557,8 +1589,8 @@ function saveFile(flag=0) {
<script>
const { v4: uuidv4 } = require('uuid');
const Quill = require('quill');
Quill.register('modules/imageResize', ImageResize);
const Question_Paper_UUID = uuidv4();
var QuestionPaper_UUID = document.getElementById('QuestionPaper_UUID_ID')
QuestionPaper_UUID.value = Question_Paper_UUID;
@ -1581,33 +1613,28 @@ var toolbarOptions2 = [
var quill = new Quill('#Question_title', {
theme: 'snow',
modules: {
toolbar: toolbarOptions,
// ImageResize:{
// displaySize:true,
// modules: [ 'Resize', 'DisplaySize', 'Toolbar' ]
// }
}
});
var quill = new Quill('#QuestionsGroupIdset ', {
theme: 'snow',
modules: {
imageResize:{
displaySize:true,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
}
}
});
var canvas = new fabric.Canvas('canvas');
var quill = new Quill('#Question_description', {
theme: 'snow',
modules: {
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
}
});
@ -1615,6 +1642,13 @@ var quill = new Quill('#workarea', {
theme: 'snow',
modules: {
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
}
});
@ -1650,22 +1684,22 @@ rtc_hide_and_show(questionDescriptionRtc);
// rtc_hide_and_show(chatRtc);
// });
var checkboxElement = document.createElement('input');
checkboxElement.type = 'checkbox';
checkboxElement.id = 'myCheckbox';
checkboxElement.textContent = 'myCheckbox';
checkboxElement.style.width = '14px';
checkboxElement.style.height = '14px';
var parentElement = document.getElementById(questionDescriptionRtc);
// var checkboxElement = document.createElement('input');
// checkboxElement.type = 'checkbox';
// checkboxElement.id = 'myCheckbox';
// checkboxElement.textContent = 'myCheckbox';
// checkboxElement.style.width = '14px';
// checkboxElement.style.height = '14px';
// var parentElement = document.getElementById(questionDescriptionRtc);
var labelElement = document.createElement('label');
labelElement.htmlFor = 'myCheckbox';
labelElement.textContent = 'Math';
// var labelElement = document.createElement('label');
// labelElement.htmlFor = 'myCheckbox';
// labelElement.textContent = 'Math';
// console.log(parentElement);
parentElement.appendChild(checkboxElement);
parentElement.appendChild(labelElement);
// // console.log(parentElement);
// parentElement.appendChild(checkboxElement);
// parentElement.appendChild(labelElement);
@ -1950,6 +1984,13 @@ inputFields.forEach(inputField => {
theme: 'snow',
modules: {
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
@ -1959,7 +2000,14 @@ inputFields.forEach(inputField => {
var quill = new Quill('#'+sectionDescription, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -2128,13 +2176,13 @@ function addQuestionGroup(idObj)
<div class=" button-group align-items-center">
<div class="addButton QGButtons" style="display: none;" id="AddButton_${QuestionGroup_ID}">
<div class="col-md-2">
<div class="addButtonIcons"><img title="QuestionGroup" src="assets/images/text.svg" alt="" onclick="addNewGroupQuestions(event, 1)" id="textButtonSectionQroupside_${QuestionGroup_ID}" title="Question Group Text Question"></div>
<div class="addButtonIcons"><img title="Text Question" src="assets/images/text.svg" alt="" onclick="addNewGroupQuestions(event, 1)" id="textButtonSectionQroupside_${QuestionGroup_ID}" title="Text Question"></div>
</div>
<div class="col-md-2">
<div class="addButtonIcons"><img title="QuestionGroup" src="assets/images/choice.svg" alt="" onclick="addNewGroupQuestions(event, 2)" id="choiseButtonSectionQroupside_${QuestionGroup_ID}" title="Question Group Choice Question"></div>
<div class="addButtonIcons"><img title="Choice Question" src="assets/images/choice.svg" alt="" onclick="addNewGroupQuestions(event, 2)" id="choiseButtonSectionQroupside_${QuestionGroup_ID}" title="Choice Question"></div>
</div>
<div class="col-md-2">
<div class="addButtonIcons"><img title="QuestionGroup" src="assets/images/Group.svg" alt="" onclick="MultiLevelQuestionGroup(event)" id="QuestionGroupButtonside_${QuestionGroup_ID}" title="Question Group on Question Group"></div>
<div class="addButtonIcons"><img title="Question Group" src="assets/images/Group.svg" alt="" onclick="MultiLevelQuestionGroup(event)" id="QuestionGroupButtonside_${QuestionGroup_ID}" title="Question Group"></div>
</div>
</div>
</div>
@ -2255,7 +2303,14 @@ function addQuestionGroup(idObj)
var quill = new Quill('#'+subSectionText, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -2263,7 +2318,14 @@ function addQuestionGroup(idObj)
var quill = new Quill('#'+subSectionDescription, {
theme: 'snow', // Choose a theme (snow, bubble, etc.)
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -2280,6 +2342,8 @@ function addQuestionGroup(idObj)
});
var sub_section_description_Div = 'subSection_description_text_' + QuestionGroup_ID;
var NewRTEId2 = 'subsection_description_rtc_' + QuestionGroup_ID;
var sub_section_description_previousDiv = $('#'+sub_section_description_Div).prev();
@ -2429,9 +2493,11 @@ scrollToElementWithoutLink(targetId);
//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, questionAreaId = false, questionRandomNo = false, questionMarks = false, questionUUID = false, questionDisplayMarks = false,questionId,CorrectAnswer)
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,questionId, CorrectAnswer)
{
const ChoiceGroupFixed_UUID = uuidv4();
console.log('CorrectAnswer', CorrectAnswer);
// inputAreaCheck(Choice)
@ -2840,7 +2906,14 @@ var typetwoQuestionName = 'textQuestionName_' + addChoiceAreaId;
var quill = new Quill('#'+typetwoQuestionName, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -2848,10 +2921,14 @@ var typetwoQuestionSubtitle = 'textQuestionSubtitle_' + addChoiceAreaId;
var quill = new Quill('#'+typetwoQuestionSubtitle, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
// imageResize:{
// displaySize:true
// }
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -2859,7 +2936,14 @@ var choiceTextField = 'choiceTextField_' + addChoiceAreaId;
var quill = new Quill('#'+choiceTextField, {
theme: 'snow',
modules: {
toolbar: toolbarOptions2
toolbar: toolbarOptions2,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
placeholder: 'Enter Choice',
});
@ -3081,7 +3165,14 @@ $(newChoiceDeleteButtonId).on('click', function() {
var quill = new Quill(newChoiceTextField, {
theme: 'snow',
modules: {
toolbar: toolbarOptions2
toolbar: toolbarOptions2,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
placeholder: 'Enter Choice',
});
@ -3450,7 +3541,14 @@ else
var quill = new Quill('#'+typeOneQuestionName, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -3459,7 +3557,14 @@ else
var quill = new Quill('#'+typeOneQuestionSubtitle, {
theme: 'snow',
modules: {
toolbar: toolbarOptions
toolbar: toolbarOptions,
clipboard: {
matchVisual: true,
},
imageResize:{
displaySize:true,
modules: [ 'Resize', 'DisplaySize', 'Toolbar' ],
}
},
});
@ -3588,7 +3693,6 @@ if(EditScroll !== '1')
// console.log(array_of_Id);
const arrayString = JSON.stringify(array_of_Id);
// console.log(arrayString);
console.log('7');
collect_Empty_Question_Id(arrayString, Textid);
@ -3697,6 +3801,7 @@ function check_Empty_Question()
if (index === array.length - 1) {
var idclass= document.getElementById(Id).className;
console.log(idclass)
if ( idclass === 'QuestionTextIdSet' || idclass === 'QuestionsGroupIdset' || idclass === 'QuestionChoiceId' ) {
attrId = document.getElementById(Id).innerHTML
}else if(idclass === 'multipleAnswerorNot'){
@ -3726,9 +3831,10 @@ function check_Empty_Question()
}
function check_Remove_Empty_Question(IdToRemove) {
console.log('IdToRemove : ', IdToRemove);
// console.log('IdToRemove : ', IdToRemove);
var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION');
var attrId= '';
array_of_Id=[];
var a = IdToRemove;
@ -3753,9 +3859,9 @@ var newVariableWithoutNumbers = a.replace(/\d/g, ''); // This removes all digits
const input_text_value = document.getElementById(IdToRemove);
if (newVariableWithoutNumbers == 'removeAndCloneQroupQuestion_') {
const attrId= '';
attrId= '';
} else {
const attrId = input_text_value.querySelector('.ql-editor')?.innerHTML;
attrId = input_text_value.querySelector('.ql-editor')?.innerHTML;
}
var parsedArray = [];
if (count !== 0) {
@ -3915,6 +4021,7 @@ function scrollToElementWithoutLink(elementId) {
confirmButtonText: 'OK'
});
}
element.focus()
}
}
@ -4575,14 +4682,17 @@ setInterval(imagebuttonidset,3000)
<script>
function findInputByValue(value) {
console.log('test', value);
value.forEach(function (param,index) {
// console.log(param.correct_answer);
var choiceId = param.correct_answer;
// console.log('correctanswer 2', param);
// var choiceId = param.correct_answer;
const inputs = document.getElementsByTagName('input');
// console.log(inputs);
for (let i = 0; i < inputs.length; i++) {
// console.log(choiceId);
if (inputs[i].value === choiceId) {
if (inputs[i].value === param) {
// return inputs[i];
inputs[i].checked= true
}

View File

@ -68,7 +68,10 @@ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
margin: auto;.loaded .loader {
top: -100%;
opacity: 0;
}
padding: 20px;
border: 1px solid #888;
width: 80%;
@ -204,11 +207,17 @@ margin-left: -16px;
<!-- loder -->
<div class="loader-wrapper">
<!-- <div class="loader-wrapper">
<div class="loader"></div>
<div class="loder-section left-section"></div>
<div class="loder-section right-section"></div>
</div>
</div> -->
<div id="overlay">
<div class="cv-spinner">
<span class="spinner"></span>
</div>
</div>
<!-- main-header -->
@ -266,7 +275,8 @@ margin-left: -16px;
</div>
<!-- jquery js -->
<script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
<script src="assets/js/vendor/jquery-3.2.1.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
<!-- <script src="./node_modules/jquery/dist/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script> -->
<!-- bootstrap js -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- carousel js -->
@ -288,7 +298,7 @@ margin-left: -16px;
<!-- venobox min js -->
<script src="venobox/venobox.min.js"></script>
<!-- isotope js -->
<script src="assets/js/isotope.pkgd.min.js"></script>
<!-- <script src="assets/js/isotope.pkgd.min.js"></script> -->
<!-- jquery nivo slider pack js -->
<script src="assets/js/jquery.nivo.slider.pack.js"></script>
<!-- jquery meanmenu js -->
@ -445,6 +455,7 @@ function validateFile(input) {
function downloadFile(filename) {
const xmlFilePath = `${xmlPath}${filename}`;
console.log(xmlFilePath)
const xmlFileNameParts = filename.split('.xml');
const xmlBaseName = xmlFileNameParts[0];
@ -488,75 +499,63 @@ if(fileList !== false)
console.log('isEncrypted NOT');
//Download XML FIle
fs.writeFile(filePathToSave, xmlFilePath, 'utf-8', (err) => {
var errorMessage = "";
if (err) {
// console.log(err.code);
if(err.code == 'EACCES'){
errorMessage = `Permission Denied.<br> Path: ${filePathToSave}`;
}
else if(err.code == 'ENOENT'){
// Download XML File
try {
errorMessage = `No Such File Directory. <br> Path: ${filePathToSave}`;
}
else{
errorMessage = `Unknown Error. <br> Path: ${filePathToSave}`;
}
Swal.fire({
title: "File Download Failed",
html: errorMessage,
icon: "error"
});
} else {
Swal.fire({
title: "File Downloaded",
icon: "success"
});
}
const content = fs.readFileSync(xmlFilePath, 'utf-8');
console.log('xml', content);
fs.writeFileSync(filePathToSave, content, 'utf-8');
Swal.fire({
title: "File Downloaded",
icon: "success"
});
} catch (err) {
let errorMessage = "";
if (err.code === 'EACCES') {
errorMessage = `Permission Denied.<br> Path: ${filePathToSave}`;
} else if (err.code === 'ENOENT') {
errorMessage = `No Such File Directory. <br> Path: ${filePathToSave}`;
} else {
errorMessage = `Unknown Error. <br> Path: ${filePathToSave}`;
}
//Download JSON FIle
if(fileList !== false)
{
fs.writeFile(jsonFilePathToSave, jsonFilePath, 'utf-8', (err) => {
var errorMessage = "";
if (err) {
console.log(err.code);
if(err.code == 'EACCES'){
errorMessage = `Permission Denied.<br> Path: ${jsonFilePathToSave}`;
console.log(errorMessage);
}
else if(err.code == 'ENOENT'){
errorMessage = `No Such File Directory. <br> Path: ${jsonFilePathToSave}`;
console.log(errorMessage);
}
else{
errorMessage = `Unknown Error. <br> Path: ${jsonFilePathToSave}`;
console.log(errorMessage);
}
Swal.fire({
title: "File Download Failed",
html: errorMessage,
icon: "error"
});
} else {
Swal.fire({
title: "File Downloaded",
icon: "success"
});
}
Swal.fire({
title: "File Download Failed",
html: errorMessage,
icon: "error"
});
}
// Download JSON File
if (fileList !== false) {
try {
const content = fs.readFileSync(jsonFilePath, 'utf-8');
console.log('json', content);
fs.writeFileSync(jsonFilePathToSave, content, 'utf-8');
Swal.fire({
title: "File Downloaded",
icon: "success"
});
} catch (err) {
let errorMessage = "";
if (err.code === 'EACCES') {
errorMessage = `Permission Denied.<br> Path: ${jsonFilePathToSave}`;
} else if (err.code === 'ENOENT') {
errorMessage = `No Such File Directory. <br> Path: ${jsonFilePathToSave}`;
} else {
errorMessage = `Unknown Error. <br> Path: ${jsonFilePathToSave}`;
}
Swal.fire({
title: "File Download Failed",
html: errorMessage,
icon: "error"
});
}
}
}
}
@ -583,6 +582,30 @@ function findFile(filePath) {
}
}
function copyFile(sourceFilePath, destinationFilePath) {
// Resolve absolute paths
const sourcePath = path.resolve(sourceFilePath);
const destinationPath = path.resolve(destinationFilePath);
// Read the content of the source file
fs.readFile(sourcePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err.message}`);
return;
}
// Write the content to the destination file
fs.writeFile(destinationPath, data, 'utf8', (err) => {
if (err) {
console.error(`Error writing file: ${err.message}`);
return;
}
console.log(`File copied from ${sourcePath} to ${destinationPath}`);
});
});
}
</script>

View File

@ -303,6 +303,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})));
}

View File

@ -1,10 +1,11 @@
const path = require('path');
const fs = require('fs');
const xml2js = require('xml2js');
document.addEventListener('DOMContentLoaded', async () => {
$("#overlay").show();
document.addEventListener('DOMContentLoaded', async () => {
function getFilesInFolder(folderName) {
const xmlFilePath = path.join(__dirname, folderName);
@ -98,10 +99,11 @@ async function loadMultipleXMLs() {
// Call the function to load and display XML files
loadMultipleXMLs();
$("#overlay").hide();
});

View File

@ -87,6 +87,8 @@ function jsonToHtml(jsonData) {
})
localStorage.removeItem('scroll');
localStorage.removeItem('EditNavExpend');
$("#overlay").hide();
}
@ -112,6 +114,8 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
var questionUUID = Question.attributes.Id;
var questionDisplayMarks = Question.display_marks;
var Choice = Question.answers;
var CorrectAnswer = Question.correct_answer;
var QuestionObj = {
@ -138,7 +142,7 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
}
else if (questionType == 'group')
{
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId);
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,questionId, CorrectAnswer);
// groupQuestion(QuestionObj);
Choice = Choice.slice(1);
@ -157,6 +161,8 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
}
// $("#overlay").hide();
}
@ -174,3 +180,4 @@ function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
});
}

View File

@ -1,144 +1,6 @@
function json2xml() {
// console.clear();
var obj = localStorage.getItem("json");
// var obj = `{
// "question_paper_title": "<p><br></p>",
// "question_paper_description": "<p><br></p>",
// "max_marks": "",
// "course_ID": "",
// "course_Code": "",
// "subject_ID": "",
// "subject_Code": "",
// "paper_No": "",
// "subject_Name": "",
// "sub_Paper_Prefix": "",
// "question_Paper_uuid": "f676ad21-b0d2-4a80-8c77-6cd2b35f1b34",
// "sections": [
// {
// "section_title": "<p>0</p>",
// "section_description": "<p><br></p>",
// "section_marks": "0",
// "section_uuid": "7c62e594-3b93-444f-9fa6-a05f87869db6",
// "section_display_marks": true,
// "section_attempt_any": "",
// "questions": [
// {
// "question": "<p>1</p>",
// "question_description": "<p><br></p>",
// "question_type": "group",
// "question_sub_type": false,
// "is_math_enabled": false,
// "display_marks": true,
// "marks": "",
// "choice_question_uuid": "40f37294-e7cb-4f19-9166-72f7a04f6391",
// "answers": [
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "387d9b85-4702-4e77-a8c3-29d713b7689e",
// "no": "a"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "1a6be686-9e7c-4b07-bf15-b9e07a01fd62",
// "no": "b"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "0640c05b-522e-422c-8050-0d5982aa3c74",
// "no": "c"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "e59f90b0-79d5-413e-85a4-ee3c181230d8",
// "no": "d"
// }
// ],
// "correct_answer": ["1a6be686-9e7c-4b07-bf15-b9e07a01fd62"]
// },
// {
// "question": "<p>2</p>",
// "question_description": "<p><br></p>",
// "question_type": "group",
// "question_sub_type": false,
// "is_math_enabled": false,
// "display_marks": true,
// "marks": "",
// "choice_question_uuid": "7a1c83e7-e9ae-4424-9336-6135eaa6b833",
// "answers": [
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "0cbb8330-8ce9-4d69-b547-68cee529a636",
// "no": "a"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "25dc4fdc-7bcf-4bea-aaa5-dc42a22c08b5",
// "no": "b"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "5b0da327-076f-488c-a46e-0b8251c83283",
// "no": "c"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "d3934305-d6fd-4601-8b1b-08067f47a8dd",
// "no": "d"
// }
// ],
// "correct_answer": ["d3934305-d6fd-4601-8b1b-08067f47a8dd"]
// },
// {
// "question": "<p>3</p>",
// "question_description": "<p><br></p>",
// "question_type": "group",
// "question_sub_type": false,
// "is_math_enabled": false,
// "display_marks": true,
// "marks": "",
// "choice_question_uuid": "6f929b53-9ebc-40fb-800e-46c42b75f2d9",
// "answers": [
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "f839312c-8de5-4cd5-8d6c-3ffd3b9efea6",
// "no": "a"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "905db769-82b2-4240-af06-fe0b15ee1f73",
// "no": "b"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "6a16126f-8100-49f8-ae33-71d4848030cf",
// "no": "c"
// },
// {
// "choice_name": "<p><br></p>",
// "is_math_enabled": false,
// "choice_uuid": "143f648a-d52c-42ff-9428-1c080326e1c8",
// "no": "d"
// }
// ],
// "correct_answer": ["143f648a-d52c-42ff-9428-1c080326e1c8", "6a16126f-8100-49f8-ae33-71d4848030cf"]
// }
// ]
// }
// ]
// }
// `
// console.log(obj);
// console.log('***********************************************************');

View File

@ -19,9 +19,44 @@ function navpane() {
function removeParagraphTags(html) {
return html.replace(/<p>/g, '').replace(/<\/p>/g, '');
return html.replace(/<p>/g, '').replace(/<\/p>/g, '').replace(/<img.*?>/g, '');
}
//function for remove <img> tag
function removeTagsAndTruncate(html, maxLength) {
const doc = new DOMParser().parseFromString(html, 'text/html');
// Remove <p> tags
const paragraphs = doc.getElementsByTagName('p');
for (let i = paragraphs.length - 1; i >= 0; i--) {
const paragraph = paragraphs[i];
paragraph.parentNode.replaceChild(document.createTextNode(paragraph.textContent), paragraph);
}
// Remove <img> tags
const images = doc.getElementsByTagName('img');
for (let i = images.length - 1; i >= 0; i--) {
const image = images[i];
image.parentNode.removeChild(image);
}
// Get the text content
const textContent = doc.body.textContent;
// Truncate the content
var truncatedContent = "";
if(textContent.length > 20)
{
truncatedContent = textContent.substring(0, maxLength) + '...';
}
else{
truncatedContent = textContent;
}
return truncatedContent;
}
function createTreeWithHeading(data, container) {
const treeTitle = removeParagraphTags(data.question_paper_title);
const heading = document.createElement('a');
@ -419,11 +454,11 @@ function navpane() {
nodeDiv.style.paddingLeft='0px';
currentlyHighlightedElement =null
});
if (nodeData.question.length > 20) {
questionLink.innerHTML = removeParagraphTags(nodeData.question.substring(0, 20) + '...');
} else {
questionLink.innerHTML = removeParagraphTags(nodeData.question);
}
questionLink.innerHTML = removeTagsAndTruncate(nodeData.question, 20);
// console.log('questionLink : ', questionLink)
nodeDiv.appendChild(questionLink);
} else if (nodeData.group_title) {

View File

@ -3046,7 +3046,7 @@ a.main_sticky {
/*Loader*/
.loader-wrapper {
/* .loader-wrapper {
position: fixed;
top: 0;
bottom: 0;
@ -3056,8 +3056,8 @@ a.main_sticky {
height: 100%;
transition: 0.8s 1s ease;
z-index: 666;
}
.loader {
} */
/* .loader {
position: relative;
display: block;
z-index: 201;
@ -3104,10 +3104,10 @@ a.main_sticky {
-moz-animation: spin 2.5s linear infinite;
-o-animation: spin 2.5s linear infinite;
animation: spin 2.5s linear infinite;
}
} */
/* Here comes the Magic */
@-webkit-keyframes spin {
/* @-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
@ -3150,38 +3150,36 @@ a.main_sticky {
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
} */
.loader-wrapper .loder-section {
/* .loader-wrapper .loder-section {
position: fixed;
top: 0;
width: 55%;
height: 100%;
background: #111;
z-index: 2;
}
.loader-wrapper .loder-section.left-section {
left: 0;
transition: 1s 1.5s ease;
}
.loader-wrapper .loder-section.right-section {
right: 0;
transition: 1s 1.5s ease;
}
/* When page loaded */
.loaded .loder-section {
} */
/* .loader-wrapper .loder-section.left-section {
left: 0;
transition: 15s 2s ease;
}
.loader-wrapper .loder-section.right-section {
right: 0;
transition: 15s 2s ease;
}
When page loaded
.loaded .loader-wrapper {
display: none;
transition: 1s 1.5s ease;
}
.loaded .loader-wrapper {
display: none;
transition: 1s 1.5s ease;
}
.loaded .loader {
transition: 10s 1.5s ease;
} */
/* .loaded .loader {
top: -100%;
opacity: 0;
}
} */
/* New Add CSS Class */
@ -3780,3 +3778,36 @@ width:85px;
font-weight: 500;
font-size: 14px;
}
#overlay{
position: fixed;
top: 0;
z-index: 100;
width: 100%;
height:100%;
display: none;
background: rgba(0,0,0,0.8);
}
.cv-spinner {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.spinner {
width: 120px;
height: 120px;
border: 16px #ddd solid;
border-top: 16px #2e93e6 solid;
border-radius: 50%;
animation: sp-anime 0.8s infinite linear;
}
@keyframes sp-anime {
100% {
transform: rotate(360deg);
}
}
.is-hide{
display:none;
}

View File

@ -4,7 +4,7 @@ function xml2json(xmlData) {
// console.log(xmlData);
var jsonDecodeData = localStorage.getItem('json_Decode_Data_For_Mcq_Crt_Ans');
// console.log(typeof jsonDecodeData);
console.log(jsonDecodeData);
function getAttributesOfXMLNode(node)
{