Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Export data from Powerschool Pro from the console
var nameElements = $('.student-name').toArray();
var assignmentElements = $('var').toArray();
var names = [];
var assignments = [];
var assignmentNumber;
assignmentElements.forEach(function(name,index){
assignments.push(name.innerHTML)
})
names = names.slice(0,0.5*(names.length))
var rows = $( "tr[id*='std']" ).toArray()
rows.forEach(function(row){
var currentName = $(row).find('.student-name')[0].innerHTML;
var gradeElements = $(row).find('var');
gradeElements = gradeElements.slice(1,gradeElements.length).toArray();
grades = [];
gradeElements.forEach(function(grade){
var currGrade = (parseFloat(grade.innerHTML)!=NaN)?parseFloat(grade.innerHTML):'';
grades.push(currGrade)
})
if(grades.length>0){
names.push([currentName,grades])
}
})
assignmentNumber = names[0][1].length;
assignmentString = 'Name \t';
for(var i = 0;i<2*assignmentNumber-1;i+=2){
assignmentString += assignments[i] + '\t '
}
var gradeString = '';
names.forEach(function(name){
var currentString = '';
currentString += name[0]+ "\t "
name[1].forEach(function(grade){
currentString += grade + "\t "
})
gradeString += currentString + "\n "
})
var exportData = assignmentString+"\n"+gradeString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment