Commit cf241b6b by Braden MacDonald

Address some of nedbat's comments

parent 363a5192
...@@ -65,6 +65,7 @@ class MCQBlock(QuestionnaireAbstractBlock): ...@@ -65,6 +65,7 @@ class MCQBlock(QuestionnaireAbstractBlock):
def describe_choice_correctness(self, choice_value): def describe_choice_correctness(self, choice_value):
if choice_value in self.correct_choices: if choice_value in self.correct_choices:
if len(self.correct_choices) == 1: if len(self.correct_choices) == 1:
# Translators: This is an adjective, describing a choice as correct
return self._(u"Correct") return self._(u"Correct")
return self._(u"Acceptable") return self._(u"Acceptable")
else: else:
......
...@@ -36,6 +36,12 @@ from .step import StepParentMixin, StepMixin ...@@ -36,6 +36,12 @@ from .step import StepParentMixin, StepMixin
from xblockutils.resources import ResourceLoader from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin, StudioContainerXBlockMixin from xblockutils.studio_editable import StudioEditableXBlockMixin, StudioContainerXBlockMixin
try:
# Used to detect if we're in the workbench so we can add Font Awesome
from workbench.runtime import WorkbenchRuntime
except ImportError:
WorkbenchRuntime = False
# Globals ########################################################### # Globals ###########################################################
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -224,9 +230,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -224,9 +230,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
for child_id in self.children: for child_id in self.children:
child = self.runtime.get_block(child_id) child = self.runtime.get_block(child_id)
if isinstance(child, MentoringMessageBlock): if not isinstance(child, MentoringMessageBlock):
pass
else:
try: try:
if self.is_assessment and isinstance(child, StepMixin): if self.is_assessment and isinstance(child, StepMixin):
child_fragment = child.render('assessment_step_view', context) child_fragment = child.render('assessment_step_view', context)
...@@ -258,12 +262,8 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -258,12 +262,8 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
self.include_theme_files(fragment) self.include_theme_files(fragment)
# Workbench doesn't have font awesome, so add it: # Workbench doesn't have font awesome, so add it:
try: if WorkbenchRuntime and isinstance(self.runtime, WorkbenchRuntime):
from workbench.runtime import WorkbenchRuntime fragment.add_css_url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css')
if isinstance(self.runtime, WorkbenchRuntime):
fragment.add_css_url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css')
except ImportError:
pass
fragment.initialize_js('MentoringBlock') fragment.initialize_js('MentoringBlock')
...@@ -533,7 +533,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -533,7 +533,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
if msg_type in message_types_present: if msg_type in message_types_present:
validation.add(ValidationMessage( validation.add(ValidationMessage(
ValidationMessage.ERROR, ValidationMessage.ERROR,
self._(u"There should only be one '{}' message component.".format(msg_type)) self._(u"There should only be one '{msg_type}' message component.").format(msg_type=msg_type)
)) ))
message_types_present.add(msg_type) message_types_present.add(msg_type)
if a_child_has_issues: if a_child_has_issues:
......
...@@ -246,7 +246,8 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc ...@@ -246,7 +246,8 @@ class QuestionnaireAbstractBlock(StudioEditableXBlockMixin, StudioContainerXBloc
values_with_tips = set() values_with_tips = set()
for tip in self.get_tips(): for tip in self.get_tips():
values = set(tip.values) values = set(tip.values)
for dummy in (values & values_with_tips): if values & values_with_tips:
add_error(self._(u"Multiple tips configured for the same choice.")) add_error(self._(u"Multiple tips configured for the same choice."))
break
values_with_tips.update(values) values_with_tips.update(values)
return validation return validation
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