mirror of
https://github.com/ae-utbm/sith.git
synced 2024-10-31 19:38:04 +00:00
pedagogy: grade averages for UVs
This commit is contained in:
parent
4f7a8661ba
commit
205f93569a
@ -51,6 +51,33 @@ class UV(models.Model):
|
|||||||
"""
|
"""
|
||||||
return user.is_subscribed
|
return user.is_subscribed
|
||||||
|
|
||||||
|
def __grade_average_generic(self, field):
|
||||||
|
comments = self.comments.filter(**{field + "__gte": 0})
|
||||||
|
if not comments.exists():
|
||||||
|
return -1
|
||||||
|
|
||||||
|
return int(sum(comments.values_list(field, flat=True)) / comments.count())
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_global_average(self):
|
||||||
|
return self.__grade_average_generic("grade_global")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_utility_average(self):
|
||||||
|
return self.__grade_average_generic("grade_utility")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_interest_average(self):
|
||||||
|
return self.__grade_average_generic("grade_interest")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_teaching_average(self):
|
||||||
|
return self.__grade_average_generic("grade_teaching")
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def grade_work_load_average(self):
|
||||||
|
return self.__grade_average_generic("grade_work_load")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.code
|
return self.code
|
||||||
|
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
<p>{{ object.key_concepts|markdown }}</p>
|
<p>{{ object.key_concepts|markdown }}</p>
|
||||||
<p>{% trans %}UV manager: {% endtrans %}{{ object.manager }}</p>
|
<p>{% trans %}UV manager: {% endtrans %}{{ object.manager }}</p>
|
||||||
|
|
||||||
|
<p>{{ object.grade_global_average }}</p>
|
||||||
|
<p>{{ object.grade_utility_average }}</p>
|
||||||
|
<p>{{ object.grade_interest_average }}</p>
|
||||||
|
<p>{{ object.grade_teaching_average }}</p>
|
||||||
|
<p>{{ object.grade_work_load_average }}</p>
|
||||||
|
|
||||||
{% if object.comments.exists() %}
|
{% if object.comments.exists() %}
|
||||||
<h2>{% trans %}Comments{% endtrans %}</h2>
|
<h2>{% trans %}Comments{% endtrans %}</h2>
|
||||||
{% for comment in object.comments.all() %}
|
{% for comment in object.comments.all() %}
|
||||||
|
Loading…
Reference in New Issue
Block a user