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

Add number, mean and all

This commit is contained in:
Mo 2022-04-12 13:29:08 +02:00
parent d6180f4ccb
commit 6d281dfe3a

View file

@ -1041,8 +1041,8 @@ def groupExperimentQueryFactory():
def assistantFilterOptions(): def assistantFilterOptions():
assistants = Assistant.query.filter(Assistant.user.has(User.active == True)) activeAssistants = assistantQueryFactory()
return tuple((assistant.id, assistant.repr()) for assistant in assistants) return tuple((assistant.id, assistant.repr()) for assistant in activeAssistants)
class AppointmentView(SecureAdminModelView): class AppointmentView(SecureAdminModelView):
@ -1444,20 +1444,25 @@ class AnalysisView(SecureAdminBaseView):
def markHist(data, title): def markHist(data, title):
fig = Figure() fig = Figure()
ax = fig.subplots() ax = fig.subplots()
ax.set_title(title)
ax.set_xlim(MIN_MARK - 0.5, MAX_MARK + 0.5) ax.set_xlim(MIN_MARK - 0.5, MAX_MARK + 0.5)
ax.set_xticks(np.arange(MAX_MARK + 1)) ax.set_xticks(np.arange(MAX_MARK + 1))
ax.set_xlabel("Mark") ax.set_xlabel("Mark")
if data: N = data.size
title += f"\nN = {N}"
if N > 0:
hist = ax.hist( hist = ax.hist(
data, data,
bins=np.arange(MAX_MARK) - 0.5, bins=np.arange(MAX_MARK) - 0.5,
) )
ax.set_yticks(np.arange(len(data) + 1)) ax.set_yticks(np.arange(N + 1))
title += f" | mean = {round(np.mean(data), 1)}"
else: else:
ax.set_yticks(np.arange(2)) ax.set_yticks(np.arange(2))
ax.set_title(title)
buf = BytesIO() buf = BytesIO()
fig.savefig(buf, format="png") fig.savefig(buf, format="png")
@ -1465,21 +1470,37 @@ class AnalysisView(SecureAdminBaseView):
def markHists(markType, activeAssistants): def markHists(markType, activeAssistants):
attr = markType.lower() + "_mark" attr = markType.lower() + "_mark"
return [ markTypeTitleAddition = f" | {markType} marks"
hists = [
AnalysisView.markHist( AnalysisView.markHist(
data=[getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks], data=np.array([getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]),
title=f"{assistant.repr()} - {markType} Marks", title=assistant.repr() + markTypeTitleAddition,
) )
for assistant in activeAssistants for assistant in activeAssistants
] ]
hists.append(
AnalysisView.markHist(
data=np.hstack(
[
[getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]
for assistant in activeAssistants
]
),
title="All" + markTypeTitleAddition,
)
)
return hists
@expose(methods=("GET", "POST")) @expose(methods=("GET", "POST"))
def index(self): def index(self):
form = AnalysisView.AnalysisForm() form = AnalysisView.AnalysisForm()
if form.validate_on_submit(): if form.validate_on_submit():
if form.assistantMarksSubmit.data: if form.assistantMarksSubmit.data:
activeAssistants = Assistant.query.filter(Assistant.user.has(User.active == True)) activeAssistants = assistantQueryFactory()
oralMarkHists = AnalysisView.markHists("Oral", activeAssistants) oralMarkHists = AnalysisView.markHists("Oral", activeAssistants)
protocolMarkHists = AnalysisView.markHists("Protocol", activeAssistants) protocolMarkHists = AnalysisView.markHists("Protocol", activeAssistants)