-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: grant course staff exam access tokens #359
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! I left a comment.
@@ -815,6 +815,26 @@ def test_access_no_due_date(self, attempt_status, response_status): | |||
if response_status == 200: | |||
self.assert_valid_exam_access_token(response, self.user, no_due_date_exam) | |||
|
|||
def test_access_user_is_course_staff(self): | |||
""" | |||
Verify the endpoint grants access for an exam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you agree with my suggestion below, please update the docstring and the test.
edx_exams/apps/api/v1/views.py
Outdated
@@ -385,6 +385,10 @@ def get_response(cls, exam, user): | |||
elif exam.due_date is not None and timezone.now() >= exam.due_date: | |||
grant_access, response_status = True, status.HTTP_200_OK | |||
|
|||
# If user is course staff, then grant them access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what we want, but I think we should have this before line 369. On the frontend, access to the contents of the exam will always be granted to staff members. Because of this, they never see any exam functionality and will not be able to start an exam attempt. Therefore, we can short circuit early and give them access immediately if they are a staff member - no need to look at exam attempts. This makes the code easier to reason about. Does that match your understanding?
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
JIRA: Link to JIRA ticket
Description: Add a fix to allow course staff to view the exams they create, as currently some courses staff are blocked from viewing the exams they've created.
Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.
Dependencies: dependencies on other outstanding PRs, issues, etc.
Installation instructions: List any non-trivial installation
instructions.
Testing instructions:
Merge checklist:
Post merge: