mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Fix analysis
This commit is contained in:
parent
7c29114587
commit
dd4908cc45
2 changed files with 40 additions and 21 deletions
|
@ -1467,32 +1467,47 @@ class AnalysisView(SecureAdminBaseView):
|
|||
|
||||
return AnalysisView.htmlFig(fig)
|
||||
|
||||
def get_experiment_marks(assistant, attr):
|
||||
data = []
|
||||
|
||||
for experimentMark in assistant.experiment_marks:
|
||||
mark = getattr(experimentMark, attr)
|
||||
if mark is not None:
|
||||
data.append(mark)
|
||||
|
||||
return np.array(data)
|
||||
|
||||
def markHists(markType, activeAssistants):
|
||||
attr = markType.lower() + "_mark"
|
||||
markTypeTitleAddition = f" | {markType} marks"
|
||||
marks = [AnalysisView.get_experiment_marks(assistant, attr) for assistant in activeAssistants]
|
||||
|
||||
hists = [
|
||||
AnalysisView.markHist(
|
||||
data=np.array([getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]),
|
||||
title=assistant.repr() + markTypeTitleAddition,
|
||||
data=marks[i],
|
||||
title=activeAssistants[i].repr() + markTypeTitleAddition,
|
||||
)
|
||||
for assistant in activeAssistants
|
||||
for i in range(len(marks))
|
||||
]
|
||||
|
||||
hists.append(
|
||||
AnalysisView.markHist(
|
||||
data=np.hstack(
|
||||
[
|
||||
[getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]
|
||||
for assistant in activeAssistants
|
||||
]
|
||||
),
|
||||
data=np.hstack(marks),
|
||||
title="All" + markTypeTitleAddition,
|
||||
)
|
||||
)
|
||||
|
||||
return hists
|
||||
|
||||
def get_final_part_marks(part):
|
||||
data = []
|
||||
for partStudent in part.part_students:
|
||||
mark = partStudent.final_part_mark
|
||||
if mark is not None:
|
||||
data.append(mark)
|
||||
|
||||
return np.array(data)
|
||||
|
||||
@expose(methods=("GET", "POST"))
|
||||
def index(self):
|
||||
form = AnalysisView.AnalysisForm()
|
||||
|
@ -1515,7 +1530,7 @@ class AnalysisView(SecureAdminBaseView):
|
|||
parts = current_user.active_semester.parts
|
||||
activeSemesterFinalPartMarksHists = [
|
||||
AnalysisView.markHist(
|
||||
data=np.array([partStudent.final_part_mark for partStudent in part.part_students]),
|
||||
data=AnalysisView.get_final_part_marks(part),
|
||||
title=part.repr(),
|
||||
)
|
||||
for part in parts
|
||||
|
@ -1538,8 +1553,10 @@ class AnalysisView(SecureAdminBaseView):
|
|||
)
|
||||
|
||||
fig = Figure()
|
||||
lenMeanFinalPartMarks = len(meanFinalPartMarks)
|
||||
if lenMeanFinalPartMarks > 0:
|
||||
ax = fig.subplots()
|
||||
x = range(1, len(meanFinalPartMarks) + 1)
|
||||
x = range(1, lenMeanFinalPartMarks + 1)
|
||||
ax.plot(
|
||||
x,
|
||||
meanFinalPartMarks,
|
||||
|
|
|
@ -19,6 +19,8 @@ python-dotenv = ">=0.20.0"
|
|||
gunicorn = ">=20.1.0"
|
||||
email-validator = ">=1.2.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
|
Loading…
Reference in a new issue