-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add utility function to validate whether turnitin is enable…
…d in course
- Loading branch information
Showing
3 changed files
with
35 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,26 @@ | ||
"""Event handlers for the Turnitin plugin.""" | ||
|
||
from django.conf import settings | ||
from opaque_keys.edx.keys import UsageKey | ||
|
||
from platform_plugin_turnitin.edxapp_wrapper.modulestore import modulestore | ||
from platform_plugin_turnitin.tasks import ora_submission_created_task | ||
from platform_plugin_turnitin.utils import enabled_in_course | ||
|
||
|
||
def ora_submission_created(submission, **kwargs): | ||
""" | ||
Handle the ORA_SUBMISSION_CREATED event. | ||
Args: | ||
submission (ORASubmissionData): The ORA submission data. | ||
""" | ||
if settings.ENABLE_TURNITIN_SUBMISSION: | ||
call_ora_submission_created_task(submission) | ||
return | ||
|
||
course_key = UsageKey.from_string(submission.location).course_key | ||
course_block = modulestore().get_course(course_key) | ||
enable_in_course = course_block.other_course_settings.get("ENABLE_TURNITIN_SUBMISSION", False) | ||
|
||
if enable_in_course: | ||
call_ora_submission_created_task(submission) | ||
|
||
|
||
def call_ora_submission_created_task(submission) -> None: | ||
""" | ||
Call the ORA submission created task. | ||
If the Turnitin feature is enabled globally or in the course, create a new task to | ||
send the ORA submission data to Turnitin. | ||
Args: | ||
submission (ORASubmissionData): The ORA submission data. | ||
""" | ||
ora_submission_created_task.delay( | ||
submission.uuid, | ||
submission.anonymous_user_id, | ||
submission.answer.parts, | ||
submission.answer.file_names, | ||
submission.answer.file_urls, | ||
) | ||
if settings.ENABLE_TURNITIN_SUBMISSION or enabled_in_course(submission.location): | ||
ora_submission_created_task.delay( | ||
submission.uuid, | ||
submission.anonymous_user_id, | ||
submission.answer.parts, | ||
submission.answer.file_names, | ||
submission.answer.file_urls, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters