Skip to content

Commit

Permalink
fix: add minor fixes and helpful comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cup0fCoffee committed Apr 8, 2024
1 parent 1e26b4a commit 88634fc
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions xmodule/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ class ProblemFeedbackService(Service):
"""
An XBlock Service that allows XModules to define:
- if the answers are visible
- whether correctness is currently hidden. When correctness is hidden, this
limits the user's access to the correct/incorrect flags, messages, problem
scores, and aggregate subsection and course grades.
* If the answers are visible.
* Whether correctness is currently hidden. When correctness is hidden, this
limits the user's access to the correct/incorrect flags, messages, problem
scores, and aggregate subsection and course grades.
"""
def __init__(self, block=None, user_is_staff=False, **kwargs):
super().__init__(**kwargs)
Expand All @@ -333,6 +333,16 @@ def __init__(self, block=None, user_is_staff=False, **kwargs):
def is_past_due(self):
"""
Returns if the problem is past its due date.
This method returns True when an XBlock doesn't have a due date. That
is because if an XBlock doesn't have a due date, and we are trying to
assess whether we can display a correct answer to a learner, we want to
treat an answered problem without a due date as past due. Otherwise, we
can never show the answer to a learner, since there is no due date.
There are scenarios where you would want is_past_due to return False
when an XBlock doesn't have a due date, for example, when determining
whether a learner should still be able to submit their answer.
"""
if not self._xblock:
return False
Expand Down Expand Up @@ -366,7 +376,9 @@ def closed(self):

if self.used_all_attempts():
return True
elif (self.xblock is None or self._xblock.close_date is not None) and self.is_past_due():
# Using XBlock's is_past_due method, as it's suited for checking the
# submission deadline, unlike the is_past_due method of this service.
elif self._xblock.is_past_due():
return True
return False

Expand All @@ -382,7 +394,7 @@ def answer_available(self):
attempts = self._xblock.attempts
is_correct = self._xblock.is_correct()
required_attempts = self._xblock.attempts_before_showanswer_button
has_due_date = getattr(self._xblock, 'due', None) is not None
has_due_date = getattr(self._xblock, 'close_date', None) is not None
past_due = self.is_past_due()
is_attempted = self.is_attempted()
used_all_attempts = self.used_all_attempts()
Expand Down

0 comments on commit 88634fc

Please sign in to comment.