From 2d398ee6480eccb3f4aa2cd331022f3a32ae622b Mon Sep 17 00:00:00 2001 From: dzhuang Date: Tue, 7 Feb 2017 17:14:19 +0800 Subject: [PATCH] Hide grade_points field in HumanTextFeedbackForm if points is zero. --- course/page/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/course/page/base.py b/course/page/base.py index a5742323..518ace17 100644 --- a/course/page/base.py +++ b/course/page/base.py @@ -820,7 +820,7 @@ class HumanTextFeedbackForm(StyledForm): [0, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 100]), label=_("Grade percent")) - if point_value is not None: + if point_value is not None and point_value != 0: self.fields["grade_points"] = forms.FloatField( min_value=0, max_value=MAX_EXTRA_CREDIT_FACTOR*point_value, @@ -893,7 +893,7 @@ class HumanTextFeedbackForm(StyledForm): if self.point_value is None: return self.cleaned_data["grade_percent"] elif (self.cleaned_data["grade_percent"] is not None - and self.cleaned_data["grade_points"] is not None): + and self.cleaned_data.get("grade_points") is not None): points_percent = 100*self.cleaned_data["grade_points"]/self.point_value direct_percent = self.cleaned_data["grade_percent"] @@ -905,7 +905,7 @@ class HumanTextFeedbackForm(StyledForm): elif self.cleaned_data["grade_percent"] is not None: return self.cleaned_data["grade_percent"] - elif self.cleaned_data["grade_points"] is not None: + elif self.cleaned_data.get("grade_points") is not None: if self.point_value: return 100*self.cleaned_data["grade_points"]/self.point_value else: -- GitLab