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
0ca70266
Commit
0ca70266
authored
Mar 13, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MRQ: Add message popup to MRQ, upon any click on submit
parent
b362bc34
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
18 deletions
+38
-18
mentoring/mrq.py
+1
-0
mentoring/public/css/questionnaire.css
+6
-3
mentoring/public/js/questionnaire.js
+24
-14
mentoring/questionnaire.py
+4
-1
mentoring/templates/html/mrqblock_choices.html
+1
-0
mentoring/templates/xml/mentoring_default.xml
+2
-0
No files found.
mentoring/mrq.py
View file @
0ca70266
...
@@ -78,6 +78,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
...
@@ -78,6 +78,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
'submissions'
:
submissions
,
'submissions'
:
submissions
,
'completed'
:
completed
,
'completed'
:
completed
,
'choices'
:
results
,
'choices'
:
results
,
'message'
:
self
.
message
,
}
}
log
.
debug
(
u'MRQ submissions result:
%
s'
,
result
)
log
.
debug
(
u'MRQ submissions result:
%
s'
,
result
)
return
result
return
result
mentoring/public/css/questionnaire.css
View file @
0ca70266
...
@@ -30,7 +30,8 @@
...
@@ -30,7 +30,8 @@
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.mentoring
.choices
.choice-tips
{
.mentoring
.choices
.choice-tips
,
.mentoring
.choices
.choice-message
{
display
:
none
;
display
:
none
;
color
:
#fff
;
color
:
#fff
;
position
:
absolute
;
position
:
absolute
;
...
@@ -51,11 +52,13 @@
...
@@ -51,11 +52,13 @@
font-family
:
arial
;
font-family
:
arial
;
}
}
.mentoring
.choices
.choice-tips
.tip-choice-group
{
.mentoring
.choices
.choice-tips
.tip-choice-group
,
.mentoring
.choices
.choice-message
.message-content
{
position
:
relative
;
position
:
relative
;
}
}
.mentoring
.choices
.choice-tips
.tip-choice-group
.close
{
.mentoring
.choices
.choice-tips
.close
,
.mentoring
.choices
.choice-message
.close
{
background-image
:
url({{ close_icon_url }})
;
background-image
:
url({{ close_icon_url }})
;
cursor
:
pointer
;
cursor
:
pointer
;
position
:
absolute
;
position
:
absolute
;
...
...
mentoring/public/js/questionnaire.js
View file @
0ca70266
...
@@ -36,18 +36,34 @@ function MRQBlock(runtime, element) {
...
@@ -36,18 +36,34 @@ function MRQBlock(runtime, element) {
},
},
handleSubmit
:
function
(
result
)
{
handleSubmit
:
function
(
result
)
{
var
messageDOM
=
$
(
'.choice-message'
,
element
),
allPopupsDOM
=
$
(
'.choice-tips, .choice-message'
,
element
),
clearPopupEvents
=
function
()
{
allPopupsDOM
.
hide
();
$
(
'.close'
,
allPopupsDOM
).
off
(
'click'
);
},
showPopup
=
function
(
popupDOM
)
{
clearPopupEvents
();
popupDOM
.
show
();
popupDOM
.
on
(
'click'
,
function
()
{
clearPopupEvents
();
choiceTipsDOM
.
hide
();
});
};
if
(
result
.
message
)
{
messageDOM
.
html
(
'<div class="message-content"><div class="close"></div>'
+
result
.
message
+
'</div>'
);
showPopup
(
messageDOM
);
}
$
.
each
(
result
.
choices
,
function
(
index
,
choice
)
{
$
.
each
(
result
.
choices
,
function
(
index
,
choice
)
{
var
choiceInputDOM
=
$
(
'.choice input[value='
+
choice
.
value
+
']'
,
element
),
var
choiceInputDOM
=
$
(
'.choice input[value='
+
choice
.
value
+
']'
,
element
),
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
),
choiceDOM
=
choiceInputDOM
.
closest
(
'.choice'
),
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
),
choiceResultDOM
=
$
(
'.choice-result'
,
choiceDOM
),
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
),
choiceTipsDOM
=
$
(
'.choice-tips'
,
choiceDOM
),
choiceTipsCloseDOM
,
choiceTipsCloseDOM
;
clearPopupEvents
;
clearPopupEvents
=
function
()
{
$
(
'.choice-tips'
,
element
).
hide
();
$
(
'.choice-tips .close'
).
off
(
'click'
);
};
if
(
choice
.
completed
)
{
if
(
choice
.
completed
)
{
choiceResultDOM
.
removeClass
(
'incorrect'
).
addClass
(
'correct'
);
choiceResultDOM
.
removeClass
(
'incorrect'
).
addClass
(
'correct'
);
...
@@ -59,13 +75,7 @@ function MRQBlock(runtime, element) {
...
@@ -59,13 +75,7 @@ function MRQBlock(runtime, element) {
choiceTipsCloseDOM
=
$
(
'.close'
,
choiceTipsDOM
);
choiceTipsCloseDOM
=
$
(
'.close'
,
choiceTipsDOM
);
choiceResultDOM
.
off
(
'click'
).
on
(
'click'
,
function
()
{
choiceResultDOM
.
off
(
'click'
).
on
(
'click'
,
function
()
{
clearPopupEvents
();
showPopup
(
choiceTipsDOM
);
choiceTipsDOM
.
show
();
choiceTipsCloseDOM
.
on
(
'click'
,
function
()
{
clearPopupEvents
();
choiceTipsDOM
.
hide
();
});
});
});
});
});
}
}
...
...
mentoring/questionnaire.py
View file @
0ca70266
...
@@ -50,6 +50,7 @@ class QuestionnaireAbstractBlock(LightChild):
...
@@ -50,6 +50,7 @@ class QuestionnaireAbstractBlock(LightChild):
"""
"""
type
=
String
(
help
=
"Type of questionnaire"
,
scope
=
Scope
.
content
,
default
=
"choices"
)
type
=
String
(
help
=
"Type of questionnaire"
,
scope
=
Scope
.
content
,
default
=
"choices"
)
question
=
String
(
help
=
"Question to ask the student"
,
scope
=
Scope
.
content
,
default
=
""
)
question
=
String
(
help
=
"Question to ask the student"
,
scope
=
Scope
.
content
,
default
=
""
)
message
=
String
(
help
=
"General feedback provided when submiting"
,
scope
=
Scope
.
content
,
default
=
""
)
valid_types
=
(
'choices'
)
valid_types
=
(
'choices'
)
...
@@ -57,8 +58,10 @@ class QuestionnaireAbstractBlock(LightChild):
...
@@ -57,8 +58,10 @@ class QuestionnaireAbstractBlock(LightChild):
def
init_block_from_node
(
cls
,
block
,
node
,
attr
):
def
init_block_from_node
(
cls
,
block
,
node
,
attr
):
block
.
light_children
=
[]
block
.
light_children
=
[]
for
child_id
,
xml_child
in
enumerate
(
node
):
for
child_id
,
xml_child
in
enumerate
(
node
):
if
xml_child
.
tag
==
"question"
:
if
xml_child
.
tag
==
'question'
:
block
.
question
=
xml_child
.
text
block
.
question
=
xml_child
.
text
elif
xml_child
.
tag
==
'message'
and
xml_child
.
get
(
'type'
)
==
'on-submit'
:
block
.
message
=
(
xml_child
.
text
or
''
)
.
strip
()
else
:
else
:
cls
.
add_node_as_child
(
block
,
xml_child
,
child_id
)
cls
.
add_node_as_child
(
block
,
xml_child
,
child_id
)
...
...
mentoring/templates/html/mrqblock_choices.html
View file @
0ca70266
...
@@ -10,5 +10,6 @@
...
@@ -10,5 +10,6 @@
<div
class=
"choice-tips"
></div>
<div
class=
"choice-tips"
></div>
</div>
</div>
{% endfor %}
{% endfor %}
<div
class=
"choice-message"
></div>
</div>
</div>
</fieldset>
</fieldset>
mentoring/templates/xml/mentoring_default.xml
View file @
0ca70266
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
<tip
require=
"gracefulness"
>
This MRQ is indeed very graceful
</tip>
<tip
require=
"gracefulness"
>
This MRQ is indeed very graceful
</tip>
<tip
require=
"elegance,beauty"
>
This is something everyone has to like about this MRQ
</tip>
<tip
require=
"elegance,beauty"
>
This is something everyone has to like about this MRQ
</tip>
<tip
reject=
"bugs"
>
Nah, there isn't any!
</tip>
<tip
reject=
"bugs"
>
Nah, there isn't any!
</tip>
<message
type=
"on-submit"
>
Thank you for answering!
</message>
</mrq>
</mrq>
<message
type=
"completed"
>
<message
type=
"completed"
>
...
...
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