Skip to content

Commit 9b5518b

Browse files
authored
Add scores and allScores JS objects to staff view (#1267)
* Add scores and allScores JS objects to staff view Staff can now access scores as a JS object on their overview page for a student. `scores` should match the object embedded on the student view (only inactive assignments and public scores) while `allScores` includes active assignments and hidden scores. * Add newlines
1 parent 44aadee commit 9b5518b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

server/templates/_globalhelpers.html

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
{% macro backup_style(backup_id) %}
22
<tt>{{ backup_id }}</tt>
33
{% endmacro %}
4+
5+
{% macro js_scores(var_name, assigns, show_hidden=False) %}
6+
<script>
7+
var {{ var_name }} = {
8+
{% for assign, subm_time, group, fs, scores in assigns %}
9+
"{{ assign.name.split('/')[-1] }}": {
10+
{% for score in scores %}
11+
{% if score.public or show_hidden %}
12+
"{{ score.kind }}": {{ score.score }},
13+
{% endif %}
14+
{% endfor %}
15+
},
16+
{% endfor %}
17+
};
18+
</script>
19+
{% endmacro %}

server/templates/staff/student/overview.html

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% extends "staff/base.html" %}
2+
{% import "_globalhelpers.html" as helpers %}
23

34
{% block title %} {{ student.identifier }} - {{ current_course.display_name_with_semester }}{% endblock %}
45

@@ -96,4 +97,7 @@ <h5 class="widget-user-desc"> {{ student.role | capitalize }}</h5>
9697
{% endblock %}
9798

9899
{% block page_js %}
100+
101+
{{ helpers.js_scores('scores', assignments['inactive']) }}
102+
{{ helpers.js_scores('allScores', assignments['active'] + assignments['inactive'], True)}}
99103
{% endblock %}

server/templates/student/course/index.html

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% extends "student/base.html" %}
22
{% import 'student/course/_assigntable.html' as table %}
3+
{% import '_globalhelpers.html' as helpers %}
34

45
{% block title %} {{ course.display_name_with_semester }} | Ok {% endblock %}
56

@@ -37,15 +38,5 @@ <h1>{{ course.display_name_with_semester}}</h1>
3738
{% endblock %}
3839

3940
{% block js %}
40-
<script>
41-
var scores = {
42-
{% for assign, subm_time, group, fs, scores in inactive %}
43-
"{{ assign.name.split('/')[-1] }}": {
44-
{% for score in scores %}
45-
"{{ score.kind }}": {{ score.score }},
46-
{% endfor %}
47-
},
48-
{% endfor %}
49-
};
50-
</script>
41+
{{ helpers.js_scores('scores', inactive) }}
5142
{% endblock %}

0 commit comments

Comments
 (0)