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
8acd1bb1
Commit
8acd1bb1
authored
Jul 26, 2016
by
sanfordstudent
Committed by
GitHub
Jul 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13090 from edx/sstudent/TNL-5071
adding request cache for milestones
parents
a1e93f61
f02889e8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
55 deletions
+63
-55
common/djangoapps/util/milestones_helpers.py
+52
-47
lms/djangoapps/course_api/blocks/transformers/tests/test_milestones.py
+8
-3
lms/djangoapps/gating/api.py
+3
-4
openedx/core/lib/gating/api.py
+0
-1
No files found.
common/djangoapps/util/milestones_helpers.py
View file @
8acd1bb1
This diff is collapsed.
Click to expand it.
lms/djangoapps/course_api/blocks/transformers/tests/test_milestones.py
View file @
8acd1bb1
...
@@ -158,7 +158,12 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
...
@@ -158,7 +158,12 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
"""
"""
self
.
course
.
enable_subsection_gating
=
True
self
.
course
.
enable_subsection_gating
=
True
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
)
with
self
.
assertNumQueries
(
3
):
self
.
get_blocks_and_check_against_expected
(
self
.
user
,
expected_blocks_before_completion
)
# clear the request cache to simulate a new request
self
.
clear_caches
()
# 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
)):
...
@@ -169,8 +174,8 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
...
@@ -169,8 +174,8 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
self
.
course
,
self
.
course
,
UsageKey
.
from_string
(
unicode
(
self
.
blocks
[
gating_block_child
]
.
location
)),
UsageKey
.
from_string
(
unicode
(
self
.
blocks
[
gating_block_child
]
.
location
)),
self
.
user
.
id
)
self
.
user
.
id
)
with
self
.
assertNumQueries
(
2
):
self
.
get_blocks_and_check_against_expected
(
self
.
user
,
self
.
ALL_BLOCKS_EXCEPT_SPECIAL
)
self
.
get_blocks_and_check_against_expected
(
self
.
user
,
self
.
ALL_BLOCKS_EXCEPT_SPECIAL
)
def
test_staff_access
(
self
):
def
test_staff_access
(
self
):
"""
"""
...
...
lms/djangoapps/gating/api.py
View file @
8acd1bb1
...
@@ -7,10 +7,9 @@ import json
...
@@ -7,10 +7,9 @@ import json
from
collections
import
defaultdict
from
collections
import
defaultdict
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
milestones
import
api
as
milestones_api
from
openedx.core.lib.gating
import
api
as
gating_api
from
openedx.core.lib.gating
import
api
as
gating_api
from
lms.djangoapps.grades.module_grades
import
get_module_score
from
lms.djangoapps.grades.module_grades
import
get_module_score
from
util
import
milestones_helpers
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -81,6 +80,6 @@ def evaluate_prerequisite(course, prereq_content_key, user_id):
...
@@ -81,6 +80,6 @@ def evaluate_prerequisite(course, prereq_content_key, user_id):
)
)
if
score
>=
min_score
:
if
score
>=
min_score
:
milestones_
api
.
add_user_milestone
({
'id'
:
user_id
},
prereq_milestone
)
milestones_
helpers
.
add_user_milestone
({
'id'
:
user_id
},
prereq_milestone
)
else
:
else
:
milestones_
api
.
remove_user_milestone
({
'id'
:
user_id
},
prereq_milestone
)
milestones_
helpers
.
remove_user_milestone
({
'id'
:
user_id
},
prereq_milestone
)
openedx/core/lib/gating/api.py
View file @
8acd1bb1
...
@@ -9,7 +9,6 @@ from opaque_keys.edx.keys import UsageKey
...
@@ -9,7 +9,6 @@ from opaque_keys.edx.keys import UsageKey
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
openedx.core.lib.gating.exceptions
import
GatingValidationError
from
openedx.core.lib.gating.exceptions
import
GatingValidationError
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
# This is used to namespace gating-specific milestones
# This is used to namespace gating-specific milestones
...
...
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