Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
1d6d2f2a
Commit
1d6d2f2a
authored
10 years ago
by
zubair-arbi
Browse files
Options
Downloads
Patches
Plain Diff
set position to default value if POST request don't have position argument
TNL-922
parent
8a685cec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/seq_module.py
+7
-1
7 additions, 1 deletion
common/lib/xmodule/xmodule/seq_module.py
lms/djangoapps/courseware/tests/test_module_render.py
+39
-0
39 additions, 0 deletions
lms/djangoapps/courseware/tests/test_module_render.py
with
46 additions
and
1 deletion
common/lib/xmodule/xmodule/seq_module.py
+
7
−
1
View file @
1d6d2f2a
...
...
@@ -88,7 +88,13 @@ class SequenceModule(SequenceFields, XModule):
def
handle_ajax
(
self
,
dispatch
,
data
):
# TODO: bounds checking
'''
get = request.POST instance
'''
if
dispatch
==
'
goto_position
'
:
self
.
position
=
int
(
data
[
'
position
'
])
# set position to default value if either 'position' argument not
# found in request or it is a non-positive integer
position
=
data
.
get
(
'
position
'
,
u
'
1
'
)
if
position
.
isdigit
()
and
int
(
position
)
>
0
:
self
.
position
=
int
(
position
)
else
:
self
.
position
=
1
return
json
.
dumps
({
'
success
'
:
True
})
raise
NotFoundError
(
'
Unexpected dispatch type
'
)
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_module_render.py
+
39
−
0
View file @
1d6d2f2a
# -*- coding: utf-8 -*-
"""
Test for lms courseware app, module render unit
"""
...
...
@@ -177,6 +178,44 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertEquals
(
403
,
response
.
status_code
)
self
.
assertEquals
(
'
Unauthenticated
'
,
response
.
content
)
def
test_missing_position_handler
(
self
):
"""
Test that sending POST request without or invalid position argument don
'
t raise server error
"""
self
.
client
.
login
(
username
=
self
.
mock_user
.
username
,
password
=
"
test
"
)
dispatch_url
=
reverse
(
'
xblock_handler
'
,
args
=
[
self
.
course_key
.
to_deprecated_string
(),
quote_slashes
(
self
.
course_key
.
make_usage_key
(
'
videosequence
'
,
'
Toy_Videos
'
).
to_deprecated_string
()),
'
xmodule_handler
'
,
'
goto_position
'
]
)
response
=
self
.
client
.
post
(
dispatch_url
)
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'
position
'
:
''
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'
position
'
:
'
-1
'
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'
position
'
:
"
string
"
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'
position
'
:
u
"
Φυσικά
"
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
response
=
self
.
client
.
post
(
dispatch_url
,
{
'
position
'
:
None
})
self
.
assertEqual
(
200
,
response
.
status_code
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
),
{
'
success
'
:
True
})
@ddt.data
(
'
pure
'
,
'
vertical
'
)
@XBlock.register_temp_plugin
(
PureXBlock
,
identifier
=
'
pure
'
)
def
test_rebinding_same_user
(
self
,
block_type
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment