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:
parent
d6180f4ccb
commit
6d281dfe3a
1 changed files with 30 additions and 9 deletions
|
@ -1041,8 +1041,8 @@ def groupExperimentQueryFactory():
|
|||
|
||||
|
||||
def assistantFilterOptions():
|
||||
assistants = Assistant.query.filter(Assistant.user.has(User.active == True))
|
||||
return tuple((assistant.id, assistant.repr()) for assistant in assistants)
|
||||
activeAssistants = assistantQueryFactory()
|
||||
return tuple((assistant.id, assistant.repr()) for assistant in activeAssistants)
|
||||
|
||||
|
||||
class AppointmentView(SecureAdminModelView):
|
||||
|
@ -1444,20 +1444,25 @@ class AnalysisView(SecureAdminBaseView):
|
|||
def markHist(data, title):
|
||||
fig = Figure()
|
||||
ax = fig.subplots()
|
||||
ax.set_title(title)
|
||||
ax.set_xlim(MIN_MARK - 0.5, MAX_MARK + 0.5)
|
||||
ax.set_xticks(np.arange(MAX_MARK + 1))
|
||||
ax.set_xlabel("Mark")
|
||||
|
||||
if data:
|
||||
N = data.size
|
||||
title += f"\nN = {N}"
|
||||
|
||||
if N > 0:
|
||||
hist = ax.hist(
|
||||
data,
|
||||
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:
|
||||
ax.set_yticks(np.arange(2))
|
||||
|
||||
ax.set_title(title)
|
||||
|
||||
buf = BytesIO()
|
||||
fig.savefig(buf, format="png")
|
||||
|
||||
|
@ -1465,21 +1470,37 @@ class AnalysisView(SecureAdminBaseView):
|
|||
|
||||
def markHists(markType, activeAssistants):
|
||||
attr = markType.lower() + "_mark"
|
||||
return [
|
||||
markTypeTitleAddition = f" | {markType} marks"
|
||||
|
||||
hists = [
|
||||
AnalysisView.markHist(
|
||||
data=[getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks],
|
||||
title=f"{assistant.repr()} - {markType} Marks",
|
||||
data=np.array([getattr(experimentMark, attr) for experimentMark in assistant.experiment_marks]),
|
||||
title=assistant.repr() + markTypeTitleAddition,
|
||||
)
|
||||
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"))
|
||||
def index(self):
|
||||
form = AnalysisView.AnalysisForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
if form.assistantMarksSubmit.data:
|
||||
activeAssistants = Assistant.query.filter(Assistant.user.has(User.active == True))
|
||||
activeAssistants = assistantQueryFactory()
|
||||
|
||||
oralMarkHists = AnalysisView.markHists("Oral", activeAssistants)
|
||||
protocolMarkHists = AnalysisView.markHists("Protocol", activeAssistants)
|
||||
|
|
Loading…
Reference in a new issue