Enhance logging with student details in evaluation
Updated `iterateOverDashboardTable.js` to include student name and ID in log output. Added functions in `evaluateStartPakket.js` to fetch student name and ID from specified selectors. Adjusted `.gitignore` to exclude `.idea` directory.
This commit is contained in:
parent
3b4ccefa66
commit
05a1b85801
|
@ -1,8 +1,10 @@
|
||||||
|
// Vars
|
||||||
const IFRAME_SELECTOR = 'iframe[title="Hoofdinhoud"]';
|
const IFRAME_SELECTOR = 'iframe[title="Hoofdinhoud"]';
|
||||||
const CELL_SELECTOR =
|
const CELL_SELECTOR =
|
||||||
'a[title="Sectie uitvouwen Algemene opleidingsonderdelen"]';
|
'a[title="Sectie uitvouwen Algemene opleidingsonderdelen"]';
|
||||||
const STUDENT_NAME_CELL_SELECTOR = 'span[id="DERIVED_SCC_SUM_PERSON_NAME$5$"]'
|
const STUDENT_NAME_CELL_SELECTOR = 'span[id="DERIVED_SCC_SUM_PERSON_NAME$5$"]'
|
||||||
const STUDENT_ID_CELL_SELECTOR = 'span[id="SCC_PERS_SA_VW_EMPLID"]'
|
const STUDENT_ID_CELL_SELECTOR = 'span[id="SCC_PERS_SA_VW_EMPLID"]'
|
||||||
|
const STPKT_KEUZE_CELL_SELECTOR = 'a[title="Sectie uitvouwen Keuzeopleidingsonderdelen"]'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracted function to get the text content of a node.
|
* Extracted function to get the text content of a node.
|
||||||
|
@ -39,6 +41,7 @@ async function isStartPakketAvailable(page) {
|
||||||
const contentFrame = await getContentFrame(page);
|
const contentFrame = await getContentFrame(page);
|
||||||
await contentFrame.waitForSelector(CELL_SELECTOR);
|
await contentFrame.waitForSelector(CELL_SELECTOR);
|
||||||
const cell = await contentFrame.$(CELL_SELECTOR);
|
const cell = await contentFrame.$(CELL_SELECTOR);
|
||||||
|
const cell_keuze = await contentFrame.$(STPKT_KEUZE_CELL_SELECTOR)
|
||||||
|
|
||||||
if (!cell ) {
|
if (!cell ) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -47,16 +50,19 @@ async function isStartPakketAvailable(page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//object vars
|
//object vars
|
||||||
const isCollapsed = await isAriaExpandedFalse(cell);
|
const isCollapsed_main = await isAriaExpandedFalse(cell);
|
||||||
|
const isCollapsed_keuze = await getIsCollapsedKeuze(cell_keuze);
|
||||||
|
const isCollapsed = isCollapsed_main && isCollapsed_keuze;
|
||||||
const studName = await getStudName(contentFrame);
|
const studName = await getStudName(contentFrame);
|
||||||
const studId = await getStudId(contentFrame);
|
const studId = await getStudId(contentFrame);
|
||||||
console.log(`Aria-expanded: ${isCollapsed}`);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isCollapsed: isCollapsed,
|
isCollapsed: isCollapsed,
|
||||||
|
isCollapsed_main: isCollapsed_main,
|
||||||
|
isCollapsed_keuze: isCollapsed_keuze,
|
||||||
studName: studName,
|
studName: studName,
|
||||||
studId: studId,
|
studId: studId,
|
||||||
// Add more properties here in the future as needed
|
// more properties here
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +81,14 @@ async function isAriaExpandedFalse(node) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getIsCollapsedKeuze(cell_keuze) {
|
||||||
|
if (cell_keuze) {
|
||||||
|
return await isAriaExpandedFalse(cell_keuze);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getStudName(frame) {
|
async function getStudName(frame) {
|
||||||
const cell = await frame.$(STUDENT_NAME_CELL_SELECTOR);
|
const cell = await frame.$(STUDENT_NAME_CELL_SELECTOR);
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
|
|
|
@ -6,6 +6,9 @@ start dan het script
|
||||||
*/
|
*/
|
||||||
const puppeteer = require("puppeteer");
|
const puppeteer = require("puppeteer");
|
||||||
const isStartPakketAvailable = require("./evaluateStartPakket");
|
const isStartPakketAvailable = require("./evaluateStartPakket");
|
||||||
|
const xlsx = require("xlsx");
|
||||||
|
const fs = require("fs");
|
||||||
|
const saveResultsToExcel = require("./saveResultsToExcel");
|
||||||
|
|
||||||
async function iterateOverDashboardTable() {
|
async function iterateOverDashboardTable() {
|
||||||
/*connection to local host */
|
/*connection to local host */
|
||||||
|
@ -13,6 +16,9 @@ async function iterateOverDashboardTable() {
|
||||||
browserURL: "http://localhost:9222", // Connect to the browser's debugging address
|
browserURL: "http://localhost:9222", // Connect to the browser's debugging address
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//array to store results for Excel export
|
||||||
|
let results = []
|
||||||
|
|
||||||
// Get all open pages (tabs)
|
// Get all open pages (tabs)
|
||||||
const pages = await browser.pages();
|
const pages = await browser.pages();
|
||||||
console.log(`Found ${pages.length} open pages on the browser.`);
|
console.log(`Found ${pages.length} open pages on the browser.`);
|
||||||
|
@ -49,6 +55,7 @@ async function iterateOverDashboardTable() {
|
||||||
);
|
);
|
||||||
console.log(`Found ${links.length} AA-links to process.`);
|
console.log(`Found ${links.length} AA-links to process.`);
|
||||||
|
|
||||||
|
// process links
|
||||||
for (let i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
console.log(`Processing link ${i + 1}`);
|
console.log(`Processing link ${i + 1}`);
|
||||||
|
|
||||||
|
@ -76,19 +83,39 @@ async function iterateOverDashboardTable() {
|
||||||
try {
|
try {
|
||||||
const evaluationResult = await isStartPakketAvailable(newPage);
|
const evaluationResult = await isStartPakketAvailable(newPage);
|
||||||
|
|
||||||
if (evaluationResult.isCollapsed) {
|
//Save results for Excel
|
||||||
console.log(`Evaluation succeeded for link ${i + 1} student name: ${evaluationResult.studName}
|
results.push({
|
||||||
ID: ${evaluationResult.studId}`);
|
LinkNumber: i +1,
|
||||||
} else {
|
StudentName: evaluationResult.studName || 'N/A',
|
||||||
console.log(`Evaluation failed for link ${i + 1}`);
|
StudentID: evaluationResult.studId || "N/A",
|
||||||
}
|
IsCollapsed: evaluationResult.isCollapsed ? "Yes" : "No",
|
||||||
|
IsCollapsedKeuze: evaluationResult.isCollapsed_keuze ? "Yes" : "No",
|
||||||
|
IsCollapsedMain: evaluationResult.isCollapsed_main ? "Yes" : "No",
|
||||||
|
})
|
||||||
|
console.log(`Link ${i + 1 } processed successfully.`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error processing link ${i + 1}:`, error.message);
|
console.error(`Error processing link ${i + 1}:`, error.message);
|
||||||
|
// Save error for Excel
|
||||||
|
results.push({
|
||||||
|
LinkNumber: i + 1,
|
||||||
|
StudentName: "Error",
|
||||||
|
StudentID: "Error",
|
||||||
|
IsCollapsed: "Error",
|
||||||
|
IsCollapsedKeuze: "Error",
|
||||||
|
IsCollapsedMain: "Error",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
await newPage.close();
|
await newPage.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("All links processed.");
|
console.log("All links processed.");
|
||||||
|
saveResultsToExcel(results, "DashboardResults.xlsx");
|
||||||
|
console.log("Results saved successfully to DashboardResults.xlsx");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = iterateOverDashboardTable();
|
module.exports = iterateOverDashboardTable();
|
||||||
|
|
106
package-lock.json
generated
106
package-lock.json
generated
|
@ -9,7 +9,8 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"inquirer": "^12.1.0",
|
"inquirer": "^12.1.0",
|
||||||
"puppeteer": "^23.7.0"
|
"puppeteer": "^23.7.0",
|
||||||
|
"xlsx": "^0.18.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
|
@ -333,6 +334,15 @@
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/adler-32": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/agent-base": {
|
"node_modules/agent-base": {
|
||||||
"version": "7.1.1",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz",
|
||||||
|
@ -525,6 +535,19 @@
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/cfb": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"adler-32": "~1.3.0",
|
||||||
|
"crc-32": "~1.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chardet": {
|
"node_modules/chardet": {
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
|
||||||
|
@ -568,6 +591,15 @@
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/codepage": {
|
||||||
|
"version": "1.15.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz",
|
||||||
|
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/color-convert": {
|
"node_modules/color-convert": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
@ -612,6 +644,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/crc-32": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"crc32": "bin/crc32.njs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/data-uri-to-buffer": {
|
"node_modules/data-uri-to-buffer": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
|
||||||
|
@ -801,6 +845,15 @@
|
||||||
"pend": "~1.2.0"
|
"pend": "~1.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/frac": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fs-extra": {
|
"node_modules/fs-extra": {
|
||||||
"version": "11.2.0",
|
"version": "11.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
|
||||||
|
@ -1370,6 +1423,18 @@
|
||||||
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
|
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
|
||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
|
"node_modules/ssf": {
|
||||||
|
"version": "0.11.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz",
|
||||||
|
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"frac": "~1.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/streamx": {
|
"node_modules/streamx": {
|
||||||
"version": "2.20.1",
|
"version": "2.20.1",
|
||||||
"resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.1.tgz",
|
"resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.1.tgz",
|
||||||
|
@ -1514,6 +1579,24 @@
|
||||||
"integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==",
|
"integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/wmf": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/word": {
|
||||||
|
"version": "0.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz",
|
||||||
|
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/wrap-ansi": {
|
"node_modules/wrap-ansi": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
|
||||||
|
@ -1558,6 +1641,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/xlsx": {
|
||||||
|
"version": "0.18.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz",
|
||||||
|
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"adler-32": "~1.3.0",
|
||||||
|
"cfb": "~1.2.1",
|
||||||
|
"codepage": "~1.15.0",
|
||||||
|
"crc-32": "~1.2.1",
|
||||||
|
"ssf": "~0.11.2",
|
||||||
|
"wmf": "~1.0.1",
|
||||||
|
"word": "~0.3.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"xlsx": "bin/xlsx.njs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/y18n": {
|
"node_modules/y18n": {
|
||||||
"version": "5.0.8",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"inquirer": "^12.1.0",
|
"inquirer": "^12.1.0",
|
||||||
"puppeteer": "^23.7.0"
|
"puppeteer": "^23.7.0",
|
||||||
|
"xlsx": "^0.18.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
saveResultsToExcel.js
Normal file
10
saveResultsToExcel.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
function saveResultsToExcel(data, filename) {
|
||||||
|
const workbook = xlsx.utils.book_new(); // Create a new workbook
|
||||||
|
const worksheet = xlsx.utils.json_to_sheet(data); // Convert data to worksheet
|
||||||
|
xlsx.utils.book_append_sheet(workbook, worksheet, "Results"); // Add worksheet to workbook
|
||||||
|
|
||||||
|
// Write workbook to file
|
||||||
|
xlsx.writeFile(workbook, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = saveResultsToExcel;
|
Loading…
Reference in New Issue
Block a user