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
d996c2a3
Commit
d996c2a3
authored
Jul 26, 2016
by
Sanford Student
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
per cliff's review
parent
c3d829f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
22 deletions
+21
-22
common/djangoapps/util/milestones_helpers.py
+21
-22
No files found.
common/djangoapps/util/milestones_helpers.py
View file @
d996c2a3
...
@@ -35,15 +35,14 @@ def is_entrance_exams_enabled():
...
@@ -35,15 +35,14 @@ def is_entrance_exams_enabled():
Checks to see if the Entrance Exams feature is enabled
Checks to see if the Entrance Exams feature is enabled
Use this operation instead of checking the feature flag all over the place
Use this operation instead of checking the feature flag all over the place
"""
"""
return
settings
.
FEATURES
.
get
(
'ENTRANCE_EXAMS'
,
False
)
return
settings
.
FEATURES
.
get
(
'ENTRANCE_EXAMS'
)
def
is_prerequisite_courses_enabled
():
def
is_prerequisite_courses_enabled
():
"""
"""
Returns boolean indicating prerequisite courses enabled system wide or not.
Returns boolean indicating prerequisite courses enabled system wide or not.
"""
"""
return
settings
.
FEATURES
.
get
(
'ENABLE_PREREQUISITE_COURSES'
,
False
)
\
return
settings
.
FEATURES
.
get
(
'ENABLE_PREREQUISITE_COURSES'
)
and
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
)
and
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
)
def
add_prerequisite_course
(
course_key
,
prerequisite_course_key
):
def
add_prerequisite_course
(
course_key
,
prerequisite_course_key
):
...
@@ -185,7 +184,7 @@ def fulfill_course_milestone(course_key, user):
...
@@ -185,7 +184,7 @@ def fulfill_course_milestone(course_key, user):
Marks the course specified by the given course_key as complete for the given user.
Marks the course specified by the given course_key as complete for the given user.
If any other courses require this course as a prerequisite, their milestones will be appropriately updated.
If any other courses require this course as a prerequisite, their milestones will be appropriately updated.
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
try
:
try
:
course_milestones
=
milestones_api
.
get_course_milestones
(
course_key
=
course_key
,
relationship
=
"fulfills"
)
course_milestones
=
milestones_api
.
get_course_milestones
(
course_key
=
course_key
,
relationship
=
"fulfills"
)
...
@@ -201,7 +200,7 @@ def remove_course_milestones(course_key, user, relationship):
...
@@ -201,7 +200,7 @@ def remove_course_milestones(course_key, user, relationship):
"""
"""
Remove all user milestones for the course specified by course_key.
Remove all user milestones for the course specified by course_key.
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
course_milestones
=
milestones_api
.
get_course_milestones
(
course_key
=
course_key
,
relationship
=
relationship
)
course_milestones
=
milestones_api
.
get_course_milestones
(
course_key
=
course_key
,
relationship
=
relationship
)
for
milestone
in
course_milestones
:
for
milestone
in
course_milestones
:
...
@@ -214,7 +213,7 @@ def get_required_content(course, user):
...
@@ -214,7 +213,7 @@ def get_required_content(course, user):
and if those milestones can be fulfilled via completion of a particular course content module
and if those milestones can be fulfilled via completion of a particular course content module
"""
"""
required_content
=
[]
required_content
=
[]
if
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
# Get all of the outstanding milestones for this course, for this user
# Get all of the outstanding milestones for this course, for this user
try
:
try
:
milestone_paths
=
get_course_milestones_fulfillment_paths
(
milestone_paths
=
get_course_milestones_fulfillment_paths
(
...
@@ -237,7 +236,7 @@ def milestones_achieved_by_user(user, namespace):
...
@@ -237,7 +236,7 @@ def milestones_achieved_by_user(user, namespace):
"""
"""
It would fetch list of milestones completed by user
It would fetch list of milestones completed by user
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
get_user_milestones
({
'id'
:
user
.
id
},
namespace
)
return
milestones_api
.
get_user_milestones
({
'id'
:
user
.
id
},
namespace
)
...
@@ -257,7 +256,7 @@ def seed_milestone_relationship_types():
...
@@ -257,7 +256,7 @@ def seed_milestone_relationship_types():
"""
"""
Helper method to pre-populate MRTs so the tests can run
Helper method to pre-populate MRTs so the tests can run
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
MilestoneRelationshipType
.
objects
.
create
(
name
=
'requires'
)
MilestoneRelationshipType
.
objects
.
create
(
name
=
'requires'
)
MilestoneRelationshipType
.
objects
.
create
(
name
=
'fulfills'
)
MilestoneRelationshipType
.
objects
.
create
(
name
=
'fulfills'
)
...
@@ -285,7 +284,7 @@ def add_milestone(milestone_data):
...
@@ -285,7 +284,7 @@ def add_milestone(milestone_data):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
add_milestone
(
milestone_data
)
return
milestones_api
.
add_milestone
(
milestone_data
)
...
@@ -294,7 +293,7 @@ def get_milestones(namespace):
...
@@ -294,7 +293,7 @@ def get_milestones(namespace):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
[]
return
[]
return
milestones_api
.
get_milestones
(
namespace
)
return
milestones_api
.
get_milestones
(
namespace
)
...
@@ -303,7 +302,7 @@ def get_milestone_relationship_types():
...
@@ -303,7 +302,7 @@ def get_milestone_relationship_types():
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
{}
return
{}
return
milestones_api
.
get_milestone_relationship_types
()
return
milestones_api
.
get_milestone_relationship_types
()
...
@@ -312,7 +311,7 @@ def add_course_milestone(course_id, relationship, milestone):
...
@@ -312,7 +311,7 @@ def add_course_milestone(course_id, relationship, milestone):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
add_course_milestone
(
course_id
,
relationship
,
milestone
)
return
milestones_api
.
add_course_milestone
(
course_id
,
relationship
,
milestone
)
...
@@ -321,7 +320,7 @@ def get_course_milestones(course_id):
...
@@ -321,7 +320,7 @@ def get_course_milestones(course_id):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
[]
return
[]
return
milestones_api
.
get_course_milestones
(
course_id
)
return
milestones_api
.
get_course_milestones
(
course_id
)
...
@@ -330,7 +329,7 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone)
...
@@ -330,7 +329,7 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone)
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
add_course_content_milestone
(
course_id
,
content_id
,
relationship
,
milestone
)
return
milestones_api
.
add_course_content_milestone
(
course_id
,
content_id
,
relationship
,
milestone
)
...
@@ -341,7 +340,7 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
...
@@ -341,7 +340,7 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
Uses the request cache to store all of a user's
Uses the request cache to store all of a user's
milestones
milestones
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
[]
return
[]
if
user_id
is
None
:
if
user_id
is
None
:
...
@@ -352,7 +351,7 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
...
@@ -352,7 +351,7 @@ def get_course_content_milestones(course_id, content_id, relationship, user_id=N
request_cache_dict
[
user_id
]
=
{}
request_cache_dict
[
user_id
]
=
{}
if
relationship
not
in
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
(
request_cache_dict
[
user_id
][
relationship
]
=
milestones_api
.
get_course_content_milestones
(
course_key
=
course_id
,
course_key
=
course_id
,
relationship
=
relationship
,
relationship
=
relationship
,
user
=
{
"id"
:
user_id
}
user
=
{
"id"
:
user_id
}
...
@@ -365,7 +364,7 @@ def remove_course_content_user_milestones(course_key, content_key, user, relatio
...
@@ -365,7 +364,7 @@ def remove_course_content_user_milestones(course_key, content_key, user, relatio
"""
"""
Removes the specified User-Milestone link from the system for the specified course content module.
Removes the specified User-Milestone link from the system for the specified course content module.
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
[]
return
[]
course_content_milestones
=
milestones_api
.
get_course_content_milestones
(
course_key
,
content_key
,
relationship
)
course_content_milestones
=
milestones_api
.
get_course_content_milestones
(
course_key
,
content_key
,
relationship
)
...
@@ -377,14 +376,14 @@ def remove_content_references(content_id):
...
@@ -377,14 +376,14 @@ def remove_content_references(content_id):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
remove_content_references
(
content_id
)
return
milestones_api
.
remove_content_references
(
content_id
)
def
any_unfulfilled_milestones
(
course_id
,
user_id
):
def
any_unfulfilled_milestones
(
course_id
,
user_id
):
""" Returns a boolean if user has any unfulfilled milestones """
""" Returns a boolean if user has any unfulfilled milestones """
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
False
return
False
return
bool
(
return
bool
(
get_course_milestones_fulfillment_paths
(
course_id
,
{
"id"
:
user_id
})
get_course_milestones_fulfillment_paths
(
course_id
,
{
"id"
:
user_id
})
...
@@ -395,7 +394,7 @@ def get_course_milestones_fulfillment_paths(course_id, user_id):
...
@@ -395,7 +394,7 @@ def get_course_milestones_fulfillment_paths(course_id, user_id):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
get_course_milestones_fulfillment_paths
(
return
milestones_api
.
get_course_milestones_fulfillment_paths
(
course_id
,
course_id
,
...
@@ -407,7 +406,7 @@ def add_user_milestone(user, milestone):
...
@@ -407,7 +406,7 @@ def add_user_milestone(user, milestone):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
add_user_milestone
(
user
,
milestone
)
return
milestones_api
.
add_user_milestone
(
user
,
milestone
)
...
@@ -416,6 +415,6 @@ def remove_user_milestone(user, milestone):
...
@@ -416,6 +415,6 @@ def remove_user_milestone(user, milestone):
"""
"""
Client API operation adapter/wrapper
Client API operation adapter/wrapper
"""
"""
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
,
False
):
if
not
settings
.
FEATURES
.
get
(
'MILESTONES_APP'
):
return
None
return
None
return
milestones_api
.
remove_user_milestone
(
user
,
milestone
)
return
milestones_api
.
remove_user_milestone
(
user
,
milestone
)
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