Skip to content

Commit

Permalink
fix: add trans filter to html templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Nov 16, 2023
1 parent 3eababa commit c2bd87b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 40 deletions.
53 changes: 25 additions & 28 deletions feedback/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,16 @@
except ModuleNotFoundError: # For backward compatibility with releases older than Quince.
from xblockutils.resources import ResourceLoader

resource_loader = ResourceLoader(__name__)
from feedback.utils import _

# We provide default text which is designed to elicit student thought. We'd
# like instructors to customize this to something highly structured (not
# "What did you think?" and "How did you like it?".
DEFAULT_FREEFORM = "What did you learn from this? What was missing?"
DEFAULT_LIKERT = "How would you rate this as a learning experience?"
DEFAULT_DEFAULT = "Think about the material, and try to synthesize key " \
"lessons learned, as well as key gaps in our presentation."
DEFAULT_PLACEHOLDER = "Take a little bit of time to reflect here. " \
"Research shows that a meaningful synthesis will help " \
"you better understand and remember material from " \
"this course."
DEFAULT_ICON = "face"
DEFAULT_SCALETEXT = ["Excellent", "Good", "Average", "Fair", "Poor"]
resource_loader = ResourceLoader(__name__)

# Unicode alt faces are cute, but we do nulls instead for a11y.
ICON_SETS = {'face': [""]*5, # u"😁😊😐😞😭",
'num': "12345",
'midface': [""]*5} # u"😞😐😊😐😞"}


def _(text):
"""
Make '_' a no-op, so we can scrape strings
"""
return text


@XBlock.needs('i18n')
class FeedbackXBlock(XBlock):
"""
Expand All @@ -62,12 +43,28 @@ class FeedbackXBlock(XBlock):
# will default to the ones in default_prompt.
prompts = List(
default=[
{'freeform': DEFAULT_FREEFORM,
'default_text': DEFAULT_DEFAULT,
'likert': DEFAULT_LIKERT,
'placeholder': DEFAULT_PLACEHOLDER,
'scale_text': DEFAULT_SCALETEXT,
'icon_set': DEFAULT_ICON}
{
"freeform": _("What did you learn from this? What was missing?"),
"default_text": _(
"Think about the material, and try to synthesize key "
"lessons learned, as well as key gaps in our presentation."
),
"likert": _("How would you rate this as a learning experience?"),
"placeholder": _(
"Take a little bit of time to reflect here. "
"Research shows that a meaningful synthesis will help "
"you better understand and remember material from "
"this course."
),
"scale_text": [
_("Excellent"),
_("Good"),
_("Average"),
_("Fair"),
_("Poor"),
],
"icon_set": "face",
}
],
scope=Scope.settings,
help=_("Freeform user prompt"),
Expand Down Expand Up @@ -163,7 +160,7 @@ def get_prompt(self, index=-1):
_("Fair"),
_("Poor")],
'icon_set': 'num',
'placeholder': "Please take a moment to thoughtfully reflect."
'placeholder': _("Please take a moment to thoughtfully reflect.")
}

prompt.update(self.prompts[index])
Expand Down
6 changes: 3 additions & 3 deletions feedback/templates/html/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<div class="feedback_block">
<form action="" onsubmit="return false;">
<fieldset class="feedback_likert_field">
<legend class="feedback_likert_header">{{likert_prompt}}</legend>
<legend class="feedback_likert_header">{% trans likert_prompt %}</legend>
<div class="feedback_likert_scale">{{scale|safe}}</div>
</fieldset>

<div class="feedback_header_div">
<label class="feedback_header" for="feedback_freeform_textarea">{{freeform_prompt}}</label>
<label class="feedback_header" for="feedback_freeform_textarea">{% trans freeform_prompt %}</label>
</div>
<div class="feedback_freeform_input">
<textarea name="feedback_freeform_textarea" class="feedback_freeform_area" rows="6" cols="45" placeholder="{{placeholder}}">{{self.user_freeform}}</textarea>
<textarea name="feedback_freeform_textarea" class="feedback_freeform_area" rows="6" cols="45" placeholder="{% trans placeholder %}">{% trans self.user_freeform %}</textarea>
<div class="feedback_thank_you" aria-live=polite>{{response}}</div>
</div>
<button type="submit" class="feedback_submit_feedback">{% trans "Submit Feedback" %}</button>
Expand Down
4 changes: 3 additions & 1 deletion feedback/templates/html/scale_item.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load i18n %}

<div class="feedback_likert_rating">
<label title="{{scale_text}}" class="feedback_likert_label">
<input data-id="radio_{{idx}}" name="feedback_scale" class="feedback_radio" type="radio" {{active}}/>
Expand All @@ -8,6 +10,6 @@
<img src="{{act_icon}}" alt="{{unicode_icon}}"/>
</span>
<br/>
<span>{{scale_text}}</span>
<span>{% trans scale_text %}</span>
</label>
</div>
4 changes: 3 additions & 1 deletion feedback/templates/html/staff_item.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load i18n %}

<div class="feedback_likert_rating">
<label title="{{scale_text}}" class="feedback_likert_label">
<input data-id="radio_{{idx}}" name="feedback_scale" class="feedback_radio" type="radio" {{active}}/>
Expand All @@ -8,7 +10,7 @@
<img src="{{act_icon}}" alt="{{unicode_icon}}"/>
</span>
<br/>
<span>{{scale_text}}</span>
<span>{% trans scale_text %}</span>
<br/>
({{vote_cnt}})
</label>
Expand Down
14 changes: 7 additions & 7 deletions feedback/templates/html/studio_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="placeholder" aria-describedby="placeholder_span">{% trans "Freeform placeholder"%}</label>
<input class="input setting-input" name="placeholder" id="placeholder" value="{{placeholder}}" type="text" />
<input class="input setting-input" name="placeholder" id="placeholder" value="{% trans placeholder %}" type="text" />
</div>
<span id="placeholder_span" class="tip setting-help">{% trans "This is shown as grayed out text before the student has answered." %}</span>
</li>
Expand All @@ -70,47 +70,47 @@
<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert" aria-describedby="lik_example">{% trans "Likert prompt" %}</label>
<input class="input setting-input" name="likert" id="likert" value="{{likert}}" type="text" />
<input class="input setting-input" name="likert" id="likert" value="{% trans likert %}" type="text" />
</div>
<span id="lik_example" class="tip setting-help">{% trans "Example: Please rate your overall experience with this section." %}</span>
</li>

<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert0" aria-describedby="lik_excel">{% trans "Likert option 1" %}</label>
<input class="input setting-input" name="likert0" id="likert0" value="{{likert0}}" type="text" />
<input class="input setting-input" name="likert0" id="likert0" value="{% trans likert0 %}" type="text" />
</div>
<span id="lik_excel" class="tip setting-help">{% trans "Example: Excellent!" %}</span>
</li>

<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert1" aria-describedby="lik_good">{% trans "Likert option 2" %}</label>
<input class="input setting-input" name="likert1" id="likert1" value="{{likert1}}" type="text" />
<input class="input setting-input" name="likert1" id="likert1" value="{% trans likert1 %}" type="text" />
</div>
<span id="lik_good" class="tip setting-help">{% trans "Example: Good" %}</span>
</li>

<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert2" aria-describedby="lik_ave">{% trans "Likert option 3" %}</label>
<input class="input setting-input" name="likert2" id="likert2" value="{{likert2}}" type="text" />
<input class="input setting-input" name="likert2" id="likert2" value="{% trans likert2 %}" type="text" />
</div>
<span id="lik_ave" class="tip setting-help">{% trans "Example: Average" %}</span>
</li>

<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert3" aria-describedby="lik_fair">{% trans "Likert option 4" %}</label>
<input class="input setting-input" name="likert3" id="likert3" value="{{likert3}}" type="text" />
<input class="input setting-input" name="likert3" id="likert3" value="{% trans likert3 %}" type="text" />
</div>
<span id="lik_fair" class="tip setting-help">{% trans "Example: Fair" %}</span>
</li>

<li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting">
<label class="label setting-label" for="likert4" aria-describedby="lik_poor">{% trans "Likert option 5" %}</label>
<input class="input setting-input" name="likert4" id="likert4" value="{{likert4}}" type="text" />
<input class="input setting-input" name="likert4" id="likert4" value="{% trans likert4 %}" type="text" />
</div>
<span id="lik_poor" class="tip setting-help">{% trans "Example: Poor" %}</span>
</li>
Expand Down
8 changes: 8 additions & 0 deletions feedback/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Utilities for feedback app"""


def _(text):
"""
Make '_' a no-op, so we can scrape strings
"""
return text

0 comments on commit c2bd87b

Please sign in to comment.