Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
f0c75daa
Commit
f0c75daa
authored
Dec 31, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds dependency between mentoring blocks & warning message when not met
parent
9918a144
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
7 deletions
+58
-7
mentoring/mentoring.py
+39
-5
static/css/mentoring.css
+12
-1
templates/html/mentoring.html
+6
-0
templates/xml
+1
-1
No files found.
mentoring/mentoring.py
View file @
f0c75daa
...
...
@@ -27,9 +27,20 @@ class MentoringBlock(XBlock, XBlockWithChildrenFragmentsMixin):
student is a) provided mentoring advices and asked to alter his answer, or b) is given the
ok to continue.
"""
attempted
=
Boolean
(
help
=
"Has the student attempted this mentoring step?"
,
default
=
False
,
scope
=
Scope
.
user_state
)
completed
=
Boolean
(
help
=
"Has the student completed this mentoring step?"
,
default
=
False
,
scope
=
Scope
.
user_state
)
completed_message
=
String
(
help
=
"Message to display upon completion"
,
scope
=
Scope
.
content
,
default
=
""
)
attempted
=
Boolean
(
help
=
"Has the student attempted this mentoring step?"
,
default
=
False
,
scope
=
Scope
.
user_state
)
completed
=
Boolean
(
help
=
"Has the student completed this mentoring step?"
,
default
=
False
,
scope
=
Scope
.
user_state
)
completed_message
=
String
(
help
=
"Message to display upon completion"
,
scope
=
Scope
.
content
,
default
=
""
)
next_step
=
String
(
help
=
"url_name of the next step the student must complete (global to all blocks)"
,
default
=
'mentoring_first'
,
scope
=
Scope
.
preferences
)
followed_by
=
String
(
help
=
"url_name of the step after the current mentoring block in workflow"
,
default
=
None
,
scope
=
Scope
.
content
)
url_name
=
String
(
help
=
"Name of the current step, used for URL building"
,
default
=
'mentoring'
,
scope
=
Scope
.
content
)
enforce_dependency
=
Boolean
(
help
=
"Should the next step be the current block to complete?"
,
default
=
True
,
scope
=
Scope
.
content
)
has_children
=
True
@classmethod
...
...
@@ -57,6 +68,7 @@ class MentoringBlock(XBlock, XBlockWithChildrenFragmentsMixin):
fragment
.
add_content
(
render_template
(
'templates/html/mentoring.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
'missing_dependency_url'
:
self
.
has_missing_dependency
and
self
.
next_step_url
,
}))
fragment
.
add_css
(
load_resource
(
'static/css/mentoring.css'
))
fragment
.
add_javascript
(
load_resource
(
'static/js/vendor/underscore-min.js'
))
...
...
@@ -71,6 +83,21 @@ class MentoringBlock(XBlock, XBlockWithChildrenFragmentsMixin):
return
fragment
@property
def
has_missing_dependency
(
self
):
"""
Returns True if the student needs to complete another step before being able to complete
the current one, and False otherwise
"""
return
self
.
enforce_dependency
and
(
not
self
.
completed
)
and
(
self
.
next_step
!=
self
.
url_name
)
@property
def
next_step_url
(
self
):
"""
Returns the URL of the next step's page
"""
return
'/jump_to_id/{}'
.
format
(
self
.
next_step
)
@XBlock.json_handler
def
submit
(
self
,
submissions
,
suffix
=
''
):
log
.
info
(
u'Received submissions: {}'
.
format
(
submissions
))
...
...
@@ -87,12 +114,19 @@ class MentoringBlock(XBlock, XBlockWithChildrenFragmentsMixin):
child
.
save
()
completed
=
completed
and
child_result
[
'completed'
]
self
.
completed
=
bool
(
completed
)
if
self
.
completed
:
if
completed
:
message
=
self
.
completed_message
else
:
message
=
''
if
self
.
has_missing_dependency
:
completed
=
False
message
=
'You need to complete all previous steps before being able to complete '
+
\
'the current one.'
elif
completed
and
self
.
next_step
==
self
.
url_name
:
self
.
next_step
=
self
.
followed_by
self
.
completed
=
bool
(
completed
)
return
{
'submitResults'
:
submit_results
,
'completed'
:
self
.
completed
,
...
...
static/css/mentoring.css
View file @
f0c75daa
.messages
{
.me
ntoring
.me
ssages
{
margin-top
:
10px
;
}
.mentoring
.warning
{
border
:
1px
solid
;
margin
:
10px
0px
;
padding
:
15px
10px
;
-moz-border-radius
:
.5em
;
-webkit-border-radius
:
.5em
;
border-radius
:
.5em
;
color
:
#9F6000
;
background-color
:
#FEEFB3
;
}
templates/html/mentoring.html
View file @
f0c75daa
<div
class=
"mentoring"
>
{% if missing_dependency_url %}
<div
class=
"warning"
>
You need to complete
<a
href=
"{{ missing_dependency_url }}"
>
the following step
</a>
before
attempting this step.
</div>
{% endif %}
{% for name, c in named_children %}
{{c.body_html|safe}}
{% endfor %}
...
...
xml
@
4b9773a8
Subproject commit
83c5f4eef7b995e3720b80f67c70eaf634966298
Subproject commit
4b9773a832c06d91da2b2446bdf2682be28de3bc
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