Skip to content
Snippets Groups Projects
Commit 90ed473b authored by Martin Mareš's avatar Martin Mareš
Browse files

Teacher/JS: Displaying graders

parent 83141429
No related branches found
No related tags found
No related merge requests found
......@@ -165,6 +165,18 @@ def teacher(sident: str, cident: str):
except KeyError:
pass
have_graders = js_mode and (g.course.split_grading or g.course.student_grading)
topic_graders: Dict[int, List[Tuple[db.User, bool]]] = {tid: [] for tid in topics.keys()}
if have_graders:
for grader, user in list(sess.execute(
select(db.Grader, db.User)
.select_from(db.Grader)
.join(db.Grader.user)
.filter(db.Grader.tid.in_(topics.keys()))
.order_by(db.User.last_name, db.User.last_name)
)):
topic_graders[grader.tid].append((user, grader.student_grader))
auto_grid = owl.auto_eval.eval_queue_grid(topic_list)
for key, auto in auto_grid.items():
gtid, guid = key
......@@ -182,6 +194,7 @@ def teacher(sident: str, cident: str):
# app.logger.debug(students)
# app.logger.debug(solutions)
# app.logger.debug(totals)
# app.logger.debug(topic_graders)
def to_json():
tops = []
......@@ -192,6 +205,17 @@ def teacher(sident: str, cident: str):
tj['t_link'] = url_for('topic_index', sident=g.course.semester.ident, cident=g.course.ident, tident=t.ident)
if t.deadline is not None:
tj['t_deadline'] = owl.jinja.reltimeformat(t.deadline)
if have_graders:
tgr = topic_graders[t.tid]
if g.course.split_grading:
tj['t_am_grader'] = any(u.uid == g.uid for u, _ in tgr)
else:
tj['t_am_grader'] = True
tj['t_graders'] = [u.full_name() + (" (student)" if is_student else "") for u, is_student in tgr]
tj['t_graders_short'] = [u.first_name[0] + u.last_name[0] for u, _ in tgr]
tj['t_student_graders'] = any(is_student for _, is_student in tgr)
tj['t_teacher_graders'] = any(not is_student for _, is_student in tgr)
tj['t_grader_link'] = url_for('admin_topic_graders', sident=g.course.semester.ident, cident=g.course.ident, tid=t.tid)
tops.append(tj)
if t.tid in topics_followed_by_header:
group += 1
......@@ -237,6 +261,7 @@ def teacher(sident: str, cident: str):
'course_max': float(course_total),
'pass_threshold': float(g.course.pass_threshold) if g.course.pass_threshold is not None else None,
'show_uids': g.course.anon_grading,
'have_graders': have_graders,
}
return json.JSONEncoder(ensure_ascii=False, indent=1).encode(out)
......
......@@ -390,6 +390,26 @@ footer {
text-align: center;
}
/* Graders */
#results .grading th {
text-align: center;
}
#results .grading td {
text-align: center;
}
#results td.grme {
background-color: #b162ee;
font-size: smaller;
}
#results td.grother {
background-color: #62beee;
font-size: smaller;
}
#results td.grstud {
background-color: #62ee96;
font-size: smaller;
}
/* Settings */
.settings {
......
......@@ -167,6 +167,26 @@ class teachersView {
total.addText(s.t_total.toFixed(2));
}
renderGraders() {
const grading = this.table.addChild('tr').addClass('grading');
grading.addChild('th').addText('Graders');
for (const [t, g] of this.topicCells(grading)) {
const a = g.addChild('a');
a.e.href = t.t_grader_link;
if (t.t_graders.length > 0) {
g.e.title = t.t_graders.join(", ");
g.addClass(t.t_am_grader ? 'grme' : t.t_student_graders ? 'grstud' : 'grother');
let text = t.t_graders_short[0]
if (t.t_graders_short.length > 1)
text += "+";
a.addText(text);
} else {
a.addText('');
}
}
grading.addChild('td').addClass('tnextgroup');
}
*topicCells(row, element='td') {
let prev_group = -1;
for (const t of this.visible_topics) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment