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:
bdaneels 2024-11-27 16:39:20 +01:00
parent b92f1c8c29
commit 3b4ccefa66
3 changed files with 27 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules
vars.js
vars.js
.idea

View File

@ -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;

View File

@ -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}`);
}