add updateResultsDatabase functionality and results.json for storing course results
This commit is contained in:
parent
8c5dc7db04
commit
df67c3c2c5
|
@ -14,6 +14,7 @@ const wait = require("./wait");
|
|||
const courseEnrolled = require("./coursesEnrolled");
|
||||
const parseCourseResults = require('./utils/parseCourseResults');
|
||||
const config = require("./config.js");
|
||||
const updateResultsDatabase = require("./utils/updateResultsDatabase");
|
||||
|
||||
async function iterateOverDashboardTable() {
|
||||
/*connection to local host */
|
||||
|
@ -146,6 +147,7 @@ async function iterateOverDashboardTable() {
|
|||
}
|
||||
results.push(result);
|
||||
appendToExcel(result, filename);
|
||||
updateResultsDatabase(result)
|
||||
}
|
||||
|
||||
|
||||
|
|
74
utils/results.json
Normal file
74
utils/results.json
Normal file
|
@ -0,0 +1,74 @@
|
|||
[
|
||||
{
|
||||
"LinkNumber": 1,
|
||||
"StudentName": "William Van Dessel",
|
||||
"StudentID": "20001044",
|
||||
"IsCollapsed": "Yes",
|
||||
"IsCollapsedKeuze": "Yes",
|
||||
"IsCollapsedMain": "Yes",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1010FLWGES Gesch. van de middeleeuwen - 6.00SP, \n1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, \n1053FLWGES Hist oef 1 - 6.00SP, ",
|
||||
"totalStudiepunten": 24
|
||||
},
|
||||
{
|
||||
"LinkNumber": 2,
|
||||
"StudentName": "Joren Van Roy",
|
||||
"StudentID": "20141999",
|
||||
"IsCollapsed": "No",
|
||||
"IsCollapsedKeuze": "Yes",
|
||||
"IsCollapsedMain": "No",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, \n1300PSWSOC Inleiding tot de Sociologie - 6.00SP, \n1087FLWGES Central and Eastern Europe - 3.00SP, \n1013FLWGES Eigentijdse geschiedenis - 6.00SP, \n1200PSWPOL Inleiding tot de Politicologie - 6.00SP, \n1104TEWVSG Inl. tot het recht - 6.00SP, \n1300PSWSFP Samenleving, feiten, problemen - 6.00SP, \n1302TEWVSG Levensbesch., mens en markt - 3.00SP, ",
|
||||
"totalStudiepunten": 48
|
||||
},
|
||||
{
|
||||
"LinkNumber": 4,
|
||||
"StudentName": "Zeynep Öcbe",
|
||||
"StudentID": "20193168",
|
||||
"IsCollapsed": "No",
|
||||
"IsCollapsedKeuze": "No",
|
||||
"IsCollapsedMain": "No",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, \n1053FLWGES Hist oef 1 - 6.00SP, \n1067FLWGES Byzantijnse gesch. - 3.00SP, \n1001IOBGJU Global Justice - 3.00SP, ",
|
||||
"totalStudiepunten": 24
|
||||
},
|
||||
{
|
||||
"LinkNumber": 5,
|
||||
"StudentName": "Jens Aelbrecht",
|
||||
"StudentID": "20213047",
|
||||
"IsCollapsed": "No",
|
||||
"IsCollapsedKeuze": "Yes",
|
||||
"IsCollapsedMain": "No",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1002FLWGES Inleiding tot de economie - 6.00SP, \n1005FLWGES Oefeningen paleografie - 3.00SP, \n1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, \n1053FLWGES Hist oef 1 - 6.00SP, \n1300PSWSOC Sociologie - 6.00SP, \n1054FLWGES Inleiding wijsbegeerte - 6.00SP, \n1067FLWGES Byzantijnse gesch. - 3.00SP, \n1000PSWPUB Publiekrecht - 3.00SP, \n1013FLWGES Eigentijdse geschiedenis - 6.00SP, \n1200PSWPOL Politicologie - 6.00SP, \n1001CPGVKA Levensbeschouwing & wet - 3.00SP, ",
|
||||
"totalStudiepunten": 60
|
||||
},
|
||||
{
|
||||
"LinkNumber": 6,
|
||||
"StudentName": "Hadi Dagher",
|
||||
"StudentID": "20221279",
|
||||
"IsCollapsed": "No",
|
||||
"IsCollapsedKeuze": "No",
|
||||
"IsCollapsedMain": "No",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1002FLWGES Inleiding tot de economie - 6.00SP, \n1005FLWGES Oefeningen paleografie - 3.00SP, \n1053FLWGES Hist oef 1 - 6.00SP, \n1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, ",
|
||||
"totalStudiepunten": 27
|
||||
},
|
||||
{
|
||||
"LinkNumber": 7,
|
||||
"StudentName": "Casper Janssens",
|
||||
"StudentID": "20221960",
|
||||
"IsCollapsed": "No",
|
||||
"IsCollapsedKeuze": "Yes",
|
||||
"IsCollapsedMain": "No",
|
||||
"ContainsVZP": "No",
|
||||
"ContainsVZPKeuze": "No",
|
||||
"coursesResult": "1002FLWGES Inleiding tot de economie - 6.00SP, \n1003FLWGES Historische methode - 6.00SP, \n1005FLWGES Oefeningen paleografie - 3.00SP, \n1010FLWGES Gesch. van de middeleeuwen - 6.00SP, \n1011FLWGES Gesch. van de nieuwe tijd - 6.00SP, \n1014FLWGES Inleiding wereldgeschiedenis - 6.00SP, \n1053FLWGES Hist oef 1 - 6.00SP, \n1000RECPOL Politicologie - 3.00SP, \n1300PSWSOC Sociologie - 6.00SP, \n1000RECGPR Geschiedenis privaatrecht - 6.00SP, \n1200RECTEN Taalgebruik Engels - 3.00SP, ",
|
||||
"totalStudiepunten": 57
|
||||
}
|
||||
]
|
39
utils/updateResultsDatabase.js
Normal file
39
utils/updateResultsDatabase.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const resultsFilePath = path.join(__dirname, "results.json");
|
||||
|
||||
// Flag to track if the file has been reset
|
||||
let isFileReset = false;
|
||||
|
||||
function updateResultsDatabase(newResult) {
|
||||
// Check if the file needs to be reset
|
||||
if (!isFileReset) {
|
||||
if (fs.existsSync(resultsFilePath)) {
|
||||
const fileContent = fs.readFileSync(resultsFilePath, "utf-8");
|
||||
if (fileContent.trim()) {
|
||||
// Reset the file to an empty array
|
||||
fs.writeFileSync(resultsFilePath, JSON.stringify([], null, 2));
|
||||
console.log("Old data removed from results.json.");
|
||||
}
|
||||
}
|
||||
isFileReset = true; // Mark the file as reset
|
||||
}
|
||||
|
||||
// Read existing results or initialize an empty array
|
||||
let results = [];
|
||||
if (fs.existsSync(resultsFilePath)) {
|
||||
const fileContent = fs.readFileSync(resultsFilePath, "utf-8");
|
||||
if (fileContent.trim()) {
|
||||
results = JSON.parse(fileContent);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the new result to the array
|
||||
results.push(newResult);
|
||||
|
||||
// Write the updated results back to the file
|
||||
fs.writeFileSync(resultsFilePath, JSON.stringify(results, null, 2));
|
||||
}
|
||||
|
||||
module.exports = updateResultsDatabase;
|
Loading…
Reference in New Issue
Block a user