Skip to content
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
8 changes: 8 additions & 0 deletions problem_builder/public/js/mentoring_with_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,14 @@ function MentoringWithStepsBlock(runtime, element) {
reviewTipsDOM.empty().hide();
}

function updateNextLabel() {
var step = steps[activeStep];
nextDOM.attr('value', step.getStepLabel());
}

function updateDisplay() {
cleanAll();

if (atReviewStep()) {
// Tell supporting runtimes to enable navigation between units;
// user is currently not in the middle of an attempt
Expand All @@ -188,6 +194,7 @@ function MentoringWithStepsBlock(runtime, element) {
} else {
showActiveStep();
validateXBlock();
updateNextLabel();
nextDOM.attr('disabled', 'disabled');
if (isLastStep() && reviewStep) {
reviewDOM.attr('disabled', 'disabled');
Expand Down Expand Up @@ -243,6 +250,7 @@ function MentoringWithStepsBlock(runtime, element) {
activeStep = stepIndex;
cleanAll();
showActiveStep();
updateNextLabel();

if (isLastStep()) {
reviewDOM.show();
Expand Down
4 changes: 4 additions & 0 deletions problem_builder/public/js/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function MentoringStepBlock(runtime, element) {
callIfExists(child, 'handleReview', result);
}
}
},

getStepLabel: function() {
return $('.sb-step', element).data('next-button-label');
}

};
Expand Down
8 changes: 7 additions & 1 deletion problem_builder/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ class MentoringStepBlock(
scope=Scope.user_state
)

editable_fields = ('display_name', 'show_title',)
next_button_label = String(
display_name=_("Next Button Label"),
help=_("Customize the text of the 'Next' button."),
default=_("Next Step")
)

editable_fields = ('display_name', 'show_title', 'next_button_label')

@lazy
def siblings(self):
Expand Down
2 changes: 1 addition & 1 deletion problem_builder/templates/html/step.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="sb-step">
<div class="sb-step" data-next-button-label="{{ self.next_button_label }}">
{% if show_title %}
<div class="title">
<h3>
Expand Down
15 changes: 15 additions & 0 deletions problem_builder/tests/integration/test_step_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,21 @@ def extended_feedback_checks(self, step_builder, controls, expected_results):
None, step_builder, controls, extended_feedback=True, alternative_review=True
)

def test_next_label(self):
step_builder, controls = self.load_assessment_scenario("step_builder_next.xml")
self.expect_question_visible(None, step_builder)
self.assertEqual(controls.next_question.get_attribute('value'), "Next Challenge")
self.freeform_answer(None, step_builder, controls, 'This is the answer', CORRECT)
self.expect_question_visible(None, step_builder)
self.assertEqual(controls.next_question.get_attribute('value'), "Next Item")
self.single_choice_question(None, step_builder, controls, 'Maybe not', INCORRECT)
self.rating_question(None, step_builder, controls, "5 - Extremely good", CORRECT, last=True)

# Check extended feedback loads the labels correctly.
step_builder.find_elements_by_css_selector('.correct-list li a')[0].click()
self.expect_question_visible(None, step_builder)
self.assertEqual(controls.next_question.get_attribute('value'), "Next Challenge")

@data(
{"max_attempts": 0, "extended_feedback": False}, # Unlimited attempts, no extended feedback
{"max_attempts": 1, "extended_feedback": True}, # Limited attempts, extended feedback
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<step-builder url_name="step-builder" display_name="Step Builder"
max_attempts="1" extended_feedback="True">

<sb-step display_name="First step" next_button_label="Next Challenge">
<pb-answer name="goal" question="What is your goal?" />
</sb-step>

<sb-step display_name="Second step" next_button_label="Next Item">
<pb-mcq name="mcq_1_1" question="Do you like this MCQ?" correct_choices='["yes"]'>
<pb-choice value="yes">Yes</pb-choice>
<pb-choice value="maybenot">Maybe not</pb-choice>
<pb-choice value="understand">I don't understand</pb-choice>

<pb-tip values='["yes"]'>Great!</pb-tip>
<pb-tip values='["maybenot"]'>Ah, damn.</pb-tip>
<pb-tip values='["understand"]'><div id="test-custom-html">Really?</div></pb-tip>
</pb-mcq>
</sb-step>

<sb-step display_name="Third step">
<pb-rating name="mcq_1_2" low="Not good at all" high="Extremely good" question="How much do you rate this MCQ?" correct_choices='["4","5"]'>
<pb-choice value="notwant">I don't want to rate it</pb-choice>
<pb-tip values='["4","5"]'>I love good grades.</pb-tip>
<pb-tip values='["1","2", "3"]'>Will do better next time...</pb-tip>
<pb-tip values='["notwant"]'>Your loss!</pb-tip>
</pb-rating>
</sb-step>

<sb-review-step />

</step-builder>