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
d9e0ba45
Commit
d9e0ba45
authored
Jul 26, 2016
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first round of self review and code review
parent
7d690dde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
17 deletions
+13
-17
common/djangoapps/util/milestones_helpers.py
+9
-17
lms/djangoapps/course_api/blocks/transformers/tests/test_milestones.py
+4
-0
No files found.
common/djangoapps/util/milestones_helpers.py
View file @
d9e0ba45
...
@@ -338,6 +338,8 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone)
...
@@ -338,6 +338,8 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone)
def
get_course_content_milestones
(
course_id
,
content_id
,
relationship
,
user_id
=
None
):
def
get_course_content_milestones
(
course_id
,
content_id
,
relationship
,
user_id
=
None
):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
Uses the request cache to store all of a user's
milestones
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
return
[]
return
[]
...
@@ -347,26 +349,16 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
...
@@ -347,26 +349,16 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
request_cache_dict
=
request_cache
.
get_cache
(
REQUEST_CACHE_NAME
)
request_cache_dict
=
request_cache
.
get_cache
(
REQUEST_CACHE_NAME
)
if
user_id
not
in
request_cache_dict
:
if
user_id
not
in
request_cache_dict
:
request_cache_dict
[
user_id
]
=
milestones_api
.
get_course_content_milestones
(
request_cache_dict
[
user_id
]
=
{}
if
relationship
not
in
request_cache_dict
[
user_id
]:
request_cache_dict
[
user_id
][
'requires'
]
=
milestones_api
.
get_course_content_milestones
(
course_key
=
course_id
,
course_key
=
course_id
,
relationship
=
relationship
,
user
=
{
"id"
:
user_id
}
user
=
{
"id"
:
user_id
}
)
)
milestones_for_content
=
[]
if
relationship
==
"requires"
:
return
[
m
for
m
in
request_cache_dict
[
user_id
][
relationship
]
if
m
[
'content_id'
]
==
content_id
]
for
milestone
in
request_cache_dict
[
user_id
]:
if
milestone
[
"content_id"
]
==
content_id
and
milestone
[
"requirements"
]:
milestones_for_content
.
append
(
milestone
)
if
relationship
==
"fulfills"
:
for
milestone
in
request_cache_dict
[
user_id
]:
if
milestone
[
"namespace"
]
.
contains
(
content_id
)
and
milestone
[
"requirements"
]:
milestones_for_content
.
append
(
milestone
)
return
milestones_api
.
get_course_content_milestones
(
course_id
,
content_id
,
relationship
,
user
=
{
"id"
:
user_id
}
)
def
remove_course_content_user_milestones
(
course_key
,
content_key
,
user
,
relationship
):
def
remove_course_content_user_milestones
(
course_key
,
content_key
,
user
,
relationship
):
...
...
lms/djangoapps/course_api/blocks/transformers/tests/test_milestones.py
View file @
d9e0ba45
...
@@ -10,6 +10,7 @@ from lms.djangoapps.course_blocks.transformers.tests.helpers import CourseStruct
...
@@ -10,6 +10,7 @@ from lms.djangoapps.course_blocks.transformers.tests.helpers import CourseStruct
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.keys
import
UsageKey
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.core.lib.gating
import
api
as
gating_api
from
request_cache.middleware
import
RequestCache
from
student.tests.factories
import
CourseEnrollmentFactory
from
student.tests.factories
import
CourseEnrollmentFactory
from
..milestones
import
MilestonesTransformer
from
..milestones
import
MilestonesTransformer
...
@@ -160,6 +161,9 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
...
@@ -160,6 +161,9 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
self
.
setup_gated_section
(
self
.
blocks
[
gated_block_ref
],
self
.
blocks
[
gating_block_ref
])
self
.
setup_gated_section
(
self
.
blocks
[
gated_block_ref
],
self
.
blocks
[
gating_block_ref
])
self
.
get_blocks_and_check_against_expected
(
self
.
user
,
expected_blocks_before_completion
)
self
.
get_blocks_and_check_against_expected
(
self
.
user
,
expected_blocks_before_completion
)
# We clear the request cache to simulate a new request in the LMS.
RequestCache
.
clear_request_cache
()
# mock the api that the lms gating api calls to get the score for each block to always return 1 (ie 100%)
# mock the api that the lms gating api calls to get the score for each block to always return 1 (ie 100%)
with
patch
(
'gating.api.get_module_score'
,
Mock
(
return_value
=
1
)):
with
patch
(
'gating.api.get_module_score'
,
Mock
(
return_value
=
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