def get(self, request): """ returns the get_active_exams_for_user """ return Response( get_active_exams_for_user( user_id=request.data.get('user_id', None), course_id=request.data.get('course_id', None)))
def get(self, request): """ returns the get_active_exams_for_user """ return Response(get_active_exams_for_user( user_id=request.DATA.get('user_id', None), course_id=request.DATA.get('course_id', None) ))
def get(self, request): """ returns the get_active_exams_for_user """ return Response( get_active_exams_for_user( user_id=request.data.get("user_id", None), course_id=request.data.get("course_id", None) ) )
def get(self, request): # pylint: disable=unused-argument """ HTTP GET Handler. Returns the status of the exam attempt. """ exams = get_active_exams_for_user(request.user.id) if exams: exam_info = exams[0] exam = exam_info['exam'] attempt = exam_info['attempt'] time_remaining_seconds = get_time_remaining_for_attempt(attempt) proctoring_settings = getattr(settings, 'PROCTORING_SETTINGS', {}) low_threshold_pct = proctoring_settings.get('low_threshold_pct', .2) critically_low_threshold_pct = proctoring_settings.get('critically_low_threshold_pct', .05) low_threshold = int(low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60) critically_low_threshold = int( critically_low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60 ) exam_url_path = '' try: # resolve the LMS url, note we can't assume we're running in # a same process as the LMS exam_url_path = reverse( 'courseware.views.jump_to', args=[exam['course_id'], exam['content_id']] ) except NoReverseMatch: pass response_dict = { 'in_timed_exam': True, 'taking_as_proctored': attempt['taking_as_proctored'], 'exam_display_name': exam['exam_name'], 'exam_url_path': exam_url_path, 'time_remaining_seconds': time_remaining_seconds, 'low_threshold_sec': low_threshold, 'critically_low_threshold_sec': critically_low_threshold, 'course_id': exam['course_id'], 'attempt_id': attempt['id'], 'attempt_status': attempt['status'] } else: response_dict = { 'in_timed_exam': False, 'is_proctored': False, } return Response( data=response_dict, status=status.HTTP_200_OK )
def get(self, request): # pylint: disable=unused-argument """ HTTP GET Handler. Returns the status of the exam attempt. """ exams = get_active_exams_for_user(request.user.id) if exams: exam_info = exams[0] exam = exam_info["exam"] attempt = exam_info["attempt"] time_remaining_seconds = get_time_remaining_for_attempt(attempt) proctoring_settings = getattr(settings, "PROCTORING_SETTINGS", {}) low_threshold_pct = proctoring_settings.get("low_threshold_pct", 0.2) critically_low_threshold_pct = proctoring_settings.get("critically_low_threshold_pct", 0.05) low_threshold = int(low_threshold_pct * float(attempt["allowed_time_limit_mins"]) * 60) critically_low_threshold = int( critically_low_threshold_pct * float(attempt["allowed_time_limit_mins"]) * 60 ) exam_url_path = "" try: # resolve the LMS url, note we can't assume we're running in # a same process as the LMS exam_url_path = reverse("courseware.views.jump_to", args=[exam["course_id"], exam["content_id"]]) except NoReverseMatch: pass response_dict = { "in_timed_exam": True, "taking_as_proctored": attempt["taking_as_proctored"], "exam_type": ( _("timed") if not attempt["taking_as_proctored"] else (_("practice") if attempt["is_sample_attempt"] else _("proctored")) ), "exam_display_name": exam["exam_name"], "exam_url_path": exam_url_path, "time_remaining_seconds": time_remaining_seconds, "low_threshold_sec": low_threshold, "critically_low_threshold_sec": critically_low_threshold, "course_id": exam["course_id"], "attempt_id": attempt["id"], "accessibility_time_string": _("you have {remaining_time} remaining").format( remaining_time=humanized_time(int(round(time_remaining_seconds / 60.0, 0))) ), "attempt_status": attempt["status"], } else: response_dict = {"in_timed_exam": False, "is_proctored": False} return Response(data=response_dict, status=status.HTTP_200_OK)
def get(self, request): # pylint: disable=unused-argument """ HTTP GET Handler. Returns the status of the exam attempt. """ exams = get_active_exams_for_user(request.user.id) if exams: exam_info = exams[0] exam = exam_info['exam'] attempt = exam_info['attempt'] time_remaining_seconds = get_time_remaining_for_attempt(attempt) proctoring_settings = getattr(settings, 'PROCTORING_SETTINGS', {}) low_threshold_pct = proctoring_settings.get( 'low_threshold_pct', .2) critically_low_threshold_pct = proctoring_settings.get( 'critically_low_threshold_pct', .05) low_threshold = int(low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60) critically_low_threshold = int( critically_low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60) exam_url_path = '' try: # resolve the LMS url, note we can't assume we're running in # a same process as the LMS exam_url_path = reverse( 'courseware.views.jump_to', args=[exam['course_id'], exam['content_id']]) except NoReverseMatch: pass response_dict = { 'in_timed_exam': True, 'taking_as_proctored': attempt['taking_as_proctored'], 'exam_type': (_('timed') if not attempt['taking_as_proctored'] else (_('practice') if attempt['is_sample_attempt'] else _('proctored'))), 'exam_display_name': exam['exam_name'], 'exam_url_path': exam_url_path, 'time_remaining_seconds': time_remaining_seconds, 'low_threshold_sec': low_threshold, 'critically_low_threshold_sec': critically_low_threshold, 'course_id': exam['course_id'], 'attempt_id': attempt['id'], 'accessibility_time_string': _('you have {remaining_time} remaining').format( remaining_time=humanized_time( int(round(time_remaining_seconds / 60.0, 0)))), 'attempt_status': attempt['status'] } else: response_dict = {'in_timed_exam': False, 'is_proctored': False} return Response(data=response_dict, status=status.HTTP_200_OK)
def get(self, request): # pylint: disable=unused-argument """ HTTP GET Handler. Returns the status of the exam attempt. """ exams = get_active_exams_for_user(request.user.id) if exams: exam_info = exams[0] exam = exam_info['exam'] attempt = exam_info['attempt'] provider = get_backend_provider(exam) time_remaining_seconds = get_time_remaining_for_attempt(attempt) proctoring_settings = getattr(settings, 'PROCTORING_SETTINGS', {}) low_threshold_pct = proctoring_settings.get('low_threshold_pct', .2) critically_low_threshold_pct = proctoring_settings.get('critically_low_threshold_pct', .05) low_threshold = int(low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60) critically_low_threshold = int( critically_low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60 ) exam_url_path = '' try: # resolve the LMS url, note we can't assume we're running in # a same process as the LMS exam_url_path = reverse('jump_to', args=[exam['course_id'], exam['content_id']]) except NoReverseMatch: LOG.exception(u"Can't find exam url for course %s", exam['course_id']) response_dict = { 'in_timed_exam': True, 'taking_as_proctored': attempt['taking_as_proctored'], 'exam_type': ( _('a timed exam') if not attempt['taking_as_proctored'] else (_('a proctored exam') if not attempt['is_sample_attempt'] else (_('an onboarding exam') if provider.supports_onboarding else _('a practice exam'))) ), 'exam_display_name': exam['exam_name'], 'exam_url_path': exam_url_path, 'time_remaining_seconds': time_remaining_seconds, 'low_threshold_sec': low_threshold, 'critically_low_threshold_sec': critically_low_threshold, 'course_id': exam['course_id'], 'attempt_id': attempt['id'], 'accessibility_time_string': _(u'you have {remaining_time} remaining').format( remaining_time=humanized_time(int(round(time_remaining_seconds / 60.0, 0))) ), 'attempt_status': attempt['status'], 'exam_started_poll_url': reverse( 'edx_proctoring:proctored_exam.attempt', args=[attempt['id']] ), } if provider: response_dict['desktop_application_js_url'] = provider.get_javascript() response_dict['ping_interval'] = provider.ping_interval else: response_dict['desktop_application_js_url'] = '' else: response_dict = { 'in_timed_exam': False, 'is_proctored': False } return Response(data=response_dict, status=status.HTTP_200_OK)
def get(self, request): # pylint: disable=unused-argument """ HTTP GET Handler. Returns the status of the exam attempt. """ exams = get_active_exams_for_user(request.user.id) if exams: exam_info = exams[0] exam = exam_info['exam'] attempt = exam_info['attempt'] provider = get_backend_provider(exam) time_remaining_seconds = get_time_remaining_for_attempt(attempt) proctoring_settings = getattr(settings, 'PROCTORING_SETTINGS', {}) low_threshold_pct = proctoring_settings.get('low_threshold_pct', .2) critically_low_threshold_pct = proctoring_settings.get('critically_low_threshold_pct', .05) low_threshold = int(low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60) critically_low_threshold = int( critically_low_threshold_pct * float(attempt['allowed_time_limit_mins']) * 60 ) exam_url_path = '' try: # resolve the LMS url, note we can't assume we're running in # a same process as the LMS exam_url_path = reverse('jump_to', args=[exam['course_id'], exam['content_id']]) except NoReverseMatch: LOG.exception("Can't find exam url for course %s", exam['course_id']) response_dict = { 'in_timed_exam': True, 'taking_as_proctored': attempt['taking_as_proctored'], 'exam_type': ( _('a timed exam') if not attempt['taking_as_proctored'] else (_('a proctored exam') if not attempt['is_sample_attempt'] else (_('an onboarding exam') if provider.supports_onboarding else _('a practice exam'))) ), 'exam_display_name': exam['exam_name'], 'exam_url_path': exam_url_path, 'time_remaining_seconds': time_remaining_seconds, 'low_threshold_sec': low_threshold, 'critically_low_threshold_sec': critically_low_threshold, 'course_id': exam['course_id'], 'attempt_id': attempt['id'], 'accessibility_time_string': _('you have {remaining_time} remaining').format( remaining_time=humanized_time(int(round(time_remaining_seconds / 60.0, 0))) ), 'attempt_status': attempt['status'], 'exam_started_poll_url': reverse( 'edx_proctoring:proctored_exam.attempt', args=[attempt['id']] ), } if provider: response_dict['desktop_application_js_url'] = provider.get_javascript() response_dict['ping_interval'] = provider.ping_interval else: response_dict['desktop_application_js_url'] = '' else: response_dict = { 'in_timed_exam': False, 'is_proctored': False } return Response(data=response_dict, status=status.HTTP_200_OK)