Skip to content

Instantly share code, notes, and snippets.

@casdr
Created June 4, 2017 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casdr/ffe4e2e4a7eb6f9b0bb1f29c3351a33d to your computer and use it in GitHub Desktop.
Save casdr/ffe4e2e4a7eb6f9b0bb1f29c3351a33d to your computer and use it in GitHub Desktop.
Get itslearning grades and format them nicely
__author__ = "Cas de Reuver"
__copyright__ = "Copyright (C) 2017 BlaLabs"
__license__ = "GPLv2"
__version__ = "1.1.0"
# heeft deze 2 dingetjes nodig
# kan gwn pip install beautifulsoup4 prettytable doen
from bs4 import BeautifulSoup
from prettytable import PrettyTable
import sys
fijl = open(sys.argv[1], 'r').read()
tomatensoep = BeautifulSoup(fijl, 'html.parser')
groupies = {}
for tomaat in tomatensoep.find_all(class_='ccl-accordion-section'):
sjors = tomaat.find(class_='ccl-accordion-section-header-container').get_text().strip()
nummertjes = []
for nummertje in tomaat.find_all(class_='ccl-rwgm-col-three'):
nummertjes.append({
'autobandventieldopje': nummertje.find(class_='gb-headerlink').get_text(),
'bushalte': nummertje.find(class_='assessmentcontainer').get_text().replace('Grade: ', '').replace('Cijfer: ', '') # begin te nederlandsen
})
groupies[sjors] = nummertjes
poppetje = tomatensoep.find(class_='ccl-pageheader-title').get_text()
print("Grade list for " + poppetje)
print()
for titeltje, nummertjes in groupies.items():
print(titeltje)
t = PrettyTable(['Name', 'Grade'])
for aardappel in nummertjes:
t.add_row([aardappel['autobandventieldopje'], aardappel['bushalte']])
print(t)
print()
print("Legend: 7.5-10 = Goed, 5.5-7.5 = Beetje goed, 4.5-5.5 = Onvoldoende")
print("Generated by blalabs.itslearning.gradeparser")
print("Created by Cas de Reuver <cdreuver@blalabs.com>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment