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
8bc35e10
Commit
8bc35e10
authored
Nov 26, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for custom message displayed upon quizz completion
parent
067a241a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
12 deletions
+40
-12
mentoring/mentoring.py
+34
-9
static/js/mentoring.js
+4
-1
static/js/quizz.js
+1
-1
templates/html/mentoring.html
+1
-1
No files found.
mentoring/mentoring.py
View file @
8bc35e10
...
@@ -32,17 +32,27 @@ class MentoringBlock(XBlock):
...
@@ -32,17 +32,27 @@ class MentoringBlock(XBlock):
prompt
=
String
(
help
=
"Initial text displayed with the text input"
,
default
=
'Your answer?'
,
scope
=
Scope
.
content
)
prompt
=
String
(
help
=
"Initial text displayed with the text input"
,
default
=
'Your answer?'
,
scope
=
Scope
.
content
)
attempted
=
Boolean
(
help
=
"Has the student attempted this mentoring step?"
,
default
=
False
,
scope
=
Scope
.
user_state
)
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
=
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
=
""
)
has_children
=
True
has_children
=
True
def
get_children_fragment
(
self
,
context
):
@classmethod
fragment
=
Fragment
()
def
parse_xml
(
cls
,
node
,
runtime
,
keys
):
named_child_frags
=
[]
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
for
child_id
in
self
.
children
:
# pylint: disable=E1101
child
=
self
.
runtime
.
get_block
(
child_id
)
for
child
in
node
:
frag
=
self
.
runtime
.
render_child
(
child
,
"mentoring_view"
,
context
)
if
child
.
tag
==
'message'
:
fragment
.
add_frag_resources
(
frag
)
if
child
.
get
(
'type'
)
==
'completed'
:
named_child_frags
.
append
((
child
.
name
,
frag
))
block
.
completed_message
=
child
.
text
return
fragment
,
named_child_frags
else
:
raise
ValueError
,
u'Invalid value for message type: `{}`'
.
format
(
child
.
get
(
'type'
))
else
:
block
.
runtime
.
add_node_as_child
(
block
,
child
)
for
name
,
value
in
node
.
items
():
if
name
in
block
.
fields
:
setattr
(
block
,
name
,
value
)
return
block
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
"""
"""
...
@@ -70,6 +80,16 @@ class MentoringBlock(XBlock):
...
@@ -70,6 +80,16 @@ class MentoringBlock(XBlock):
return
fragment
return
fragment
def
get_children_fragment
(
self
,
context
):
fragment
=
Fragment
()
named_child_frags
=
[]
for
child_id
in
self
.
children
:
# pylint: disable=E1101
child
=
self
.
runtime
.
get_block
(
child_id
)
frag
=
self
.
runtime
.
render_child
(
child
,
"mentoring_view"
,
context
)
fragment
.
add_frag_resources
(
frag
)
named_child_frags
.
append
((
child
.
name
,
frag
))
return
fragment
,
named_child_frags
@XBlock.json_handler
@XBlock.json_handler
def
submit
(
self
,
submissions
,
suffix
=
''
):
def
submit
(
self
,
submissions
,
suffix
=
''
):
log
.
info
(
u'Received submissions: {}'
.
format
(
submissions
))
log
.
info
(
u'Received submissions: {}'
.
format
(
submissions
))
...
@@ -87,10 +107,15 @@ class MentoringBlock(XBlock):
...
@@ -87,10 +107,15 @@ class MentoringBlock(XBlock):
completed
=
completed
and
child_result
[
'completed'
]
completed
=
completed
and
child_result
[
'completed'
]
self
.
completed
=
bool
(
completed
)
self
.
completed
=
bool
(
completed
)
if
self
.
completed
:
message
=
self
.
completed_message
else
:
message
=
''
return
{
return
{
'submitResults'
:
submit_results
,
'submitResults'
:
submit_results
,
'completed'
:
self
.
completed
,
'completed'
:
self
.
completed
,
'message'
:
message
,
}
}
def
studio_view
(
self
,
context
):
def
studio_view
(
self
,
context
):
...
...
static/js/mentoring.js
View file @
8bc35e10
...
@@ -15,7 +15,7 @@ function MentoringBlock(runtime, element) {
...
@@ -15,7 +15,7 @@ function MentoringBlock(runtime, element) {
}
}
function
handleSubmitResults
(
results
)
{
function
handleSubmitResults
(
results
)
{
$
(
'.
quizz-tip
s'
,
element
).
empty
();
$
(
'.
message
s'
,
element
).
empty
();
$
.
each
(
results
.
submitResults
||
[],
function
(
index
,
submitResult
)
{
$
.
each
(
results
.
submitResults
||
[],
function
(
index
,
submitResult
)
{
var
input
=
submitResult
[
0
],
var
input
=
submitResult
[
0
],
...
@@ -25,6 +25,9 @@ function MentoringBlock(runtime, element) {
...
@@ -25,6 +25,9 @@ function MentoringBlock(runtime, element) {
$
(
'.progress'
,
element
).
data
(
'completed'
,
results
.
completed
?
'True'
:
'False'
)
$
(
'.progress'
,
element
).
data
(
'completed'
,
results
.
completed
?
'True'
:
'False'
)
renderProgress
();
renderProgress
();
// Messages should only be displayed upon hitting 'submit', not on page reload
$
(
'.messages'
,
element
).
append
(
results
.
message
);
}
}
$
(
element
).
find
(
'.submit'
).
bind
(
'click'
,
function
()
{
$
(
element
).
find
(
'.submit'
).
bind
(
'click'
,
function
()
{
...
...
static/js/quizz.js
View file @
8bc35e10
...
@@ -10,7 +10,7 @@ function QuizzBlock(runtime, element) {
...
@@ -10,7 +10,7 @@ function QuizzBlock(runtime, element) {
}
}
},
},
handleSubmit
:
function
(
result
)
{
handleSubmit
:
function
(
result
)
{
var
tipsDom
=
$
(
element
).
parent
().
find
(
'.
quizz-tip
s'
),
var
tipsDom
=
$
(
element
).
parent
().
find
(
'.
message
s'
),
tipHtml
=
(
result
||
{}).
tip
||
''
;
tipHtml
=
(
result
||
{}).
tip
||
''
;
if
(
tipHtml
)
{
if
(
tipHtml
)
{
...
...
templates/html/mentoring.html
View file @
8bc35e10
...
@@ -6,5 +6,5 @@
...
@@ -6,5 +6,5 @@
<span
class=
"progress"
data-completed=
"{{ self.completed }}"
>
<span
class=
"progress"
data-completed=
"{{ self.completed }}"
>
<span
class=
'indicator'
></span>
<span
class=
'indicator'
></span>
</span>
</span>
<div
class=
"
quizz-tip
s"
></div>
<div
class=
"
message
s"
></div>
</div>
</div>
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