Commit 21ee62c0 by Tim Krones

Add option to control whether or not header title is shown to students.

parent 5736ed87
......@@ -29,6 +29,13 @@ class DragAndDropBlock(XBlock):
default="Drag and Drop"
)
show_title = Boolean(
display_name="Show title",
help="Display the title to the user?",
scope=Scope.settings,
default=True
)
question_text = String(
display_name="Question text",
help="The question text that is displayed to the user",
......@@ -128,6 +135,7 @@ class DragAndDropBlock(XBlock):
@XBlock.json_handler
def studio_submit(self, submissions, suffix=''):
self.display_name = submissions['display_name']
self.show_title = submissions['show_title']
self.question_text = submissions['question_text']
self.weight = float(submissions['weight'])
self.data = submissions['data']
......@@ -244,6 +252,7 @@ class DragAndDropBlock(XBlock):
}
data['title'] = self.display_name
data['show_title'] = self.show_title
data['question_text'] = self.question_text
return data
......
......@@ -244,6 +244,7 @@ function DragAndDropBlock(runtime, element) {
var context = {
header_html: state.title,
show_title: state.show_title,
question_html: state.question_text,
popup_html: state.state.feedback || '',
feedback_html: $.trim(state.state.finished ? state.feedback.finish : state.feedback.start),
......
......@@ -410,6 +410,7 @@ function DragAndDropEditBlock(runtime, element) {
var data = {
'display_name': $(element).find('.display-name').val(),
'show_title': $(element).find('.show-title').is(':checked'),
'weight': $(element).find('.weight').val(),
'question_text': $(element).find('.question-text').val(),
'data': _fn.data,
......
......@@ -74,9 +74,13 @@
};
var mainTemplate = function(ctx) {
var problemHeader = '';
if (ctx.show_title) {
problemHeader = h('h2.problem-header', {innerHTML: ctx.header_html});
}
return (
h('section.xblock--drag-and-drop', [
h('h2.problem-header', {innerHTML: ctx.header_html}),
problemHeader,
h('section.problem', {role: 'application'}, [
h('div.title1', 'Question'),
h('p', {innerHTML: ctx.question_html})
......
......@@ -17,6 +17,8 @@
<form class="feedback-form">
<h3>Question title</h3>
<input class="display-name" value="{{ self.display_name }}" />
<input class="show-title" type="checkbox" value="{{ self.show_title }}"
{% if self.show_title %}checked="checked"{% endif %}> Show title
<h3>Maximum score</h3>
<input class="weight" value="1" value="{{ self.weight }}"/>
......
......@@ -70,5 +70,6 @@
},
"targetImg": "http://i0.kym-cdn.com/photos/images/newsfeed/000/030/404/1260585284155.png",
"title": "Drag and Drop",
"show_title": true,
"question_text": ""
}
......@@ -70,5 +70,6 @@
},
"targetImg": "http://i0.kym-cdn.com/photos/images/newsfeed/000/030/404/1260585284155.png",
"title": "Drag and Drop",
"show_title": true,
"question_text": ""
}
......@@ -59,6 +59,7 @@ def test_studio_submit():
body = json.dumps({
'display_name': "Test Drag & Drop",
'show_title': True,
'question_text': "Question Drag & Drop",
'weight': '5',
'data': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment