move: přesunuty vzorečky na přepočet bodů do seminar.utils
This commit is contained in:
parent
c8516d6eda
commit
d66effcd46
2 changed files with 16 additions and 16 deletions
|
@ -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):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
import decimal
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import permission_required, \
|
||||
|
@ -44,6 +45,14 @@ AnonymousUser.je_org = False
|
|||
AnonymousUser.je_resitel = False
|
||||
|
||||
|
||||
def vzorecek_na_prepocet(body, resitelu):
|
||||
return body * 3 / (resitelu + 2)
|
||||
|
||||
|
||||
def inverze_vzorecku_na_prepocet(body: decimal.Decimal, resitelu) -> decimal.Decimal:
|
||||
return round(body * (resitelu + 2) / 3, 1)
|
||||
|
||||
|
||||
class FirstTagParser(HTMLParser):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.firstTag = None
|
||||
|
|
Loading…
Reference in a new issue