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
3aedae9e
Commit
3aedae9e
authored
Nov 29, 2017
by
Bessie Steinberg
Committed by
Bill Filler
Nov 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deduplicate the get blocks function
parent
c04f9ffa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
34 deletions
+24
-34
openedx/features/course_experience/utils.py
+21
-32
openedx/features/course_experience/views/course_outline.py
+3
-2
No files found.
openedx/features/course_experience/utils.py
View file @
3aedae9e
...
...
@@ -8,29 +8,9 @@ from lms.djangoapps.course_blocks.utils import get_student_module_as_dict
from
request_cache.middleware
import
request_cached
from
xmodule.modulestore.django
import
modulestore
#TODO: what does request_cached do?
@request_cached
def
get_all_course_blocks
(
request
,
course_id
):
#TODO: add description
course_key
=
CourseKey
.
from_string
(
course_id
)
course_usage_key
=
modulestore
()
.
make_course_usage_key
(
course_key
)
# TODO: dedup this code
# TODO: :have this only be called once per outline render fragment
all_blocks
=
get_blocks
(
request
,
course_usage_key
,
user
=
request
.
user
,
nav_depth
=
3
,
requested_fields
=
[
'children'
,
'display_name'
,
'type'
,
'due'
,
'graded'
,
'special_exam_info'
,
'format'
],
block_types_filter
=
[
'course'
,
'chapter'
,
'sequential'
]
)
return
all_blocks
@request_cached
def
get_course_outline_block_tree
(
request
,
course_id
):
def
get_course_outline_block_tree
(
request
,
course_id
,
all_blocks
=
None
):
"""
Returns the root block of the course outline, with children as blocks.
"""
...
...
@@ -80,18 +60,9 @@ def get_course_outline_block_tree(request, course_id):
block
[
'children'
][
-
1
][
'last_accessed'
]
=
True
course_key
=
CourseKey
.
from_string
(
course_id
)
course_usage_key
=
modulestore
()
.
make_course_usage_key
(
course_key
)
# TODO: dedup this code
# TODO: :have this only be called once per outline render fragment
all_blocks
=
get_blocks
(
request
,
course_usage_key
,
user
=
request
.
user
,
nav_depth
=
3
,
requested_fields
=
[
'children'
,
'display_name'
,
'type'
,
'due'
,
'graded'
,
'special_exam_info'
,
'format'
],
block_types_filter
=
[
'course'
,
'chapter'
,
'sequential'
]
)
if
all_blocks
is
None
:
all_blocks
=
get_all_course_blocks
(
request
,
course_id
)
course_outline_root_block
=
all_blocks
[
'blocks'
]
.
get
(
all_blocks
[
'root'
],
None
)
if
course_outline_root_block
:
...
...
@@ -101,4 +72,22 @@ def get_course_outline_block_tree(request, course_id):
return
course_outline_root_block
# TODO: what does request_cached do?
# TODO: this annotation breaks the build why?
# @request_cached
def
get_all_course_blocks
(
request
,
course_id
):
#TODO: add description
course_key
=
CourseKey
.
from_string
(
course_id
)
course_usage_key
=
modulestore
()
.
make_course_usage_key
(
course_key
)
all_blocks
=
get_blocks
(
request
,
course_usage_key
,
user
=
request
.
user
,
nav_depth
=
3
,
requested_fields
=
[
'children'
,
'display_name'
,
'type'
,
'due'
,
'graded'
,
'special_exam_info'
,
'format'
],
block_types_filter
=
[
'course'
,
'chapter'
,
'sequential'
]
)
return
all_blocks
openedx/features/course_experience/views/course_outline.py
View file @
3aedae9e
...
...
@@ -25,9 +25,8 @@ class CourseOutlineFragmentView(EdxFragmentView):
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
course_overview
=
get_course_overview_with_access
(
request
.
user
,
'load'
,
course_key
,
check_if_enrolled
=
True
)
# TODO: only generate all course blocks once
course_block_tree
=
get_course_outline_block_tree
(
request
,
course_id
)
all_course_blocks
=
get_all_course_blocks
(
request
,
course_id
)
course_block_tree
=
get_course_outline_block_tree
(
request
,
course_id
,
all_course_blocks
)
if
not
course_block_tree
:
return
None
...
...
@@ -48,11 +47,13 @@ class CourseOutlineFragmentView(EdxFragmentView):
course_content_milestones
=
{}
#TODO: use cache not the get_all method
all_course_prereqs
=
get_all_course_content_milestones
(
course_key
,
relationship
=
'requires'
,
user_id
=
None
)
#TODO: use cache not the get_all method
unfulfilled_prereqs
=
get_all_course_content_milestones
(
course_key
,
relationship
=
'requires'
,
...
...
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