mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Add final part mark analysis
This commit is contained in:
parent
d71070008d
commit
05de612e23
3 changed files with 75 additions and 4 deletions
|
@ -63,6 +63,7 @@ from advlabdb.utils import (
|
||||||
initActiveSemesterMenuLinks,
|
initActiveSemesterMenuLinks,
|
||||||
randomPassword,
|
randomPassword,
|
||||||
setUserActiveSemester,
|
setUserActiveSemester,
|
||||||
|
sortedSemestersStartingWithNewest,
|
||||||
userActiveSemester,
|
userActiveSemester,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1440,6 +1441,15 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
assistantMarksSubmit = SubmitField(
|
assistantMarksSubmit = SubmitField(
|
||||||
label="Assistant's marks",
|
label="Assistant's marks",
|
||||||
)
|
)
|
||||||
|
finalPartMarksSubmit = SubmitField(
|
||||||
|
label="Final part marks",
|
||||||
|
)
|
||||||
|
|
||||||
|
def htmlFig(fig):
|
||||||
|
buf = BytesIO()
|
||||||
|
fig.savefig(buf, format="png")
|
||||||
|
|
||||||
|
return b64encode(buf.getbuffer()).decode("ascii")
|
||||||
|
|
||||||
def markHist(data, title):
|
def markHist(data, title):
|
||||||
fig = Figure()
|
fig = Figure()
|
||||||
|
@ -1463,10 +1473,7 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
|
|
||||||
ax.set_title(title)
|
ax.set_title(title)
|
||||||
|
|
||||||
buf = BytesIO()
|
return AnalysisView.htmlFig(fig)
|
||||||
fig.savefig(buf, format="png")
|
|
||||||
|
|
||||||
return b64encode(buf.getbuffer()).decode("ascii")
|
|
||||||
|
|
||||||
def markHists(markType, activeAssistants):
|
def markHists(markType, activeAssistants):
|
||||||
attr = markType.lower() + "_mark"
|
attr = markType.lower() + "_mark"
|
||||||
|
@ -1512,6 +1519,53 @@ class AnalysisView(SecureAdminBaseView):
|
||||||
protocolMarkHists=protocolMarkHists,
|
protocolMarkHists=protocolMarkHists,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if form.finalPartMarksSubmit.data:
|
||||||
|
parts = userActiveSemester().parts
|
||||||
|
activeSemesterFinalPartMarksHists = [
|
||||||
|
AnalysisView.markHist(
|
||||||
|
data=np.array([partStudent.final_part_mark for partStudent in part.part_students]),
|
||||||
|
title=part.repr(),
|
||||||
|
)
|
||||||
|
for part in parts
|
||||||
|
]
|
||||||
|
|
||||||
|
semesters = sortedSemestersStartingWithNewest()
|
||||||
|
semesterLabels = [semester.repr() for semester in semesters]
|
||||||
|
meanFinalPartMarks = np.flip(
|
||||||
|
[
|
||||||
|
np.mean(
|
||||||
|
np.hstack(
|
||||||
|
[
|
||||||
|
[partStudent.final_part_mark for partStudent in part.part_students]
|
||||||
|
for part in semester.parts
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for semester in semesters
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
fig = Figure()
|
||||||
|
ax = fig.subplots()
|
||||||
|
x = range(1, len(meanFinalPartMarks) + 1)
|
||||||
|
ax.plot(
|
||||||
|
x,
|
||||||
|
meanFinalPartMarks,
|
||||||
|
marker="d",
|
||||||
|
)
|
||||||
|
# TODO: Change ticks to semester labels
|
||||||
|
# TODO: Check linestyle
|
||||||
|
ax.set_xticks(x)
|
||||||
|
ax.set_xlim(0.5, x[-1] + 0.5)
|
||||||
|
|
||||||
|
meanFinalPartMarksPlot = AnalysisView.htmlFig(fig)
|
||||||
|
|
||||||
|
return self.render(
|
||||||
|
"analysis/final_part_marks.html",
|
||||||
|
activeSemesterFinalPartMarksHists=activeSemesterFinalPartMarksHists,
|
||||||
|
meanFinalPartMarksPlot=meanFinalPartMarksPlot,
|
||||||
|
)
|
||||||
|
|
||||||
return self.render("analysis/analysis.html", form=form)
|
return self.render("analysis/analysis.html", form=form)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,7 @@
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{{ form.csrf_token }}
|
{{ form.csrf_token }}
|
||||||
{{ form.assistantMarksSubmit }}
|
{{ form.assistantMarksSubmit }}
|
||||||
|
<hr>
|
||||||
|
{{ form.finalPartMarksSubmit }}
|
||||||
</form>
|
</form>
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
|
|
15
advlabdb/templates/analysis/final_part_marks.html
Normal file
15
advlabdb/templates/analysis/final_part_marks.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{% from "macros.html" import information %}
|
||||||
|
{% extends "admin/master.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
{{information(current_user, userActiveSemester, role="admin")}}
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
{% for activeSemesterFinalPartMarksHist in activeSemesterFinalPartMarksHists %}
|
||||||
|
<img src="data:image/png;base64,{{activeSemesterFinalPartMarksHist}}">
|
||||||
|
<hr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<img src="data:image/png;base64,{{meanFinalPartMarksPlot}}">
|
||||||
|
{% endblock body %}
|
Loading…
Reference in a new issue