Skip to content

feat: handle exam submission and reset - #33323

Merged
zacharis278 merged 5 commits into
masterfrom
zhancock/completion-event-consumer
Oct 6, 2023
Merged

zacharis278 merged 5 commits into
masterfrom
zhancock/completion-event-consumer

Conversation

@zacharis278

@zacharis278 zacharis278 commented Sep 22, 2023 •

Copy link
Copy Markdown
Contributor

MST-2112

Handles events from edx-exams that impact learner completion

Design note. I stayed away from calling anything within the InstructorService class for this event handler. I'd recommend this approach for other consumers as well since the purpose of that class is to be injected into edx-proctoring at runtime. It might cause small amounts of duplicate logic but it allows us to keep the integration with edx-proctoring and edx-exams clearly separated. I'd expect InstructorService to go away if/when edx-proctoring is no longer in use. This is a similar pattern to what we did on the exam publishing side of things.

Refactors some tests out of InstructorService. Most of these tests were testing behavior in tasks.py anyway and it's now called from more than one location. I added a test file to handle that behavior specifically.

@ilee2u

ilee2u commented Sep 29, 2023 •

Copy link
Copy Markdown
Contributor

quick reminder to point this PR to the MST-1789-downstream-triggers branch

Yep never mind that, we're merging to master now.

@ilee2u

ilee2u commented Oct 2, 2023

Copy link
Copy Markdown
Contributor

quick reminder to point this PR to the MST-1789-downstream-triggers branch

Note this message may be dated depending on whether or not the openedx-events is unpinned on master via this PR: #33392

@zacharis278
zacharis278 force-pushed the zhancock/completion-event-consumer branch from 3227985 to e033037 Compare October 3, 2023 15:39
@zacharis278
zacharis278 marked this pull request as ready for review October 3, 2023 16:38
@zacharis278
zacharis278 force-pushed the zhancock/completion-event-consumer branch from e033037 to 25794ac Compare October 3, 2023 17:35
Comment thread lms/djangoapps/instructor/handlers.py Outdated
'Error occurred while attempting to reset module state for user_id '
f'{student.id} for content_id {content_id}.'
)
log.error(err_msg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: small inconsistency in how log.error() is called w/ or w/o a err_msg variable defined.

course_key = event_data.course_key
content_id = str(usage_key)

try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this code is mostly a copy/paste of the delete_student_attempt() code in services.py. Should we do something similar to what we did in the invalidate certificate consumer PR, where we compartmentalize this code in an api function (or something similar)?

@ilee2u ilee2u Oct 3, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note that if you chose to do this, you may have to (slightly) modify your handlers and services tests, and may also need to add a test to test_api.py for coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here is similar but I'd argue a helper function adds complexity since the purpose of these two functions is to interface with a different system with slightly different inputs.

Thinking a bit forward to the fact that services.py eventually goes away. Better to duplicate and easily delete half than need to refactor shared code later.

I think there's something to be said about where the call to reset_student_attempts is. It could probably be refactored into the update_completion_task but I stopped short of that to avoid reworking too many things.

@ilee2u ilee2u Oct 4, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, in that case, should I refactor my code in the invalidate certificate PR to not have a helper function for the same reason? We decided that this is dependent on whether or not the helper function would call something in another service.

@zacharis278
zacharis278 force-pushed the zhancock/completion-event-consumer branch from f8bb2d9 to c67bd20 Compare October 4, 2023 19:08

@varshamenon4 varshamenon4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@zacharis278
zacharis278 merged commit 9f16b0f into master Oct 6, 2023
@zacharis278
zacharis278 deleted the zhancock/completion-event-consumer branch October 6, 2023 13:10
zacharis278 added a commit that referenced this pull request Oct 6, 2023
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants