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
a984fbb6
Commit
a984fbb6
authored
Aug 13, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #394 from MITx/feature/victor/hide-error-modules
Hide errors from non-staff users
parents
fdee13e4
3455f8f6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
common/lib/xmodule/xmodule/error_module.py
+10
-1
lms/djangoapps/courseware/courses.py
+9
-0
lms/djangoapps/courseware/grades.py
+6
-0
lms/djangoapps/courseware/module_render.py
+3
-2
No files found.
common/lib/xmodule/xmodule/error_module.py
View file @
a984fbb6
...
@@ -27,6 +27,14 @@ class ErrorModule(XModule):
...
@@ -27,6 +27,14 @@ class ErrorModule(XModule):
'is_staff'
:
self
.
system
.
is_staff
,
'is_staff'
:
self
.
system
.
is_staff
,
})
})
def
displayable_items
(
self
):
"""Hide errors in the profile and table of contents for non-staff
users.
"""
if
self
.
system
.
is_staff
:
return
[
self
]
return
[]
class
ErrorDescriptor
(
EditingDescriptor
):
class
ErrorDescriptor
(
EditingDescriptor
):
"""
"""
Module that provides a raw editing view of broken xml.
Module that provides a raw editing view of broken xml.
...
@@ -75,7 +83,8 @@ class ErrorDescriptor(EditingDescriptor):
...
@@ -75,7 +83,8 @@ class ErrorDescriptor(EditingDescriptor):
# TODO (vshnayder): Do we need a unique slug here? Just pick a random
# TODO (vshnayder): Do we need a unique slug here? Just pick a random
# 64-bit num?
# 64-bit num?
location
=
[
'i4x'
,
org
,
course
,
'error'
,
url_name
]
location
=
[
'i4x'
,
org
,
course
,
'error'
,
url_name
]
metadata
=
{}
# stays in the xml_data
# real metadata stays in the xml_data, but add a display name
metadata
=
{
'display_name'
:
'Error '
+
url_name
}
return
cls
(
system
,
definition
,
location
=
location
,
metadata
=
metadata
)
return
cls
(
system
,
definition
,
location
=
location
,
metadata
=
metadata
)
...
...
lms/djangoapps/courseware/courses.py
View file @
a984fbb6
...
@@ -8,6 +8,7 @@ from django.conf import settings
...
@@ -8,6 +8,7 @@ from django.conf import settings
from
django.http
import
Http404
from
django.http
import
Http404
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
static_replace
import
replace_urls
,
try_staticfiles_lookup
from
static_replace
import
replace_urls
,
try_staticfiles_lookup
...
@@ -178,6 +179,14 @@ def has_staff_access_to_course_id(user, course_id):
...
@@ -178,6 +179,14 @@ def has_staff_access_to_course_id(user, course_id):
return
has_staff_access_to_course
(
user
,
loc
.
course
)
return
has_staff_access_to_course
(
user
,
loc
.
course
)
def
has_staff_access_to_location
(
user
,
location
):
"""Helper method that checks whether the user has staff access to
the course of the location.
location: something that can be passed to Location
"""
return
has_staff_access_to_course
(
user
,
Location
(
location
)
.
course
)
def
has_access_to_course
(
user
,
course
):
def
has_access_to_course
(
user
,
course
):
'''course is the .course element of a location'''
'''course is the .course element of a location'''
if
course
.
metadata
.
get
(
'ispublic'
):
if
course
.
metadata
.
get
(
'ispublic'
):
...
...
lms/djangoapps/courseware/grades.py
View file @
a984fbb6
...
@@ -146,8 +146,14 @@ def progress_summary(student, course, grader, student_module_cache):
...
@@ -146,8 +146,14 @@ def progress_summary(student, course, grader, student_module_cache):
"""
"""
chapters
=
[]
chapters
=
[]
for
c
in
course
.
get_children
():
for
c
in
course
.
get_children
():
# Don't include chapters that aren't displayable (e.g. due to error)
if
c
not
in
c
.
displayable_items
():
continue
sections
=
[]
sections
=
[]
for
s
in
c
.
get_children
():
for
s
in
c
.
get_children
():
# Same for sections
if
s
not
in
s
.
displayable_items
():
continue
graded
=
s
.
metadata
.
get
(
'graded'
,
False
)
graded
=
s
.
metadata
.
get
(
'graded'
,
False
)
scores
=
[]
scores
=
[]
for
module
in
yield_module_descendents
(
s
):
for
module
in
yield_module_descendents
(
s
):
...
...
lms/djangoapps/courseware/module_render.py
View file @
a984fbb6
...
@@ -16,7 +16,8 @@ from xmodule.exceptions import NotFoundError
...
@@ -16,7 +16,8 @@ from xmodule.exceptions import NotFoundError
from
xmodule.x_module
import
ModuleSystem
from
xmodule.x_module
import
ModuleSystem
from
xmodule_modifiers
import
replace_static_urls
,
add_histogram
,
wrap_xmodule
from
xmodule_modifiers
import
replace_static_urls
,
add_histogram
,
wrap_xmodule
from
courseware.courses
import
has_staff_access_to_course
from
courseware.courses
import
(
has_staff_access_to_course
,
has_staff_access_to_location
)
log
=
logging
.
getLogger
(
"mitx.courseware"
)
log
=
logging
.
getLogger
(
"mitx.courseware"
)
...
@@ -182,7 +183,7 @@ def get_module(user, request, location, student_module_cache, position=None):
...
@@ -182,7 +183,7 @@ def get_module(user, request, location, student_module_cache, position=None):
# a module is coming through get_html and is therefore covered
# a module is coming through get_html and is therefore covered
# by the replace_static_urls code below
# by the replace_static_urls code below
replace_urls
=
replace_urls
,
replace_urls
=
replace_urls
,
is_staff
=
user
.
is_staff
,
is_staff
=
has_staff_access_to_location
(
user
,
location
)
,
)
)
# pass position specified in URL to module through ModuleSystem
# pass position specified in URL to module through ModuleSystem
system
.
set
(
'position'
,
position
)
system
.
set
(
'position'
,
position
)
...
...
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