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
f448b63c
Commit
f448b63c
authored
Dec 13, 2017
by
Bill Filler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize calls to calculate subsection grade
parent
61a38ec8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
common/lib/xmodule/xmodule/seq_module.py
+3
-3
openedx/core/lib/gating/api.py
+8
-8
openedx/core/lib/gating/services.py
+2
-2
No files found.
common/lib/xmodule/xmodule/seq_module.py
View file @
f448b63c
...
...
@@ -297,7 +297,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
banner_text
=
_
(
'This subsection is unlocked for learners when they meet the prerequisite requirements.'
)
else
:
# check if prerequiste has been met
prereq_met
,
prereq_meta_info
=
self
.
_is_prereq_met
(
True
)
prereq_met
,
prereq_meta_info
=
self
.
_
compute_
is_prereq_met
(
True
)
fragment
=
Fragment
()
params
=
{
...
...
@@ -339,7 +339,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
return
False
def
_is_prereq_met
(
self
,
recalc_on_unmet
):
def
_
compute_
is_prereq_met
(
self
,
recalc_on_unmet
):
"""
Evaluate if the user has completed the prerequiste
...
...
@@ -352,7 +352,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
"""
gating_service
=
self
.
runtime
.
service
(
self
,
'gating'
)
if
gating_service
:
return
gating_service
.
is_prereq_met
(
self
.
location
,
self
.
runtime
.
user_id
,
recalc_on_unmet
)
return
gating_service
.
compute_
is_prereq_met
(
self
.
location
,
self
.
runtime
.
user_id
,
recalc_on_unmet
)
return
False
,
{}
...
...
openedx/core/lib/gating/api.py
View file @
f448b63c
...
...
@@ -306,9 +306,10 @@ def get_gated_content(course, user):
]
def
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.
Will recalculate the subsection grade if specified and prereq unmet
Arguments:
content_id (BlockUsageLocator): BlockUsageLocator for the content
...
...
@@ -339,14 +340,13 @@ def is_prereq_met(content_id, user_id, recalc_on_unmet=False):
store
=
modulestore
()
with
store
.
bulk_operations
(
course_id
):
course_structure
=
get_course_blocks
(
student
,
store
.
make_course_usage_key
(
course_id
))
course
=
store
.
get_course
(
course_id
,
depth
=
0
)
subsection_grade_factory
=
SubsectionGradeFactory
(
student
,
course
,
course_structure
)
subsection_usage_key
=
UsageKey
.
from_string
(
_get_gating_block_id
(
milestone
))
subsection_structure
=
get_course_blocks
(
student
,
subsection_usage_key
)
subsection_grade_factory
=
SubsectionGradeFactory
(
student
,
None
,
subsection_structure
)
if
subsection_usage_key
in
course
_structure
:
if
subsection_usage_key
in
subsection
_structure
:
# this will force a recalcuation of the subsection grade
subsection_grade
=
subsection_grade_factory
.
update
(
course
_structure
[
subsection_usage_key
])
subsection_grade
=
subsection_grade_factory
.
update
(
subsection
_structure
[
subsection_usage_key
])
prereq_met
=
update_milestone
(
milestone
,
subsection_grade
,
milestone
,
user_id
)
prereq_meta_info
=
{
'url'
:
reverse
(
'jump_to'
,
kwargs
=
{
'course_id'
:
course_id
,
'location'
:
subsection_usage_key
}),
...
...
@@ -405,7 +405,7 @@ def _get_subsection_percentage(subsection_grade):
"""
Returns the percentage value of the given subsection_grade.
"""
return
_calculate_ratio
(
subsection_grade
.
graded_total
.
earned
,
subsection_grade
.
graded_total
.
possible
)
*
100.0
return
subsection_grade
.
percent_graded
*
100.0
def
_calculate_ratio
(
earned
,
possible
):
...
...
openedx/core/lib/gating/services.py
View file @
f448b63c
...
...
@@ -9,7 +9,7 @@ class GatingService(object):
An XBlock service to talk to the Gating api.
"""
def
is_prereq_met
(
self
,
content_id
,
user_id
,
recalc_on_unmet
=
False
):
def
compute_
is_prereq_met
(
self
,
content_id
,
user_id
,
recalc_on_unmet
=
False
):
"""
Returns true if the prequiste has been met for a given milestone
...
...
@@ -22,7 +22,7 @@ class GatingService(object):
tuple: True|False,
prereq_meta_info = { 'url': prereq_url|None, 'display_name': prereq_name|None}
"""
return
gating_api
.
is_prereq_met
(
content_id
,
user_id
,
recalc_on_unmet
)
return
gating_api
.
compute_
is_prereq_met
(
content_id
,
user_id
,
recalc_on_unmet
)
def
is_prereq_required
(
self
,
course_key
,
content_key
,
relationship
):
"""
...
...
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