|
7 | 7 | from django.conf import settings |
8 | 8 | from django.contrib.auth.models import Group |
9 | 9 | from django.db import models |
| 10 | +from opaque_keys.edx.django.models import CourseKeyField, UsageKeyField |
10 | 11 | from opaque_keys.edx.locator import LibraryLocatorV2 |
11 | 12 |
|
12 | 13 |
|
@@ -87,3 +88,109 @@ class ContentLibraryPermission(models.Model): |
87 | 88 | def __str__(self): |
88 | 89 | who = self.user.username if self.user else self.group.name |
89 | 90 | return f"ContentLibraryPermission ({self.access_level} for {who})" |
| 91 | + |
| 92 | + |
| 93 | +class CourseOverview(models.Model): |
| 94 | + """ |
| 95 | + Model for storing and caching basic information about a course. |
| 96 | +
|
| 97 | + This model contains basic course metadata such as an ID, display name, |
| 98 | + image URL, and any other information that would be necessary to display |
| 99 | + a course as part of: |
| 100 | + user dashboard (enrolled courses) |
| 101 | + course catalog (courses to enroll in) |
| 102 | + course about (meta data about the course) |
| 103 | +
|
| 104 | + .. no_pii: |
| 105 | + """ |
| 106 | + |
| 107 | + class Meta: |
| 108 | + app_label = "course_overviews" |
| 109 | + |
| 110 | + # IMPORTANT: Bump this whenever you modify this model and/or add a migration. |
| 111 | + VERSION = 19 |
| 112 | + |
| 113 | + # Cache entry versioning. |
| 114 | + version = models.IntegerField() |
| 115 | + |
| 116 | + # Course identification |
| 117 | + id = CourseKeyField(db_index=True, primary_key=True, max_length=255) |
| 118 | + _location = UsageKeyField(max_length=255) |
| 119 | + org = models.TextField(max_length=255, default="outdated_entry") |
| 120 | + display_name = models.TextField(null=True) |
| 121 | + display_number_with_default = models.TextField() |
| 122 | + display_org_with_default = models.TextField() |
| 123 | + |
| 124 | + start = models.DateTimeField(null=True) |
| 125 | + end = models.DateTimeField(null=True) |
| 126 | + |
| 127 | + # These are deprecated and unused, but cannot be dropped via simple migration due to the size of the downstream |
| 128 | + # history table. See DENG-19 for details. |
| 129 | + # Please use start and end above for these values. |
| 130 | + start_date = models.DateTimeField(null=True) |
| 131 | + end_date = models.DateTimeField(null=True) |
| 132 | + |
| 133 | + advertised_start = models.TextField(null=True) |
| 134 | + announcement = models.DateTimeField(null=True) |
| 135 | + |
| 136 | + # URLs |
| 137 | + # Not allowing null per django convention; not sure why many TextFields in this model do allow null |
| 138 | + banner_image_url = models.TextField() |
| 139 | + course_image_url = models.TextField() |
| 140 | + social_sharing_url = models.TextField(null=True) |
| 141 | + end_of_course_survey_url = models.TextField(null=True) |
| 142 | + |
| 143 | + # Certification data |
| 144 | + certificates_display_behavior = models.TextField(null=True) |
| 145 | + certificates_show_before_end = models.BooleanField(default=False) |
| 146 | + cert_html_view_enabled = models.BooleanField(default=False) |
| 147 | + has_any_active_web_certificate = models.BooleanField(default=False) |
| 148 | + cert_name_short = models.TextField() |
| 149 | + cert_name_long = models.TextField() |
| 150 | + certificate_available_date = models.DateTimeField(default=None, null=True) |
| 151 | + |
| 152 | + # Grading |
| 153 | + lowest_passing_grade = models.DecimalField(max_digits=5, decimal_places=2, null=True) |
| 154 | + |
| 155 | + # Access parameters |
| 156 | + days_early_for_beta = models.FloatField(null=True) |
| 157 | + mobile_available = models.BooleanField(default=False) |
| 158 | + visible_to_staff_only = models.BooleanField(default=False) |
| 159 | + _pre_requisite_courses_json = models.TextField() # JSON representation of list of CourseKey strings |
| 160 | + |
| 161 | + # Enrollment details |
| 162 | + enrollment_start = models.DateTimeField(null=True) |
| 163 | + enrollment_end = models.DateTimeField(null=True) |
| 164 | + enrollment_domain = models.TextField(null=True) |
| 165 | + invitation_only = models.BooleanField(default=False) |
| 166 | + max_student_enrollments_allowed = models.IntegerField(null=True) |
| 167 | + |
| 168 | + # Catalog information |
| 169 | + catalog_visibility = models.TextField(null=True) |
| 170 | + short_description = models.TextField(null=True) |
| 171 | + course_video_url = models.TextField(null=True) |
| 172 | + effort = models.TextField(null=True) |
| 173 | + self_paced = models.BooleanField(default=False) |
| 174 | + marketing_url = models.TextField(null=True) |
| 175 | + eligible_for_financial_aid = models.BooleanField(default=True) |
| 176 | + |
| 177 | + # Course highlight info, used to guide course update emails |
| 178 | + has_highlights = models.BooleanField(null=True, default=None) # if None, you have to look up the answer yourself |
| 179 | + |
| 180 | + # Proctoring |
| 181 | + enable_proctored_exams = models.BooleanField(default=False) |
| 182 | + proctoring_provider = models.TextField(null=True) |
| 183 | + proctoring_escalation_email = models.TextField(null=True) |
| 184 | + allow_proctoring_opt_out = models.BooleanField(default=False) |
| 185 | + |
| 186 | + # Entrance Exam information |
| 187 | + entrance_exam_enabled = models.BooleanField(default=False) |
| 188 | + entrance_exam_id = models.CharField(max_length=255, blank=True) |
| 189 | + entrance_exam_minimum_score_pct = models.FloatField(default=0.65) |
| 190 | + |
| 191 | + # Open Response Assessment configuration |
| 192 | + force_on_flexible_peer_openassessments = models.BooleanField(default=False) |
| 193 | + |
| 194 | + external_id = models.CharField(max_length=128, null=True, blank=True) |
| 195 | + |
| 196 | + language = models.TextField(null=True) |
0 commit comments