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
96e64464
Commit
96e64464
authored
Dec 10, 2015
by
Ayub-Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-fix TNL-3556 Instructor tool "View as Specific Student" doesn't work on the course updates page.
-Added test for TNL-3556.
parent
c66d3cba
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
17 deletions
+53
-17
AUTHORS
+1
-0
lms/djangoapps/courseware/courses.py
+5
-5
lms/djangoapps/courseware/tests/test_courses.py
+4
-4
lms/djangoapps/courseware/tests/test_masquerade.py
+35
-0
lms/djangoapps/courseware/tests/test_module_render.py
+1
-1
lms/djangoapps/courseware/views.py
+1
-1
lms/djangoapps/mobile_api/course_info/views.py
+2
-2
lms/templates/courseware/info.html
+4
-4
No files found.
AUTHORS
View file @
96e64464
...
@@ -260,3 +260,4 @@ Jacek Bzdak <jbzdak@gmail.com>
...
@@ -260,3 +260,4 @@ Jacek Bzdak <jbzdak@gmail.com>
Jillian Vogel <pomegranited@gmail.com>
Jillian Vogel <pomegranited@gmail.com>
Dan Powell <dan@abakas.com>
Dan Powell <dan@abakas.com>
Mariana Araújo <simbelm.ne@gmail.com>
Mariana Araújo <simbelm.ne@gmail.com>
Muhammad Ayub Khan <ayub.khan@arbisoft.com>
lms/djangoapps/courseware/courses.py
View file @
96e64464
...
@@ -242,7 +242,7 @@ def get_course_about_section(request, course, section_key):
...
@@ -242,7 +242,7 @@ def get_course_about_section(request, course, section_key):
raise
KeyError
(
"Invalid about key "
+
str
(
section_key
))
raise
KeyError
(
"Invalid about key "
+
str
(
section_key
))
def
get_course_info_section_module
(
request
,
course
,
section_key
):
def
get_course_info_section_module
(
request
,
user
,
course
,
section_key
):
"""
"""
This returns the course info module for a given section_key.
This returns the course info module for a given section_key.
...
@@ -255,10 +255,10 @@ def get_course_info_section_module(request, course, section_key):
...
@@ -255,10 +255,10 @@ def get_course_info_section_module(request, course, section_key):
usage_key
=
course
.
id
.
make_usage_key
(
'course_info'
,
section_key
)
usage_key
=
course
.
id
.
make_usage_key
(
'course_info'
,
section_key
)
# Use an empty cache
# Use an empty cache
field_data_cache
=
FieldDataCache
([],
course
.
id
,
request
.
user
)
field_data_cache
=
FieldDataCache
([],
course
.
id
,
user
)
return
get_module
(
return
get_module
(
request
.
user
,
user
,
request
,
request
,
usage_key
,
usage_key
,
field_data_cache
,
field_data_cache
,
...
@@ -269,7 +269,7 @@ def get_course_info_section_module(request, course, section_key):
...
@@ -269,7 +269,7 @@ def get_course_info_section_module(request, course, section_key):
)
)
def
get_course_info_section
(
request
,
course
,
section_key
):
def
get_course_info_section
(
request
,
user
,
course
,
section_key
):
"""
"""
This returns the snippet of html to be rendered on the course info page,
This returns the snippet of html to be rendered on the course info page,
given the key for the section.
given the key for the section.
...
@@ -280,7 +280,7 @@ def get_course_info_section(request, course, section_key):
...
@@ -280,7 +280,7 @@ def get_course_info_section(request, course, section_key):
- updates
- updates
- guest_updates
- guest_updates
"""
"""
info_module
=
get_course_info_section_module
(
request
,
course
,
section_key
)
info_module
=
get_course_info_section_module
(
request
,
user
,
course
,
section_key
)
html
=
''
html
=
''
if
info_module
is
not
None
:
if
info_module
is
not
None
:
...
...
lms/djangoapps/courseware/tests/test_courses.py
View file @
96e64464
...
@@ -277,7 +277,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
...
@@ -277,7 +277,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
def
test_get_course_info_section_render
(
self
):
def
test_get_course_info_section_render
(
self
):
# Test render works okay
# Test render works okay
course_info
=
get_course_info_section
(
self
.
request
,
self
.
course
,
'handouts'
)
course_info
=
get_course_info_section
(
self
.
request
,
self
.
request
.
user
,
self
.
course
,
'handouts'
)
self
.
assertEqual
(
course_info
,
u"<a href='/c4x/edX/toy/asset/handouts_sample_handout.txt'>Sample</a>"
)
self
.
assertEqual
(
course_info
,
u"<a href='/c4x/edX/toy/asset/handouts_sample_handout.txt'>Sample</a>"
)
# Test when render raises an exception
# Test when render raises an exception
...
@@ -285,7 +285,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
...
@@ -285,7 +285,7 @@ class CoursesRenderTest(ModuleStoreTestCase):
mock_module_render
.
return_value
=
mock
.
MagicMock
(
mock_module_render
.
return_value
=
mock
.
MagicMock
(
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
)
)
course_info
=
get_course_info_section
(
self
.
request
,
self
.
course
,
'handouts'
)
course_info
=
get_course_info_section
(
self
.
request
,
self
.
request
.
user
,
self
.
course
,
'handouts'
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
def
test_get_course_about_section_render
(
self
):
def
test_get_course_about_section_render
(
self
):
...
@@ -315,7 +315,7 @@ class XmlCoursesRenderTest(ModuleStoreTestCase):
...
@@ -315,7 +315,7 @@ class XmlCoursesRenderTest(ModuleStoreTestCase):
request
=
get_request_for_user
(
UserFactory
.
create
())
request
=
get_request_for_user
(
UserFactory
.
create
())
# Test render works okay. Note the href is different in XML courses.
# Test render works okay. Note the href is different in XML courses.
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
course_info
=
get_course_info_section
(
request
,
request
.
user
,
course
,
'handouts'
)
self
.
assertEqual
(
course_info
,
"<a href='/static/toy/handouts/sample_handout.txt'>Sample</a>"
)
self
.
assertEqual
(
course_info
,
"<a href='/static/toy/handouts/sample_handout.txt'>Sample</a>"
)
# Test when render raises an exception
# Test when render raises an exception
...
@@ -323,7 +323,7 @@ class XmlCoursesRenderTest(ModuleStoreTestCase):
...
@@ -323,7 +323,7 @@ class XmlCoursesRenderTest(ModuleStoreTestCase):
mock_module_render
.
return_value
=
mock
.
MagicMock
(
mock_module_render
.
return_value
=
mock
.
MagicMock
(
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
)
)
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
course_info
=
get_course_info_section
(
request
,
request
.
user
,
course
,
'handouts'
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
...
...
lms/djangoapps/courseware/tests/test_masquerade.py
View file @
96e64464
...
@@ -41,6 +41,11 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -41,6 +41,11 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
# working properly, we must use start dates and set a start date in the past (otherwise the access
# working properly, we must use start dates and set a start date in the past (otherwise the access
# checks exist prematurely).
# checks exist prematurely).
self
.
course
=
CourseFactory
.
create
(
number
=
'masquerade-test'
,
metadata
=
{
'start'
:
datetime
.
now
(
UTC
())})
self
.
course
=
CourseFactory
.
create
(
number
=
'masquerade-test'
,
metadata
=
{
'start'
:
datetime
.
now
(
UTC
())})
# Creates info page and puts random data in it for specific student info page test
self
.
info_page
=
ItemFactory
.
create
(
category
=
"course_info"
,
parent_location
=
self
.
course
.
location
,
data
=
"OOGIE BLOOGIE"
,
display_name
=
"updates"
)
self
.
chapter
=
ItemFactory
.
create
(
self
.
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
parent_location
=
self
.
course
.
location
,
category
=
"chapter"
,
category
=
"chapter"
,
...
@@ -89,6 +94,18 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -89,6 +94,18 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
)
return
self
.
client
.
get
(
url
)
return
self
.
client
.
get
(
url
)
def
get_course_info_page
(
self
):
"""
Returns the server response for course info page.
"""
url
=
reverse
(
'info'
,
kwargs
=
{
'course_id'
:
unicode
(
self
.
course
.
id
),
}
)
return
self
.
client
.
get
(
url
)
def
_create_mock_json_request
(
self
,
user
,
body
,
method
=
'POST'
,
session
=
None
):
def
_create_mock_json_request
(
self
,
user
,
body
,
method
=
'POST'
,
session
=
None
):
"""
"""
Returns a mock JSON request for the specified user
Returns a mock JSON request for the specified user
...
@@ -298,6 +315,24 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
...
@@ -298,6 +315,24 @@ class TestStaffMasqueradeAsSpecificStudent(StaffMasqueradeTestCase, ProblemSubmi
self
.
login_student
()
self
.
login_student
()
self
.
assertEqual
(
self
.
get_progress_detail
(),
u'2/2'
)
self
.
assertEqual
(
self
.
get_progress_detail
(),
u'2/2'
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_masquerade_as_specific_student_course_info
(
self
):
"""
Test masquerading as a specific user for course info page.
We login with login_staff and check course info page content if it's working and then we
set masquerade to view same page as a specific student and test if it's working or not.
"""
# Log in as staff, and check we can see the info page.
self
.
login_staff
()
content
=
self
.
get_course_info_page
()
.
content
self
.
assertIn
(
"OOGIE BLOOGIE"
,
content
)
# Masquerade as the student, and check we can see the info page.
self
.
update_masquerade
(
role
=
'student'
,
user_name
=
self
.
student_user
.
username
)
content
=
self
.
get_course_info_page
()
.
content
self
.
assertIn
(
"OOGIE BLOOGIE"
,
content
)
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
TestGetMasqueradingGroupId
(
StaffMasqueradeTestCase
):
class
TestGetMasqueradingGroupId
(
StaffMasqueradeTestCase
):
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
96e64464
...
@@ -1152,7 +1152,7 @@ class TestHtmlModifiers(ModuleStoreTestCase):
...
@@ -1152,7 +1152,7 @@ class TestHtmlModifiers(ModuleStoreTestCase):
def
test_get_course_info_section
(
self
):
def
test_get_course_info_section
(
self
):
self
.
course
.
static_asset_path
=
"toy_course_dir"
self
.
course
.
static_asset_path
=
"toy_course_dir"
get_course_info_section
(
self
.
request
,
self
.
course
,
"handouts"
)
get_course_info_section
(
self
.
request
,
self
.
request
.
user
,
self
.
course
,
"handouts"
)
# NOTE: check handouts output...right now test course seems to have no such content
# NOTE: check handouts output...right now test course seems to have no such content
# at least this makes sure get_course_info_section returns without exception
# at least this makes sure get_course_info_section returns without exception
...
...
lms/djangoapps/courseware/views.py
View file @
96e64464
...
@@ -704,9 +704,9 @@ def course_info(request, course_id):
...
@@ -704,9 +704,9 @@ def course_info(request, course_id):
url_to_enroll
=
marketing_link
(
'COURSES'
)
url_to_enroll
=
marketing_link
(
'COURSES'
)
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
CourseEnrollment
.
is_enrolled
(
user
,
course
.
id
)
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
CourseEnrollment
.
is_enrolled
(
user
,
course
.
id
)
context
=
{
context
=
{
'request'
:
request
,
'request'
:
request
,
'masquerade_user'
:
user
,
'course_id'
:
course_key
.
to_deprecated_string
(),
'course_id'
:
course_key
.
to_deprecated_string
(),
'cache'
:
None
,
'cache'
:
None
,
'course'
:
course
,
'course'
:
course
,
...
...
lms/djangoapps/mobile_api/course_info/views.py
View file @
96e64464
...
@@ -37,7 +37,7 @@ class CourseUpdatesList(generics.ListAPIView):
...
@@ -37,7 +37,7 @@ class CourseUpdatesList(generics.ListAPIView):
@mobile_course_access
()
@mobile_course_access
()
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
course_updates_module
=
get_course_info_section_module
(
request
,
course
,
'updates'
)
course_updates_module
=
get_course_info_section_module
(
request
,
request
.
user
,
course
,
'updates'
)
update_items
=
get_course_update_items
(
course_updates_module
)
update_items
=
get_course_update_items
(
course_updates_module
)
updates_to_show
=
[
updates_to_show
=
[
...
@@ -77,7 +77,7 @@ class CourseHandoutsList(generics.ListAPIView):
...
@@ -77,7 +77,7 @@ class CourseHandoutsList(generics.ListAPIView):
@mobile_course_access
()
@mobile_course_access
()
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
def
list
(
self
,
request
,
course
,
*
args
,
**
kwargs
):
course_handouts_module
=
get_course_info_section_module
(
request
,
course
,
'handouts'
)
course_handouts_module
=
get_course_info_section_module
(
request
,
request
.
user
,
course
,
'handouts'
)
if
course_handouts_module
:
if
course_handouts_module
:
handouts_html
=
course_handouts_module
.
data
handouts_html
=
course_handouts_module
.
data
handouts_html
=
replace_static_urls
(
handouts_html
=
replace_static_urls
(
...
...
lms/templates/courseware/info.html
View file @
96e64464
...
@@ -58,7 +58,7 @@ $(document).ready(function(){
...
@@ -58,7 +58,7 @@ $(document).ready(function(){
% endif
% endif
<h1>
${_("Course Updates
&
News")}
</h1>
<h1>
${_("Course Updates
&
News")}
</h1>
${get_course_info_section(request, course, 'updates')}
${get_course_info_section(request,
masquerade_user,
course, 'updates')}
</section>
</section>
<section
aria-label=
"${_('Handout Navigation')}"
class=
"handouts"
>
<section
aria-label=
"${_('Handout Navigation')}"
class=
"handouts"
>
% if False:
% if False:
...
@@ -67,16 +67,16 @@ $(document).ready(function(){
...
@@ -67,16 +67,16 @@ $(document).ready(function(){
% endif
% endif
<h1>
${_(course.info_sidebar_name)}
</h1>
<h1>
${_(course.info_sidebar_name)}
</h1>
${get_course_info_section(request, course, 'handouts')}
${get_course_info_section(request,
masquerade_user,
course, 'handouts')}
</section>
</section>
% else:
% else:
<section
class=
"updates"
>
<section
class=
"updates"
>
<h1>
${_("Course Updates
&
News")}
</h1>
<h1>
${_("Course Updates
&
News")}
</h1>
${get_course_info_section(request, course, 'guest_updates')}
${get_course_info_section(request,
masquerade_user,
course, 'guest_updates')}
</section>
</section>
<section
aria-label=
"${_('Handout Navigation')}"
class=
"handouts"
>
<section
aria-label=
"${_('Handout Navigation')}"
class=
"handouts"
>
<h1>
${_("Course Handouts")}
</h1>
<h1>
${_("Course Handouts")}
</h1>
${get_course_info_section(request, course, 'guest_handouts')}
${get_course_info_section(request,
masquerade_user,
course, 'guest_handouts')}
</section>
</section>
% endif
% endif
</div>
</div>
...
...
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