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
869ad9aa
Commit
869ad9aa
authored
Dec 20, 2017
by
Bill Filler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bfiller/gated-content-block' into bfiller/gated-content-combined
parents
67e98b72
ce919e8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
common/lib/xmodule/xmodule/seq_module.py
+19
-0
openedx/core/lib/gating/api.py
+29
-0
openedx/core/lib/gating/services.py
+16
-0
No files found.
common/lib/xmodule/xmodule/seq_module.py
View file @
869ad9aa
...
@@ -298,6 +298,8 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
...
@@ -298,6 +298,8 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
else
:
else
:
# check if prerequiste has been met
# check if prerequiste has been met
prereq_met
,
prereq_meta_info
=
self
.
_compute_is_prereq_met
(
True
)
prereq_met
,
prereq_meta_info
=
self
.
_compute_is_prereq_met
(
True
)
if
prereq_met
and
not
self
.
_is_gate_fulfilled
():
banner_text
=
_
(
'This section is a prerequiste. You must complete this section in order to unlock additional content.'
)
fragment
=
Fragment
()
fragment
=
Fragment
()
params
=
{
params
=
{
...
@@ -323,6 +325,23 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
...
@@ -323,6 +325,23 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
return
fragment
return
fragment
def
_is_gate_fulfilled
(
self
):
"""
Determines if this section is a prereq and has any unfulfilled milestones.
Returns:
True if section has no unfufilled milestones or is not a prerequiste.
False otherwise
"""
gating_service
=
self
.
runtime
.
service
(
self
,
'gating'
)
if
gating_service
:
fulfilled
=
gating_service
.
is_gate_fulfilled
(
self
.
course_id
,
self
.
location
,
self
.
runtime
.
user_id
)
return
fulfilled
return
True
def
_is_prereq_required
(
self
):
def
_is_prereq_required
(
self
):
"""
"""
Checks whether a prerequiste is required for this Section
Checks whether a prerequiste is required for this Section
...
...
openedx/core/lib/gating/api.py
View file @
869ad9aa
...
@@ -306,6 +306,34 @@ def get_gated_content(course, user):
...
@@ -306,6 +306,34 @@ def get_gated_content(course, user):
]
]
def
is_gate_fulfilled
(
course_key
,
gating_content_key
,
user_id
):
"""
Determines if a prerequiste section specified by gating_content_key
has any unfulfilled milestones.
Arguments:
course_key (CourseUsageLocator): Course locator
gating_content_key (BlockUsageLocator): The locator for the section content
user_id: The id of the user
Returns:
Returns True if section has no unfufilled milestones or is not a prerequiste.
Returns False otherwise
"""
gating_milestone
=
get_gating_milestone
(
course_key
,
gating_content_key
,
"fulfills"
)
if
not
gating_milestone
:
return
True
unfulfilled_milestones
=
[
m
[
'content_id'
]
for
m
in
milestones_helpers
.
get_course_content_milestones
(
course_key
,
None
,
'requires'
,
user_id
)
if
m
[
'namespace'
]
==
gating_milestone
[
'namespace'
]
]
return
not
unfulfilled_milestones
def
compute_is_prereq_met
(
content_id
,
user_id
,
recalc_on_unmet
=
False
):
def
compute_is_prereq_met
(
content_id
,
user_id
,
recalc_on_unmet
=
False
):
"""
"""
Returns true if the prequiste has been met for a given milestone.
Returns true if the prequiste has been met for a given milestone.
...
@@ -329,6 +357,7 @@ def compute_is_prereq_met(content_id, user_id, recalc_on_unmet=False):
...
@@ -329,6 +357,7 @@ def compute_is_prereq_met(content_id, user_id, recalc_on_unmet=False):
'requires'
,
'requires'
,
user_id
user_id
)
)
prereq_met
=
not
unfulfilled_milestones
prereq_met
=
not
unfulfilled_milestones
prereq_meta_info
=
{
'url'
:
None
,
'display_name'
:
None
}
prereq_meta_info
=
{
'url'
:
None
,
'display_name'
:
None
}
...
...
openedx/core/lib/gating/services.py
View file @
869ad9aa
...
@@ -37,3 +37,19 @@ class GatingService(object):
...
@@ -37,3 +37,19 @@ class GatingService(object):
dict or None: The gating milestone dict or None
dict or None: The gating milestone dict or None
"""
"""
return
gating_api
.
get_gating_milestone
(
course_key
,
content_key
,
relationship
)
return
gating_api
.
get_gating_milestone
(
course_key
,
content_key
,
relationship
)
def
is_gate_fulfilled
(
self
,
course_key
,
gating_content_key
,
user_id
):
"""
Determines if a prerequiste section specified by gating_content_key
has any unfulfilled milestones.
Arguments:
course_key (CourseUsageLocator): Course locator
gating_content_key (BlockUsageLocator): The locator for the section content
user_id: The id of the user
Returns:
Returns True if section has no unfufilled milestones or is not a prerequiste.
Returns False otherwise
"""
return
gating_api
.
is_gate_fulfilled
(
course_key
,
gating_content_key
,
user_id
)
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