|
| 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 datetime import datetime |
| 8 | + |
| 9 | +import attr |
| 10 | +from opaque_keys.edx.keys import CourseKey |
| 11 | + |
| 12 | + |
| 13 | +@attr.s(frozen=True) |
| 14 | +class UserNonPersonalData: |
| 15 | + """ |
| 16 | + Attributes defined for Open edX user object based on non-PII data. |
| 17 | +
|
| 18 | + Arguments: |
| 19 | + id (int): unique identifier for the Django User object. |
| 20 | + is_active (bool): indicates whether the user is active. |
| 21 | + """ |
| 22 | + |
| 23 | + id = attr.ib(type=int) |
| 24 | + is_active = attr.ib(type=bool, default=True) |
| 25 | + |
| 26 | + |
| 27 | +@attr.s(frozen=True) |
| 28 | +class UserPersonalData: |
| 29 | + """ |
| 30 | + Attributes defined for Open edX user object based on PII data. |
| 31 | +
|
| 32 | + Arguments: |
| 33 | + username (str): username associated with the Open edX user. |
| 34 | + email (str): email associated with the Open edX user. |
| 35 | + name (str): email associated with the Open edX user's profile. |
| 36 | + """ |
| 37 | + |
| 38 | + username = attr.ib(type=str) |
| 39 | + email = attr.ib(type=str) |
| 40 | + name = attr.ib(type=str, factory=str) |
| 41 | + |
| 42 | + |
| 43 | +@attr.s(frozen=True) |
| 44 | +class UserData: |
| 45 | + """ |
| 46 | + Attributes defined for Open edX user object. |
| 47 | +
|
| 48 | + Arguments: |
| 49 | + user_non_pii (UserNonPersonalData): user's Personal Identifiable |
| 50 | + Information. |
| 51 | + user_pii (UserPersonalData): user's Non Personal Identifiable |
| 52 | + Information. |
| 53 | + """ |
| 54 | + |
| 55 | + user_non_pii = attr.ib(type=UserNonPersonalData) |
| 56 | + user_pii = attr.ib(type=UserPersonalData) |
| 57 | + |
| 58 | + |
| 59 | +@attr.s(frozen=True) |
| 60 | +class CourseData: |
| 61 | + """ |
| 62 | + Attributes defined for Open edX Course Overview object. |
| 63 | +
|
| 64 | + Arguments: |
| 65 | + course_key (str): identifier of the Course object. |
| 66 | + display_name (str): display name associated with the course. |
| 67 | + start (datetime): start date for the course. |
| 68 | + end (datetime): end date for the course. |
| 69 | + """ |
| 70 | + |
| 71 | + course_key = attr.ib(type=CourseKey) |
| 72 | + display_name = attr.ib(type=str, factory=str) |
| 73 | + start = attr.ib(type=datetime, default=None) |
| 74 | + end = attr.ib(type=datetime, default=None) |
| 75 | + |
| 76 | + |
| 77 | +@attr.s(frozen=True) |
| 78 | +class CourseEnrollmentData: |
| 79 | + """ |
| 80 | + Attributes defined for Open edX Course Enrollment object. |
| 81 | +
|
| 82 | + Arguments: |
| 83 | + user (UserData): user associated with the Course Enrollment. |
| 84 | + course (CourseData): course where the user is enrolled in. |
| 85 | + mode (str): course mode associated with the course. |
| 86 | + is_active (bool): whether the enrollment is active. |
| 87 | + creation_date (datetime): creation date of the enrollment. |
| 88 | + created_by (UserData): if available, who created the enrollment. |
| 89 | + """ |
| 90 | + |
| 91 | + user = attr.ib(type=UserData) |
| 92 | + course = attr.ib(type=CourseData) |
| 93 | + mode = attr.ib(type=str) |
| 94 | + is_active = attr.ib(type=bool) |
| 95 | + creation_date = attr.ib(type=datetime) |
| 96 | + created_by = attr.ib(type=UserData, default=None) |
| 97 | + |
| 98 | + |
| 99 | +@attr.s(frozen=True) |
| 100 | +class CertificateData: |
| 101 | + """ |
| 102 | + Attributes defined for Open edX Certificate data object. |
| 103 | +
|
| 104 | + Arguments: |
| 105 | + user (UserData): user associated with the Certificate. |
| 106 | + course (CourseData): course where the user obtained the certificate. |
| 107 | + mode (str): course mode associated with the course. |
| 108 | + grade (str): user's grade in this course run. |
| 109 | + current_status (str): current certificate status. |
| 110 | + previous_status (str): if available, pre-event certificate status. |
| 111 | + download_url (str): URL where the PDF version of the certificate. |
| 112 | + name (str): user's name. |
| 113 | + """ |
| 114 | + |
| 115 | + user = attr.ib(type=UserData) |
| 116 | + course = attr.ib(type=CourseData) |
| 117 | + mode = attr.ib(type=str) |
| 118 | + grade = attr.ib(type=str) |
| 119 | + download_url = attr.ib(type=str) |
| 120 | + name = attr.ib(type=str) |
| 121 | + current_status = attr.ib(type=str) |
| 122 | + previous_status = attr.ib(type=str, factory=str) |
| 123 | + |
| 124 | + |
| 125 | +@attr.s(frozen=True) |
| 126 | +class CohortData: |
| 127 | + """ |
| 128 | + Attributes defined for Open edX Cohort Membership object. |
| 129 | +
|
| 130 | + Arguments: |
| 131 | + user (UserData): user assigned to the group. |
| 132 | + course (CourseData): course associated with the course group. |
| 133 | + name (str): name of the cohort group. |
| 134 | + """ |
| 135 | + |
| 136 | + user = attr.ib(type=UserData) |
| 137 | + course = attr.ib(type=CourseData) |
| 138 | + name = attr.ib(type=str) |
0 commit comments