1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Add number of missing final part marks to both spaces

This commit is contained in:
Mo 2022-02-24 01:10:04 +01:00
parent 8d34d3d564
commit d0a6090553
12 changed files with 73 additions and 32 deletions

View file

@ -41,9 +41,7 @@ assistantSpace = Admin(
url="/assistant", url="/assistant",
endpoint="assistantSpace", endpoint="assistantSpace",
template_mode="bootstrap3", template_mode="bootstrap3",
index_view=customClasses.SecureAssistantIndexView( index_view=customClasses.SecureAssistantIndexView(name="Assistant", url="/assistant", endpoint="assistantSpace"),
name="Assistant", template="assistant_index.html", url="/assistant", endpoint="assistantSpace"
),
) )
from advlabdb import models from advlabdb import models

View file

@ -2,9 +2,10 @@ from flask import flash, redirect, request, url_for
from flask_admin import AdminIndexView, BaseView, expose from flask_admin import AdminIndexView, BaseView, expose
from flask_admin.contrib.sqla import ModelView from flask_admin.contrib.sqla import ModelView
from flask_security import current_user from flask_security import current_user
from sqlalchemy import and_
from advlabdb.exceptions import DataBaseException, ModelViewException from advlabdb.exceptions import DataBaseException, ModelViewException
from advlabdb.models import ExperimentMark, Part, PartStudent from advlabdb.models import ExperimentMark, Part, PartStudent, GroupExperiment, SemesterExperiment, Assistant
from advlabdb.utils import reportBadAttempt, userActiveSemester from advlabdb.utils import reportBadAttempt, userActiveSemester
@ -28,13 +29,20 @@ class SecureAdminIndexView(CustomIndexView):
@expose() @expose()
def index(self): def index(self):
number_of_missing_final_experiment_marks = ExperimentMark.query.filter( active_semester_experiment_marks_query = ExperimentMark.query.filter(
ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester())), ExperimentMark.part_student.has(PartStudent.part.has(Part.semester == userActiveSemester()))
ExperimentMark.final_experiment_mark == None, )
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
ExperimentMark.final_experiment_mark == None
).count() ).count()
return self.render( return self.render(
"admin_index.html", number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks "admin_index.html",
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
number_of_all_experiment_marks=number_of_all_experiment_marks,
) )
@ -42,6 +50,31 @@ class SecureAssistantIndexView(CustomIndexView):
def is_accessible(self): def is_accessible(self):
return assistantViewIsAccessible() return assistantViewIsAccessible()
@expose()
def index(self):
active_semester_experiment_marks_query = ExperimentMark.query.filter(
ExperimentMark.group_experiment.has(
GroupExperiment.semester_experiment.has(
and_(
SemesterExperiment.semester == userActiveSemester(),
SemesterExperiment.assistants.any(Assistant.user == current_user),
)
)
)
)
number_of_all_experiment_marks = active_semester_experiment_marks_query.count()
number_of_missing_final_experiment_marks = active_semester_experiment_marks_query.filter(
ExperimentMark.final_experiment_mark == None
).count()
return self.render(
"assistant_index.html",
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
number_of_all_experiment_marks=number_of_all_experiment_marks,
)
class CustomModelView(ModelView): class CustomModelView(ModelView):
create_modal = True create_modal = True

View file

@ -1,11 +1,11 @@
{% from "macros.html" import information %} {% from "macros.html" import information, missing_final_experiment_marks %}
{% extends "admin/index.html" %} {% extends "admin/index.html" %}
{% block body %} {% block body %}
{{information(current_user, userActiveSemester, role="admin")}} {{information(current_user, userActiveSemester, role="admin")}}
<h3>Welcome back, commander!</h3> <h3>Welcome back, commander!</h3>
<p>Number of missing final experiment marks: {{ number_of_missing_final_experiment_marks }}</p> {{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
{{ super() }} {{ super() }}
{% endblock %} {% endblock %}

View file

@ -1,8 +1,11 @@
{% from "macros.html" import information %} {% from "macros.html" import information, missing_final_experiment_marks %}
{% extends "admin/index.html" %} {% extends "admin/index.html" %}
{% block body %} {% block body %}
{{information(current_user, userActiveSemester, role="assistant")}} {{information(current_user, userActiveSemester, role="assistant")}}
<h3>Welcome back!</h3> <h3>Welcome back!</h3>
{{missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
{{ super() }} {{ super() }}
{% endblock %} {% endblock %}

View file

@ -9,3 +9,10 @@ User: <a href="{{url_for('index')}}{{role}}/user/details/?id={{current_user.id}}
| <a href="{{ url_for('index') }}admin">Admin space</a>. | <a href="{{ url_for('index') }}admin">Admin space</a>.
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks) %}
<p>
Number of missing final experiment marks:
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
</p>
{% endmacro %}