Skip to content

Commit

Permalink
Restructuring moodle course completion request and allowed continuous…
Browse files Browse the repository at this point in the history
… learner transmission till course completion (#1964)

* refactor: adding log inside moodle request wrapper

* feat: allow incomplete course learner transmissions till completion
  • Loading branch information
MueezKhan246 authored Dec 11, 2023
1 parent 4a1687f commit cc4a810
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Change Log
Unreleased
----------
[4.8.11]
--------
feat: allow incomplete course learner transmissions till completion
refactor: adding log inside moodle request wrapper

[4.8.10]
--------
feat: not submitting sso orchestrator records if no changes occur
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.8.10"
__version__ = "4.8.11"
37 changes: 24 additions & 13 deletions integrated_channels/moodle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def inner(self, *args, **kwargs):
# This only happens for grades AFAICT. Zero also doesn't necessarily mean success,
# but we have nothing else to go on
if body == 0:
if method.__name__ == "_wrapped_create_course_completion":
completion_data = kwargs.get('payload')
course_id = completion_data.get('courseID', None)
LOGGER.info(
'Integer Response for Moodle Course Completion'
f'for course={course_id} '
f' response: {response} '
f'Status Code: {response.status_code}, '
f'Text: {response.text}, '
f'Headers: {response.headers}, '
)
return 200, ''
raise ClientError('Moodle API Grade Update failed with int code: {code}'.format(code=body), 500)
if isinstance(body, str):
Expand Down Expand Up @@ -351,19 +362,19 @@ def _wrapped_create_course_completion(self, user_id, payload):
headers = response.headers
else:
headers = None

LOGGER.info(
'Learner Data Transmission'
f'for course={completion_data["courseID"]} with data '
f'source: {module_name}, '
f'activityid: {course_module_id}, '
f'grades[0][studentid]: {moodle_user_id}, '
f'grades[0][grade]: {completion_data["grade"] * self.enterprise_configuration.grade_scale} '
f' with response: {response} '
f'Status Code: {status_code}, '
f'Text: {text}, '
f'Headers: {headers}, '
)
if not status_code or not text or not headers:
LOGGER.info(
'Learner Data Transmission'
f'for course={completion_data["courseID"]} with data '
f'source: {module_name}, '
f'activityid: {course_module_id}, '
f'grades[0][studentid]: {moodle_user_id}, '
f'grades[0][grade]: {completion_data["grade"] * self.enterprise_configuration.grade_scale} '
f' with response: {response} '
f'Status Code: {status_code}, '
f'Text: {text}, '
f'Headers: {headers}, '
)

return response

Expand Down
3 changes: 2 additions & 1 deletion integrated_channels/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def is_already_transmitted(
enterprise_course_enrollment_id=enterprise_enrollment_id,
plugin_configuration_id=enterprise_configuration_id,
error_message='',
status__lt=400
status__lt=400,
course_completed=True
)
if subsection_id:
already_transmitted = already_transmitted.filter(subsection_id=subsection_id)
Expand Down

0 comments on commit cc4a810

Please sign in to comment.