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
8bbc11cb
Commit
8bbc11cb
authored
Sep 10, 2013
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename stripping function, make it more explicit
parent
bc424173
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
18 deletions
+18
-18
lms/djangoapps/instructor/views/api.py
+10
-10
lms/djangoapps/instructor/views/legacy.py
+4
-4
lms/djangoapps/instructor/views/tools.py
+4
-4
No files found.
lms/djangoapps/instructor/views/api.py
View file @
8bbc11cb
...
...
@@ -32,7 +32,7 @@ import instructor_task.api
from
instructor_task.api_helper
import
AlreadyRunningError
import
instructor.enrollment
as
enrollment
from
instructor.enrollment
import
enroll_email
,
unenroll_email
from
instructor.views.tools
import
_clean_field
from
instructor.views.tools
import
strip_if_string
import
instructor.access
as
access
import
analytics.basic
import
analytics.distributions
...
...
@@ -234,7 +234,7 @@ def modify_access(request, course_id):
request
.
user
,
course_id
,
'instructor'
,
depth
=
None
)
email
=
_clean_field
(
request
.
GET
.
get
(
'email'
))
email
=
strip_if_string
(
request
.
GET
.
get
(
'email'
))
rolename
=
request
.
GET
.
get
(
'rolename'
)
action
=
request
.
GET
.
get
(
'action'
)
...
...
@@ -434,7 +434,7 @@ def get_student_progress_url(request, course_id):
'progress_url': '/../...'
}
"""
student_email
=
_clean_field
(
request
.
GET
.
get
(
'student_email'
))
student_email
=
strip_if_string
(
request
.
GET
.
get
(
'student_email'
))
user
=
User
.
objects
.
get
(
email
=
student_email
)
progress_url
=
reverse
(
'student_progress'
,
kwargs
=
{
'course_id'
:
course_id
,
'student_id'
:
user
.
id
})
...
...
@@ -475,8 +475,8 @@ def reset_student_attempts(request, course_id):
request
.
user
,
course_id
,
'staff'
,
depth
=
None
)
problem_to_reset
=
_clean_field
(
request
.
GET
.
get
(
'problem_to_reset'
))
student_email
=
_clean_field
(
request
.
GET
.
get
(
'student_email'
))
problem_to_reset
=
strip_if_string
(
request
.
GET
.
get
(
'problem_to_reset'
))
student_email
=
strip_if_string
(
request
.
GET
.
get
(
'student_email'
))
all_students
=
request
.
GET
.
get
(
'all_students'
,
False
)
in
[
'true'
,
'True'
,
True
]
delete_module
=
request
.
GET
.
get
(
'delete_module'
,
False
)
in
[
'true'
,
'True'
,
True
]
...
...
@@ -532,8 +532,8 @@ def rescore_problem(request, course_id):
all_students and student_email cannot both be present.
"""
problem_to_reset
=
_clean_field
(
request
.
GET
.
get
(
'problem_to_reset'
))
student_email
=
_clean_field
(
request
.
GET
.
get
(
'student_email'
,
False
))
problem_to_reset
=
strip_if_string
(
request
.
GET
.
get
(
'problem_to_reset'
))
student_email
=
strip_if_string
(
request
.
GET
.
get
(
'student_email'
,
False
))
all_students
=
request
.
GET
.
get
(
'all_students'
)
in
[
'true'
,
'True'
,
True
]
if
not
(
problem_to_reset
and
(
all_students
or
student_email
)):
...
...
@@ -577,8 +577,8 @@ def list_instructor_tasks(request, course_id):
- `problem_urlname` and `student_email` lists task
history for problem AND student (intersection)
"""
problem_urlname
=
_clean_field
(
request
.
GET
.
get
(
'problem_urlname'
,
False
))
student_email
=
_clean_field
(
request
.
GET
.
get
(
'student_email'
,
False
))
problem_urlname
=
strip_if_string
(
request
.
GET
.
get
(
'problem_urlname'
,
False
))
student_email
=
strip_if_string
(
request
.
GET
.
get
(
'student_email'
,
False
))
if
student_email
and
not
problem_urlname
:
return
HttpResponseBadRequest
(
...
...
@@ -694,7 +694,7 @@ def update_forum_role_membership(request, course_id):
request
.
user
,
course_id
,
FORUM_ROLE_ADMINISTRATOR
)
email
=
_clean_field
(
request
.
GET
.
get
(
'email'
))
email
=
strip_if_string
(
request
.
GET
.
get
(
'email'
))
rolename
=
request
.
GET
.
get
(
'rolename'
)
action
=
request
.
GET
.
get
(
'action'
)
...
...
lms/djangoapps/instructor/views/legacy.py
View file @
8bbc11cb
...
...
@@ -41,7 +41,7 @@ from django_comment_common.models import (Role,
FORUM_ROLE_COMMUNITY_TA
)
from
django_comment_client.utils
import
has_forum_access
from
instructor.offline_gradecalc
import
student_grades
,
offline_grades_available
from
instructor.views.tools
import
_clean_field
from
instructor.views.tools
import
strip_if_string
from
instructor_task.api
import
(
get_running_instructor_tasks
,
get_instructor_task_history
,
submit_rescore_problem_for_all_students
,
...
...
@@ -173,7 +173,7 @@ def instructor_dashboard(request, course_id):
is provided, "problem" is assumed.
"""
# remove whitespace
urlname
=
_clean_field
(
urlname
)
urlname
=
strip_if_string
(
urlname
)
# tolerate an XML suffix in the urlname
if
urlname
[
-
4
:]
==
".xml"
:
...
...
@@ -189,7 +189,7 @@ def instructor_dashboard(request, course_id):
def
get_student_from_identifier
(
unique_student_identifier
):
"""Gets a student object using either an email address or username"""
unique_student_identifier
=
_clean_field
(
unique_student_identifier
)
unique_student_identifier
=
strip_if_string
(
unique_student_identifier
)
msg
=
""
try
:
if
"@"
in
unique_student_identifier
:
...
...
@@ -1001,7 +1001,7 @@ def _add_or_remove_user_group(request, username_or_email, group, group_title, ev
to do.
"""
user
=
None
username_or_email
=
_clean_field
(
username_or_email
)
username_or_email
=
strip_if_string
(
username_or_email
)
try
:
if
'@'
in
username_or_email
:
user
=
User
.
objects
.
get
(
email
=
username_or_email
)
...
...
lms/djangoapps/instructor/views/tools.py
View file @
8bbc11cb
"""
Tools for the instructor dashboard
"""
def
_clean_field
(
field
):
if
field
:
return
field
.
strip
()
return
field
def
strip_if_string
(
value
):
if
isinstance
(
value
,
basestring
)
:
return
value
.
strip
()
return
value
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