Skip to content

Commit 63a2f53

Browse files
committed
render compose submissions
1 parent 97f960a commit 63a2f53

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

teleband/templates/assignments/assignment_list.html

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{% extends "base.html" %}
22

33
{% block content %}
4-
hello<br>
4+
<script>
5+
const compositions = [];
6+
const containers = [];
7+
</script>
58
{% comment %} https://developer.mozilla.org/en-US/docs/Web/HTML/Element/col#usage_notes {% endcomment %}
69
<table class="dashboard">
710
<colgroup>
@@ -101,18 +104,60 @@
101104
<td>{{ assn.instrument.id }}</td>
102105
<td>{{ assn.instrument.name }}</td>
103106
<td>{{ sub.id }}</td>
107+
{% if assn.activity.category == 'Create' %}
108+
<td>
109+
Create, see below
110+
</td>
111+
{% else %}
104112
<td>{{ sub.content }}</td>
113+
{% endif %}
105114
<td>{{ sub.submitted }}</td>
106115
<td>{{ sub.grade }}</td>
107116
<td>{{ sub.self_grade }}</td>
108117
<td>{{ att.id }}</td>
109118
<td>{{ att.file }}</td>
110119
<td>{{ att.submitted }}</td>
111120
</tr>
112-
{% endfor %}
121+
{% if assn.activity.category == 'Create' %}
122+
<tr>
123+
<td colspan="22">
124+
<div class="" id="flat-{{sub.id}}"></div>
125+
<script>
126+
compositions.push({{ sub.content | safe }})
127+
containers.push(document.getElementById('flat-{{sub.id}}'))
128+
</script>
129+
</td>
130+
</tr>
131+
{% endif %}
113132
{% endfor %}
114-
{% endif %}
115-
</tbody>
133+
{% endfor %}
134+
{% endif %}
135+
</tbody>
116136
{% endfor %}
117137
</table>
118-
{% endblock content %}
138+
{% endblock content %}
139+
140+
{% block custom_javascript %}
141+
<script src="https://prod.flat-cdn.com/embed-js/v2.3.0/embed.min.js"></script>
142+
<script>
143+
for (let i=0; i<compositions.length; i++) {
144+
let embed = new Flat.Embed(containers[i], {
145+
score: 'blank',
146+
embedParams: {
147+
appId: '60a51c906bcde01fc75a3ad0',
148+
layout: 'responsive',
149+
branding: false,
150+
themePrimary: '#450084',
151+
controlsDisplay: false,
152+
controlsPlay: false,
153+
controlsFullscreen: false,
154+
controlsZoom: false,
155+
controlsPrint: false,
156+
displayFirstLinePartsNames: false,
157+
toolsetId: '64be80de738efff96cc27edd',
158+
},
159+
});
160+
embed.loadJSON(compositions[i]);
161+
}
162+
</script>
163+
{% endblock custom_javascript %}

teleband/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,8 @@
112112
</script>
113113
{% endcomment %}
114114
{% endblock inline_javascript %}
115+
116+
{% block custom_javascript %}
117+
{% endblock custom_javascript %}
115118
</body>
116119
</html>

0 commit comments

Comments
 (0)