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
996b6fb6
Commit
996b6fb6
authored
Dec 07, 2017
by
Bill Filler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more changes
parent
46aec4aa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
20 deletions
+26
-20
common/lib/xmodule/xmodule/js/src/sequence/display.js
+17
-11
common/lib/xmodule/xmodule/seq_module.py
+2
-3
lms/djangoapps/gating/signals.py
+3
-0
lms/templates/_gated_content.html
+1
-4
openedx/core/lib/gating/api.py
+3
-2
No files found.
common/lib/xmodule/xmodule/js/src/sequence/display.js
View file @
996b6fb6
...
...
@@ -7,7 +7,7 @@
this
.
Sequence
=
(
function
()
{
function
Sequence
(
element
)
{
var
self
=
this
;
//alert
("in Sequence for element" + element);
console
.
log
(
"in Sequence for element"
+
element
);
this
.
removeBookmarkIconFromActiveNavItem
=
function
(
event
)
{
return
Sequence
.
prototype
.
removeBookmarkIconFromActiveNavItem
.
apply
(
self
,
[
event
]);
};
...
...
@@ -63,18 +63,20 @@
this
.
ajaxUrl
=
this
.
el
.
data
(
'ajax-url'
);
this
.
nextUrl
=
this
.
el
.
data
(
'next-url'
);
this
.
prevUrl
=
this
.
el
.
data
(
'prev-url'
);
this
.
gateContent
=
this
.
el
.
data
(
'gate-content'
);
this
.
gateContent
=
this
.
el
.
data
(
'gate-content'
)
.
toLowerCase
()
;
this
.
prereqUrl
=
this
.
el
.
data
(
'prereq-url'
);
this
.
prereqSectionName
=
this
.
el
.
data
(
'prereq-section-name'
);
this
.
unitName
=
this
.
el
.
data
(
'unit-name'
);
this
.
scoreReached
=
this
.
el
.
data
(
'score-reached'
);
this
.
calculateScore
=
this
.
el
.
data
(
'calculate-score'
);
this
.
scoreReached
=
this
.
el
.
data
(
'score-reached'
)
.
toLowerCase
()
;
this
.
calculateScore
=
this
.
el
.
data
(
'calculate-score'
)
.
toLowerCase
()
;
this
.
keydownHandler
(
$
(
element
).
find
(
'#sequence-list .tab'
));
this
.
base_page_title
=
(
$
(
'title'
).
data
(
'base-title'
)
||
''
).
trim
();
this
.
bind
();
this
.
render
(
parseInt
(
this
.
el
.
data
(
'position'
),
10
));
if
(
this
.
calculateScore
)
{
this
.
recalcGrade
();
console
.
log
(
"calculateScore="
+
this
.
calculateScore
+
" typeof="
+
(
typeof
this
.
calculateScore
));
if
(
this
.
calculateScore
==
"True"
||
this
.
calculateScore
==
"true"
)
{
// TODO - remove setTimeout, just for testing
setTimeout
(
this
.
recalcGrade
,
200
);
}
}
...
...
@@ -111,6 +113,9 @@
self
.
sr_container
=
self
.
$
(
'.sr-is-focusable'
);
self
.
num_contents
=
self
.
contents
.
length
;
self
.
bind
();
// TODO - for some reason the content only renders for HTML
// And not for Problems/Videos. How to force rendering of
// the Xblocks?
self
.
render
(
1
);
}
);
...
...
@@ -134,14 +139,15 @@
self
.
gateContent
=
response
.
gate_content
;
self
.
scoreReached
=
response
.
score_reached
;
self
.
calculateScore
=
response
.
calculate_score
;
console
.
log
(
"scoreReached="
+
self
.
scoreReached
+
" type="
+
(
typeof
self
.
scoreReached
));
$
(
'.ui-loading'
).
hide
();
$
(
'#main-content'
).
html
(
response
.
html
);
if
(
self
.
scoreReached
)
{
if
(
self
.
scoreReached
==
true
)
{
// if we reached the score, load the contents
// after a short delay
self
.
el
.
find
(
'.icon .fa
.fa-lock'
).
removeClass
(
'fa-lock'
).
addClass
(
'fa-unlock'
);
$
(
'
.fa-lock'
).
removeClass
(
'fa-lock'
).
addClass
(
'fa-unlock'
);
$
(
'#loading-content'
).
show
();
setTimeout
(
self
.
loadSeqContents
,
6
000
);
setTimeout
(
self
.
loadSeqContents
,
3
000
);
}
}
);
...
...
@@ -240,7 +246,7 @@
* 'new_content_state' is the updated content of the problem.
* 'new_state' is the updated state of the problem.
*/
alert
(
"in addToUpdatedProblems for problemId="
+
problemId
);
console
.
log
(
"in addToUpdatedProblems for problemId="
+
problemId
);
// initialize for the current sequence if there isn't any updated problem for this position.
if
(
!
this
.
anyUpdatedProblems
(
this
.
position
))
{
this
.
updatedProblems
[
this
.
position
]
=
{};
...
...
@@ -325,7 +331,7 @@
if
(
this
.
anyUpdatedProblems
(
newPosition
))
{
$
.
each
(
this
.
updatedProblems
[
newPosition
],
function
(
problemId
,
latestData
)
{
alert
(
"updating problem index="
+
newPosition
+
" problemId="
+
problemId
);
console
.
log
(
"updating problem index="
+
newPosition
+
" problemId="
+
problemId
);
var
latestContent
,
latestResponse
;
latestContent
=
latestData
[
0
];
latestResponse
=
latestData
[
1
];
...
...
common/lib/xmodule/xmodule/seq_module.py
View file @
996b6fb6
...
...
@@ -208,7 +208,6 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
elif
dispatch
==
'recalc_grade'
:
# force a grade recalculation
unlock
=
self
.
_is_prereq_met
(
True
)
unlock
=
True
params
=
{
'gate_content'
:
not
unlock
,
...
...
@@ -350,8 +349,8 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule):
'prereq_url'
:
milestone_meta_info
[
'url'
]
if
gate_content
else
None
,
'prereq_section_name'
:
milestone_meta_info
[
'display_name'
]
if
gate_content
else
None
,
'unit_name'
:
"My Unit"
,
'score_reached'
:
False
,
'calculate_score'
:
True
'score_reached'
:
not
gate_content
,
'calculate_score'
:
gate_content
}
fragment
.
add_content
(
self
.
system
.
render_template
(
"seq_module.html"
,
params
))
...
...
lms/djangoapps/gating/signals.py
View file @
996b6fb6
...
...
@@ -6,6 +6,7 @@ from django.dispatch import receiver
from
gating
import
api
as
gating_api
from
lms.djangoapps.grades.signals.signals
import
SUBSECTION_SCORE_CHANGED
from
openedx.core.djangoapps.signals.signals
import
COURSE_GRADE_CHANGED
import
time
@receiver
(
SUBSECTION_SCORE_CHANGED
)
...
...
@@ -21,6 +22,8 @@ def evaluate_subsection_gated_milestones(**kwargs):
None
"""
subsection_grade
=
kwargs
[
'subsection_grade'
]
# TODO - for testing, remove
time
.
sleep
(
10
)
gating_api
.
evaluate_prerequisite
(
kwargs
[
'course'
],
subsection_grade
,
kwargs
.
get
(
'user'
))
...
...
lms/templates/_gated_content.html
View file @
996b6fb6
...
...
@@ -36,7 +36,7 @@ from openedx.core.djangolib.markup import HTML, Text
<p>
% if score_reached:
<h3>
<span
class=
"icon fa fa-check-circle-o"
aria-hidden=
"true"
>
&
nbsp
</span>
${_("Congratulations you have unlocked this section!")}
<span
class=
"icon fa fa-check-circle-o"
style=
"color:green"
aria-hidden=
"true"
>
&
nbsp
</span>
${_("Congratulations you have unlocked this section!")}
<div
id=
"loading-content"
class=
"ui-loading is-hidden"
>
<p>
<span
class=
"spin"
>
...
...
@@ -54,9 +54,6 @@ from openedx.core.djangolib.markup import HTML, Text
<p>
<button><a
href=
"${prereq_url}"
>
${_("Go to Prerequiste Section")}
</a></button>
</p>
<p>
<button><span
class=
"recalc-grade"
>
Recalculate Grade
</span></button>
</p>
% endif
</p>
</div>
openedx/core/lib/gating/api.py
View file @
996b6fb6
...
...
@@ -371,12 +371,11 @@ def is_prereq_met(course_id, content_id, user_id, recalc_on_unmet=False):
user_id: The id of the user
recalc_on_unmet: Recalculate the grade if prereq has not yet been met
"""
# first check source of truth.. the database
#prereq_met = milestones_api.user_has_milestone({'id': user_id}, milestone)
# if unfullfilled milestones exist it means prereq has not been met
unfulfilled_milestones
=
milestones_api
.
get_course_content_milestones
(
course_id
,
content_id
,
'requires'
,
{
'id'
:
user_id
})
prereq_met
=
not
unfulfilled_milestones
if
prereq_met
or
not
recalc_on_unmet
:
return
prereq_met
...
...
@@ -396,9 +395,11 @@ def is_prereq_met(course_id, content_id, user_id, recalc_on_unmet=False):
subsection_percentage
=
_get_subsection_percentage
(
subsection_grade
)
if
subsection_percentage
>=
min_percentage
:
prereq_met
=
True
# TODO - should save to database here or let happen through async listener?
#milestones_helpers.add_user_milestone({'id': user.id}, prereq_milestone)
else
:
prereq_met
=
False
# TODO - should save to database here or let happen through async listener
#milestones_helpers.remove_user_milestone({'id': user.id}, prereq_milestone)
return
prereq_met
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