Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: submision history endpoint from koa nelp #679

Open
wants to merge 2 commits into
base: ednx-release/mango.master.nelp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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