@@ -19,11 +19,31 @@ class GradesChoices(IntegerChoices):
1919 VERY_WELL = 3 , _ ('Very well' )
2020 EXCELLENT = 4 , _ ('Excellent' )
2121
22+ class GradesDMPChoices (IntegerChoices ):
23+ VYBORNY = 1 , _ ('1 - výborný' )
24+ CHVALITEBNY = 2 , _ ('2 - chvalitebný' )
25+ DOBRY = 3 , _ ('3 - dobrý' )
26+ DOSTATECNY = 4 , _ ('4 - dostatečný' )
27+ NEDOSTATECNY = 5 , _ ('5 - nedostatečný' )
28+
29+ class GradesAPChoices (IntegerChoices ):
30+ A = 1 , 'A'
31+ B = 2 , 'B'
32+ C = 3 , 'C'
33+ D = 4 , 'D'
34+ E = 5 , 'E'
35+ F = 6 , 'F'
36+
2237 class DifficultyChoices (IntegerChoices ):
2338 UNDER_AVERAGE = 1 , _ ('Under average' )
2439 AVERAGE = 2 , _ ('Average' )
2540 OVER_AVERAGE = 3 , _ ('Over average' )
2641
42+ class DifficultyNewChoices (IntegerChoices ):
43+ OVER_AVERAGE = 1 , _ ('Over average' )
44+ AVERAGE = 2 , _ ('Average' )
45+ UNDER_AVERAGE = 3 , _ ('Under average' )
46+
2747 thesis = models .ForeignKey (
2848 to = 'thesis.Thesis' ,
2949 on_delete = models .CASCADE ,
@@ -45,24 +65,24 @@ class DifficultyChoices(IntegerChoices):
4565 )
4666 difficulty = models .PositiveSmallIntegerField (
4767 verbose_name = _ ('Difficulty' ),
48- help_text = _ ('As value between 1 and 3 inclusive, higher is harder .' ),
68+ help_text = _ ('As value between 1 and 3 inclusive.' ),
4969 validators = [MinValueValidator (1 ), MaxValueValidator (3 )],
5070 choices = DifficultyChoices .choices ,
5171 )
5272 grades = ArrayField (
5373 models .PositiveSmallIntegerField (
54- validators = [MinValueValidator (1 ), MaxValueValidator (4 )],
55- choices = GradesChoices .choices ,
56- help_text = _ ('As value between 1 and 4 inclusive, higher is better .' ),
74+ validators = [MinValueValidator (1 ), MaxValueValidator (6 )],
75+ choices = GradesAPChoices .choices ,
76+ help_text = _ ('As value between 1 and 6 inclusive.' ),
5777 ),
5878 validators = [ArrayMinLengthValidator (5 ), ArrayMaxLengthValidator (6 )],
5979 verbose_name = _ ('Grades' ),
6080 )
6181 grade_proposal = models .PositiveSmallIntegerField (
6282 verbose_name = _ ('Proposed grade' ),
63- validators = [MinValueValidator (1 ), MaxValueValidator (4 )],
64- help_text = _ ('As value between 1 and 4 inclusive, higher is better .' ),
65- choices = GradesChoices .choices ,
83+ validators = [MinValueValidator (1 ), MaxValueValidator (6 )],
84+ help_text = _ ('As value between 1 and 6 inclusive.' ),
85+ choices = GradesAPChoices .choices ,
6686 )
6787
6888 class Meta :
@@ -73,6 +93,30 @@ class Meta:
7393 def __str__ (self ):
7494 return _ ('Review on {} from {}' ).format (self .thesis , self .user )
7595
96+ GRADE_TYPE_CUTOFF_YEAR = 2026
97+
98+ @staticmethod
99+ def get_grade_config (category_grade_type , published_at ):
100+ """Return (choices_class, max_value, lower_is_better) for given category and publish date."""
101+ use_new = published_at and published_at .year >= Review .GRADE_TYPE_CUTOFF_YEAR
102+ if not use_new :
103+ return Review .GradesChoices , 4 , False
104+ if category_grade_type == 'ap' :
105+ return Review .GradesAPChoices , 6 , True
106+ return Review .GradesDMPChoices , 5 , True
107+
108+ def get_grades_choices (self ):
109+ choices_class , _ , _ = self .get_grade_config (
110+ self .thesis .category .grade_type , self .thesis .published_at
111+ )
112+ return choices_class
113+
114+ def get_difficulty_choices (self ):
115+ use_new = self .thesis .published_at and self .thesis .published_at .year >= self .GRADE_TYPE_CUTOFF_YEAR
116+ if use_new :
117+ return self .DifficultyNewChoices
118+ return self .DifficultyChoices
119+
76120 @property
77121 def gradings (self ):
78122 return tuple (filter (None , (
0 commit comments