Skip to content

Commit 239c979

Browse files
JoshuaAHairstonhcientist
authored andcommitted
the csv export and proof of concept for the png export
1 parent df4cd5d commit 239c979

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

Diff for: teleband/dashboards/views.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,29 @@ def csv_view(request):
7373
writer = csv.writer(response)
7474
writer.writerow(["ID", "Course ID", "Course Name", "Piece ID", "Piece Name", "Piece Plan ID", "Piece Plan Name",
7575
"Student ID", "Student Instrument ID", "Student Instrument Name", "Assignment Activity ID",
76-
"Assignment Activity", "Assignment Instrument ID", "Assignment Instrument Name", "Submissions"])
76+
"Assignment Activity", "Assignment Instrument ID", "Assignment Instrument Name", "Submissions ID",
77+
"Submissions Content", "Submissions submitted", "Submissions grade", "Submissions Self Grade",
78+
"Submission Attatchnment ID", "Submission Attachment File", "Submission Attachment Submitted"])
7779
for assn in assignments:
78-
writer.writerow([assn.id, assn.enrollment.course.id, assn.enrollment.course.name, assn.piece.id,
79-
assn.piece.name, assn.piece_plan.id, assn.piece_plan, assn.enrollment.user.id,
80-
assn.enrollment.instrument.id, assn.enrollment.instrument.name, assn.activity.id,
81-
assn.activity, assn.instrument.id, assn.instrument.name, "N/A"])
80+
if len(assn.submissions.all()) == 0:
8281

82+
writer.writerow([assn.id, assn.enrollment.course.id, assn.enrollment.course.name, assn.piece.id,
83+
assn.piece.name, assn.piece_plan.id, assn.piece_plan, assn.enrollment.user.id,
84+
assn.enrollment.instrument.id, assn.enrollment.instrument.name, assn.activity.id,
85+
assn.activity, assn.instrument.id, assn.instrument.name, "N/A", "N/A", "N/A",
86+
"N/A", "N/A", "N/A", "N/A", "N/A"])
87+
else:
88+
for sub in assn.submissions.all():
89+
for att in sub.attachments.all():
90+
csv_val = [assn.id, assn.enrollment.course.id, assn.enrollment.course.name, assn.piece.id,
91+
assn.piece.name, assn.piece_plan.id, assn.piece_plan, assn.enrollment.user.id,
92+
assn.enrollment.instrument.id, assn.enrollment.instrument.name, assn.activity.id,
93+
assn.activity, assn.instrument.id, assn.instrument.name, sub.id]
94+
if assn.activity.category == "Create":
95+
csv_val.append("Create, see below")
96+
else:
97+
csv_val.append(sub.content)
98+
csv_val.extend([sub.submitted, sub.grade, sub.self_grade, att.id, att.file, att.submitted])
99+
100+
writer.writerow(csv_val)
83101
return response

Diff for: teleband/templates/assignments/assignment_list.html

+21-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@
123123
{% if assn.activity.category == 'Create' %}
124124
<tr>
125125
<td colspan="22">
126-
<div class="" id="flat-{{sub.id}}"></div>
126+
<div class="" id="flat-{{sub.id}}">
127+
<div class="score"></div>
128+
<div class="png"></div>
129+
</div>
127130
<script>
128131
compositions.push({{ sub.content | safe }})
129132
containers.push(document.getElementById('flat-{{sub.id}}'))
@@ -143,7 +146,7 @@
143146
<script src="https://prod.flat-cdn.com/embed-js/v2.3.0/embed.min.js"></script>
144147
<script>
145148
for (let i = 0; i < compositions.length; i++) {
146-
let embed = new Flat.Embed(containers[i], {
149+
let embed = new Flat.Embed(containers[i].getElementsByClassName("score")[0], {
147150
score: 'blank',
148151
embedParams: {
149152
appId: '60a51c906bcde01fc75a3ad0',
@@ -159,7 +162,22 @@
159162
toolsetId: '64be80de738efff96cc27edd',
160163
},
161164
});
162-
embed.loadJSON(compositions[i]);
165+
embed.loadJSON(compositions[i]).then(() => {
166+
embed.getPNG({
167+
result: "dataURL"
168+
})
169+
.then(function (png) {
170+
console.log("png")
171+
console.log(png)
172+
const scoreimg = document.createElement("a")
173+
scoreimg.href = png
174+
scoreimg.download = `${containers[i].id}-composition.png`
175+
containers[i].getElementsByClassName("png")[0].append(scoreimg)
176+
scoreimg.click()
177+
178+
})
179+
});
180+
163181
}
164182
</script>
165183
{% endblock custom_javascript %}

0 commit comments

Comments
 (0)