add: různé druhy bodů u hodnocení
This commit is contained in:
parent
f96c24a474
commit
57b7c6372d
1 changed files with 65 additions and 0 deletions
|
@ -115,6 +115,71 @@ class Hodnoceni(bm.SeminarModelBase):
|
|||
|
||||
feedback = models.TextField('zpětná vazba', blank=True, default='', help_text='Zpětná vazba řešiteli (plain text)')
|
||||
|
||||
# TODO najít správné místo
|
||||
@staticmethod
|
||||
def vzorecek_na_prepocet(body, resitelu):
|
||||
return body * 3 / (resitelu + 2)
|
||||
|
||||
# TODO najít správné místo
|
||||
@staticmethod
|
||||
def inverze_vzorecku_na_prepocet(body, resitelu):
|
||||
return body * (resitelu + 2) / 3
|
||||
|
||||
@property
|
||||
def body_celkem(self):
|
||||
# FIXME řeším jen prvního řešitele.
|
||||
return Hodnoceni.objects.filter(problem=self.problem, reseni__resitele=self.reseni.resitele.first(), body__isnull=False).aggregate(Sum("body"))["body__sum"]
|
||||
|
||||
@body_celkem.setter
|
||||
def body_celkem(self, value):
|
||||
if value is None:
|
||||
self.body = None
|
||||
else:
|
||||
if self.body is None:
|
||||
self.body = 0
|
||||
if self.body_celkem is None:
|
||||
self.body += value
|
||||
else:
|
||||
self.body += value - self.body_celkem
|
||||
|
||||
@property
|
||||
def body_neprepocitane(self):
|
||||
if self.body is None:
|
||||
return None
|
||||
return self.inverze_vzorecku_na_prepocet(self.body, self.reseni.resitele.count())
|
||||
|
||||
@body_neprepocitane.setter
|
||||
def body_neprepocitane(self, value):
|
||||
if value is None:
|
||||
self.body = None
|
||||
else:
|
||||
self.body = self.vzorecek_na_prepocet(value, self.reseni.resitele.count())
|
||||
|
||||
@property
|
||||
def body_neprepocitane_celkem(self):
|
||||
if self.body_celkem is None:
|
||||
return None
|
||||
return self.inverze_vzorecku_na_prepocet(self.body_celkem, self.reseni.resitele.count())
|
||||
|
||||
@body_neprepocitane_celkem.setter
|
||||
def body_neprepocitane_celkem(self, value):
|
||||
if value is None:
|
||||
self.body = None
|
||||
else:
|
||||
self.body_celkem = self.vzorecek_na_prepocet(value, self.reseni.resitele.count())
|
||||
|
||||
@property
|
||||
def body_max(self):
|
||||
if not isinstance(Hodnoceni.objects.first().problem, am.Uloha):
|
||||
return None
|
||||
return self.problem.uloha.max_body
|
||||
|
||||
@property
|
||||
def body_neprepocitane_max(self):
|
||||
if self.body_max is None:
|
||||
return None
|
||||
return self.inverze_vzorecku_na_prepocet(self.body_max, self.reseni.resitele.count())
|
||||
|
||||
def __str__(self):
|
||||
return "{}, {}, {}".format(self.problem, self.reseni, self.body)
|
||||
|
||||
|
|
Loading…
Reference in a new issue