From 13aaff403c12e42268ebbc83b3adb6359cfb3771 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Kon=C4=8Dick=C3=BD?=
 <koncicky@kam.mff.cuni.cz>
Date: Sat, 13 Mar 2021 14:12:24 +0100
Subject: [PATCH 1/2] Anonymous grading: DB support

---
 db.ddl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/db.ddl b/db.ddl
index 48371eb..f8d8273 100644
--- a/db.ddl
+++ b/db.ddl
@@ -30,7 +30,8 @@ CREATE TABLE owl_courses (
 	ident		varchar(255)	UNIQUE NOT NULL,
 	name		varchar(255)	NOT NULL,
 	enroll_token	varchar(255)	UNIQUE NOT NULL,
-	student_grading	boolean		NOT NULL DEFAULT FALSE
+	student_grading	boolean		NOT NULL DEFAULT FALSE,
+	anon_grading	boolean		NOT NULL DEFAULT FALSE
 );
 
 CREATE TABLE owl_enroll (
-- 
GitLab


From 283554faa2c815e64c67506d8e031bc6cf31df03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Kon=C4=8Dick=C3=BD?=
 <koncicky@kam.mff.cuni.cz>
Date: Sat, 13 Mar 2021 20:22:10 +0100
Subject: [PATCH 2/2] Anonymous grading: If enabled, non teacher graders see
 only UID

---
 templates/admin-course.html  | 2 +-
 templates/admin-courses.html | 7 ++++++-
 templates/topic-grade.html   | 9 +++++++--
 templates/topic.html         | 7 ++++++-
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/templates/admin-course.html b/templates/admin-course.html
index 3f43893..df1cd53 100644
--- a/templates/admin-course.html
+++ b/templates/admin-course.html
@@ -7,7 +7,7 @@
 		<tr><th>Name<td>{{ g.course.name }}
 		<tr><th>Enroll token<td><code>{{ g.course.enroll_token }}</code>
 		<tr><th>Teachers<td>{{ teachers|sort|join(', ') }}
-		<tr><th>Student grading<td>{{ 'enabled' if g.course.student_grading else 'disabled' }}
+		<tr><th>Student grading<td>{{ 'enabled' if g.course.student_grading else 'disabled' }}{% if g.course.anon_grading %} (anonymous){% endif %}
 	</table>
 
 	<div class=buttons>
diff --git a/templates/admin-courses.html b/templates/admin-courses.html
index d0e139f..eb1b729 100644
--- a/templates/admin-courses.html
+++ b/templates/admin-courses.html
@@ -18,7 +18,12 @@
 		{% else %}
 			<td>–
 		{% endif %}
-		<td>{{ 'yes' if c.student_grading else 'no' }}
+		<td>
+		{% if c.student_grading %}
+			{{ 'anonymous' if c.anon_grading else 'yes' }}
+		{% else %}
+			no
+		{% endif %}
 	{% endfor %}
 	</table>
 
diff --git a/templates/topic-grade.html b/templates/topic-grade.html
index 83ec78f..c68fee8 100644
--- a/templates/topic-grade.html
+++ b/templates/topic-grade.html
@@ -10,12 +10,17 @@
 
 	<h3>Grade {{t.title}}</h3>
 		<table class=results>
-			<tr><th class='tbeforehdr'>Full name
+			<tr><th class='tbeforehdr'>Name
 			<th>Points
 			<tr><th class='tbeforehdr'>max.
 			<td class='pts'>{{ t.max_points if t.max_points != None else "" }}
 		{% for s in students.values() %}
-			<tr><td class='tbeforehdr'>{{ s.full_name }}
+			<tr><td class='tbeforehdr'>
+				{% if c.anon_grading and s.uid != g.uid %}
+					Student {{ s.uid }}
+				{% else %}
+					{{ s.full_name }}
+				{% endif %}
 				{% set sol=solutions[s.uid] %}
 				{% set cls=[] %}
 				{% if sol.last_activity == None %}
diff --git a/templates/topic.html b/templates/topic.html
index 656ba39..ab36981 100644
--- a/templates/topic.html
+++ b/templates/topic.html
@@ -39,7 +39,12 @@
 	{% endif %}
 
 	<div id=p{{ p.pid }} class='{{ cls | join(" ") }}'>
-		<p class=phdr>{{ p.author_name }} —
+		<p class=phdr>
+		{%- if g.course.anon_grading and not g.is_teacher and p.author_uid != g.uid and p.author_uid == student_uid -%}
+			Student {{student_uid}} —
+		{% else -%}
+			{{ p.author_name }} —
+		{% endif -%}
 		{% if p.modified != None %}
 			{% set when=p.modified %}
 			modified
-- 
GitLab