Skip to content

Instantly share code, notes, and snippets.

@battis
Created August 21, 2024 17:11
Show Gist options
  • Save battis/81d72c542c0f2e7beb250bc8a27d9c91 to your computer and use it in GitHub Desktop.
Save battis/81d72c542c0f2e7beb250bc8a27d9c91 to your computer and use it in GitHub Desktop.
Parse the web view of Blackbaud's "Manage Learning Profiles" into a TSV list
/*
* Parse the list of learning profiles under
* Academics > Grades > Grades Management > Manage Learning Profiles
*
* The output is essentially a TSV.
*
* There is a known bug in Blackbaud were past students' (not alums) names are
* not shown (Case 019825709). The names have to be deduced by actually viewing
* the learning profile. All of these names are at the start of the list.
*/
let student = [];
let students = Array.from(document.querySelectorAll('.maintext .tblrow')).reduce((students, row) => {
if (row.querySelector('img')) {
students.push(student);
student = [];
return students;
} else {
student.push(row);
return students;
}
}, []).map(s => s.map(r => Array.from(r.querySelectorAll('.tblcell')).reduce((data, cell) => {
if (cell.querySelector('a') || cell.innerText == '') {
return data;
} else {
const status = cell.innerText.match(/^(Active|Inactive|Pending): (.+)$/);
if (status) {
data.push(status[1], status[2]);
} else {
const author = cell.innerText.match(/^Author: (.+)$/);
if (author) {
data.push(author[1]);
} else {
const name = cell.innerText.match(/^(.+), ([^\(]+)( \((.+)\))? '(\d+)$/)
if (name) {
data.push(name[1], name[2], name[4] || '', `20${name[5]}`)
} else {
data.push(cell.innerText)
}
}
}
return data;
}
}, []))).map(student => {
const final = [];
for (const row of student) {
final.push(...row);
}
return final;
}).map(student => student.join('\t')).join('\n');
console.log(students);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment