Skip to content

Commit

Permalink
fix: move course_end_date property to InheritanceMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Cup0fCoffee committed Dec 29, 2024
1 parent f419080 commit be7e100
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 0 additions & 12 deletions xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,18 +787,6 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
}
yield (user_state.username, report)

@property
def course_end_date(self):
"""
Return the end date of the problem's course
"""

try:
course_block_key = self.runtime.course_entry.structure['root']
return self.runtime.course_entry.structure['blocks'][course_block_key].fields['end']
except (AttributeError, KeyError):
return None

def get_seed(self):
"""
Generate the seed if not set and return it.
Expand Down
14 changes: 13 additions & 1 deletion xmodule/modulestore/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,24 @@ def close_date(self):
can be submitted till due date and the graceperiod. If no
graceperiod, then the close date is same as the due date.
"""
due_date = self.due
due_date = self.due or self.course_end_date

if self.graceperiod is not None and due_date:
return due_date + self.graceperiod
return due_date

@property
def course_end_date(self):
"""
Return the end date of the problem's course
"""

try:
course_block_key = self.runtime.course_entry.structure['root']
return self.runtime.course_entry.structure['blocks'][course_block_key].fields['end']
except (AttributeError, KeyError):
return None

def is_past_due(self):
"""
Returns the boolean identifying if the submission due date has passed.
Expand Down
2 changes: 1 addition & 1 deletion xmodule/tests/test_capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def test_closed(self):
due=self.yesterday_str)
assert block.closed()

@patch.object(ProblemBlock, 'course_end_date', new_callable=PropertyMock)
@patch('xmodule.modulestore.inheritance.InheritanceMixin.course_end_date', new_callable=PropertyMock)
def test_closed_for_archive(self, mock_course_end_date):

# Utility to create a datetime object in the past
Expand Down

0 comments on commit be7e100

Please sign in to comment.