Skip to content

Commit

Permalink
feat: submision history endpoint from koa nelp
Browse files Browse the repository at this point in the history
(BB-1389) Update enrollment serializer and Add problem submission history endpoint

Squashed all commits from https://github.com/edx/edx-platform/pull/20948

(cherry picked from commit c102e41c6d92e5fb7db66de4d3624f03da213631)

This cherry-pick was modified and updated to work with mango.
  • Loading branch information
xirdneh authored and johanseto committed Oct 5, 2022
1 parent a0da4a9 commit 17b3fb3
Show file tree
Hide file tree
Showing 7 changed files with 723 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/access_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def check_start_date(user, days_early_for_beta, start, course_key, display_error
Returns:
AccessResponse: Either ACCESS_GRANTED or StartDateError.
"""
start_dates_disabled = settings.FEATURES['DISABLE_START_DATES']
start_dates_disabled = settings.FEATURES.get('DISABLE_START_DATES', False)
masquerading_as_student = is_masquerading_as_student(user, course_key)

if start_dates_disabled and not masquerading_as_student:
Expand Down
15 changes: 15 additions & 0 deletions lms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@

RATELIMIT_RATE = '2/m'


COURSE_ENROLLMENT_MODES['test'] = {
"id": 8,
"slug": u"test",
"display_name": u"Test",
"min_price": 0
}

COURSE_ENROLLMENT_MODES['test_mode'] = {
"id": 9,
"slug": u"test_mode",
"display_name": u"Test Mode",
"min_price": 0
}

##### LOGISTRATION RATE LIMIT SETTINGS #####
LOGISTRATION_RATELIMIT_RATE = '5/5m'
LOGISTRATION_PER_EMAIL_RATELIMIT_RATE = '6/5m'
Expand Down
43 changes: 40 additions & 3 deletions openedx/core/djangoapps/enrollments/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnrollment
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
from xmodule.modulestore.django import modulestore
from django.core.exceptions import PermissionDenied

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,15 +86,49 @@ class CourseEnrollmentSerializer(serializers.ModelSerializer):
"""
course_details = CourseSerializer(source="course_overview")
user = serializers.SerializerMethodField('get_username')
user = serializers.SerializerMethodField("get_username")
finished = serializers.SerializerMethodField()
grading = serializers.SerializerMethodField()

def get_username(self, model):
"""Retrieves the username from the associated model."""
return model.username

class Meta:
def get_finished(self, model):
"""Retrieve finished course."""
course = modulestore().get_course(model.course_id)
if course:
try:
coursegrade = CourseGradeFactory().read(model.user, course).passed
except PermissionDenied:
return False
return coursegrade
return False

def get_grading(self, model):
"""Retrieve course grade."""
course = modulestore().get_course(model.course_id)
course_grade = None
summary = []
current_grade = 0
if course:
try:
course_grade = CourseGradeFactory().read(model.user, course)
current_grade = int(course_grade.percent * 100)
for section in course_grade.summary.get(u'section_breakdown'):
if section.get(u'prominent'):
summary.append(section)
except PermissionDenied:
pass
return [
{u'current_grade': current_grade,
u'certificate_eligible': course_grade.passed if course_grade else False,
u'summary': summary}
]

class Meta(object):
model = CourseEnrollment
fields = ('created', 'mode', 'is_active', 'course_details', 'user')
fields = ('created', 'mode', 'is_active', 'course_details', 'user', 'finished', 'grading')
lookup_field = 'username'


Expand Down
Loading

0 comments on commit 17b3fb3

Please sign in to comment.