Skip to content

Commit

Permalink
Merge pull request #290 from edx/afzaledx/sol-1802_zendesk_tickets_fo…
Browse files Browse the repository at this point in the history
…r_suspicious_proctored_attempts

(WIP) SOL-1802 Create Zendesk ticket when "Suspicious" proctored exam reviews are received from the proctoring provider
  • Loading branch information
Douglas Hall committed May 27, 2016
2 parents f5df57f + 931ee10 commit 13f398f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
18 changes: 18 additions & 0 deletions edx_proctoring/backends/software_secure.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ProctoredExamReviewAlreadyExists,
ProctoredExamBadReviewStatus,
)
from edx_proctoring.runtime import get_runtime_service
from edx_proctoring.utils import locate_attempt_by_attempt_code, emit_event
from edx_proctoring. models import (
ProctoredExamSoftwareSecureReview,
Expand Down Expand Up @@ -64,6 +65,7 @@ def __init__(self, organization, exam_sponsor, exam_register_endpoint,
self.send_email = send_email
self.passing_review_status = ['Clean', 'Rules Violation']
self.failing_review_status = ['Not Reviewed', 'Suspicious']
self.notify_support_for_status = ['Suspicious']

def register_exam_attempt(self, exam, context):
"""
Expand Down Expand Up @@ -261,6 +263,8 @@ def on_review_callback(self, payload):
exam = serialized_exam_object.data
emit_event(exam, 'review_received', attempt=attempt, override_data=data)

self._create_zendesk_ticket(review, serialized_exam_object, serialized_attempt_obj)

def on_review_saved(self, review, allow_rejects=False): # pylint: disable=arguments-differ
"""
called when a review has been save - either through API (on_review_callback) or via Django Admin panel
Expand Down Expand Up @@ -349,6 +353,20 @@ def _split_fullname(self, full_name):

return (first_name, last_name)

def _create_zendesk_ticket(self, review, serialized_exam_object, serialized_attempt_obj):
"""
Creates a Zendesk ticket for reviews with status listed in self.notify_support_for_status
"""
if review.review_status in self.notify_support_for_status:
instructor_service = get_runtime_service('instructor')
if instructor_service:
instructor_service.send_support_notification(
course_id=serialized_exam_object["course_id"],
exam_name=serialized_exam_object["exam_name"],
student_username=serialized_attempt_obj["user"]["username"],
review_status=review.review_status
)

def _get_payload(self, exam, context):
"""
Constructs the data payload that Software Secure expects
Expand Down
3 changes: 2 additions & 1 deletion edx_proctoring/backends/tests/test_software_secure.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
TEST_REVIEW_PAYLOAD
)

from edx_proctoring.tests.test_services import MockCreditService
from edx_proctoring.tests.test_services import MockCreditService, MockInstructorService
from edx_proctoring.backends.software_secure import SOFTWARE_SECURE_INVALID_CHARS


Expand Down Expand Up @@ -104,6 +104,7 @@ def setUp(self):
self.user.save()

set_runtime_service('credit', MockCreditService())
set_runtime_service('instructor', MockInstructorService())

def tearDown(self):
"""
Expand Down
6 changes: 6 additions & 0 deletions edx_proctoring/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ def is_course_staff(self, user, course_id):
"""
return self.is_user_course_staff

def send_support_notification(self, course_id, exam_name, student_username, review_status):
"""
Mocked implementation of send_support_notification
"""
pass


class TestProctoringService(unittest.TestCase):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_requirements(*requirements_paths):

setup(
name='edx-proctoring',
version='0.12.17',
version='0.12.18',
description='Proctoring subsystem for Open edX',
long_description=open('README.md').read(),
author='edX',
Expand Down

0 comments on commit 13f398f

Please sign in to comment.