From 3b4ccefa66f7776067f83e1c68452f9af8ffbca1 Mon Sep 17 00:00:00 2001 From: bdaneels Date: Wed, 27 Nov 2024 16:39:20 +0100 Subject: [PATCH] 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. --- .gitignore | 3 ++- evaluateStartPakket.js | 24 +++++++++++++++++++++++- iterateOverDashboardTable.js | 3 ++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f89b161..153875e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -vars.js \ No newline at end of file +vars.js +.idea \ No newline at end of file diff --git a/evaluateStartPakket.js b/evaluateStartPakket.js index 5d86f9a..839f3d3 100644 --- a/evaluateStartPakket.js +++ b/evaluateStartPakket.js @@ -1,6 +1,8 @@ const IFRAME_SELECTOR = 'iframe[title="Hoofdinhoud"]'; const CELL_SELECTOR = 'a[title="Sectie uitvouwen Algemene opleidingsonderdelen"]'; +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"]' /** * Extracted function to get the text content of a node. @@ -44,12 +46,16 @@ async function isStartPakketAvailable(page) { ); } + //object vars const isCollapsed = await isAriaExpandedFalse(cell); - + const studName = await getStudName(contentFrame); + const studId = await getStudId(contentFrame); console.log(`Aria-expanded: ${isCollapsed}`); return { isCollapsed: isCollapsed, + studName: studName, + studId: studId, // Add more properties here in the future as needed }; } @@ -69,4 +75,20 @@ async function isAriaExpandedFalse(node) { ); } +async function getStudName(frame) { + const cell = await frame.$(STUDENT_NAME_CELL_SELECTOR); + if (!cell) { + throw new Error("Cell student name is not defined"); + } + return await getNodeTextContent(cell); +} + +async function getStudId(frame) { + const cell = await frame.$(STUDENT_ID_CELL_SELECTOR); + if (!cell) { + throw new Error("Cell student id is not defined"); + } + return await getNodeTextContent(cell); +} + module.exports = isStartPakketAvailable; diff --git a/iterateOverDashboardTable.js b/iterateOverDashboardTable.js index bf1bff4..605e86f 100644 --- a/iterateOverDashboardTable.js +++ b/iterateOverDashboardTable.js @@ -77,7 +77,8 @@ async function iterateOverDashboardTable() { const evaluationResult = await isStartPakketAvailable(newPage); if (evaluationResult.isCollapsed) { - console.log(`Evaluation succeeded for link ${i + 1}`); + console.log(`Evaluation succeeded for link ${i + 1} student name: ${evaluationResult.studName} + ID: ${evaluationResult.studId}`); } else { console.log(`Evaluation failed for link ${i + 1}`); }