Skip to content

Commit

Permalink
Merge pull request #1977 from open-craft/agrendalath/fc-0026-beta_tes…
Browse files Browse the repository at this point in the history
…ting_days

refactor: use `days_early_for_beta` from `InheritanceMixin` instead of runtime [FC-0026]
  • Loading branch information
pomegranited authored Jun 14, 2023
2 parents 7912a81 + f05e193 commit 0f8b0f9
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ JIRA: [JIRA-XXXX](https://openedx.atlassian.net/browse/JIRA-XXXX)

- [ ] Reviewed the [release process](https://github.com/openedx/edx-ora2/blob/master/.github/release_process.md)
- [ ] Translations and JS/SASS compiled
- [ ] Bumped version number in [setup.py](https://github.com/openedx/edx-ora2/blob/a62e81a9b0d89223476967ec3c27f3557a850735/setup.py#L39) and [package.json](https://github.com/openedx/edx-ora2/blob/a62e81a9b0d89223476967ec3c27f3557a850735/package.json#L3)
- [ ] Bumped version number in [openassessment/\_\_init\_\_.py](https://github.com/openedx/edx-ora2/blob/master/openassessment/__init__.py#L4) and [package.json](https://github.com/openedx/edx-ora2/blob/master/package.json#L3)

**Testing Instructions**

Expand Down
4 changes: 2 additions & 2 deletions .github/release_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Before Merging a pull request:
- [ ] Get a green Travis build for this PR
- [ ] Address PR comments
- [ ] Get approving review from code owner
- [ ] Bump version number in [setup.py](../setup.py) and [package.json](../package.json) following [semantic versioning](https://semver.org/) conventions
- [ ] Bump version number in [openassessment/\_\_init\_\_.py](../openassessment/__init__.py) and [package.json](../package.json) following [semantic versioning](https://semver.org/) conventions

## Publish to PyPi

When a PR is ready to release, do the following to publish a new version of ORA:

- [ ] Merge to `master`
- [ ] Create a [release tag on GitHub](https://github.com/openedx/edx-ora2/releases) matching version number in setup.py/package.json
- [ ] Create a [release tag on GitHub](https://github.com/openedx/edx-ora2/releases) matching version number in `openassessment/__init__.py`/`package.json`
- [ ] Grab a coffee while our automated process submits the build to PyPi
- [ ] Confirm new version appears in [PyPi: ora2](https://pypi.org/project/ora2)

Expand Down
2 changes: 1 addition & 1 deletion openassessment/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Initialization Information for Open Assessment Module
"""
__version__ = '5.0.2'
__version__ = '5.0.3'
10 changes: 4 additions & 6 deletions openassessment/xblock/openassessmentblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,12 +1339,10 @@ def _adjust_start_date_for_beta_testers(self, start):
"""
Returns the start date for a Beta tester.
"""
if hasattr(self, "xmodule_runtime"):
days_early_for_beta = getattr(self.xmodule_runtime, 'days_early_for_beta', 0) # pylint: disable=no-member
if days_early_for_beta is not None:
delta = dt.timedelta(days_early_for_beta)
effective = start - delta
return effective
if days_early_for_beta := getattr(self, 'days_early_for_beta', None):
delta = dt.timedelta(days_early_for_beta)
effective = start - delta
return effective

return start

Expand Down
10 changes: 5 additions & 5 deletions openassessment/xblock/test/test_openassessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ def _set_up_days_early_for_beta(self, xblock, days_early):
"""
Helper function to set up start date early for beta testers
"""
xblock.days_early_for_beta = days_early
xblock.xmodule_runtime = Mock(
course_id='test_course',
anonymous_student_id='test_student',
days_early_for_beta=days_early,
user_is_staff=False,
user_is_beta_tester=True
)
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_formatted_start_dates_for_beta_tester_with_days_early(self, time_zone,
# Set start dates
xblock = self._set_up_start_date(dt.datetime(2014, 4, 6, 1, 1, 1))
self._set_up_days_early_for_beta(xblock, 5)
self.assertEqual(xblock.xmodule_runtime.days_early_for_beta, 5)
self.assertEqual(xblock.days_early_for_beta, 5)

resp = self._render_xblock(xblock)
self.assertIn(expected_start_date, resp.body.decode('utf-8'))
Expand All @@ -392,7 +392,7 @@ def test_formatted_end_dates_for_beta_tester_with_days_early(self, time_zone, ex
xblock = self._set_up_start_date(dt.datetime(2014, 4, 6, 1, 1, 1))
xblock.due = dt.datetime(2014, 5, 1)
self._set_up_days_early_for_beta(xblock, 5)
self.assertEqual(xblock.xmodule_runtime.days_early_for_beta, 5)
self.assertEqual(xblock.days_early_for_beta, 5)
resp = self._render_xblock(xblock)
self.assertIn(expected_end_date, resp.body.decode('utf-8'))

Expand Down Expand Up @@ -449,7 +449,7 @@ def test_formatted_start_dates_for_beta_tester_with_nonetype_days_early(self, ti
# Set start dates
xblock = self._set_up_start_date(dt.datetime(2014, 4, 6, 1, 1, 1))
self._set_up_days_early_for_beta(xblock, None)
self.assertEqual(xblock.xmodule_runtime.days_early_for_beta, None)
self.assertEqual(xblock.days_early_for_beta, None)

resp = self._render_xblock(xblock)
self.assertIn(expected_start_date, resp.body.decode('utf-8'))
Expand All @@ -465,7 +465,7 @@ def test_formatted_end_dates_for_beta_tester_with_nonetype_days_early(self, time
# Set due dates
xblock = self._set_up_end_date(dt.datetime(2014, 5, 1))
self._set_up_days_early_for_beta(xblock, None)
self.assertEqual(xblock.xmodule_runtime.days_early_for_beta, None)
self.assertEqual(xblock.days_early_for_beta, None)

resp = self._render_xblock(xblock)
self.assertIn(expected_end_date, resp.body.decode('utf-8'))
Expand Down
2 changes: 0 additions & 2 deletions openassessment/xblock/test/test_staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ def _create_mock_runtime(
is_admin,
anonymous_user_id,
user_is_beta=False,
days_early_for_beta=0
):
"""
Internal helper to define a mock runtime.
Expand All @@ -455,7 +454,6 @@ def _create_mock_runtime(
user_is_staff=is_staff,
user_is_admin=is_admin,
user_is_beta=user_is_beta,
days_early_for_beta=days_early_for_beta,
service=lambda self, service: Mock(
get_anonymous_student_id=lambda user_id, course_id: anonymous_user_id
)
Expand Down
2 changes: 0 additions & 2 deletions openassessment/xblock/test/test_staff_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,6 @@ def _create_mock_runtime(
is_admin,
anonymous_user_id,
user_is_beta=False,
days_early_for_beta=0
):
"""
Internal helper to define a mock runtime.
Expand All @@ -1452,7 +1451,6 @@ def _create_mock_runtime(
user_is_staff=is_staff,
user_is_admin=is_admin,
user_is_beta=user_is_beta,
days_early_for_beta=days_early_for_beta,
service=lambda self, service: Mock(
get_anonymous_student_id=lambda user_id, course_id: anonymous_user_id
)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edx-ora2",
"version": "5.0.2",
"version": "5.0.3",
"repository": "https://github.com/openedx/edx-ora2.git",
"dependencies": {
"@edx/frontend-build": "^6.1.1",
Expand Down

0 comments on commit 0f8b0f9

Please sign in to comment.