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

Teacher/JS: Mode "my posts needing attention"

parent 90ed473b
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
<div class=buttons> <div class=buttons>
<button id="mode_all" onclick="tv.setMode(TMODE_ALL)">All</button> <button id="mode_all" onclick="tv.setMode(TMODE_ALL)">All</button>
<button id="mode_attn" onclick="tv.setMode(TMODE_ATTN)">Unresolved</button> <button id="mode_attn" onclick="tv.setMode(TMODE_ATTN)" title="Threads with unanswered posts">Unresolved</button>
<button id="mode_my" onclick="tv.setMode(TMODE_MY)" title="Threads with unanswered posts in topics where I am a grader">My unresolved</button>
<a class=button href='{{ url_for('results_json', sident=c.semester.ident, cident=c.ident) }}'>JSON</a> <a class=button href='{{ url_for('results_json', sident=c.semester.ident, cident=c.ident) }}'>JSON</a>
<a class=button href='{{ url_for('results_csv', sident=c.semester.ident, cident=c.ident) }}'>CSV</a> <a class=button href='{{ url_for('results_csv', sident=c.semester.ident, cident=c.ident) }}'>CSV</a>
...@@ -73,6 +74,7 @@ ...@@ -73,6 +74,7 @@
<script> <script>
const tv = new teachersView({{ json_data|safe }}); const tv = new teachersView({{ json_data|safe }});
{% if 'mattn' in color_defaults %}tv.mode = TMODE_ATTN;{% endif %} {% if 'mattn' in color_defaults %}tv.mode = TMODE_ATTN;{% endif %}
{% if 'mmy' in color_defaults %}tv.mode = TMODE_MY;{% endif %}
tv.render(); tv.render();
tv.recalcToggles(); tv.recalcToggles();
view.style.display = 'block'; view.style.display = 'block';
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const TMODE_ALL = 0; const TMODE_ALL = 0;
const TMODE_ATTN = 1; const TMODE_ATTN = 1;
const TMODE_MY = 2;
class htmlBuilder { class htmlBuilder {
constructor(e) { constructor(e) {
...@@ -35,6 +36,7 @@ class teachersView { ...@@ -35,6 +36,7 @@ class teachersView {
this.course_max = json_data.course_max; this.course_max = json_data.course_max;
this.pass_threshold = json_data.pass_threshold; this.pass_threshold = json_data.pass_threshold;
this.show_uids = json_data.show_uids; this.show_uids = json_data.show_uids;
this.have_graders = json_data.have_graders;
this.mode = TMODE_ALL; this.mode = TMODE_ALL;
console.log("Teacher: Initialized"); console.log("Teacher: Initialized");
} }
...@@ -49,14 +51,19 @@ class teachersView { ...@@ -49,14 +51,19 @@ class teachersView {
this.renderMaxima(); this.renderMaxima();
for (const s of this.visible_students) for (const s of this.visible_students)
this.renderStudent(s); this.renderStudent(s);
if (this.have_graders)
this.renderGraders();
} }
select() { select() {
if (this.mode == TMODE_ATTN) { if (this.mode == TMODE_ATTN || this.mode == TMODE_MY) {
const stud = new Set(); const stud = new Set();
const top = new Set(); const top = new Set();
let topics = this.topics;
if (this.mode == TMODE_MY && this.have_graders)
topics = topics.filter((t) => t.t_am_grader || !t.t_teacher_graders);
for (const s of this.students) { for (const s of this.students) {
for (const t of this.topics) { for (const t of topics) {
const sol = this.solutions[s.uid][t.tid]; const sol = this.solutions[s.uid][t.tid];
if (sol && sol.l == 'n') { if (sol && sol.l == 'n') {
stud.add(s.uid); stud.add(s.uid);
...@@ -231,9 +238,16 @@ class teachersView { ...@@ -231,9 +238,16 @@ class teachersView {
tokens.push("mattn"); tokens.push("mattn");
mode_all.classList.remove("active"); mode_all.classList.remove("active");
mode_attn.classList.add("active"); mode_attn.classList.add("active");
mode_my.classList.remove("active");
} else if (this.mode == TMODE_MY) {
tokens.push("mmy");
mode_all.classList.remove("active");
mode_attn.classList.remove("active");
mode_my.classList.add("active");
} else { } else {
mode_all.classList.add("active"); mode_all.classList.add("active");
mode_attn.classList.remove("active"); mode_attn.classList.remove("active");
mode_my.classList.remove("active");
} }
document.cookie = "owl_colors=" + tokens.join(":") + "; max-age=31536000; path={{ url_for('index') }}"; document.cookie = "owl_colors=" + tokens.join(":") + "; max-age=31536000; path={{ url_for('index') }}";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment