Skip to content

Commit

Permalink
Add customisation for end of course label
Browse files Browse the repository at this point in the history
Fix #1
  • Loading branch information
fcheval committed Aug 5, 2015
1 parent 2c4f15d commit 122ba2c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
6 changes: 4 additions & 2 deletions feedback/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

DISPLAY_NAME = "Feedback"

POST_URL = '#'
POST_URL = "#"

EXIT_LABEL = 'Save and exit'
EXIT_LABEL = "Save and exit"

TITLE = "Congratulation, you finished this course!"

MAX_SCORE = 5
16 changes: 15 additions & 1 deletion feedback/feedbackblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from xblock.fields import Scope, Integer, String, Boolean
from xblock.fragment import Fragment

from feedback.defaults import DISPLAY_NAME, POST_URL, EXIT_LABEL, MAX_SCORE
from feedback.defaults import DISPLAY_NAME, POST_URL, EXIT_LABEL, MAX_SCORE, TITLE


@XBlock.wants("settings")
Expand Down Expand Up @@ -56,6 +56,12 @@ class FeedbackXBlock(XBlock):
help="Label for button exit.",
)

title = String(
default="",
scope=Scope.content,
help="Label for text at the end of the class.",
)

is_submited = Boolean(
default=False,
scope=Scope.user_state,
Expand Down Expand Up @@ -95,6 +101,7 @@ def student_view(self, context=None):

post_url = self.post_url
exit_label = self.exit_label
title = self.title

settings_service = self.runtime.service(self, 'settings')
if settings_service:
Expand All @@ -108,6 +115,10 @@ def student_view(self, context=None):
s = settings.get('exit_label')
exit_label = s if s else EXIT_LABEL

if title == "":
s = settings.get('title')
title = s if s else TITLE

context = {
'skills_score': self.skills_score,
'course_score': self.course_score,
Expand All @@ -119,6 +130,7 @@ def student_view(self, context=None):
'course_id': unicode(self.runtime.course_id),
'is_submited': self.is_submited,
'is_locked': self.is_locked,
'title': title,
}

html = self.render_template("static/html/view-feedback.html", context)
Expand All @@ -141,6 +153,7 @@ def studio_view(self, context=None):
'max_score': self.max_score,
'exit_label': self.exit_label,
'is_locked': self.is_locked,
'title': self.title,
}

html = self.render_template("static/html/edit-feedback.html", context)
Expand Down Expand Up @@ -201,6 +214,7 @@ def studio_submit(self, data, suffix=''):
self.is_locked = data['lock']
self.exit_label = unicode(data['exitLabel'])
self.max_score = unicode(data['maxScore'])
self.title = unicode(data['title'])

return {
'result': 'success',
Expand Down
10 changes: 10 additions & 0 deletions feedback/static/html/edit-feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
</div>
<span class="tip setting-help">If this field is empty, it will use a default value set by the platform’s administrator.</span>
</li>
<li class="field comp-setting-entry">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="xblock-feedback-title-label">Title : </label>
<input class="input setting-input" type="text" id="xblock-feedback-title-label" value="{{ title }}" required>
<button class="action setting-clear inactive" type="button" name="setting-clear" value="Clear" data-tooltip="Clear">
<i class="fa fa-undo"></i>
</button>
</div>
<span class="tip setting-help">If this field is empty, it will use a default value set by the platform’s administrator.</span>
</li>
<li class="field comp-setting-entry">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="xblock-feedback-post-url">Target POST URL:</label>
Expand Down
2 changes: 1 addition & 1 deletion feedback/static/html/view-feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
{% else %}
<h2>
Félicitation, vous avez terminé ce cours !
{{ title }}
</h2>
<form method="POST" action="{{ post_url }}">
<input type="hidden" name="course_id" value="{{ course_id }}" />
Expand Down
1 change: 1 addition & 0 deletions feedback/static/js/src/edit-feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function FeedbackXBlockStudio(runtime, element) {
var handlerUrl = runtime.handlerUrl(element, 'studio_submit');
var data = {
exitLabel: $('#xblock-feedback-exit-label', element).val(),
title: $('#xblock-feedback-title-label').val(),
postUrl: $('#xblock-feedback-post-url', element).val(),
maxScore: $('#xblock-feedback-max-score', element).val(),
lock: $('#xblock-feedback-lock-when-voted option:selected').val()
Expand Down

0 comments on commit 122ba2c

Please sign in to comment.