Skip to content
Snippets Groups Projects
Unverified Commit 1cfc6738 authored by Andytr1's avatar Andytr1 Committed by GitHub
Browse files

Merge pull request #20631 from edx/andytr1/proctored_report

EDUCATOR-4290 support for provider and track
parents d5ee03e8 0bd94327
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ from django.core.serializers.json import DjangoJSONEncoder ...@@ -16,7 +16,7 @@ from django.core.serializers.json import DjangoJSONEncoder
from django.db.models import Count, Q from django.db.models import Count, Q
from django.urls import reverse from django.urls import reverse
from edx_proctoring.api import get_exam_violation_report from edx_proctoring.api import get_exam_violation_report
from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.keys import UsageKey, CourseKey
from six import text_type from six import text_type
import xmodule.graders as xmgraders import xmodule.graders as xmgraders
...@@ -35,6 +35,7 @@ from shoppingcart.models import ( ...@@ -35,6 +35,7 @@ from shoppingcart.models import (
) )
from student.models import CourseEnrollment, CourseEnrollmentAllowed from student.models import CourseEnrollment, CourseEnrollmentAllowed
STUDENT_FEATURES = ('id', 'username', 'first_name', 'last_name', 'is_staff', 'email') STUDENT_FEATURES = ('id', 'username', 'first_name', 'last_name', 'is_staff', 'email')
PROFILE_FEATURES = ('name', 'language', 'location', 'year_of_birth', 'gender', PROFILE_FEATURES = ('name', 'language', 'location', 'year_of_birth', 'gender',
'level_of_education', 'mailing_address', 'goals', 'meta', 'level_of_education', 'mailing_address', 'goals', 'meta',
...@@ -333,7 +334,7 @@ def get_proctored_exam_results(course_key, features): ...@@ -333,7 +334,7 @@ def get_proctored_exam_results(course_key, features):
""" """
comment_statuses = ['Rules Violation', 'Suspicious'] comment_statuses = ['Rules Violation', 'Suspicious']
def extract_details(exam_attempt, features): def extract_details(exam_attempt, features, course_enrollment):
""" """
Build dict containing information about a single student exam_attempt. Build dict containing information about a single student exam_attempt.
""" """
...@@ -351,10 +352,26 @@ def get_proctored_exam_results(course_key, features): ...@@ -351,10 +352,26 @@ def get_proctored_exam_results(course_key, features):
u'{status} Comments'.format(status=status): '; '.join(comment_list), u'{status} Comments'.format(status=status): '; '.join(comment_list),
}) })
proctored_exam['track'] = course_enrollment[exam_attempt['user_id']]
return proctored_exam return proctored_exam
exam_attempts = get_exam_violation_report(course_key) exam_attempts = get_exam_violation_report(course_key)
return [extract_details(exam_attempt, features) for exam_attempt in exam_attempts] course_enrollment = get_enrollments_for_course(exam_attempts)
return [extract_details(exam_attempt, features, course_enrollment) for exam_attempt in exam_attempts]
def get_enrollments_for_course(exam_attempts):
"""
Returns all enrollments from a list of attempts. user_id is passed from proctoring.
"""
if exam_attempts:
users = []
for e in exam_attempts:
users.append(e['user_id'])
enrollments = {c.user_id: c.mode for c in CourseEnrollment.objects.filter(
course_id=CourseKey.from_string(exam_attempts[0]['course_id']), user_id__in=users)}
return enrollments
def coupon_codes_features(features, coupons_list, course_id): def coupon_codes_features(features, coupons_list, course_id):
......
...@@ -252,6 +252,7 @@ class TestAnalyticsBasic(ModuleStoreTestCase): ...@@ -252,6 +252,7 @@ class TestAnalyticsBasic(ModuleStoreTestCase):
'Suspicious Comments', 'Suspicious Comments',
'Rules Violation Count', 'Rules Violation Count',
'Rules Violation Comments', 'Rules Violation Comments',
'track'
] ]
proctored_exam_id = create_exam(self.course_key, 'Test Content', 'Test Exam', 1) proctored_exam_id = create_exam(self.course_key, 'Test Content', 'Test Exam', 1)
......
...@@ -118,8 +118,11 @@ def upload_proctored_exam_results_report(_xmodule_instance_args, _entry_id, cour ...@@ -118,8 +118,11 @@ def upload_proctored_exam_results_report(_xmodule_instance_args, _entry_id, cour
'Suspicious Count', 'Suspicious Count',
'Suspicious Comments', 'Suspicious Comments',
'Rules Violation Count', 'Rules Violation Count',
'Rules Violation Comments' 'Rules Violation Comments',
'provider',
'track'
] ]
student_data = get_proctored_exam_results(course_id, query_features) student_data = get_proctored_exam_results(course_id, query_features)
header, rows = format_dictlist(student_data, query_features) header, rows = format_dictlist(student_data, query_features)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment