Skip to content

Commit

Permalink
Add Student Course Progress model - EDLY-4795 (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoor-ahmed-1 authored Oct 26, 2022
1 parent b683dc6 commit 0497164
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
16 changes: 15 additions & 1 deletion openedx/features/edly/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

from django.contrib import admin

from openedx.features.edly.models import EdlyOrganization, EdlySubOrganization, EdlyUserProfile
from openedx.features.edly.models import (
EdlyOrganization,
EdlySubOrganization,
EdlyUserProfile,
StudentCourseProgress,
)


class EdlySubOrganizationAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -72,6 +77,15 @@ def edly_sub_organizations_slugs(self, obj):
return ', '.join(obj.edly_sub_organizations.values_list('slug', flat=True))


class StudentCourseProgressAdmin(admin.ModelAdmin):
"""
Admin interface for the "StudentCourseProgress" object.
"""
list_display = ['student', 'course_id', 'completed_block', 'completion_date']
search_fields = ['course_id', 'student__username', 'student__email']


admin.site.register(StudentCourseProgress, StudentCourseProgressAdmin)
admin.site.register(EdlyOrganization, EdlyOrganizationAdmin)
admin.site.register(EdlySubOrganization, EdlySubOrganizationAdmin)
admin.site.register(EdlyUserProfile, EdlyUserProfileAdmin)
39 changes: 39 additions & 0 deletions openedx/features/edly/migrations/0010_studentcourseprogress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# pylint: skip-file
# flake8: noqa
# Generated by Django 2.2.16 on 2022-10-25 06:25

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
import opaque_keys.edx.django.models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('edly', '0009_edlysuborganization_is_active'),
]

operations = [
migrations.CreateModel(
name='StudentCourseProgress',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('course_id', opaque_keys.edx.django.models.CourseKeyField(db_index=True, max_length=255)),
('completed_block', models.TextField()),
('completed_unit', models.TextField()),
('completed_subsection', models.TextField()),
('completed_section', models.TextField()),
('completion_date', models.DateTimeField(blank=True, null=True)),
('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('course_id', 'student')},
},
),
]
20 changes: 19 additions & 1 deletion openedx/features/edly/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.core.validators import RegexValidator
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _

from model_utils.models import TimeStampedModel
from opaque_keys.edx.django.models import CourseKeyField
from organizations.models import Organization

from student.roles import GlobalCourseCreatorRole

EDLY_SLUG_VALIDATOR = RegexValidator(r'^[0-9a-z-]*$', 'Only small case alphanumeric and hyphen characters are allowed.')
Expand Down Expand Up @@ -101,3 +103,19 @@ def get_linked_edly_sub_organizations(self):
"""
edly_sub_org_slugs = self.edly_sub_organizations.values_list('slug', flat=True)
return edly_sub_org_slugs


class StudentCourseProgress(TimeStampedModel):
"""
Current course progress model for students.
"""
course_id = CourseKeyField(max_length=255, db_index=True)
student = models.ForeignKey(get_user_model(), db_index=True, on_delete=models.CASCADE)
completed_block = models.TextField()
completed_unit = models.TextField()
completed_subsection = models.TextField()
completed_section = models.TextField()
completion_date = models.DateTimeField(blank=True, null=True)

class Meta(object):
unique_together = (('course_id', 'student'),)

0 comments on commit 0497164

Please sign in to comment.