killed rebase
This commit is contained in:
@@ -16,7 +16,7 @@ from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db.models import Count, Q
|
||||
from django.urls import reverse
|
||||
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
|
||||
|
||||
import xmodule.graders as xmgraders
|
||||
@@ -35,6 +35,7 @@ from shoppingcart.models import (
|
||||
)
|
||||
from student.models import CourseEnrollment, CourseEnrollmentAllowed
|
||||
|
||||
|
||||
STUDENT_FEATURES = ('id', 'username', 'first_name', 'last_name', 'is_staff', 'email')
|
||||
PROFILE_FEATURES = ('name', 'language', 'location', 'year_of_birth', 'gender',
|
||||
'level_of_education', 'mailing_address', 'goals', 'meta',
|
||||
@@ -333,7 +334,7 @@ def get_proctored_exam_results(course_key, features):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
@@ -351,10 +352,26 @@ def get_proctored_exam_results(course_key, features):
|
||||
u'{status} Comments'.format(status=status): '; '.join(comment_list),
|
||||
})
|
||||
|
||||
proctored_exam['track'] = course_enrollment[exam_attempt['user_id']]
|
||||
return proctored_exam
|
||||
|
||||
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):
|
||||
|
||||
@@ -252,6 +252,7 @@ class TestAnalyticsBasic(ModuleStoreTestCase):
|
||||
'Suspicious Comments',
|
||||
'Rules Violation Count',
|
||||
'Rules Violation Comments',
|
||||
'track'
|
||||
]
|
||||
|
||||
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
|
||||
'Suspicious Count',
|
||||
'Suspicious Comments',
|
||||
'Rules Violation Count',
|
||||
'Rules Violation Comments'
|
||||
'Rules Violation Comments',
|
||||
'provider',
|
||||
'track'
|
||||
]
|
||||
|
||||
student_data = get_proctored_exam_results(course_id, query_features)
|
||||
header, rows = format_dictlist(student_data, query_features)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user