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
1a76c1b0
Commit
1a76c1b0
authored
Apr 07, 2014
by
Alan Boudreault
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added FeedbackBlock to get a more flexible control of the popup window.
parent
5da686d1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
12 deletions
+96
-12
mentoring/__init__.py
+1
-0
mentoring/feedback.py
+56
-0
mentoring/mentoring.py
+5
-2
mentoring/public/css/questionnaire.css
+5
-5
mentoring/public/js/questionnaire.js
+2
-2
mentoring/questionnaire.py
+18
-0
mentoring/templates/html/feedback.html
+5
-0
mentoring/templates/html/mcqblock_choices.html
+1
-1
mentoring/templates/html/mcqblock_rating.html
+1
-1
mentoring/templates/html/mrqblock_choices.html
+1
-1
setup.py
+1
-0
No files found.
mentoring/__init__.py
View file @
1a76c1b0
...
@@ -8,3 +8,4 @@ from .mentoring import MentoringBlock
...
@@ -8,3 +8,4 @@ from .mentoring import MentoringBlock
from
.message
import
MentoringMessageBlock
from
.message
import
MentoringMessageBlock
from
.table
import
MentoringTableBlock
,
MentoringTableColumnBlock
,
MentoringTableColumnHeaderBlock
from
.table
import
MentoringTableBlock
,
MentoringTableColumnBlock
,
MentoringTableColumnHeaderBlock
from
.tip
import
TipBlock
from
.tip
import
TipBlock
from
.feedback
import
FeedbackBlock
mentoring/feedback.py
0 → 100644
View file @
1a76c1b0
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Harvard
#
# Authors:
# Alan Boudreault <alan@alanb.ca>
#
# This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of
# the GNU Affero General Public License (AGPL) as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version of the AGPL published by the FSF.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
#
# Imports ###########################################################
import
logging
from
.light_children
import
LightChild
,
Scope
,
String
from
.utils
import
render_template
# Globals ###########################################################
log
=
logging
.
getLogger
(
__name__
)
# Classes ###########################################################
class
FeedbackBlock
(
LightChild
):
"""
Represent a feedback block. Currently only used to set the width/heigth style but could be
useful to set a static header/body etc.
"""
width
=
String
(
help
=
"Width of the feedback popup"
,
scope
=
Scope
.
content
,
default
=
''
)
height
=
String
(
help
=
"Height of the feedback popup"
,
scope
=
Scope
.
content
,
default
=
''
)
def
render
(
self
):
"""
Returns a fragment containing the formatted feedback
"""
fragment
,
named_children
=
self
.
get_children_fragment
({})
fragment
.
add_content
(
render_template
(
'templates/html/feedback.html'
,
{
'self'
:
self
,
'named_children'
:
named_children
,
}))
return
self
.
xblock_container
.
fragment_text_rewriting
(
fragment
)
mentoring/mentoring.py
View file @
1a76c1b0
...
@@ -35,6 +35,7 @@ from xblock.fragment import Fragment
...
@@ -35,6 +35,7 @@ from xblock.fragment import Fragment
from
.light_children
import
XBlockWithLightChildren
from
.light_children
import
XBlockWithLightChildren
from
.message
import
MentoringMessageBlock
from
.message
import
MentoringMessageBlock
from
.feedback
import
FeedbackBlock
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
...
@@ -77,8 +78,10 @@ class MentoringBlock(XBlockWithLightChildren):
...
@@ -77,8 +78,10 @@ class MentoringBlock(XBlockWithLightChildren):
has_score
=
True
has_score
=
True
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
,
fragment
,
named_children
=
self
.
get_children_fragment
(
not_instance_of
=
MentoringMessageBlock
)
context
,
view_name
=
'mentoring_view'
,
not_instance_of
=
(
MentoringMessageBlock
,
FeedbackBlock
)
)
fragment
.
add_content
(
render_template
(
'templates/html/mentoring.html'
,
{
fragment
.
add_content
(
render_template
(
'templates/html/mentoring.html'
,
{
'self'
:
self
,
'self'
:
self
,
...
...
mentoring/public/css/questionnaire.css
View file @
1a76c1b0
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
}
}
.mentoring
.questionnaire
.choice-tips
,
.mentoring
.questionnaire
.choice-tips
,
.mentoring
.questionnaire
.
choice-message
{
.mentoring
.questionnaire
.
feedback
{
display
:
none
;
display
:
none
;
color
:
#fff
;
color
:
#fff
;
position
:
absolute
;
position
:
absolute
;
...
@@ -54,13 +54,13 @@
...
@@ -54,13 +54,13 @@
}
}
.mentoring
.questionnaire
.choice-tips
.tip-choice-group
,
.mentoring
.questionnaire
.choice-tips
.tip-choice-group
,
.mentoring
.questionnaire
.
choice-message
.tip-choice-group
,
.mentoring
.questionnaire
.
feedback
.tip-choice-group
,
.mentoring
.questionnaire
.
choice-message
.message-content
{
.mentoring
.questionnaire
.
feedback
.message-content
{
position
:
relative
;
position
:
relative
;
}
}
.mentoring
.questionnaire
.choice-tips
.close
,
.mentoring
.questionnaire
.choice-tips
.close
,
.mentoring
.questionnaire
.
choice-message
.close
{
.mentoring
.questionnaire
.
feedback
.close
{
background-image
:
url({{ close_icon_url }})
;
background-image
:
url({{ close_icon_url }})
;
cursor
:
pointer
;
cursor
:
pointer
;
position
:
absolute
;
position
:
absolute
;
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
}
}
.mentoring
.questionnaire
.choice-tips
p
,
.mentoring
.questionnaire
.choice-tips
p
,
.mentoring
.questionnaire
.
choice-message
p
{
.mentoring
.questionnaire
.
feedback
p
{
color
:
#fff
;
color
:
#fff
;
}
}
...
...
mentoring/public/js/questionnaire.js
View file @
1a76c1b0
// TODO: Split in two files
// TODO: Split in two files
function
MessageView
(
element
)
{
function
MessageView
(
element
)
{
return
{
return
{
messageDOM
:
$
(
'.
choice-message
'
,
element
),
messageDOM
:
$
(
'.
feedback
'
,
element
),
allPopupsDOM
:
$
(
'.choice-tips, .
choice-message
'
,
element
),
allPopupsDOM
:
$
(
'.choice-tips, .
feedback
'
,
element
),
clearPopupEvents
:
function
()
{
clearPopupEvents
:
function
()
{
this
.
allPopupsDOM
.
hide
();
this
.
allPopupsDOM
.
hide
();
$
(
'.close'
,
this
.
allPopupsDOM
).
off
(
'click'
);
$
(
'.close'
,
this
.
allPopupsDOM
).
off
(
'click'
);
...
...
mentoring/questionnaire.py
View file @
1a76c1b0
...
@@ -30,6 +30,7 @@ from xblock.fragment import Fragment
...
@@ -30,6 +30,7 @@ from xblock.fragment import Fragment
from
.choice
import
ChoiceBlock
from
.choice
import
ChoiceBlock
from
.light_children
import
LightChild
,
Scope
,
String
from
.light_children
import
LightChild
,
Scope
,
String
from
.tip
import
TipBlock
from
.tip
import
TipBlock
from
.feedback
import
FeedbackBlock
from
.utils
import
render_template
from
.utils
import
render_template
...
@@ -80,6 +81,7 @@ class QuestionnaireAbstractBlock(LightChild):
...
@@ -80,6 +81,7 @@ class QuestionnaireAbstractBlock(LightChild):
html
=
render_template
(
template_path
,
{
html
=
render_template
(
template_path
,
{
'self'
:
self
,
'self'
:
self
,
'custom_choices'
:
self
.
custom_choices
,
'custom_choices'
:
self
.
custom_choices
,
'feedback'
:
self
.
get_feedback
()
.
render
()
})
})
fragment
=
Fragment
(
html
)
fragment
=
Fragment
(
html
)
...
@@ -111,6 +113,22 @@ class QuestionnaireAbstractBlock(LightChild):
...
@@ -111,6 +113,22 @@ class QuestionnaireAbstractBlock(LightChild):
tips
.
append
(
child
)
tips
.
append
(
child
)
return
tips
return
tips
def
get_feedback
(
self
):
"""
Returns the feedback child in this block. If there is no feedback block, provide a default one.
"""
feedback
=
None
for
child
in
self
.
get_children_objects
():
if
isinstance
(
child
,
FeedbackBlock
):
feedback
=
child
break
if
feedback
is
None
:
feedback
=
FeedbackBlock
(
self
)
feedback
.
init_block_from_node
(
feedback
,[],{})
return
feedback
def
get_submission_display
(
self
,
submission
):
def
get_submission_display
(
self
,
submission
):
"""
"""
Get the human-readable version of a submission value
Get the human-readable version of a submission value
...
...
mentoring/templates/html/feedback.html
0 → 100644
View file @
1a76c1b0
<div
class=
"feedback"
style=
"{% if self.width %}width:{{self.width}};{% endif %}{% if self.height %}height:{{self.height}};{% endif %}"
>
</div>
mentoring/templates/html/mcqblock_choices.html
View file @
1a76c1b0
...
@@ -10,6 +10,6 @@
...
@@ -10,6 +10,6 @@
<div
class=
"choice-tips"
></div>
<div
class=
"choice-tips"
></div>
</div>
</div>
{% endfor %}
{% endfor %}
<div
class=
"choice-message"
></div>
{{feedback.body_html|safe}}
</div>
</div>
</fieldset>
</fieldset>
mentoring/templates/html/mcqblock_rating.html
View file @
1a76c1b0
...
@@ -35,6 +35,6 @@
...
@@ -35,6 +35,6 @@
<div
class=
"choice-tips"
></div>
<div
class=
"choice-tips"
></div>
</div>
</div>
{% endfor %}
{% endfor %}
<div
class=
"choice-message"
></div>
{{feedback.body_html|safe}}
</div>
</div>
</fieldset>
</fieldset>
mentoring/templates/html/mrqblock_choices.html
View file @
1a76c1b0
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<div
class=
"choice-tips"
></div>
<div
class=
"choice-tips"
></div>
</div>
</div>
{% endfor %}
{% endfor %}
<div
class=
"choice-message"
></div>
{{feedback.body_html|safe}}
</div>
</div>
</fieldset>
</fieldset>
<div
class=
"show-answer"
>
<div
class=
"show-answer"
>
...
...
setup.py
View file @
1a76c1b0
...
@@ -59,6 +59,7 @@ BLOCKS_CHILDREN = [
...
@@ -59,6 +59,7 @@ BLOCKS_CHILDREN = [
'tip = mentoring:TipBlock'
,
'tip = mentoring:TipBlock'
,
'choice = mentoring:ChoiceBlock'
,
'choice = mentoring:ChoiceBlock'
,
'html = mentoring:HTMLBlock'
,
'html = mentoring:HTMLBlock'
,
'feedback = mentoring:FeedbackBlock'
]
]
setup
(
setup
(
...
...
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