Skip to content

Commit

Permalink
feat: new COURSE_CATALOG_INFO_CHANGED signal for course_authoring (#81)
Browse files Browse the repository at this point in the history
* feat: new COURSE_CATALOG_INFO_CHANGED signal for course_authoring
  • Loading branch information
rgraber authored Jul 25, 2022
1 parent 6e48994 commit 98f99ea
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Unreleased
Changed
~~~~~~~

[0.11.0] - 2022-07-21
---------------------
Added
~~~~~~~
* Added new content_authoring module with new COURSE_CATALOG_INFO_CHANGED signal

[0.10.0] - 2022-05-20
---------------------
Changed
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__ = "0.10.0"
__version__ = "0.11.0"
7 changes: 7 additions & 0 deletions openedx_events/content_authoring/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Package where events related to the ``content_authoring`` subdomain are implemented.
"""
# Comment broken up to deal with line-length issues with the long URL

# The ``content_authoring`` subdomain corresponds to {Architecture Subdomain} defined in OEP-41.
# https://open-edx-proposals.readthedocs.io/en/latest/architectural-decisions/oep-0041-arch-async-server-event-messaging.html
64 changes: 64 additions & 0 deletions openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
Data attributes for events within the architecture subdomain ``content_authoring``.
These attributes follow the form of attr objects specified in OEP-49 data
pattern.
The attributes for the events come from the CourseDetailView in the LMS, with some unused fields removed
(see deprecation proposal at https://github.com/openedx/public-engineering/issues/160)
"""
from datetime import datetime

import attr
from opaque_keys.edx.keys import CourseKey


@attr.s(frozen=True)
class CourseScheduleData:
"""
Data describing course scheduling.
Arguments:
start (datetime): course start date
pacing (str): 'instructor' or 'self'
end (datetime): course end date (optional)
enrollment_start (datetime): start of course enrollment (optional)
enrollment_end (datetime): end of course enrollment (optional)
"""

start = attr.ib(type=datetime)
pacing = attr.ib(type=str)
end = attr.ib(type=datetime, default=None)
enrollment_start = attr.ib(type=datetime, default=None)
enrollment_end = attr.ib(type=datetime, default=None)


@attr.s(frozen=True)
class CourseCatalogData:
"""
Data needed for a course catalog entry.
Arguments:
course_key (CourseKey): identifier of the Course object.
name (str): course name
org (str): course organization identifier
number (str): course number
schedule_data (CourseScheduleData): scheduling information for the course
short_description (str): one- or two-sentence course description (optional)
effort (str): estimated level of effort in hours per week (optional). Kept as a str to align with the lms model.
hidden (bool): whether the course is hidden from search (optional)
invitation_only (bool): whether the course requires an invitation to enroll
"""

# basic identifiers
course_key = attr.ib(type=CourseKey)
name = attr.ib(type=str)
number = attr.ib(type=str)
org = attr.ib(type=str)

# additional marketing information
schedule_data = attr.ib(type=CourseScheduleData)
short_description = attr.ib(type=str, default=None)
effort = attr.ib(type=str, default=None)
hidden = attr.ib(type=bool, default=False)
invitation_only = attr.ib(type=bool, default=False)
23 changes: 23 additions & 0 deletions openedx_events/content_authoring/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Signal definitions for events within the architecture subdomain ``content_authoring``.
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.content_authoring.data import CourseCatalogData
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.content_authoring.course.catalog_info.changed.v1
# .. event_name: COURSE_CATALOG_INFO_CHANGED
# .. event_description: Fired when a course changes in Studio in a way that is relevant for catalog consumers.
# .. event_data: CourseCatalogData
COURSE_CATALOG_INFO_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.content_authoring.course.catalog_info.changed.v1",
data={
"catalog_info": CourseCatalogData,
}
)
12 changes: 6 additions & 6 deletions openedx_events/event_bus/avro/tests/test_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

from opaque_keys.edx.keys import CourseKey

from openedx_events.enterprise import signals # pylint: disable=unused-import
# Each new folder with signals must be manually imported in order for the signals to be cached
# and used in the unit tests. Using 'disable=reimported' with pylint will work,
# because we just use the cached signal list.
from openedx_events.content_authoring import signals # pylint: disable=unused-import
from openedx_events.enterprise import signals # pylint: disable=reimported
from openedx_events.event_bus.avro.deserializer import AvroSignalDeserializer
from openedx_events.event_bus.avro.serializer import AvroSignalSerializer
from openedx_events.event_bus.avro.tests.test_utilities import (
Expand All @@ -17,11 +21,7 @@
deserialize_bytes_to_event_data,
serialize_event_data_to_bytes,
)
# Each new folder with signals must be manually imported in order for the signals to be cached
# and used in the unit tests. Using 'disable=reimported' with pylint will work,
# because we just use the cached signal list.
# TODO (EventBus): Find a way to auto-discover these signals.
from openedx_events.learning import signals # pylint: disable=reimported
from openedx_events.learning import signals # See note above; pylint: disable=reimported
from openedx_events.tests.utils import FreezeSignalCacheMixin
from openedx_events.tooling import OpenEdxPublicSignal

Expand Down

0 comments on commit 98f99ea

Please sign in to comment.