Skip to content

Add support for the edx.course.enrollment.mode_changed event - #304

Merged
ziafazal merged 1 commit into
openedx:masterfrom
rpenido:fix/#292
Jun 7, 2023
Merged

Add support for the edx.course.enrollment.mode_changed event#304
ziafazal merged 1 commit into
openedx:masterfrom
rpenido:fix/#292

Conversation

@rpenido

@rpenido rpenido commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

Description: Add support for the edx.course.enrollment.mode_changed event. Use the same verb and transformer than edx.course.enrollment.activated

Verb

XAPI_VERB_REGISTERED = 'http://adlnet.gov/expapi/verbs/registered'

Closes #292

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 2, 2023
@openedx-webhooks

openedx-webhooks commented Jun 2, 2023

Copy link
Copy Markdown

Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

Comment thread event_routing_backends/processors/xapi/constants.py Outdated
@rpenido rpenido closed this Jun 5, 2023
@rpenido rpenido reopened this Jun 5, 2023
@bmtcril

bmtcril commented Jun 5, 2023

Copy link
Copy Markdown
Contributor

This makes sense to me, is it good to come out of draft status?

@bmtcril

bmtcril commented Jun 5, 2023

Copy link
Copy Markdown
Contributor

Looks like some issues with the docs too:

docs/event-mapping/xAPI_mapping.rst:45: D000 Title underline too short.
docs/event-mapping/xAPI_mapping.rst:45: D000 Title underline too short.
docs/event-mapping/Supported_events.rst:12: D000 Unknown target name: "edx.course.enrollment.mode_changed".
docs/event-mapping/Supported_events.rst:12: D002 Trailing whitespace

@rpenido

rpenido commented Jun 5, 2023

Copy link
Copy Markdown
Contributor Author

Thank you for the input @bmtcril!

I'm looking into the docs and Testing Instructions.

This PR will also need to increment the version number, right?

Right know, I'm having issues dispatching the event (probably related to my stack, not the code itself)

2023-06-05 17:52:16,248 ERROR 1061 [celery.app.trace] [user None] [ip None] trace.py:265 - Task event_routing_backends.tasks.dispatch_event[1d47662d-2fe5-42f1-a3fb-901af7592f68] raised unexpected: OSError(99, 'Cannot assign requested address')
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/edx/src/event-routing-backends/event_routing_backends/tasks.py", line 52, in dispatch_event
    send_event(self, event_name, event, router_type, host_config)
  File "/edx/src/event-routing-backends/event_routing_backends/tasks.py", line 74, in send_event
    client.send(event, event_name)
  File "/edx/src/event-routing-backends/event_routing_backends/utils/xapi_lrs_client.py", line 77, in send
    response = self.lrs_client.save_statement(statement_data)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/tincan/remote_lrs.py", line 203, in save_statement
    lrs_response = self._send_request(request)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/tincan/remote_lrs.py", line 132, in _send_request
    web_req.request(
  File "/usr/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 922, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

This is my statement_data:

{
   "id":"0e3fcdb0-a003-5403-8f4d-c48a97987b8d",
   "version":"1.0.3",
   "actor":{
      "objectType":"Agent",
      "account":{
         "name":"bf1b9a01-5ca9-4f2f-be97-13df6ef42731",
         "homePage":"http://localhost:18000"
      }
   },
   "verb":{
      "id":"http://adlnet.gov/expapi/verbs/registered",
      "display":{
         "en":"registered"
      }
   },
   "object":{
      "id":"http://localhost:18000/course/course-v1:edX+DemoX+Demo_Course",
      "objectType":"Activity",
      "definition":{
         "name":{
            "en":"Demonstration Course"
         },
         "type":"http://adlnet.gov/expapi/activities/course",
         "extensions":{
            "https://w3id.org/xapi/acrossx/extensions/type":"audit"
         }
      }
   },
   "timestamp":"2023-06-05T17:52:16.204763+00:00",
   "context":{
      "extensions":{
         "https://w3id.org/xapi/openedx/extension/transformer-version":"event-routing-backends@5.3.1"
      }
   }
}

I'm investigating the issue.

Thank you!

@rpenido
rpenido marked this pull request as ready for review June 5, 2023 22:35

@pomegranited pomegranited 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.

👍 This is working perfectly @rpenido :)

Just a couple of minor nits and a version bump and it's ready to merge.

  • I tested this using my Tutor OARS devstack, with the LMS image rebuilt to use this branch.
    • Enrolled in the DemoX course
    • From the LMS shell, ran:
      python manage.py lms change_enrollment -e superuser@example.com -f audit -t honor -c 'course-v1:edX+DemoX+Demo_Course'
      
    • Watched this event appear on the OARS xAPI events chart, complete with the honor course mode in the event.
  • I read through the code
  • I checked for accessibility issues N/A backend only
  • Includes documentation, and the links are working.
  • Commit structure follows OEP-0051

Comment thread docs/event-mapping/Supported_events.rst Outdated
Comment thread CHANGELOG.rst
Comment thread event_routing_backends/processors/xapi/event_transformers/enrollment_events.py Outdated

@bmtcril bmtcril 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.

👍

@bmtcril

bmtcril commented Jun 6, 2023

Copy link
Copy Markdown
Contributor

@ziafazal are we good to merge this and roll a release?

@ziafazal

ziafazal commented Jun 7, 2023

Copy link
Copy Markdown
Contributor

@bmtcril let me merge and create release.

@ziafazal
ziafazal merged commit 68683bc into openedx:master Jun 7, 2023
@openedx-webhooks

Copy link
Copy Markdown

@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

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

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add support for the edx.course.enrollment.mode_changed event

5 participants