Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

mattdrayer/WL-353: Add I18N Support #81

Merged
merged 1 commit into from
Mar 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ One of the key features in the success of peer instruction in enhancing student
cd PATH/TO/SOURCE
make deps
pip install -e .

## Running in WorkBench

make workbench
make workbench

## Running Unit Tests

make test
or

make test-py
make test-js

## Running Acceptance Tests
To run acceptance test, the devstack has to be running at localhost:8000 and localhost:8001 (configurable in protractor.conf) with auth auth enabled. To enable auto auth in cms.env.json and lms.env.json from Edx platform:

Expand All @@ -45,7 +45,7 @@ or
(Optional) Disable Django debug toolbar and contracts for faster tests: https://github.com/edx/edx-platform/wiki/Developing-on-the-edX-Developer-Stack#making-the-local-servers-run-faster

Install webdriver:

node_modules/protractor/bin/webdriver-manager update --standalone

Run tests:
Expand All @@ -57,6 +57,10 @@ Single test:
node_modules/protractor/bin/protractor protractor.conf.js --browser chrome --specs=ubcpi/static/js/features/cms.feature

## Changelog
### [0.5.2](https://github.com/ubc/ubcpi/issues?q=milestone%3A0.5.2+is%3Aclosed)
1. Updated XBlock version reference to 0.4.7
2. Added support for XBlock-level internationalization/localization

### [0.5.1](https://github.com/ubc/ubcpi/issues?q=milestone%3A0.5.1+is%3Aclosed)
1. Changed the "Question" title to "Peer Instruction Question"
2. Changed the answer icon from fa-users to fa-user and the dot at the last step
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# edX Internal Requirements
git+https://github.com/edx/XBlock.git@017b46b80e712b1318379912257cf1cc1b68eb0e#egg=XBlock
git+https://github.com/edx/XBlock.git@xblock-0.4.7#egg=XBlock==0.4.7

# edx-submissions
git+https://github.com/edx/edx-submissions.git@7c766502058e04bc9094e6cbe286e949794b80b3#egg=edx-submissions
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def readme():

