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
8569cb35
Commit
8569cb35
authored
May 09, 2017
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logic error in calculating last accessed.
parent
698475f5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
openedx/features/course_experience/tests/views/test_course_outline.py
+0
-0
openedx/features/course_experience/utils.py
+7
-7
No files found.
openedx/features/course_experience/tests/views/test_course_outline.py
View file @
8569cb35
This diff is collapsed.
Click to expand it.
openedx/features/course_experience/utils.py
View file @
8569cb35
...
...
@@ -32,15 +32,15 @@ def get_course_outline_block_tree(request, course_id):
return
block
def
set_last
ed
_accessed_default
(
block
):
def
set_last_accessed_default
(
block
):
"""
Set default of False for last_accessed on all blocks.
"""
block
[
'last_accessed'
]
=
False
for
child
in
block
.
get
(
'children'
,
[]):
set_last
ed
_accessed_default
(
child
)
set_last_accessed_default
(
child
)
def
mark_last
ed
_accessed
(
user
,
course_key
,
block
):
def
mark_last_accessed
(
user
,
course_key
,
block
):
"""
Recursively marks the branch to the last accessed block.
"""
...
...
@@ -49,10 +49,10 @@ def get_course_outline_block_tree(request, course_id):
last_accessed_child_position
=
student_module_dict
.
get
(
'position'
)
if
last_accessed_child_position
and
block
.
get
(
'children'
):
block
[
'last_accessed'
]
=
True
if
l
en
(
block
[
'children'
])
<=
last_accessed_child_position
:
if
l
ast_accessed_child_position
<=
len
(
block
[
'children'
])
:
last_accessed_child_block
=
block
[
'children'
][
last_accessed_child_position
-
1
]
last_accessed_child_block
[
'last_accessed'
]
=
True
mark_last
ed
_accessed
(
user
,
course_key
,
last_accessed_child_block
)
mark_last_accessed
(
user
,
course_key
,
last_accessed_child_block
)
else
:
# We should be using an id in place of position for last accessed. However, while using position, if
# the child block is no longer accessible we'll use the last child.
...
...
@@ -72,7 +72,7 @@ def get_course_outline_block_tree(request, course_id):
course_outline_root_block
=
all_blocks
[
'blocks'
][
all_blocks
[
'root'
]]
populate_children
(
course_outline_root_block
,
all_blocks
[
'blocks'
])
set_last
ed
_accessed_default
(
course_outline_root_block
)
mark_last
ed
_accessed
(
request
.
user
,
course_key
,
course_outline_root_block
)
set_last_accessed_default
(
course_outline_root_block
)
mark_last_accessed
(
request
.
user
,
course_key
,
course_outline_root_block
)
return
course_outline_root_block
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