Skip to content

Commit

Permalink
refactor: [ACI-814] update course passing events types (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky authored and kyrylo-kh committed Apr 12, 2024
1 parent c72e3a9 commit 19e9217
Show file tree
Hide file tree
Showing 35 changed files with 595 additions and 306 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Python CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches:
- '**'
- '**'


jobs:
Expand All @@ -15,30 +15,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: ["quality", "docs", "django32", "django42"]
python-version: ['3.8', '3.11']
toxenv: ["django42", "quality", "docs"]

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: true
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: false
37 changes: 37 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,43 @@ Change Log
Unreleased
----------
[9.10.0] - 2024-04-12
--------------------
Added
~~~~~~~
* Added new COURSE_GRADE_NOW_PASSED, COURSE_GRADE_NOW_FAILED, BADGE_AWARDED, BADGE_REVOKED events in learning

[9.9.1] - 2024-04-12
--------------------

Changed
~~~~~~~

* Updated Python classifiers to include Python 3.11.

[9.9.0] - 2024-04-11
--------------------
Added
~~~~~~~
* Added new ``ORA_SUBMISSION_CREATED`` event in learning.

[9.8.0] - 2024-04-11
--------------------
Added
~~~~~
* Added support for Python 3.11

[9.7.0] - 2024-04-04
--------------------
Added
~~~~~~~
* Added new ``SUBSIDY_REDEEMED`` and ``SUBSIDY_REDEMPTION_REVERSED`` events in enterprise.

[9.6.0] - 2024-04-01
--------------------
Added
~~~~~~~
* Added new ``CONTENT_OBJECT_TAGGED`` events in content_authoring.

[9.5.2] - 2024-02-13
--------------------
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.5.2"
__version__ = "9.10.0"
14 changes: 14 additions & 0 deletions openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,17 @@ class LibraryBlockData:

library_key = attr.ib(type=LibraryLocatorV2)
usage_key = attr.ib(type=LibraryUsageLocatorV2)


@attr.s(frozen=True)
class ContentObjectData:
"""
Data about changed content object.
Arguments:
object_id (str): identifier of the Content object. This represents the id of the course or library block
as a string. For example:
block-v1:SampleTaxonomyOrg2+STC1+2023_1+type@vertical+block@f8de78f0897049ce997777a3a31b6ea0
"""

object_id = attr.ib(type=str)
12 changes: 12 additions & 0 deletions openedx_events/content_authoring/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from openedx_events.content_authoring.data import (
CertificateConfigData,
ContentLibraryData,
ContentObjectData,
CourseCatalogData,
CourseData,
DuplicatedXBlockData,
Expand Down Expand Up @@ -198,3 +199,14 @@
"library_block": LibraryBlockData,
}
)

# .. event_type: org.openedx.content_authoring.content.object.tags.changed.v1
# .. event_name: CONTENT_OBJECT_TAGS_CHANGED
# .. event_description: emitted when an object's tags are changed
# .. event_data: ContentObjectData
CONTENT_OBJECT_TAGS_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.content.object.tags.changed.v1",
data={
"content_object": ContentObjectData
}
)
6 changes: 6 additions & 0 deletions openedx_events/enterprise/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Package where events related to the enterprise subdomain are implemented.
The enterprise subdomain corresponds to {Architecture Subdomain} defined in
the OEP-41.
"""
24 changes: 24 additions & 0 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Data attributes for events within the architecture subdomain ``enterprise``.
These attributes follow the form of attr objects specified in OEP-49 data
pattern.
"""

import attr


@attr.s(frozen=True)
class SubsidyRedemption:
"""
Attributes for a Subsidy Redemption object.
Arguments:
subsidy_identifier (str): unique identifier to fetch the applied subsidy
content_key (str): content id where subsidy is utilized
lms_user_id (str): lms user id of subsidy beneficiary
"""

