mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-09-19 18:31:16 +00:00
Add assistant missing marks table to admin home page
This commit is contained in:
parent
b6e54ba0c0
commit
0f7700b11a
4 changed files with 50 additions and 33 deletions
|
@ -4,7 +4,7 @@ from flask_admin.contrib.sqla import ModelView
|
||||||
from flask_admin.helpers import get_form_data
|
from flask_admin.helpers import get_form_data
|
||||||
from flask_admin.model.helpers import get_mdict_item_or_list
|
from flask_admin.model.helpers import get_mdict_item_or_list
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from sqlalchemy import select
|
from sqlalchemy import func, select
|
||||||
|
|
||||||
from .exceptions import DatabaseException, ModelViewException
|
from .exceptions import DatabaseException, ModelViewException
|
||||||
from .model_independent_funs import reportBadAttempt
|
from .model_independent_funs import reportBadAttempt
|
||||||
|
@ -48,22 +48,21 @@ class SecureAdminIndexView(CustomIndexView):
|
||||||
|
|
||||||
@expose("/")
|
@expose("/")
|
||||||
def index(self):
|
def index(self):
|
||||||
active_semester_experiment_mark_ids_stmt = (
|
assistants_num_missing = db.session.execute(
|
||||||
select(ExperimentMark.final_experiment_mark)
|
select(Assistant, func.count())
|
||||||
.join(PartStudent)
|
.join(Assistant.semester_experiments)
|
||||||
.join(Part)
|
.where(SemesterExperiment.semester == current_user.active_semester)
|
||||||
.where(Part.semester == current_user.active_semester)
|
.join(SemesterExperiment.group_experiments)
|
||||||
)
|
.where(GroupExperiment.experiment_marks_missing == True)
|
||||||
number_of_all_experiment_marks = get_count(active_semester_experiment_mark_ids_stmt)
|
.join(GroupExperiment.experiment_marks)
|
||||||
|
.where(ExperimentMark.final_experiment_mark == None)
|
||||||
number_of_missing_final_experiment_marks = get_count(
|
.group_by(Assistant.id)
|
||||||
active_semester_experiment_mark_ids_stmt.where(ExperimentMark.final_experiment_mark == None)
|
.order_by(func.count().desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.render(
|
return self.render(
|
||||||
"admin_index.jinja.html",
|
"admin_index.jinja.html",
|
||||||
number_of_missing_final_experiment_marks=number_of_missing_final_experiment_marks,
|
assistants_num_missing=assistants_num_missing,
|
||||||
number_of_all_experiment_marks=number_of_all_experiment_marks,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "macros.jinja.html" import information, missing_final_experiment_marks %}
|
{% from "macros.jinja.html" import information %}
|
||||||
{% extends "admin/index.html" %}
|
{% extends "admin/index.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
@ -6,7 +6,35 @@
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{{ missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks) }}
|
<div class="d-inline-flex">
|
||||||
|
<div class="table">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">
|
||||||
|
Assistant
|
||||||
|
</th>
|
||||||
|
<th scope="col">
|
||||||
|
Missing experiment marks
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{% for assistant_num_missing in assistants_num_missing %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ assistant_num_missing[0] }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ assistant_num_missing[1] }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "macros.jinja.html" import information, missing_final_experiment_marks %}
|
{% from "macros.jinja.html" import information %}
|
||||||
{% extends "admin/index.html" %}
|
{% extends "admin/index.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{{ missing_final_experiment_marks(number_of_missing_final_experiment_marks, number_of_all_experiment_marks)}}
|
<p>
|
||||||
|
Number of <strong>missing</strong> final experiment marks:
|
||||||
|
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
|
||||||
|
</p>
|
||||||
|
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
|
||||||
|
|
|
@ -2,30 +2,17 @@
|
||||||
User:
|
User:
|
||||||
<a
|
<a
|
||||||
href="{{ url_for('main.index') }}{{ role }}/user/edit/?id={{ current_user.id }}"
|
href="{{ url_for('main.index') }}{{ role }}/user/edit/?id={{ current_user.id }}"
|
||||||
>
|
>{{ current_user }}</a>
|
||||||
{{ current_user }}
|
|
||||||
</a>
|
|
||||||
| Active semester: {{ active_semester_str() }}
|
| Active semester: {{ active_semester_str() }}
|
||||||
{% if (role == "admin") and (current_user.has_role("assistant")) %}
|
{% if (role == "admin") and (current_user.has_role("assistant")) %}
|
||||||
|
|
|
|
||||||
<a
|
<a
|
||||||
href="{{ url_for('main.index') }}assistant"
|
href="{{ url_for('main.index') }}assistant"
|
||||||
>
|
>Assistant space</a>.
|
||||||
Assistant space
|
|
||||||
</a>.
|
|
||||||
{% elif (role == "assistant") and (current_user.has_role("admin")) %}
|
{% elif (role == "assistant") and (current_user.has_role("admin")) %}
|
||||||
|
|
|
|
||||||
<a
|
<a
|
||||||
href="{{ url_for('main.index') }}admin"
|
href="{{ url_for('main.index') }}admin"
|
||||||
>
|
>Admin space</a>.
|
||||||
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 <strong>missing</strong> final experiment marks:
|
|
||||||
{{ number_of_missing_final_experiment_marks }} / {{ number_of_all_experiment_marks }}
|
|
||||||
</p>
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
Loading…
Reference in a new issue