|
| 1 | +""" |
| 2 | +Data attributes for events within the architecture subdomain `learning`. |
| 3 | +
|
| 4 | +These attributes follow the form of attr objects specified in OEP-49 data |
| 5 | +pattern. |
| 6 | +""" |
| 7 | +from typing import Dict |
| 8 | + |
| 9 | +import attr |
| 10 | +from opaque_keys.edx.keys import CourseKey |
| 11 | + |
| 12 | + |
| 13 | +@attr.s(frozen=True) |
| 14 | +class UserProfileData: |
| 15 | + """ |
| 16 | + Attributes defined for Open edX student's profile object. |
| 17 | + """ |
| 18 | + |
| 19 | + meta = attr.ib(type=Dict[str, str], factory=dict) |
| 20 | + name = attr.ib(type=str, factory=str) |
| 21 | + |
| 22 | + |
| 23 | +@attr.s(frozen=True) |
| 24 | +class StudentData: |
| 25 | + """ |
| 26 | + Attributes defined for Open edX student object. |
| 27 | + """ |
| 28 | + |
| 29 | + username = attr.ib(type=str) |
| 30 | + email = attr.ib(type=str) |
| 31 | + first_name = attr.ib(type=str, factory=str) |
| 32 | + last_name = attr.ib(type=str, factory=str) |
| 33 | + is_active = attr.ib(type=bool, default=True) |
| 34 | + profile = attr.ib(type=UserProfileData, default=UserProfileData()) |
| 35 | + |
| 36 | + |
| 37 | +@attr.s(frozen=True) |
| 38 | +class RegistrationData: |
| 39 | + """ |
| 40 | + Attributes defined for Open edX registration profile object. |
| 41 | + """ |
| 42 | + |
| 43 | + activation_key = attr.ib(type=str) |
| 44 | + |
| 45 | + |
| 46 | +@attr.s(frozen=True) |
| 47 | +class CourseOverviewData: |
| 48 | + """ |
| 49 | + Attributes defined for Open edX Course Overview object. |
| 50 | + """ |
| 51 | + |
| 52 | + course_key = attr.ib(type=CourseKey) |
| 53 | + display_name = attr.ib(type=CourseKey, factory=str) |
| 54 | + |
| 55 | + |
| 56 | +@attr.s(frozen=True) |
| 57 | +class CourseEnrollmentData: |
| 58 | + """ |
| 59 | + Attributes defined for Open edX Course Enrollment object. |
| 60 | + """ |
| 61 | + |
| 62 | + user = attr.ib(type=StudentData) |
| 63 | + course = attr.ib(type=CourseOverviewData) |
| 64 | + mode = attr.ib(type=str) |
| 65 | + is_active = attr.ib(type=bool) |
| 66 | + |
| 67 | + |
| 68 | +@attr.s(frozen=True) |
| 69 | +class CertificateData(CourseEnrollmentData): |
| 70 | + """ |
| 71 | + Attributes defined for Open edX Certificate data object. |
| 72 | + """ |
| 73 | + |
| 74 | + grade = attr.ib(type=str) |
| 75 | + status = attr.ib(type=str) |
| 76 | + download_url = attr.ib(type=str) |
| 77 | + name = attr.ib(type=str) |
| 78 | + |
| 79 | + |
| 80 | +@attr.s(frozen=True) |
| 81 | +class CohortData: |
| 82 | + """ |
| 83 | + Attributes defined for Open edX Cohort Membership object. |
| 84 | + """ |
| 85 | + |
| 86 | + user = attr.ib(type=StudentData) |
| 87 | + course = attr.ib(type=CourseOverviewData) |
0 commit comments