Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
9260f881
Commit
9260f881
authored
Oct 19, 2017
by
rabiaiftikhar
Committed by
rabia23
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1542 give access to Special Exam tab to the course team
parent
8435e7b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
25 deletions
+90
-25
lms/djangoapps/instructor/tests/test_proctoring.py
+80
-17
lms/djangoapps/instructor/views/instructor_dashboard.py
+10
-8
No files found.
lms/djangoapps/instructor/tests/test_proctoring.py
View file @
9260f881
...
@@ -2,12 +2,13 @@
...
@@ -2,12 +2,13 @@
Unit tests for Edx Proctoring feature flag in new instructor dashboard.
Unit tests for Edx Proctoring feature flag in new instructor dashboard.
"""
"""
import
ddt
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
student.roles
import
Course
FinanceAdmin
Role
from
student.roles
import
Course
StaffRole
,
CourseInstructor
Role
from
student.tests.factories
import
AdminFactory
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
@@ -15,6 +16,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
...
@@ -15,6 +16,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr
(
shard
=
1
)
@attr
(
shard
=
1
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SPECIAL_EXAMS'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SPECIAL_EXAMS'
:
True
})
@ddt.ddt
class
TestProctoringDashboardViews
(
SharedModuleStoreTestCase
):
class
TestProctoringDashboardViews
(
SharedModuleStoreTestCase
):
"""
"""
Check for Proctoring view on the new instructor dashboard
Check for Proctoring view on the new instructor dashboard
...
@@ -22,10 +24,6 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
...
@@ -22,10 +24,6 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
super
(
TestProctoringDashboardViews
,
cls
)
.
setUpClass
()
super
(
TestProctoringDashboardViews
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
enable_proctored_exams
=
True
)
# URL for instructor dash
cls
.
url
=
reverse
(
'instructor_dashboard'
,
kwargs
=
{
'course_id'
:
cls
.
course
.
id
.
to_deprecated_string
()})
button
=
'<button type="button" class="btn-link special_exams" data-section="special_exams">Special Exams</button>'
button
=
'<button type="button" class="btn-link special_exams" data-section="special_exams">Special Exams</button>'
cls
.
proctoring_link
=
button
cls
.
proctoring_link
=
button
...
@@ -36,24 +34,74 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
...
@@ -36,24 +34,74 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
self
.
instructor
=
AdminFactory
.
create
()
self
.
instructor
=
AdminFactory
.
create
()
self
.
client
.
login
(
username
=
self
.
instructor
.
username
,
password
=
"test"
)
self
.
client
.
login
(
username
=
self
.
instructor
.
username
,
password
=
"test"
)
CourseFinanceAdminRole
(
self
.
course
.
id
)
.
add_users
(
self
.
instructor
)
def
setup_course_url
(
self
,
course
):
"""
Create URL for instructor dashboard
"""
self
.
url
=
reverse
(
'instructor_dashboard'
,
kwargs
=
{
'course_id'
:
course
.
id
.
to_deprecated_string
()})
def
test_pass_proctoring_tab_in_instructor_dashboard
(
self
):
def
setup_course
(
self
,
enable_proctored_exams
,
enable_timed_exams
):
"""
"""
Test Pass Proctoring Tab is in the Instructor Dashboard
Create course based on proctored exams and timed exams values
"""
"""
self
.
course
=
CourseFactory
.
create
(
enable_proctored_exams
=
enable_proctored_exams
,
enable_timed_exams
=
enable_timed_exams
)
self
.
setup_course_url
(
self
.
course
)
@ddt.data
(
(
True
,
False
),
(
False
,
True
)
)
@ddt.unpack
def
test_proctoring_tab_visible_for_global_staff
(
self
,
enable_proctored_exams
,
enable_timed_exams
):
"""
Test Proctoring Tab is visible in the Instructor Dashboard
for global staff
"""
self
.
setup_course
(
enable_proctored_exams
,
enable_timed_exams
)
self
.
instructor
.
is_staff
=
True
self
.
instructor
.
is_staff
=
True
self
.
instructor
.
save
()
self
.
instructor
.
save
()
response
=
self
.
client
.
get
(
self
.
url
)
# verify that proctoring tab is visible for global staff
self
.
assertIn
(
self
.
proctoring_link
,
response
.
content
)
self
.
_assert_proctoring_tab_is_available
()
self
.
assertIn
(
'Allowance Section'
,
response
.
content
)
@ddt.data
(
(
True
,
False
),
(
False
,
True
)
)
@ddt.unpack
def
test_proctoring_tab_visible_for_course_staff_and_admin
(
self
,
enable_proctored_exams
,
enable_timed_exams
):
"""
Test Proctoring Tab is visible in the Instructor Dashboard
for course staff(role of STAFF or ADMIN)
"""
self
.
setup_course
(
enable_proctored_exams
,
enable_timed_exams
)
def
test_no_tab_non_global_staff
(
self
):
self
.
instructor
.
is_staff
=
False
self
.
instructor
.
save
()
# verify that proctoring tab is visible for course staff
CourseStaffRole
(
self
.
course
.
id
)
.
add_users
(
self
.
instructor
)
self
.
_assert_proctoring_tab_is_available
()
# verify that proctoring tab is visible for course instructor
CourseStaffRole
(
self
.
course
.
id
)
.
remove_users
(
self
.
instructor
)
CourseInstructorRole
(
self
.
course
.
id
)
.
add_users
(
self
.
instructor
)
self
.
_assert_proctoring_tab_is_available
()
@ddt.data
(
(
True
,
False
),
(
False
,
True
)
)
@ddt.unpack
def
test_no_proctoring_tab_non_global_staff
(
self
,
enable_proctored_exams
,
enable_timed_exams
):
"""
"""
Test P
ass Proctoring Tab is not
in the Instructor Dashboard
Test P
roctoring Tab is not visible
in the Instructor Dashboard
for
non global staff users
for
course team other than role of staff or admin
"""
"""
self
.
setup_course
(
enable_proctored_exams
,
enable_timed_exams
)
self
.
instructor
.
is_staff
=
False
self
.
instructor
.
is_staff
=
False
self
.
instructor
.
save
()
self
.
instructor
.
save
()
...
@@ -62,14 +110,29 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
...
@@ -62,14 +110,29 @@ class TestProctoringDashboardViews(SharedModuleStoreTestCase):
self
.
assertNotIn
(
'Allowance Section'
,
response
.
content
)
self
.
assertNotIn
(
'Allowance Section'
,
response
.
content
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SPECIAL_EXAMS'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SPECIAL_EXAMS'
:
False
})
def
test_no_tab_flag_unset
(
self
):
@ddt.data
(
(
True
,
False
),
(
False
,
True
)
)
@ddt.unpack
def
test_no_tab_flag_unset
(
self
,
enable_proctored_exams
,
enable_timed_exams
):
"""
"""
Special Exams tab will not be visible if
Special Exams tab will not be visible if
special exams settings are not enabled inspite of
the user is not a staff member.
proctored exams or timed exams is enabled
"""
"""
self
.
setup_course
(
enable_proctored_exams
,
enable_timed_exams
)
self
.
instructor
.
is_staff
=
True
self
.
instructor
.
is_staff
=
True
self
.
instructor
.
save
()
self
.
instructor
.
save
()
response
=
self
.
client
.
get
(
self
.
url
)
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertNotIn
(
self
.
proctoring_link
,
response
.
content
)
self
.
assertNotIn
(
self
.
proctoring_link
,
response
.
content
)
self
.
assertNotIn
(
'Allowance Section'
,
response
.
content
)
self
.
assertNotIn
(
'Allowance Section'
,
response
.
content
)
def
_assert_proctoring_tab_is_available
(
self
):
"""
Asserts that proctoring tab is available for logged in user.
"""
response
=
self
.
client
.
get
(
self
.
url
)
self
.
assertIn
(
self
.
proctoring_link
,
response
.
content
)
self
.
assertIn
(
'Allowance Section'
,
response
.
content
)
lms/djangoapps/instructor/views/instructor_dashboard.py
View file @
9260f881
...
@@ -49,7 +49,7 @@ from openedx.core.lib.url_utils import quote_slashes
...
@@ -49,7 +49,7 @@ from openedx.core.lib.url_utils import quote_slashes
from
openedx.core.lib.xblock_utils
import
wrap_xblock
from
openedx.core.lib.xblock_utils
import
wrap_xblock
from
shoppingcart.models
import
Coupon
,
CourseRegCodeItem
,
PaidCourseRegistration
from
shoppingcart.models
import
Coupon
,
CourseRegCodeItem
,
PaidCourseRegistration
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseFinanceAdminRole
,
CourseSalesAdminRole
from
student.roles
import
CourseFinanceAdminRole
,
CourseSalesAdminRole
,
CourseStaffRole
,
CourseInstructorRole
from
util.json_request
import
JsonResponse
from
util.json_request
import
JsonResponse
from
xmodule.html_module
import
HtmlDescriptor
from
xmodule.html_module
import
HtmlDescriptor
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
...
@@ -174,13 +174,15 @@ def instructor_dashboard_2(request, course_id):
...
@@ -174,13 +174,15 @@ def instructor_dashboard_2(request, course_id):
# Gate access to Special Exam tab depending if either timed exams or proctored exams
# Gate access to Special Exam tab depending if either timed exams or proctored exams
# are enabled in the course
# are enabled in the course
# NOTE: For now, if we only have procotred exams enabled, then only platform Staff
user_has_access
=
any
([
# (user.is_staff) will be able to view the special exams tab. This may
request
.
user
.
is_staff
,
# change in the future
CourseStaffRole
(
course_key
)
.
has_user
(
request
.
user
),
can_see_special_exams
=
(
CourseInstructorRole
(
course_key
)
.
has_user
(
request
.
user
)
((
course
.
enable_proctored_exams
and
request
.
user
.
is_staff
)
or
course
.
enable_timed_exams
)
and
])
settings
.
FEATURES
.
get
(
'ENABLE_SPECIAL_EXAMS'
,
False
)
course_has_special_exams
=
course
.
enable_proctored_exams
or
course
.
enable_timed_exams
)
can_see_special_exams
=
course_has_special_exams
and
user_has_access
and
settings
.
FEATURES
.
get
(
'ENABLE_SPECIAL_EXAMS'
,
False
)
if
can_see_special_exams
:
if
can_see_special_exams
:
sections
.
append
(
_section_special_exams
(
course
,
access
))
sections
.
append
(
_section_special_exams
(
course
,
access
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment