Skip to content

Commit

Permalink
feat: adding event to handle persistent grades. (#99)
Browse files Browse the repository at this point in the history
New event triggered when a persistent grade is created or updated.
  • Loading branch information
DeimerM authored Sep 20, 2022
1 parent 7b5addb commit 21613ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Change Log
Unreleased
----------
[0.13.0] - 2022-09-16
---------------------
Added
~~~~~
* Added new event PERSISTENT_GRADE_SUMMARY_CHANGED.

* Improvements in make upgrade command and requirements files.
* Manually update requirements files to fix requirements bot issue with pip/setup tools.
Expand Down
3 changes: 2 additions & 1 deletion openedx_events/event_bus/avro/tests/test_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def generate_test_event_data_for_data_type(data_type):
"""
Generates test data for use in the event bus test cases.
Builds data by filling in dummy data for basic data types (int/bool/str)
Builds data by filling in dummy data for basic data types (int/float/bool/str)
and recursively breaks down the classes for nested classes into basic data types.
Arguments:
Expand All @@ -48,6 +48,7 @@ def generate_test_event_data_for_data_type(data_type):
int: 1,
bool: True,
str: "default",
float: 1.0,
CourseKey: CourseKey.from_string("course-v1:edX+DemoX.1+2014"),
datetime: datetime.now(),
}
Expand Down
26 changes: 26 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,29 @@ class CourseDiscussionConfigurationData:
unit_level_visibility = attr.ib(type=bool, default=False)
plugin_configuration = attr.ib(type=dict, default={})
contexts = attr.ib(type=List[DiscussionTopicContext], factory=list)


@attr.s(frozen=True)
class PersistentCourseGradeData:
"""
Attributes defined for Open edX PersistentCourseGrade data object.
Arguments:
user_id (int): identifier of the grade to which the grade belongs.
course (CourseData): Identifier of the course to which the grade belongs.
course_edited_timestamp (datetime): date the course was edited.
course_version (str): version of the course.
grading_policy_hash (str): grading policy hash of the course.
percent_grade (float): percentage of the grade.
letter_grade (str): grade in letter
passed_timestamp (datetime): date the course was passed.
"""

user_id = attr.ib(type=int)
course = attr.ib(type=CourseData)
course_edited_timestamp = attr.ib(type=datetime)
course_version = attr.ib(type=str)
grading_policy_hash = attr.ib(type=str)
percent_grade = attr.ib(type=float)
letter_grade = attr.ib(type=str)
passed_timestamp = attr.ib(type=datetime)
12 changes: 12 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CohortData,
CourseDiscussionConfigurationData,
CourseEnrollmentData,
PersistentCourseGradeData,
UserData,
)
from openedx_events.tooling import OpenEdxPublicSignal
Expand Down Expand Up @@ -136,3 +137,14 @@
"configuration": CourseDiscussionConfigurationData
}
)

# .. event_type: org.openedx.learning.course.persistent_grade.summary.v1
# .. event_name: PERSISTENT_GRADE_SUMMARY_CHANGED
# .. event_description: emitted when a grade changes in the course
# .. event_data: PersistentCourseGradeData
PERSISTENT_GRADE_SUMMARY_CHANGED = OpenEdxPublicSignal(
event_type="org.openedx.learning.course.persistent_grade_summary.changed.v1",
data={
"grade": PersistentCourseGradeData,
}
)

0 comments on commit 21613ce

Please sign in to comment.