Skip to content

Commit

Permalink
Fix ModuleRevealState crashing if it contains no exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael-Lenander committed Sep 23, 2023
1 parent 46dba40 commit a3f34cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exercise/reveal_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def __init__(self, module: Union[CourseModule, ModulePoints], student: Optional[
self.max_deviation: Optional[DeadlineRuleDeviation] = None

def get_deadline(self) -> Optional[datetime.datetime]:
if len(self.exercises) == 0:
return None
return max(_get_exercise_deadline(exercise) for exercise in self.exercises)

def get_latest_deadline(self) -> Optional[datetime.datetime]:
Expand All @@ -167,6 +169,8 @@ def get_latest_deadline(self) -> Optional[datetime.datetime]:
deadlines.append(
self.max_deviation.get_new_deadline(exercise_dict[self.max_deviation.exercise_id].closing_time)
)
if len(deadlines) == 0:
return None
return max(deadlines)

def get_points(self) -> Optional[int]:
Expand Down

0 comments on commit a3f34cb

Please sign in to comment.