diff --git a/QuestionPreview.html b/QuestionPreview.html
index e369721..35baf77 100644
--- a/QuestionPreview.html
+++ b/QuestionPreview.html
@@ -489,35 +489,102 @@ color: #1d3557 !important;
//Preview edit button
document.getElementById("editlink").href = "addform.html?filename=" + xmlFileName;
- // Function to load XML from a file
- function loadXML(xmlFileName) {
+//XmlPath get from .env
+
+// const decode = require('./decode');
+
+// Function to load XML from a file
+function loadXML(xmlFileName) {
- //XmlPath get from .env
const xmlPathenv=configObject.XML_FILE_PATH.trim();
-
- // const xmlPathenv=process.env.XML_FILE_PATH;
const xmlPath =path.join(__dirname,xmlPathenv);
- // console.log(xmlFileName)
- return new Promise((resolve, reject) => {
- fs.readFile(`${xmlPath}`+xmlFileName, 'utf8', (error, data) => {
- if (error) {
- reject(error);
- } else {
- if (isEncrypted === 'YES') {
- var decodeData = decode(data);
- resolve(decodeData);
- xml2json(decodeData);
- } else {
- resolve(data);
- xml2json(data);
- }
- MathJax.typeset();
- }
- });
- });
- }
-
-
+
+ // console.log('xmlFileName', xmlFileName);
+
+ var decodeData ="";
+ var encodedXmlFilePath = `${xmlPath}${xmlFileName}`;
+
+ var jsonDecodeData = "";
+ var jsonFileName = xmlFileName.split('.xml');
+ var encodedJsonFilePath = `${xmlPath}${jsonFileName[0]}_answer.json`;
+
+ // console.log('encodedJsonFilePath', encodedJsonFilePath);
+
+ var filelist = findFile(encodedJsonFilePath);
+ const decode = require('./decode');
+ if(filelist !== false)
+ {
+ //JSON File Read Function
+ fs.readFile(encodedJsonFilePath, 'utf8', (error, data) => {
+ if (error) {
+ console.error('Error reading file:', error);
+ } else {
+ if (isEncrypted === 'YES') {
+
+ jsonDecodeData = decode(encodedJsonFilePath);
+ localStorage.setItem('json_Decode_Data_For_Mcq_Crt_Ans', jsonDecodeData);
+
+ } else{
+ jsonDecodeData = data;
+ localStorage.setItem('json_Decode_Data_For_Mcq_Crt_Ans', jsonDecodeData);
+ console.log('jsonDecodeData', jsonDecodeData);
+
+ }
+
+ }
+ });
+ }
+ setTimeout(function() {
+
+ fs.readFile(`${xmlPath}${xmlFileName}`, 'utf8', (error, data) => {
+ if (error) {
+ console.error('Error reading file:', error);
+ } else {
+ if (isEncrypted === 'YES') {
+ // decrypt function call go to decode.js
+ decodeData = decode(encodedXmlFilePath);
+
+ } else{
+ decodeData = data;
+ }
+ console.log('jsonDecodeData : ', jsonDecodeData);
+ xml2json(decodeData);
+
+
+ }
+ });
+
+ }, 1000);
+
+ }
+
+
+
+
+ // Function for Finding the JSON File in the folder
+function findFile(filePath) {
+try {
+ const stats = fs.statSync(filePath);
+
+ if (stats.isFile()) {
+
+ // File exists
+ // console.log(`File found at: ${filePath}`);
+ return true;
+ } else {
+ // console.error(`Path is not a file: ${filePath}`);
+ return false;
+ }
+} catch (err) {
+ // console.error(`File not found: ${filePath}`);
+ return false;
+}
+}
+
+
+
+
+
diff --git a/addform.html b/addform.html
index e759839..5ac03cf 100644
--- a/addform.html
+++ b/addform.html
@@ -1299,41 +1299,43 @@ $('#workarea_math').click(function(){
console.log('called');
$('#workarea_math').css('margin-bottom', '240px');
localStorage.setItem('workAreaMath', true);
- });
+});
$(document).on("click", function (event) {
-// console.log('Clicked element id:', event.target.id);
-// console.log('Clicked element:', event.target);
+ // console.log('Clicked element id:', event.target.id);
+ // console.log('Clicked element:', event.target);
-const targetElement = event.target;
-var tragetedId = event.target.id.startsWith("ML");
-const classList = Array.from(event.target.classList);
-const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action"));
-const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
-// console.log('svg',isSvgElement);
-// console.log(hasMLKClass);
+ const targetElement = event.target;
+ var tragetedId = event.target.id.startsWith("ML");
+ const classList = Array.from(event.target.classList);
+ const hasMLKClass = classList.some(className => className.startsWith("MLK") || className.startsWith("row") || className.startsWith("left") || className.startsWith("ML") || className.startsWith("action"));
+ const isSvgElement = targetElement.closest('svg') || targetElement.closest('i');
+ // console.log('svg',isSvgElement);
+ // console.log(hasMLKClass);
-if (event.target.id !== 'workarea_math' && tragetedId == false && hasMLKClass == false && isSvgElement == null) {
- // console.log('Inside if');
- var value = localStorage.getItem('workAreaMath');
+ if (event.target.id !== 'workarea_math' && tragetedId == false && hasMLKClass == false && isSvgElement == null) {
+ // console.log('Inside if');
+ var value = localStorage.getItem('workAreaMath');
- if (value === 'true') {
- // console.log('Value:', value);
- $('#workarea_math').css('margin-bottom', '0px');
- localStorage.removeItem('workAreaMath');
- } else {
- // $('#workarea_math').css('margin-bottom', '190px');
- // console.log('Value is not true');
+ if (value === 'true') {
+ // console.log('Value:', value);
+ $('#workarea_math').css('margin-bottom', '0px');
+ localStorage.removeItem('workAreaMath');
+ } else {
+ // $('#workarea_math').css('margin-bottom', '190px');
+ // console.log('Value is not true');
+ }
}
-}
});
var ids = document.getElementById('workarea_math');
+
+//clear the string from the workarea and a fileds
function clearMessage() {
var val = document.getElementById('messages') ;
if(val !== null){
@@ -1465,7 +1467,9 @@ var previewbutton = document.getElementById("editPreview");
function editPreview() {
var title_id = localStorage.getItem('JSON_FOR_EMPTY_QUESTION');
- var count = "";
+ var count = "";//XmlPath get from .env
+
+// const decode = require('./decode');
if(title_id !== '' && title_id !== null)
{
var parsedArray = JSON.parse(title_id);
@@ -1550,22 +1554,22 @@ var previewbutton = document.getElementById("editPreview");
// Function for Finding the JSON File in the folder
function findFile(filePath) {
- try {
- const stats = fs.statSync(filePath);
+try {
+ const stats = fs.statSync(filePath);
- if (stats.isFile()) {
+ if (stats.isFile()) {
- // File exists
- // console.log(`File found at: ${filePath}`);
- return true;
- } else {
- // console.error(`Path is not a file: ${filePath}`);
- return false;
- }
- } catch (err) {
- // console.error(`File not found: ${filePath}`);
- return false;
- }
+ // File exists
+ // console.log(`File found at: ${filePath}`);
+ return true;
+ } else {
+ // console.error(`Path is not a file: ${filePath}`);
+ return false;
+ }
+} catch (err) {
+ // console.error(`File not found: ${filePath}`);
+ return false;
+}
}
@@ -1587,7 +1591,7 @@ function loadXML(xmlFileName) {
// console.log('encodedJsonFilePath', encodedJsonFilePath);
var filelist = findFile(encodedJsonFilePath);
-
+ const decode = require('./decode');
if(filelist !== false)
{
//JSON File Read Function
diff --git a/dashboard.html b/dashboard.html
index a1daa04..0a8977d 100644
--- a/dashboard.html
+++ b/dashboard.html
@@ -432,9 +432,9 @@ function validateFile(input) {
const allowedExtensions = ["xml"];
const fileExtension = file.name.split(".").pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
- alert('Invalid file type. Only xml files are allowed.')
- input.value = "";
- return;
+ alert('Invalid file type. Only xml files are allowed.')
+ input.value = "";
+ return;
}
}
@@ -460,19 +460,19 @@ function validateFile(input) {
function downloadFile(filename) {
- console.log(xmlPath);
+// console.log(xmlPath);
const xmlFilePath = `${xmlPath}${filename}`;
-console.log(xmlFilePath)
+// console.log(xmlFilePath)
const xmlFileNameParts = filename.split('.xml');
const xmlBaseName = xmlFileNameParts[0];
const jsonFileName = `${xmlBaseName}_answer.json`;
const jsonFilePath = `${xmlPath}${jsonFileName}`;
-console.log(jsonFilePath);
+// console.log(jsonFilePath);
var fileList = findFile(jsonFilePath);
-console.log(fileList)
+// console.log(fileList)
// const downloadsPath = process.env.DOWNLOAD_XML_FILE_PATH;
@@ -480,18 +480,18 @@ console.log(fileList)
// const isEncrypted = process.env.ENCRYPTED;
const downloadsPath = configObject.DOWNLOAD_XML_FILE_PATH.trim();
-console.log(downloadsPath,'downloadpath');
+// console.log(downloadsPath,'downloadpath');
const isEncrypted = configObject.ENCRYPTED.trim();
const filePathToSave = path.join(downloadsPath, filename);
const jsonFilePathToSave = path.join(downloadsPath, jsonFileName);
- console.log(filePathToSave);
- console.log(jsonFilePathToSave);
+// console.log(filePathToSave);
+// console.log(jsonFilePathToSave);
if(isEncrypted == 'YES'){
- console.log('isEncrypted');
+ // console.log('isEncrypted');
// XML File
@@ -510,7 +510,7 @@ if(fileList !== false)
}
else{
- console.log('isEncrypted NOT');
+ // console.log('isEncrypted NOT');
// //Download XML FIle
// console.log(xmlFilePath);