Commit eadd656d by Afzal Wali Committed by Douglas Hall

SOL-1802 Allow proctoring service to create support ticket.

parent 0f0ea0cf
...@@ -987,6 +987,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F ...@@ -987,6 +987,7 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
if xblock.category == 'course': if xblock.category == 'course':
xblock_info.update({ xblock_info.update({
"enable_proctored_exams": xblock.enable_proctored_exams, "enable_proctored_exams": xblock.enable_proctored_exams,
"create_zendesk_tickets": xblock.create_zendesk_tickets,
"enable_timed_exams": xblock.enable_timed_exams "enable_timed_exams": xblock.enable_timed_exams
}) })
elif xblock.category == 'sequential': elif xblock.category == 'sequential':
......
...@@ -742,6 +742,15 @@ class CourseFields(object): ...@@ -742,6 +742,15 @@ class CourseFields(object):
scope=Scope.settings scope=Scope.settings
) )
create_zendesk_tickets = Boolean(
display_name=_("Create Zendesk Tickets For Suspicious Proctored Exam Attempts"),
help=_(
"Enter true or false. If this value is true, a Zendesk ticket will be created for suspicious attempts."
),
default=True,
scope=Scope.settings
)
enable_timed_exams = Boolean( enable_timed_exams = Boolean(
display_name=_("Enable Timed Exams"), display_name=_("Enable Timed Exams"),
help=_( help=_(
......
...@@ -220,5 +220,6 @@ class AdvancedSettingsPage(CoursePage): ...@@ -220,5 +220,6 @@ class AdvancedSettingsPage(CoursePage):
'enable_timed_exams', 'enable_timed_exams',
'enable_subsection_gating', 'enable_subsection_gating',
'learning_info', 'learning_info',
'instructor_info' 'instructor_info',
'create_zendesk_tickets'
] ]
...@@ -6,10 +6,15 @@ import logging ...@@ -6,10 +6,15 @@ import logging
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey from opaque_keys.edx.keys import CourseKey, UsageKey
from commerce.signals import create_zendesk_ticket
from courseware.models import StudentModule from courseware.models import StudentModule
from instructor.views.tools import get_student_from_identifier from instructor.views.tools import get_student_from_identifier
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
import instructor.enrollment as enrollment import instructor.enrollment as enrollment
from django.utils.translation import ugettext as _
from xmodule.modulestore.django import modulestore
from student.roles import CourseStaffRole from student.roles import CourseStaffRole
...@@ -86,3 +91,31 @@ class InstructorService(object): ...@@ -86,3 +91,31 @@ class InstructorService(object):
else Returns False else Returns False
""" """
return auth.user_has_role(user, CourseStaffRole(CourseKey.from_string(course_id))) return auth.user_has_role(user, CourseStaffRole(CourseKey.from_string(course_id)))
def send_support_notification(self, course_id, exam_name, student_username, review_status):
"""
Creates a Zendesk ticket for an exam attempt review from the proctoring system.
Currently, it sends notifications for 'Suspicious" status, but additional statuses can be supported
by adding to the notify_support_for_status list in edx_proctoring/backends/software_secure.py
The notifications can be disabled by disabling the
"Create Zendesk Tickets For Suspicious Proctored Exam Attempts" setting in the course's Advanced settings.
"""
course_key = CourseKey.from_string(course_id)
course = modulestore().get_course(course_key)
if course.create_zendesk_tickets:
requester_name = "edx-proctoring"
email = "edx-proctoring@edx.org"
subject = _("Proctored Exam Review: {review_status}").format(review_status=review_status)
body = _(
"A proctored exam attempt for {exam_name} in {course_name} by username: {student_username} "
"was reviewed as {review_status} by the proctored exam review provider."
).format(
exam_name=exam_name,
course_name=course.display_name,
student_username=student_username,
review_status=review_status
)
tags = ["proctoring"]
create_zendesk_ticket(requester_name, email, subject, body, tags)
...@@ -10,9 +10,9 @@ from instructor.access import allow_access ...@@ -10,9 +10,9 @@ from instructor.access import allow_access
from instructor.services import InstructorService from instructor.services import InstructorService
from instructor.tests.test_tools import msk_from_problem_urlname from instructor.tests.test_tools import msk_from_problem_urlname
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from student.models import CourseEnrollment from student.models import CourseEnrollment
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
import mock
@attr('shard_1') @attr('shard_1')
...@@ -122,7 +122,7 @@ class InstructorServiceTests(SharedModuleStoreTestCase): ...@@ -122,7 +122,7 @@ class InstructorServiceTests(SharedModuleStoreTestCase):
def test_is_user_staff(self): def test_is_user_staff(self):
""" """
Test to assert that the usrr is staff or not Test to assert that the user is staff or not
""" """
result = self.service.is_course_staff( result = self.service.is_course_staff(
self.student, self.student,
...@@ -137,3 +137,28 @@ class InstructorServiceTests(SharedModuleStoreTestCase): ...@@ -137,3 +137,28 @@ class InstructorServiceTests(SharedModuleStoreTestCase):
unicode(self.course.id) unicode(self.course.id)
) )
self.assertTrue(result) self.assertTrue(result)
def test_report_suspicious_attempt(self):
"""
Test to verify that the create_zendesk_ticket() is called
"""
requester_name = "edx-proctoring"
email = "edx-proctoring@edx.org"
subject = "Proctored Exam Review: {review_status}".format(review_status="Suspicious")
body = "A proctored exam attempt for {exam_name} in {course_name} by username: {student_username} was " \
"reviewed as {review_status} by the proctored exam review provider."
body = body.format(
exam_name="test_exam", course_name=self.course.display_name, student_username="test_student",
review_status="Suspicious"
)
tags = ["proctoring"]
with mock.patch("instructor.services.create_zendesk_ticket") as mock_create_zendesk_ticket:
self.service.send_support_notification(
course_id=unicode(self.course.id),
exam_name="test_exam",
student_username="test_student",
review_status="Suspicious"
)
mock_create_zendesk_ticket.assert_called_with(requester_name, email, subject, body, tags)
...@@ -90,7 +90,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.2#egg=xblock-utils==1.0.2 ...@@ -90,7 +90,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.2#egg=xblock-utils==1.0.2
-e git+https://github.com/edx/edx-reverification-block.git@0.0.5#egg=edx-reverification-block==0.0.5 -e git+https://github.com/edx/edx-reverification-block.git@0.0.5#egg=edx-reverification-block==0.0.5
git+https://github.com/edx/edx-user-state-client.git@1.0.1#egg=edx-user-state-client==1.0.1 git+https://github.com/edx/edx-user-state-client.git@1.0.1#egg=edx-user-state-client==1.0.1
git+https://github.com/edx/xblock-lti-consumer.git@v1.0.6#egg=xblock-lti-consumer==1.0.6 git+https://github.com/edx/xblock-lti-consumer.git@v1.0.6#egg=xblock-lti-consumer==1.0.6
git+https://github.com/edx/edx-proctoring.git@0.12.17#egg=edx-proctoring==0.12.17 git+https://github.com/edx/edx-proctoring.git@0.12.18#egg=edx-proctoring==0.12.18
# Third Party XBlocks # Third Party XBlocks
-e git+https://github.com/mitodl/edx-sga@172a90fd2738f8142c10478356b2d9ed3e55334a#egg=edx-sga -e git+https://github.com/mitodl/edx-sga@172a90fd2738f8142c10478356b2d9ed3e55334a#egg=edx-sga
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment