Skip to content

Commit

Permalink
Add scores and allScores JS objects to staff view (#1267)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jathak committed May 5, 2018
1 parent 44aadee commit 9b5518b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
16 changes: 16 additions & 0 deletions server/templates/_globalhelpers.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
{% macro backup_style(backup_id) %}
<tt>{{ backup_id }}</tt>
{% endmacro %}

{% macro js_scores(var_name, assigns, show_hidden=False) %}
<script>
var {{ var_name }} = {
{% for assign, subm_time, group, fs, scores in assigns %}
"{{ assign.name.split('/')[-1] }}": {
{% for score in scores %}
{% if score.public or show_hidden %}
"{{ score.kind }}": {{ score.score }},
{% endif %}
{% endfor %}
},
{% endfor %}
};
</script>
{% endmacro %}
4 changes: 4 additions & 0 deletions server/templates/staff/student/overview.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "staff/base.html" %}
{% import "_globalhelpers.html" as helpers %}

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

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

{% block page_js %}

{{ helpers.js_scores('scores', assignments['inactive']) }}
{{ helpers.js_scores('allScores', assignments['active'] + assignments['inactive'], True)}}
{% endblock %}
13 changes: 2 additions & 11 deletions server/templates/student/course/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "student/base.html" %}
{% import 'student/course/_assigntable.html' as table %}
{% import '_globalhelpers.html' as helpers %}

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

Expand Down Expand Up @@ -37,15 +38,5 @@ <h1>{{ course.display_name_with_semester}}</h1>
{% endblock %}

{% block js %}
<script>
var scores = {
{% for assign, subm_time, group, fs, scores in inactive %}
"{{ assign.name.split('/')[-1] }}": {
{% for score in scores %}
"{{ score.kind }}": {{ score.score }},
{% endfor %}
},
{% endfor %}
};
</script>
{{ helpers.js_scores('scores', inactive) }}
{% endblock %}

0 comments on commit 9b5518b

Please sign in to comment.