setup(
name='ubcpi-xblock',
version='0.5.1',
version='0.5.2',
description='UBC Peer Instruction XBlock',
long_description=readme(),
license='Affero GNU General Public License v3 (GPLv3)',
Expand All @@ -47,7 +47,7 @@ def readme():
'ubcpi = ubcpi.ubcpi:PeerInstructionXBlock',
]
},
package_data=package_data("ubcpi", ["static", "public"]),
package_data=package_data("ubcpi", ["static", "public", "translations"]),
keywords=['edx', 'peer instruction', 'ubc'],
classifiers=[
"Development Status :: 4 - Beta",
Expand Down
122 changes: 122 additions & 0 deletions ubcpi/translations/en/LC_MESSAGES/text.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-03-16 15:27+0500\n"
"PO-Revision-Date: 2016-03-16 15:28+0500\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: ubcpi.py\n"

#: ubcpi.py
msgid "Peer Instruction"
msgstr ""

#: ubcpi.py
msgid "<p>Where does most of the mass in a fully grown tree originate?</p>"
msgstr ""

#: ubcpi.py
msgid ""
"The question the students see. This question appears above the possible "
"answers which you set below. You can use text, an image or a combination of "
"both. If you wish to add an image to your question, press the 'Add Image' "
"button."
msgstr ""

#: ubcpi.py
msgid "Air"
msgstr ""

#: ubcpi.py
msgid "Soil"
msgstr ""

#: ubcpi.py
msgid "Water"
msgstr ""

#: ubcpi.py
msgid ""
"The minimum and maximum number of characters a student is allowed for their "
"rationale."
msgstr ""

#: ubcpi.py
msgid "The correct option for the question"
msgstr ""

#: ubcpi.py
msgid "Photosynthesis"
msgstr ""

#: ubcpi.py
msgid "The feedback for student for the correct answer"
msgstr ""

#: ubcpi.py
msgid "Overall stats for the instructor"
msgstr ""

#: ubcpi.py
msgid "Tree gets carbon from air."
msgstr ""

#: ubcpi.py
msgid "Tree gets minerals from soil."
msgstr ""

#: ubcpi.py
msgid "Tree drinks water."
msgstr ""

#: ubcpi.py
msgid ""
"Instructor configured examples to give to students during the revise stage."
msgstr ""

#: ubcpi.py
msgid "System selected answers to give to students during the revise stage."
msgstr ""

#: ubcpi.py
msgid "The algorithm for selecting which answers to be presented to students"
msgstr ""

#: ubcpi.py
msgid ""
"ISO-8601 formatted string representing the start date of this assignment. We "
"ignore this."
msgstr ""

#: ubcpi.py
msgid ""
"ISO-8601 formatted string representing the due date of this assignment. We "
"ignore this."
msgstr ""

#: ubcpi.py
msgid "Problem Weight"
msgstr ""

#: ubcpi.py
msgid "System will select one of each option to present to the students."
msgstr ""

#: ubcpi.py
msgid "Completely random selection from the response pool."
msgstr ""

#: ubcpi.py
msgid "Appears above"
msgstr ""

#: ubcpi.py
msgid "Appears below"
msgstr ""
62 changes: 32 additions & 30 deletions ubcpi/ubcpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from xblock.fields import Scope, String, List, Dict, Integer, DateTime, Float
from xblock.fragment import Fragment
from xblockutils.publish_event import PublishEventMixin
from .utils import _ # pylint: disable=unused-import

from answer_pool import offer_answer, validate_seeded_answers, get_other_answers
import persistence as sas_api
Expand Down Expand Up @@ -138,6 +139,7 @@ def _serialize_opaque_key(self, key):


@XBlock.needs('user')
@XBlock.needs('i18n')
class PeerInstructionXBlock(XBlock, MissingDataFetcherMixin, PublishEventMixin):
"""
Peer Instruction XBlock
Expand All @@ -156,54 +158,54 @@ class PeerInstructionXBlock(XBlock, MissingDataFetcherMixin, PublishEventMixin):
event_namespace = 'ubc.peer_instruction'

# the display name that used on the interface
display_name = String(default="Peer Instruction")
display_name = String(default=_("Peer Instruction"))

question_text = Dict(
default={'text': '<p>Where does most of the mass in a fully grown tree originate?</p>',
default={'text': _('<p>Where does most of the mass in a fully grown tree originate?</p>'),
'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''},
scope=Scope.content,
help="The question the students see. This question appears above the possible answers which you set below. "
help=_("The question the students see. This question appears above the possible answers which you set below. "
"You can use text, an image or a combination of both. If you wish to add an image to your question, press "
"the 'Add Image' button."
"the 'Add Image' button.")
)

options = List(
default=[
{'text': 'Air', 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''},
{'text': 'Soil', 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''},
{'text': 'Water', 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''}
{'text': _('Air'), 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''},
{'text': _('Soil'), 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''},
{'text': _('Water'), 'image_url': '', 'image_position': 'below', 'image_show_fields': 0, 'image_alt': ''}
],
scope=Scope.content,
help="The possible options from which the student may select",
)

rationale_size = Dict(
default={'min': 1, 'max': MAX_RATIONALE_SIZE}, scope=Scope.content,
help="The minimum and maximum number of characters a student is allowed for their rationale.",
help=_("The minimum and maximum number of characters a student is allowed for their rationale."),
)

correct_answer = Integer(
default=0, scope=Scope.content,
help="The correct option for the question",
help=_("The correct option for the question"),
)

correct_rationale = Dict(
default={'text': "Photosynthesis"}, scope=Scope.content,
help="The feedback for student for the correct answer",
default={'text': _("Photosynthesis")}, scope=Scope.content,
help=_("The feedback for student for the correct answer"),
)

stats = Dict(
default={'original': {}, 'revised': {}}, scope=Scope.user_state_summary,
help="Overall stats for the instructor",
help=_("Overall stats for the instructor"),
)
seeds = List(
default=[
{'answer': 0, 'rationale': 'Tree gets carbon from air.'},
{'answer': 1, 'rationale': 'Tree gets minerals from soil.'},
{'answer': 2, 'rationale': 'Tree drinks water.'}
{'answer': 0, 'rationale': _('Tree gets carbon from air.')},
{'answer': 1, 'rationale': _('Tree gets minerals from soil.')},
{'answer': 2, 'rationale': _('Tree drinks water.')}
],
scope=Scope.content,
help="Instructor configured examples to give to students during the revise stage.",
help=_("Instructor configured examples to give to students during the revise stage."),
)

# sys_selected_answers dict format:
Expand All @@ -217,35 +219,35 @@ class PeerInstructionXBlock(XBlock, MissingDataFetcherMixin, PublishEventMixin):
# }
sys_selected_answers = Dict(
default={}, scope=Scope.user_state_summary,
help="System selected answers to give to students during the revise stage.",
help=_("System selected answers to give to students during the revise stage."),
)

algo = Dict(
default={'name': 'simple', 'num_responses': '#'}, scope=Scope.content,
help="The algorithm for selecting which answers to be presented to students",
help=_("The algorithm for selecting which answers to be presented to students"),
)

# Declare that we are not part of the grading System. Disabled for now as for the concern about the loading
# speed of the progress page.
has_score = True
has_score = True

start = DateTime(
default=None, scope=Scope.settings,
help="ISO-8601 formatted string representing the start date of this assignment. We ignore this."
help=_("ISO-8601 formatted string representing the start date of this assignment. We ignore this.")
)

due = DateTime(
default=None, scope=Scope.settings,
help="ISO-8601 formatted string representing the due date of this assignment. We ignore this."
help=_("ISO-8601 formatted string representing the due date of this assignment. We ignore this.")
)

# required field for LMS progress page
weight = Float(
default=1,
display_name="Problem Weight",
help=("Defines the number of points each problem is worth. "
display_name=_("Problem Weight"),
help=_(("Defines the number of points each problem is worth. "
"If the value is not set, the problem is worth the sum of the "
"option point values."),
"option point values.")),
values={"min": 0, "step": .1},
scope=Scope.settings
)
Expand All @@ -271,7 +273,7 @@ def studio_view(self, context=None):
frag.add_javascript(self.resource_string("static/js/src/ubcpi_edit.js"))

frag.initialize_js('PIEdit', {
'display_name': self.display_name,
'display_name': self.ugettext(self.display_name),
'weight': self.weight,
'correct_answer': self.correct_answer,
'correct_rationale': self.correct_rationale,
Expand All @@ -280,12 +282,12 @@ def studio_view(self, context=None):
'options': self.options,
'algo': self.algo,
'algos': {
'simple': 'System will select one of each option to present to the students.',
'random': 'Completely random selection from the response pool.'
'simple': self.ugettext('System will select one of each option to present to the students.'),
'random': self.ugettext('Completely random selection from the response pool.')
},
'image_position_locations': {
'above': 'Appears above',
'below': 'Appears below'
'above': self.ugettext('Appears above'),
'below': self.ugettext('Appears below')
},
'seeds': self.seeds,
})
Expand Down Expand Up @@ -439,7 +441,7 @@ def student_view(self, context=None):
'rationale_original': answers.get_rationale(0),
'answer_revised': answers.get_vote(1),
'rationale_revised': answers.get_rationale(1),
'display_name': self.display_name,
'display_name': self.ugettext(self.display_name),
'question_text': question,
'weight': self.weight,
'options': options,
Expand Down
7 changes: 7 additions & 0 deletions ubcpi/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
#


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