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
53444342
Commit
53444342
authored
Jun 20, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #218 from edx/cale/pep8-e128
Clean up pep8 E128 issues
parents
d687a2ae
308fe26b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
102 additions
and
70 deletions
+102
-70
lms/djangoapps/foldit/tests.py
+39
-23
lms/djangoapps/foldit/views.py
+14
-6
lms/djangoapps/instructor_task/models.py
+9
-7
lms/djangoapps/lms_migration/migrate.py
+6
-4
lms/djangoapps/open_ended_grading/staff_grading_service.py
+8
-4
lms/djangoapps/static_template_view/tests.py
+19
-18
lms/djangoapps/static_template_view/views.py
+5
-4
lms/lib/comment_client/legacy.py
+2
-4
No files found.
lms/djangoapps/foldit/tests.py
View file @
53444342
...
...
@@ -95,13 +95,19 @@ class FolditTestCase(TestCase):
response
=
self
.
make_puzzle_score_request
([
1
,
2
],
[
0.078034
,
0.080000
])
self
.
assertEqual
(
response
.
content
,
json
.
dumps
(
[{
"OperationID"
:
"SetPlayerPuzzleScores"
,
"Value"
:
[{
"PuzzleID"
:
1
,
"Status"
:
"Success"
},
{
"PuzzleID"
:
2
,
"Status"
:
"Success"
}]}]))
[{
"OperationID"
:
"SetPlayerPuzzleScores"
,
"Value"
:
[
{
"PuzzleID"
:
1
,
"Status"
:
"Success"
},
{
"PuzzleID"
:
2
,
"Status"
:
"Success"
}
]
}]
))
def
test_SetPlayerPuzzleScores_multiple
(
self
):
...
...
@@ -126,9 +132,11 @@ class FolditTestCase(TestCase):
self
.
assertEqual
(
len
(
top_10
),
1
)
# Floats always get in the way, so do almostequal
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
better_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
better_score
),
delta
=
0.5
)
# reporting a worse score shouldn't
worse_score
=
0.065
...
...
@@ -137,9 +145,11 @@ class FolditTestCase(TestCase):
top_10
=
Score
.
get_tops_n
(
10
,
puzzle_id
)
self
.
assertEqual
(
len
(
top_10
),
1
)
# should still be the better score
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
better_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
better_score
),
delta
=
0.5
)
def
test_SetPlayerPuzzleScores_manyplayers
(
self
):
"""
...
...
@@ -150,28 +160,34 @@ class FolditTestCase(TestCase):
puzzle_id
=
[
'1'
]
player1_score
=
0.08
player2_score
=
0.02
response1
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player1_score
,
self
.
user
)
response1
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player1_score
,
self
.
user
)
# There should now be a score in the db.
top_10
=
Score
.
get_tops_n
(
10
,
puzzle_id
)
self
.
assertEqual
(
len
(
top_10
),
1
)
self
.
assertEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
player1_score
))
response2
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player2_score
,
self
.
user2
)
response2
=
self
.
make_puzzle_score_request
(
puzzle_id
,
player2_score
,
self
.
user2
)
# There should now be two scores in the db
top_10
=
Score
.
get_tops_n
(
10
,
puzzle_id
)
self
.
assertEqual
(
len
(
top_10
),
2
)
# Top score should be player2_score. Second should be player1_score
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
player2_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
1
][
'score'
],
Score
.
display_score
(
player1_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
0
][
'score'
],
Score
.
display_score
(
player2_score
),
delta
=
0.5
)
self
.
assertAlmostEqual
(
top_10
[
1
][
'score'
],
Score
.
display_score
(
player1_score
),
delta
=
0.5
)
# Top score user should be self.user2.username
self
.
assertEqual
(
top_10
[
0
][
'username'
],
self
.
user2
.
username
)
...
...
lms/djangoapps/foldit/views.py
View file @
53444342
...
...
@@ -36,9 +36,13 @@ def foldit_ops(request):
"Success"
:
"false"
,
"ErrorString"
:
"Verification failed"
,
"ErrorCode"
:
"VerifyFailed"
})
log
.
warning
(
"Verification of SetPlayerPuzzleScores failed:"
+
"user
%
s, scores json
%
r, verify
%
r"
,
request
.
user
,
puzzle_scores_json
,
pz_verify_json
)
log
.
warning
(
"Verification of SetPlayerPuzzleScores failed:"
"user
%
s, scores json
%
r, verify
%
r"
,
request
.
user
,
puzzle_scores_json
,
pz_verify_json
)
else
:
# This is needed because we are not getting valid json - the
# value of ScoreType is an unquoted string. Right now regexes are
...
...
@@ -65,9 +69,13 @@ def foldit_ops(request):
"Success"
:
"false"
,
"ErrorString"
:
"Verification failed"
,
"ErrorCode"
:
"VerifyFailed"
})
log
.
warning
(
"Verification of SetPuzzlesComplete failed:"
+
" user
%
s, puzzles json
%
r, verify
%
r"
,
request
.
user
,
puzzles_complete_json
,
pc_verify_json
)
log
.
warning
(
"Verification of SetPuzzlesComplete failed:"
" user
%
s, puzzles json
%
r, verify
%
r"
,
request
.
user
,
puzzles_complete_json
,
pc_verify_json
)
else
:
puzzles_complete
=
json
.
loads
(
puzzles_complete_json
)
responses
.
append
(
save_complete
(
request
.
user
,
puzzles_complete
))
...
...
lms/djangoapps/instructor_task/models.py
View file @
53444342
...
...
@@ -84,13 +84,15 @@ class InstructorTask(models.Model):
raise
ValueError
(
msg
)
# create the task, then save it:
instructor_task
=
cls
(
course_id
=
course_id
,
task_type
=
task_type
,
task_id
=
task_id
,
task_key
=
task_key
,
task_input
=
json_task_input
,
task_state
=
QUEUING
,
requester
=
requester
)
instructor_task
=
cls
(
course_id
=
course_id
,
task_type
=
task_type
,
task_id
=
task_id
,
task_key
=
task_key
,
task_input
=
json_task_input
,
task_state
=
QUEUING
,
requester
=
requester
)
instructor_task
.
save_now
()
return
instructor_task
...
...
lms/djangoapps/lms_migration/migrate.py
View file @
53444342
...
...
@@ -118,10 +118,12 @@ def manage_modulestores(request, reload_dir=None, commit_id=None):
html
+=
'<h2>Courses loaded in the modulestore</h2>'
html
+=
'<ol>'
for
cdir
,
course
in
def_ms
.
courses
.
items
():
html
+=
'<li><a href="
%
s/migrate/reload/
%
s">
%
s</a> (
%
s)</li>'
%
(
settings
.
MITX_ROOT_URL
,
escape
(
cdir
),
escape
(
cdir
),
course
.
location
.
url
())
html
+=
'<li><a href="
%
s/migrate/reload/
%
s">
%
s</a> (
%
s)</li>'
%
(
settings
.
MITX_ROOT_URL
,
escape
(
cdir
),
escape
(
cdir
),
course
.
location
.
url
()
)
html
+=
'</ol>'
#----------------------------------------
...
...
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
53444342
...
...
@@ -270,8 +270,10 @@ def get_problem_list(request, course_id):
mimetype
=
"application/json"
)
except
GradingServiceError
:
#This is a dev_facing_error
log
.
exception
(
"Error from staff grading service in open ended grading. server url: {0}"
.
format
(
staff_grading_service
()
.
url
))
log
.
exception
(
"Error from staff grading service in open "
"ended grading. server url: {0}"
.
format
(
staff_grading_service
()
.
url
)
)
#This is a staff_facing_error
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
STAFF_ERROR_MESSAGE
}))
...
...
@@ -285,8 +287,10 @@ def _get_next(course_id, grader_id, location):
return
staff_grading_service
()
.
get_next
(
course_id
,
location
,
grader_id
)
except
GradingServiceError
:
#This is a dev facing error
log
.
exception
(
"Error from staff grading service in open ended grading. server url: {0}"
.
format
(
staff_grading_service
()
.
url
))
log
.
exception
(
"Error from staff grading service in open "
"ended grading. server url: {0}"
.
format
(
staff_grading_service
()
.
url
)
)
#This is a staff_facing_error
return
json
.
dumps
({
'success'
:
False
,
'error'
:
STAFF_ERROR_MESSAGE
})
...
...
lms/djangoapps/static_template_view/tests.py
View file @
53444342
...
...
@@ -21,23 +21,24 @@ class SimpleTest(TestCase):
"""
# since I had to remap files, pedantically test all press releases
# published to date. Decent positive test while we're at it.
all_releases
=
[
"/press/mit-and-harvard-announce-edx"
,
"/press/uc-berkeley-joins-edx"
,
"/press/edX-announces-proctored-exam-testing"
,
"/press/elsevier-collaborates-with-edx"
,
"/press/ut-joins-edx"
,
"/press/cengage-to-provide-book-content"
,
"/press/gates-foundation-announcement"
,
"/press/wellesley-college-joins-edx"
,
"/press/georgetown-joins-edx"
,
"/press/spring-courses"
,
"/press/lewin-course-announcement"
,
"/press/bostonx-announcement"
,
"/press/eric-lander-secret-of-life"
,
"/press/edx-expands-internationally"
,
"/press/xblock_announcement"
,
"/press/stanford-to-work-with-edx"
,
]
all_releases
=
[
"/press/mit-and-harvard-announce-edx"
,
"/press/uc-berkeley-joins-edx"
,
"/press/edX-announces-proctored-exam-testing"
,
"/press/elsevier-collaborates-with-edx"
,
"/press/ut-joins-edx"
,
"/press/cengage-to-provide-book-content"
,
"/press/gates-foundation-announcement"
,
"/press/wellesley-college-joins-edx"
,
"/press/georgetown-joins-edx"
,
"/press/spring-courses"
,
"/press/lewin-course-announcement"
,
"/press/bostonx-announcement"
,
"/press/eric-lander-secret-of-life"
,
"/press/edx-expands-internationally"
,
"/press/xblock_announcement"
,
"/press/stanford-to-work-with-edx"
,
]
for
rel
in
all_releases
:
response
=
self
.
client
.
get
(
rel
)
...
...
@@ -55,7 +56,7 @@ class SimpleTest(TestCase):
response
=
self
.
client
.
get
(
"/press/../homework.html"
)
self
.
assertEqual
(
response
.
status_code
,
404
)
# "." in is ascii 2E
# "." in is ascii 2E
response
=
self
.
client
.
get
(
"/press/
%2
E
%2
E/homework.html"
)
self
.
assertEqual
(
response
.
status_code
,
404
)
lms/djangoapps/static_template_view/views.py
View file @
53444342
...
...
@@ -15,10 +15,11 @@ from util.cache import cache_if_anonymous
valid_templates
=
[]
if
settings
.
STATIC_GRAB
:
valid_templates
=
valid_templates
+
[
'server-down.html'
,
'server-error.html'
'server-overloaded.html'
,
]
valid_templates
=
valid_templates
+
[
'server-down.html'
,
'server-error.html'
'server-overloaded.html'
,
]
def
index
(
request
,
template
):
...
...
lms/lib/comment_client/legacy.py
View file @
53444342
...
...
@@ -5,16 +5,14 @@ def delete_threads(commentable_id, *args, **kwargs):
def
get_threads
(
commentable_id
,
recursive
=
False
,
query_params
=
{},
*
args
,
**
kwargs
):
default_params
=
{
'page'
:
1
,
'per_page'
:
20
,
'recursive'
:
recursive
}
attributes
=
dict
(
default_params
.
items
()
+
query_params
.
items
())
response
=
_perform_request
(
'get'
,
_url_for_threads
(
commentable_id
),
\
attributes
,
*
args
,
**
kwargs
)
response
=
_perform_request
(
'get'
,
_url_for_threads
(
commentable_id
),
attributes
,
*
args
,
**
kwargs
)
return
response
.
get
(
'collection'
,
[]),
response
.
get
(
'page'
,
1
),
response
.
get
(
'num_pages'
,
1
)
def
search_threads
(
course_id
,
recursive
=
False
,
query_params
=
{},
*
args
,
**
kwargs
):
default_params
=
{
'page'
:
1
,
'per_page'
:
20
,
'course_id'
:
course_id
,
'recursive'
:
recursive
}
attributes
=
dict
(
default_params
.
items
()
+
query_params
.
items
())
response
=
_perform_request
(
'get'
,
_url_for_search_threads
(),
\
attributes
,
*
args
,
**
kwargs
)
response
=
_perform_request
(
'get'
,
_url_for_search_threads
(),
attributes
,
*
args
,
**
kwargs
)
return
response
.
get
(
'collection'
,
[]),
response
.
get
(
'page'
,
1
),
response
.
get
(
'num_pages'
,
1
)
...
...
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