1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Fix analysis

This commit is contained in:
Mo 2022-05-23 00:56:10 +02:00
parent 7c29114587
commit dd4908cc45
2 changed files with 40 additions and 21 deletions

View file

@ -1467,32 +1467,47 @@ class AnalysisView(SecureAdminBaseView):
return AnalysisView.htmlFig(fig) 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): def markHists(markType, activeAssistants):
attr = markType.lower() + "_mark" attr = markType.lower() + "_mark"
markTypeTitleAddition = f" | {markType} marks" markTypeTitleAddition = f" | {markType} marks"
marks = [AnalysisView.get_experiment_marks(assistant, attr) for assistant in activeAssistants]
hists = [ hists = [
AnalysisView.markHist( AnalysisView.markHist(
data=np.array([getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]), data=marks[i],
title=assistant.repr() + markTypeTitleAddition, title=activeAssistants[i].repr() + markTypeTitleAddition,
) )
for assistant in activeAssistants for i in range(len(marks))
] ]
hists.append( hists.append(
AnalysisView.markHist( AnalysisView.markHist(
data=np.hstack( data=np.hstack(marks),
[
[getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]
for assistant in activeAssistants
]
),
title="All" + markTypeTitleAddition, title="All" + markTypeTitleAddition,
) )
) )
return hists 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")) @expose(methods=("GET", "POST"))
def index(self): def index(self):
form = AnalysisView.AnalysisForm() form = AnalysisView.AnalysisForm()
@ -1515,7 +1530,7 @@ class AnalysisView(SecureAdminBaseView):
parts = current_user.active_semester.parts parts = current_user.active_semester.parts
activeSemesterFinalPartMarksHists = [ activeSemesterFinalPartMarksHists = [
AnalysisView.markHist( 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(), title=part.repr(),
) )
for part in parts for part in parts
@ -1538,8 +1553,10 @@ class AnalysisView(SecureAdminBaseView):
) )
fig = Figure() fig = Figure()
lenMeanFinalPartMarks = len(meanFinalPartMarks)
if lenMeanFinalPartMarks > 0:
ax = fig.subplots() ax = fig.subplots()
x = range(1, len(meanFinalPartMarks) + 1) x = range(1, lenMeanFinalPartMarks + 1)
ax.plot( ax.plot(
x, x,
meanFinalPartMarks, meanFinalPartMarks,

View file

@ -19,6 +19,8 @@ python-dotenv = ">=0.20.0"
gunicorn = ">=20.1.0" gunicorn = ">=20.1.0"
email-validator = ">=1.2.1" email-validator = ">=1.2.1"
[tool.poetry.dev-dependencies]
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"