|
| 1 | +""" |
| 2 | +Data attributes for events within the architecture subdomain `learning`. These |
| 3 | +attributes follow the form of attr objects specified in OEP-49 data pattern. |
| 4 | +""" |
| 5 | + |
| 6 | +from datetime import datetime |
| 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 ProfileData: |
| 15 | + """ |
| 16 | + Attributes defined for Open edX student's profile object. |
| 17 | + """ |
| 18 | + meta = attr.ib(type=Dict[str, str], factory=dict) |
| 19 | + name = attr.ib(type=str, factory=str) |
| 20 | + |
| 21 | + |
| 22 | +@attr.s(frozen=True) |
| 23 | +class StudentData: |
| 24 | + """ |
| 25 | + Attributes defined for Open edX student object. |
| 26 | + """ |
| 27 | + username = attr.ib(type=str) |
| 28 | + email = attr.ib(type=str) |
| 29 | + first_name = attr.ib(type=str, factory=str) |
| 30 | + last_name = attr.ib(type=str, factory=str) |
| 31 | + is_active = attr.ib(type=bool, default=False) |
| 32 | + profile = attr.ib(type=ProfileData, default=ProfileData()) |
| 33 | + |
| 34 | + |
| 35 | +@attr.s(frozen=True) |
| 36 | +class RegistrationData: |
| 37 | + """ |
| 38 | + Attributes defined for Open edX registration profile object. |
| 39 | + """ |
| 40 | + activation_key = attr.ib(type=str) |
| 41 | + |
| 42 | + |
| 43 | +@attr.s(frozen=True) |
| 44 | +class CourseData: |
| 45 | + """ |
| 46 | + Attributes defined for Open edX course object. |
| 47 | + """ |
| 48 | + course_key = attr.ib(type=CourseKey) |
| 49 | + display_name = attr.ib(type=CourseKey, factory=str) |
| 50 | + |
| 51 | + |
| 52 | +@attr.s(frozen=True) |
| 53 | +class EnrollmentData: |
| 54 | + """ |
| 55 | + Attributes defined for Open edX Course Enrollment object. |
| 56 | + """ |
| 57 | + user = attr.ib(type=StudentData) |
| 58 | + course = attr.ib(type=CourseData) |
| 59 | + mode = attr.ib(type=str) |
| 60 | + |
| 61 | + |
| 62 | +@attr.s(frozen=True) |
| 63 | +class CertificateData(EnrollmentData): |
| 64 | + """ |
| 65 | + Attributes defined for Open edX Course Enrollment object. |
| 66 | + """ |
| 67 | + status = attr.ib(type=str) |
| 68 | + available_date = attr.ib(type=datetime) |
| 69 | + |
| 70 | + |
| 71 | +@attr.s(frozen=True) |
| 72 | +class CohortData: |
| 73 | + """ |
| 74 | + Attributes defined for Open edX Course Enrollment object. |
| 75 | + """ |
| 76 | + user = attr.ib(type=StudentData) |
| 77 | + course = attr.ib(type=CourseData) |
0 commit comments