def test_get_enterprise_learner_generic_name_no_replacement(self, mock_customer_for_request): request = mock.Mock() mock_customer_for_request.return_value = { 'name': 'Test Corp', 'replace_sensitive_sso_username': False, } generic_name = get_enterprise_learner_generic_name(request) assert '' == generic_name
def render_body(context,**pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) loop = __M_loop = runtime.LoopStack() def certificate_block(): return render_certificate_block(context._locals(__M_locals)) int = context.get('int', UNDEFINED) float = context.get('float', UNDEFINED) def pagetitle(): return render_pagetitle(context._locals(__M_locals)) course = context.get('course', UNDEFINED) static = _mako_get_namespace(context, 'static') unicode = context.get('unicode', UNDEFINED) def bodyclass(): return render_bodyclass(context._locals(__M_locals)) credit_course_requirements = context.get('credit_course_requirements', UNDEFINED) def js_extra(): return render_js_extra(context._locals(__M_locals)) studio_url = context.get('studio_url', UNDEFINED) getattr = context.get('getattr', UNDEFINED) dict = context.get('dict', UNDEFINED) course_expiration_fragment = context.get('course_expiration_fragment', UNDEFINED) user_timezone = context.get('user_timezone', UNDEFINED) len = context.get('len', UNDEFINED) student = context.get('student', UNDEFINED) user_language = context.get('user_language', UNDEFINED) staff_access = context.get('staff_access', UNDEFINED) certificate_data = context.get('certificate_data', UNDEFINED) progress_graph = _mako_get_namespace(context, 'progress_graph') request = context.get('request', UNDEFINED) grade_summary = context.get('grade_summary', UNDEFINED) def headextra(): return render_headextra(context._locals(__M_locals)) courseware_summary = context.get('courseware_summary', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer(u'\n') __M_writer(u'\n') __M_writer(u'\n') __M_writer(u'\n\n') username = get_enterprise_learner_generic_name(request) or student.username __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['username'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n\n') if 'parent' not in context._data or not hasattr(context._data['parent'], 'bodyclass'): context['self'].bodyclass(**pageargs) __M_writer(u'\n\n') if 'parent' not in context._data or not hasattr(context._data['parent'], 'headextra'): context['self'].headextra(**pageargs) __M_writer(u'\n\n\n') __M_writer(u'\n\n') if 'parent' not in context._data or not hasattr(context._data['parent'], 'pagetitle'): context['self'].pagetitle(**pageargs) __M_writer(u'\n\n') if 'parent' not in context._data or not hasattr(context._data['parent'], 'js_extra'): context['self'].js_extra(**pageargs) __M_writer(u'\n\n') runtime._include_file(context, u'/courseware/course_navigation.html', _template_uri, active_page='progress') __M_writer(u'\n\n<main id="main" aria-label="Content" tabindex="-1">\n <div class="container">\n <div class="profile-wrapper">\n <section class="course-info" id="course-info-progress"\n') if getattr(course, 'language'): __M_writer(u' lang="') __M_writer(filters.html_escape(filters.decode.utf8(course.language))) __M_writer(u'"\n') __M_writer(u' >\n') if staff_access and studio_url is not None: __M_writer(u' <div class="wrap-instructor-info">\n <a class="instructor-info-action studio-view" href="') __M_writer(filters.html_escape(filters.decode.utf8(studio_url))) __M_writer(u'">') __M_writer(filters.html_escape(filters.decode.utf8(_("View Grading in studio")))) __M_writer(u'</a>\n </div>\n') __M_writer(u' <h2 class="hd hd-2 progress-certificates-title">\n ') __M_writer(filters.html_escape(filters.decode.utf8(_("Course Progress for Student '{username}' ({email})").format(username=username, email=student.email)))) __M_writer(u'\n </h2>\n') if course_expiration_fragment: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(HTML(course_expiration_fragment.content)))) __M_writer(u'\n') __M_writer(u' <div class="wrapper-msg wrapper-auto-cert">\n <div id="errors-info" class="errors-info"></div>\n ') if 'parent' not in context._data or not hasattr(context._data['parent'], 'certificate_block'): context['self'].certificate_block(**pageargs) __M_writer(u'\n </div>\n\n') if not course.disable_progress_graph: __M_writer(u' <div class="grade-detail-graph" id="grade-detail-graph"></div>\n') __M_writer(u'\n') if credit_course_requirements: __M_writer(u' <section class="credit-eligibility">\n <h3 class="hd hd-4 eligibility-heading">') __M_writer(filters.html_escape(filters.decode.utf8(_("Requirements for Course Credit")))) __M_writer(u'</h3>\n <div class="credit-eligibility-container">\n') if credit_course_requirements['eligibility_status'] == 'not_eligible': __M_writer(u' <span class="eligibility_msg">') __M_writer(filters.html_escape(filters.decode.utf8(_("{student_name}, you are no longer eligible for credit in this course.").format(student_name=student.profile.name)))) __M_writer(u'</span>\n') elif credit_course_requirements['eligibility_status'] == 'eligible': __M_writer(u' <span class="eligibility_msg">\n ') __M_writer(filters.html_escape(filters.decode.utf8(Text(_("{student_name}, you have met the requirements for credit in this course. {a_start}Go to your dashboard{a_end} to purchase course credit.")).format( student_name=student.profile.name, a_start=HTML("<a href={url}>").format(url=reverse('dashboard')), a_end=HTML("</a>") )))) __M_writer(u'\n </span>\n') elif credit_course_requirements['eligibility_status'] == 'partial_eligible': __M_writer(u' <span>') __M_writer(filters.html_escape(filters.decode.utf8(_("{student_name}, you have not yet met the requirements for credit.").format(student_name=student.profile.name)))) __M_writer(u'</span>\n') __M_writer(u'\n <a href="') __M_writer(filters.html_escape(filters.decode.utf8(settings.CREDIT_HELP_LINK_URL))) __M_writer(u'" class="credit-help">\n <span class="fa fa-question" aria-hidden="true"></span>\n <span class="sr">') __M_writer(filters.html_escape(filters.decode.utf8(_("Information about course credit requirements")))) __M_writer(u'</span>\n </a><br />\n\n <div class="requirement-container" data-eligible="') __M_writer(filters.html_escape(filters.decode.utf8(credit_course_requirements['eligibility_status']))) __M_writer(u'">\n') for requirement in credit_course_requirements['requirements']: __M_writer(u' <div class="requirement">\n <div class="requirement-name">\n ') __M_writer(filters.html_escape(filters.decode.utf8(_(requirement['display_name'])))) __M_writer(u'\n') if requirement['namespace'] == 'grade': __M_writer(u' <span>') __M_writer(filters.html_escape(filters.decode.utf8(int(requirement['criteria']['min_grade'] * 100)))) __M_writer(u'%</span>\n') __M_writer(u' </div>\n <div class="requirement-status">\n') if requirement['status']: if requirement['status'] == 'submitted': __M_writer(u' <span class="requirement-submitted">') __M_writer(filters.html_escape(filters.decode.utf8(_("Verification Submitted")))) __M_writer(u'</span>\n') elif requirement['status'] == 'failed': __M_writer(u' <span class="fa fa-times" aria-hidden="true"></span>\n <span>') __M_writer(filters.html_escape(filters.decode.utf8(_("Verification Failed" )))) __M_writer(u'</span>\n') elif requirement['status'] == 'declined': __M_writer(u' <span class="fa fa-times" aria-hidden="true"></span>\n <span>') __M_writer(filters.html_escape(filters.decode.utf8(_("Verification Declined" )))) __M_writer(u'</span>\n') elif requirement['status'] == 'satisfied': __M_writer(u' <span class="fa fa-check" aria-hidden="true"></span>\n <span class="localized-datetime" data-datetime="') __M_writer(filters.html_escape(filters.decode.utf8(requirement['status_date']))) __M_writer(u'" data-string="') __M_writer(filters.html_escape(filters.decode.utf8(_('Completed by {date}')))) __M_writer(u'" data-timezone="') __M_writer(filters.html_escape(filters.decode.utf8(user_timezone))) __M_writer(u'" data-language="') __M_writer(filters.html_escape(filters.decode.utf8(user_language))) __M_writer(u'"></span>\n') else: __M_writer(u' <span class="not-achieve">') __M_writer(filters.html_escape(filters.decode.utf8(_("Upcoming")))) __M_writer(u'</span>\n') __M_writer(u' </div>\n </div>\n') __M_writer(u' </div>\n <button class="detail-collapse">\n <span class="fa fa-caret-up" aria-hidden="true"></span>\n <span class="requirement-detail">') __M_writer(filters.html_escape(filters.decode.utf8(_("Less")))) __M_writer(u'</span>\n </button>\n </div>\n </section>\n') __M_writer(u'\n') if courseware_summary: __M_writer(u' <section class="chapters">\n <h2 class="sr">') __M_writer(filters.html_escape(filters.decode.utf8(_('Details for each chapter')))) __M_writer(u'</h2>\n') loop = __M_loop._enter(courseware_summary) try: for chapter in loop: if not chapter['display_name'] == "hidden": __M_writer(u' <section aria-labelledby="chapter_') __M_writer(filters.html_escape(filters.decode.utf8(loop.index))) __M_writer(u'">\n <h3 class="hd hd-3" id="chapter_') __M_writer(filters.html_escape(filters.decode.utf8(loop.index))) __M_writer(u'">') __M_writer(filters.html_escape(filters.decode.utf8( chapter['display_name']))) __M_writer(u'</h3>\n <div class="sections">\n') for section in chapter['sections']: __M_writer(u' <div>\n ') earned = section.all_total.earned total = section.all_total.possible percentageString = "{0:.0%}".format(section.percent_graded) if earned > 0 and total > 0 else "" __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['percentageString','total','earned'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n <h4 class="hd hd-4">\n <a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('courseware_section', kwargs=dict(course_id=text_type(course.id), chapter=chapter['url_name'], section=section.url_name))))) __M_writer(u'">\n ') __M_writer(filters.html_escape(filters.decode.utf8( section.display_name))) __M_writer(u'\n') if total > 0 or earned > 0: __M_writer(u' <span class="sr">\n ') __M_writer(filters.html_escape(filters.decode.utf8(_("{earned} of {total} possible points").format(earned='{:.3n}'.format(float(earned)), total='{:.3n}'.format(float(total)))))) __M_writer(u'\n </span>\n') __M_writer(u' </a>\n') if total > 0 or earned > 0: __M_writer(u' <span> ') __M_writer(filters.html_escape(filters.decode.utf8("({0:.3n}/{1:.3n}) {2}".format( float(earned), float(total), percentageString )))) __M_writer(u'</span>\n') __M_writer(u' </h4>\n <p>\n') if section.format is not None: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(section.format))) __M_writer(u'\n') if section.due is not None: __M_writer(u' <em class="localized-datetime" data-datetime="') __M_writer(filters.html_escape(filters.decode.utf8(section.due))) __M_writer(u'" data-string="') __M_writer(filters.html_escape(filters.decode.utf8(_('due {date}')))) __M_writer(u'" data-timezone="') __M_writer(filters.html_escape(filters.decode.utf8(user_timezone))) __M_writer(u'" data-language="') __M_writer(filters.html_escape(filters.decode.utf8(user_language))) __M_writer(u'"></em>\n') __M_writer(u' </p>\n <p class="override-notice">\n') if section.override is not None: if section.format is not None and section.format == "Exam": __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Suspicious activity detected during proctored exam review. Exam score 0.")))) __M_writer(u'\n') else: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Section grade has been overridden.")))) __M_writer(u'\n') __M_writer(u' </p>\n') if len(section.problem_scores.values()) > 0: if section.show_grades(staff_access): __M_writer(u' <dl class="scores">\n <dt class="hd hd-6">') __M_writer(filters.html_escape(filters.decode.utf8( _("Problem Scores: ") if section.graded else _("Practice Scores: ")))) __M_writer(u'</dt>\n') for score in section.problem_scores.values(): __M_writer(u' <dd>') __M_writer(filters.html_escape(filters.decode.utf8("{0:.3n}/{1:.3n}".format(float(score.earned),float(score.possible))))) __M_writer(u'</dd>\n') __M_writer(u' </dl>\n') else: __M_writer(u' <p class="hide-scores">\n') if section.show_correctness == 'past_due': if section.graded: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Problem scores are hidden until the due date.")))) __M_writer(u'\n') else: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Practice scores are hidden until the due date.")))) __M_writer(u'\n') else: if section.graded: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Problem scores are hidden.")))) __M_writer(u'\n') else: __M_writer(u' ') __M_writer(filters.html_escape(filters.decode.utf8(_("Practice scores are hidden.")))) __M_writer(u'\n') __M_writer(u' </p>\n') else: __M_writer(u' <p class="no-scores">') __M_writer(filters.html_escape(filters.decode.utf8(_("No problem scores in this section")))) __M_writer(u'</p>\n') __M_writer(u' </div>\n') __M_writer(u' </div>\n </section>\n') finally: loop = __M_loop._exit() __M_writer(u' </section>\n') __M_writer(u' </section>\n </div>\n </div>\n</main>\n') def ccall(caller): def body(): __M_writer = context.writer() __M_writer(u'\n DateUtilFactory.transform(iterationKey=".localized-datetime");\n') return '' return [body] context.caller_stack.nextcaller = runtime.Namespace('caller', context, callables=ccall(__M_caller)) try: __M_writer(filters.html_escape(filters.decode.utf8(static.require_module_async(class_name=u'DateUtilFactory',module_name=u'js/dateutil_factory')))) finally: context.caller_stack.nextcaller = None __M_writer(u'\n') return '' finally: context.caller_stack._pop_frame()
def test_get_enterprise_learner_generic_name_404_pages(self): request = mock.Mock(view_name='404') assert get_enterprise_learner_generic_name(request) is None
def get(self, request, *args, **kwargs): course_key_string = kwargs.get('course_key_string') course_key = CourseKey.from_string(course_key_string) student_id = kwargs.get('student_id') if student_id: try: student_id = int(student_id) except ValueError: raise Http404 if not course_home_mfe_progress_tab_is_active(course_key): raise Http404 # Enable NR tracing for this view based on course monitoring_utils.set_custom_attribute('course_id', course_key_string) monitoring_utils.set_custom_attribute('user_id', request.user.id) monitoring_utils.set_custom_attribute('is_staff', request.user.is_staff) is_staff = bool(has_access(request.user, 'staff', course_key)) if student_id is None or student_id == request.user.id: _, student = setup_masquerade(request, course_key, staff_access=is_staff, reset_masquerade_data=True) else: # When a student_id is passed in, we display the progress page for the user # with the provided user id, rather than the requesting user try: coach_access = has_ccx_coach_role(request.user, course_key) except CCXLocatorValidationException: coach_access = False has_access_on_students_profiles = is_staff or coach_access # Requesting access to a different student's profile if not has_access_on_students_profiles: raise Http404 try: student = User.objects.get(id=student_id) except User.DoesNotExist as exc: raise Http404 from exc username = get_enterprise_learner_generic_name( request) or student.username course = get_course_with_access(student, 'load', course_key, check_if_enrolled=False) course_overview = CourseOverview.get_from_id(course_key) enrollment = CourseEnrollment.get_enrollment(student, course_key) enrollment_mode = getattr(enrollment, 'mode', None) if not (enrollment and enrollment.is_active) and not is_staff: return Response('User not enrolled.', status=401) # The block structure is used for both the course_grade and has_scheduled content fields # So it is called upfront and reused for optimization purposes collected_block_structure = get_block_structure_manager( course_key).get_collected() course_grade = CourseGradeFactory().read( student, collected_block_structure=collected_block_structure) # Get has_scheduled_content data transformers = BlockStructureTransformers() transformers += [ start_date.StartDateTransformer(), ContentTypeGateTransformer() ] usage_key = collected_block_structure.root_block_usage_key course_blocks = get_course_blocks( student, usage_key, transformers=transformers, collected_block_structure=collected_block_structure, include_has_scheduled_content=True) has_scheduled_content = course_blocks.get_xblock_field( usage_key, 'has_scheduled_content') # Get user_has_passing_grade data user_has_passing_grade = False if not student.is_anonymous: user_grade = course_grade.percent user_has_passing_grade = user_grade >= course.lowest_passing_grade descriptor = modulestore().get_course(course_key) grading_policy = descriptor.grading_policy verification_status = IDVerificationService.user_status(student) verification_link = None if verification_status['status'] is None or verification_status[ 'status'] == 'expired': verification_link = IDVerificationService.get_verify_location( course_id=course_key) elif verification_status['status'] == 'must_reverify': verification_link = IDVerificationService.get_verify_location( course_id=course_key) verification_data = { 'link': verification_link, 'status': verification_status['status'], 'status_date': verification_status['status_date'], } data = { 'username': username, 'end': course.end, 'user_has_passing_grade': user_has_passing_grade, 'certificate_data': get_cert_data(student, course, enrollment_mode, course_grade), 'completion_summary': get_course_blocks_completion_summary(course_key, student), 'course_grade': course_grade, 'has_scheduled_content': has_scheduled_content, 'section_scores': course_grade.chapter_grades.values(), 'enrollment_mode': enrollment_mode, 'grading_policy': grading_policy, 'studio_url': get_studio_url(course, 'settings/grading'), 'verification_data': verification_data, } context = self.get_serializer_context() context['staff_access'] = is_staff context['course_blocks'] = course_blocks context['course_key'] = course_key # course_overview and enrollment will be used by VerifiedModeSerializerMixin context['course_overview'] = course_overview context['enrollment'] = enrollment serializer = self.get_serializer_class()(data, context=context) return Response(serializer.data)
def render_body(context,**pageargs): __M_caller = context.caller_stack._push_frame() try: __M_locals = __M_dict_builtin(pageargs=pageargs) getattr = context.get('getattr', UNDEFINED) request = context.get('request', UNDEFINED) user = context.get('user', UNDEFINED) self = context.get('self', UNDEFINED) __M_writer = context.writer() __M_writer(u'\n') __M_writer(u'\n\n') __M_writer(u'\n\n') ## This template should not use the target student's details when masquerading, see TNL-4895 self.real_user = getattr(user, 'real_user', user) profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] username = self.real_user.username resume_block = retrieve_last_sitewide_block_completed(username) displayname = get_enterprise_learner_generic_name(request) or username __M_locals_builtin_stored = __M_locals_builtin() __M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in ['username','resume_block','displayname','profile_image_url'] if __M_key in __M_locals_builtin_stored])) __M_writer(u'\n\n<div class="nav-item hidden-mobile nav-item-dashboard">\n <a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('dashboard')))) __M_writer(u'" class="menu-title">\n <img class="user-image-frame" src="') __M_writer(filters.html_escape(filters.decode.utf8(profile_image_url))) __M_writer(u'" alt="">\n <span class="sr-only">') __M_writer(filters.html_escape(filters.decode.utf8(_("Dashboard for:")))) __M_writer(u'</span>\n <span class="username">') __M_writer(filters.html_escape(filters.decode.utf8(displayname))) __M_writer(u'</span>\n </a>\n</div>\n<div class="nav-item hidden-mobile nav-item-dropdown" tabindex="-1">\n <div class="toggle-user-dropdown" role="button" aria-label=') __M_writer(filters.html_escape(filters.decode.utf8(_("Options Menu")))) __M_writer(u' aria-expanded="false" tabindex="0" aria-controls="user-menu">\n <span class="fa fa-caret-down" aria-hidden="true"></span>\n </div>\n <div class="dropdown-user-menu hidden" aria-label=') __M_writer(filters.html_escape(filters.decode.utf8(_("More Options")))) __M_writer(u' role="menu" id="user-menu" tabindex="-1">\n') if resume_block: __M_writer(u' <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="') __M_writer(filters.html_escape(filters.decode.utf8(resume_block))) __M_writer(u'" role="menuitem">') __M_writer(filters.html_escape(filters.decode.utf8(_("Resume your last course")))) __M_writer(u'</a></div>\n') __M_writer(u' <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('dashboard')))) __M_writer(u'" role="menuitem">') __M_writer(filters.html_escape(filters.decode.utf8(_("Dashboard")))) __M_writer(u'</a></div>\n <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('learner_profile', kwargs={'username': username})))) __M_writer(u'" role="menuitem">') __M_writer(filters.html_escape(filters.decode.utf8(_("Profile")))) __M_writer(u'</a></div>\n <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('account_settings')))) __M_writer(u'" role="menuitem">') __M_writer(filters.html_escape(filters.decode.utf8(_("Account")))) __M_writer(u'</a></div>\n <div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="') __M_writer(filters.html_escape(filters.decode.utf8(reverse('logout')))) __M_writer(u'" role="menuitem">') __M_writer(filters.html_escape(filters.decode.utf8(_("Sign Out")))) __M_writer(u'</a></div>\n </div>\n</div>\n') return '' finally: context.caller_stack._pop_frame()
def get(self, request, *args, **kwargs): course_key_string = kwargs.get('course_key_string') course_key = CourseKey.from_string(course_key_string) student_id = kwargs.get('student_id') if not course_home_mfe_progress_tab_is_active(course_key): raise Http404 # Enable NR tracing for this view based on course monitoring_utils.set_custom_attribute('course_id', course_key_string) monitoring_utils.set_custom_attribute('user_id', request.user.id) monitoring_utils.set_custom_attribute('is_staff', request.user.is_staff) is_staff = bool(has_access(request.user, 'staff', course_key)) student = self._get_student_user(request, course_key, student_id, is_staff) username = get_enterprise_learner_generic_name( request) or student.username course = get_course_with_access(student, 'load', course_key, check_if_enrolled=False) course_overview = CourseOverview.get_from_id(course_key) enrollment = CourseEnrollment.get_enrollment(student, course_key) enrollment_mode = getattr(enrollment, 'mode', None) if not (enrollment and enrollment.is_active) and not is_staff: return Response('User not enrolled.', status=401) # The block structure is used for both the course_grade and has_scheduled content fields # So it is called upfront and reused for optimization purposes collected_block_structure = get_block_structure_manager( course_key).get_collected() course_grade = CourseGradeFactory().read( student, collected_block_structure=collected_block_structure) # recalculate course grade from visible grades (stored grade was calculated over all grades, visible or not) course_grade.update(visible_grades_only=True, has_staff_access=is_staff) # Get has_scheduled_content data transformers = BlockStructureTransformers() transformers += [ start_date.StartDateTransformer(), ContentTypeGateTransformer() ] usage_key = collected_block_structure.root_block_usage_key course_blocks = get_course_blocks( student, usage_key, transformers=transformers, collected_block_structure=collected_block_structure, include_has_scheduled_content=True) has_scheduled_content = course_blocks.get_xblock_field( usage_key, 'has_scheduled_content') # Get user_has_passing_grade data user_has_passing_grade = False if not student.is_anonymous: user_grade = course_grade.percent user_has_passing_grade = user_grade >= course.lowest_passing_grade descriptor = modulestore().get_course(course_key) grading_policy = descriptor.grading_policy verification_status = IDVerificationService.user_status(student) verification_link = None if verification_status['status'] is None or verification_status[ 'status'] == 'expired': verification_link = IDVerificationService.get_verify_location( course_id=course_key) elif verification_status['status'] == 'must_reverify': verification_link = IDVerificationService.get_verify_location( course_id=course_key) verification_data = { 'link': verification_link, 'status': verification_status['status'], 'status_date': verification_status['status_date'], } access_expiration = get_access_expiration_data(request.user, course_overview) data = { 'access_expiration': access_expiration, 'certificate_data': get_cert_data(student, course, enrollment_mode, course_grade), 'completion_summary': get_course_blocks_completion_summary(course_key, student), 'course_grade': course_grade, 'credit_course_requirements': credit_course_requirements(course_key, student), 'end': course.end, 'enrollment_mode': enrollment_mode, 'grading_policy': grading_policy, 'has_scheduled_content': has_scheduled_content, 'section_scores': list(course_grade.chapter_grades.values()), 'studio_url': get_studio_url(course, 'settings/grading'), 'username': username, 'user_has_passing_grade': user_has_passing_grade, 'verification_data': verification_data, } context = self.get_serializer_context() context['staff_access'] = is_staff context['course_blocks'] = course_blocks context['course_key'] = course_key # course_overview and enrollment will be used by VerifiedModeSerializer context['course_overview'] = course_overview context['enrollment'] = enrollment serializer = self.get_serializer_class()(data, context=context) return Response(serializer.data)