subsidy_identifier = attr.ib(type=str)
content_key = attr.ib(type=str)
lms_user_id = attr.ib(type=int)
34 changes: 34 additions & 0 deletions openedx_events/enterprise/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Standardized signals definitions for events within the architecture subdomain ``enterprise``.
All signals defined in this module must follow the name and versioning
conventions specified in OEP-41.
They also must comply with the payload definition specified in
docs/decisions/0003-events-payload.rst
"""

from openedx_events.enterprise.data import SubsidyRedemption
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.enterprise.subsidy.redeemed.v1
# .. event_name: SUBSIDY_REDEEMED
# .. event_description: emitted when an enterprise subsidy is utilized.
# .. event_data: SubsidyRedemption
SUBSIDY_REDEEMED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.subsidy.redeemed.v1",
data={
"redemption": SubsidyRedemption,
}
)

# .. event_type: org.openedx.enterprise.subsidy.redemption-reversed.v1
# .. event_name: SUBSIDY_REDEMPTION_REVERSED
# .. event_description: emitted when an enterprise subsidy is reversed.
# .. event_data: SubsidyRedemption
SUBSIDY_REDEMPTION_REVERSED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.subsidy.redemption-reversed.v1",
data={
"redemption": SubsidyRedemption,
}
)
21 changes: 0 additions & 21 deletions openedx_events/event_bus/avro/custom_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from abc import ABC, abstractmethod
from datetime import datetime

from ccx_keys.locator import CCXLocator
from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locator import LibraryLocatorV2, LibraryUsageLocatorV2

Expand Down Expand Up @@ -50,25 +49,6 @@ def deserialize(data: str):
return CourseKey.from_string(data)


class CcxCourseLocatorAvroSerializer(BaseCustomTypeAvroSerializer):
"""
CustomTypeAvroSerializer for CCXLocator class.
"""

cls = CCXLocator
field_type = PYTHON_TYPE_TO_AVRO_MAPPING[str]

@staticmethod
def serialize(obj) -> str:
"""Serialize obj into string."""
return str(obj)

@staticmethod
def deserialize(data: str):
"""Deserialize string into obj."""
return CCXLocator.from_string(data)


class DatetimeAvroSerializer(BaseCustomTypeAvroSerializer):
"""
CustomTypeAvroSerializer for datetime class.
Expand Down Expand Up @@ -151,7 +131,6 @@ def deserialize(data: str):

DEFAULT_CUSTOM_SERIALIZERS = [
CourseKeyAvroSerializer,
CcxCourseLocatorAvroSerializer,
DatetimeAvroSerializer,
LibraryLocatorV2AvroSerializer,
LibraryUsageLocatorV2AvroSerializer,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "content_object",
"type": {
"name": "ContentObjectData",
"type": "record",
"fields": [
{
"name": "object_id",
"type": "string"
}
]
}
}
],
"namespace": "org.openedx.content_authoring.content.object.tags.changed.v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "redemption",
"type": {
"name": "SubsidyRedemption",
"type": "record",
"fields": [
{
"name": "subsidy_identifier",
"type": "string"
},
{
"name": "content_key",
"type": "string"
},
{
"name": "lms_user_id",
"type": "long"
}
]
}
}
],
"namespace": "org.openedx.enterprise.subsidy.redeemed.v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "redemption",
"type": {
"name": "SubsidyRedemption",
"type": "record",
"fields": [
{
"name": "subsidy_identifier",
"type": "string"
},
{
"name": "content_key",
"type": "string"
},
{
"name": "lms_user_id",
"type": "long"
}
]
}
}
],
"namespace": "org.openedx.enterprise.subsidy.redemption-reversed.v1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"type": "string"
},
{
"name": "origin",
"name": "type",
"type": "string"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"type": "string"
},
{
"name": "origin",
"name": "type",
"type": "string"
},
{
Expand Down
Loading

0 comments on commit 19e9217

Please sign in to comment.