|
|
@ -1,4 +1,3 @@ |
|
|
|
import decimal |
|
|
|
import os |
|
|
|
|
|
|
|
import reversion |
|
|
@ -15,6 +14,8 @@ from seminar.models import personalni as pm |
|
|
|
from seminar.models import treenode as tm |
|
|
|
from seminar.models import base as bm |
|
|
|
|
|
|
|
from seminar.utils import vzorecek_na_prepocet, inverze_vzorecku_na_prepocet |
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
class Reseni(bm.SeminarModelBase): |
|
|
@ -116,16 +117,6 @@ 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: decimal.Decimal, resitelu) -> decimal.Decimal: |
|
|
|
return round(body * (resitelu + 2) / 3, 1) |
|
|
|
|
|
|
|
@property |
|
|
|
def body_celkem(self): |
|
|
|
# FIXME řeším jen prvního řešitele. |
|
|
@ -147,33 +138,33 @@ class Hodnoceni(bm.SeminarModelBase): |
|
|
|
def body_neprepocitane(self): |
|
|
|
if self.body is None: |
|
|
|
return None |
|
|
|
return self.inverze_vzorecku_na_prepocet(self.body, self.reseni.resitele.count()) |
|
|
|
return 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()) |
|
|
|
self.body = 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()) |
|
|
|
return 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()) |
|
|
|
self.body_celkem = vzorecek_na_prepocet(value, self.reseni.resitele.count()) |
|
|
|
|
|
|
|
@property |
|
|
|
def body_max(self): |
|
|
|
if self.body_neprepocitane_max is None: |
|
|
|
return None |
|
|
|
return self.vzorecek_na_prepocet(self.body_neprepocitane_max, self.reseni.resitele.count()) |
|
|
|
return vzorecek_na_prepocet(self.body_neprepocitane_max, self.reseni.resitele.count()) |
|
|
|
|
|
|
|
@property |
|
|
|
def body_neprepocitane_max(self): |
|
|
|