Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
d46ea873
Commit
d46ea873
authored
9 years ago
by
Awais Jibran
Browse files
Options
Downloads
Plain Diff
Merge pull request #11656 from attiyaIshaque/ai/tnl3848-list-index-out-of-range
Fix list index out of range in Textbook's chapters.
parents
a0871900
99e717fb
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/staticbook/tests.py
+11
-0
11 additions, 0 deletions
lms/djangoapps/staticbook/tests.py
lms/djangoapps/staticbook/views.py
+1
-1
1 addition, 1 deletion
lms/djangoapps/staticbook/views.py
with
12 additions
and
1 deletion
lms/djangoapps/staticbook/tests.py
+
11
−
0
View file @
d46ea873
...
...
@@ -227,6 +227,17 @@ class StaticPdfBookTest(StaticBookTest):
self
.
assertContains
(
response
,
'
file=/static/awesomesauce/{}
'
.
format
(
PORTABLE_PDF_BOOK
[
'
chapters
'
][
0
][
'
url
'
].
replace
(
'
/static/
'
,
''
)))
def
test_invalid_chapter_id
(
self
):
"""
Test that 1st chapter is displayed to the user when an invalid chapter id is provided
"""
self
.
make_course
(
pdf_textbooks
=
[
PDF_BOOK
])
invalid_chapter
=
len
(
PDF_BOOK
[
'
chapters
'
])
+
1
url
=
self
.
make_url
(
'
pdf_book
'
,
book_index
=
0
,
chapter
=
invalid_chapter
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertContains
(
response
,
"
Chapter 1 for PDF
"
)
class
StaticHtmlBookTest
(
StaticBookTest
):
"""
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/staticbook/views.py
+
1
−
1
View file @
d46ea873
...
...
@@ -99,7 +99,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
if
'
chapters
'
in
textbook
:
for
entry
in
textbook
[
'
chapters
'
]:
entry
[
'
url
'
]
=
remap_static_url
(
entry
[
'
url
'
],
course
)
if
chapter
is
not
None
:
if
chapter
is
not
None
and
int
(
chapter
)
<=
(
len
(
textbook
[
'
chapters
'
]))
:
current_chapter
=
textbook
[
'
chapters
'
][
int
(
chapter
)
-
1
]
else
:
current_chapter
=
textbook
[
'
chapters
'
][
0
]
...
...
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