def markbar(m): return str(qt.tag('span', "%s" % ','.join(["%2.1f" % (i-classavg) for i in m]), {'class': 'bar'}))
""") def getlect(p): return Project(p).lecturer c = dict((key, len(list(vals))) for (key, vals) in itertools.groupby(projects, getlect)) lecturers = sorted(c.keys()) # TODO: this table desperately needs to keep the headers on top # Options to try: # http://stackoverflow.com/questions/643340/freeze-th-header-and-scrolling-data outfile.write(str(qt.h1('Selections'))) outfile.write(str(qt.p('Report generated on ' + datetime.datetime.now().strftime('%c')))) outfile.write("<table class='selectionmatrix'>\n") outfile.write(str(qt.tag('colgroup', [], {'class': 'names'}))) for l in lecturers: outfile.write(str(qt.tag('colgroup', [], {'span': c[l], 'class': 'lect', 'id': 'col_'+l}))) outfile.write("<thead>") outfile.write(str(qt.tr([qt.th()] + [qt.th(l, {'colspan': c[l]}) for l in lecturers]))) outfile.write(str(qt.tr([qt.th('Project')] \ + [qt.th(Project(p).number, {'class': 'sel%s' % (p in selected), 'title': '%s (%s)' % (','.join(studentsbyproject.get(p, [])), projectdescriptions.get(p, ''))}) for p in projects]))) outfile.write(str(qt.tr([qt.td("Min")] + [qt.td(minperproject[p]) for p in projects]))) outfile.write(str(qt.tr([qt.td("Students")] + [qt.td(nstudentsbyproject[p]) for p in projects]))) outfile.write(str(qt.tr([qt.td("Max")] + [qt.td(maxperproject[p]) for p in projects]))) outfile.write(str("</thead>\n")) outfile.write("<tbody overflow='scroll'>") for s in students: n = studentnames[s]