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
acc6d4f2
Commit
acc6d4f2
authored
Mar 25, 2016
by
attiyaishaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed error on Course Home, when viewed as specific student.
parent
84e88eba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
lms/djangoapps/courseware/tests/test_masquerade.py
+25
-0
lms/djangoapps/courseware/views.py
+5
-5
No files found.
lms/djangoapps/courseware/tests/test_masquerade.py
View file @
acc6d4f2
...
...
@@ -28,6 +28,7 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
openedx.core.djangoapps.self_paced.models
import
SelfPacedConfiguration
class
MasqueradeTestCase
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
...
...
@@ -281,6 +282,30 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
return
json
.
loads
(
self
.
look_at_question
(
self
.
problem_display_name
)
.
content
)[
'progress_detail'
]
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_masquerade_as_specific_user_on_self_paced
(
self
):
"""
Test masquerading as a specific user for course info page when self paced configuration
"enable_course_home_improvements" flag is set
Login as a staff user and visit course info page.
set masquerade to view same page as a specific student and revisit the course info page.
"""
# Log in as staff, and check we can see the info page.
self
.
login_staff
()
response
=
self
.
get_course_info_page
()
self
.
assertEqual
(
response
.
status_code
,
200
)
content
=
response
.
content
self
.
assertIn
(
"OOGIE BLOOGIE"
,
content
)
# Masquerade as the student,enable the self paced configuration, and check we can see the info page.
SelfPacedConfiguration
(
enable_course_home_improvements
=
True
)
.
save
()
self
.
update_masquerade
(
role
=
'student'
,
user_name
=
self
.
student_user
.
username
)
response
=
self
.
get_course_info_page
()
self
.
assertEqual
(
response
.
status_code
,
200
)
content
=
response
.
content
self
.
assertIn
(
"OOGIE BLOOGIE"
,
content
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_masquerade_as_specific_student
(
self
):
"""
Test masquerading as a specific user.
...
...
lms/djangoapps/courseware/views.py
View file @
acc6d4f2
...
...
@@ -727,7 +727,7 @@ def course_info(request, course_id):
# Get the URL of the user's last position in order to display the 'where you were last' message
context
[
'last_accessed_courseware_url'
]
=
None
if
SelfPacedConfiguration
.
current
()
.
enable_course_home_improvements
:
context
[
'last_accessed_courseware_url'
]
=
get_last_accessed_courseware
(
course
,
request
)
context
[
'last_accessed_courseware_url'
]
=
get_last_accessed_courseware
(
course
,
request
,
user
)
now
=
datetime
.
now
(
UTC
())
effective_start
=
_adjust_start_date_for_beta_testers
(
user
,
course
,
course_key
)
...
...
@@ -742,16 +742,16 @@ def course_info(request, course_id):
return
render_to_response
(
'courseware/info.html'
,
context
)
def
get_last_accessed_courseware
(
course
,
request
):
def
get_last_accessed_courseware
(
course
,
request
,
user
):
"""
Return the
URL the courseware module that this request's user last
accessed,
or None if it cannot be found.
Return the
courseware module URL that the user last accessed,
or None if it cannot be found.
"""
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
course
.
id
,
request
.
user
,
course
,
depth
=
2
)
course_module
=
get_module_for_descriptor
(
request
.
user
,
request
,
course
,
field_data_cache
,
course
.
id
,
course
=
course
user
,
request
,
course
,
field_data_cache
,
course
.
id
,
course
=
course
)
chapter_module
=
get_current_child
(
course_module
)
if
chapter_module
is
not
None
:
...
...
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