Commit b542f0c5 by Braden MacDonald

Fix: Refreshing the page during a second step builder attempt will display previous answers

parent 318d8c04
...@@ -958,6 +958,8 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes ...@@ -958,6 +958,8 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
fragment = Fragment() fragment = Fragment()
children_contents = [] children_contents = []
context = context or {}
context['hide_prev_answer'] = True # For Step Builder, we don't show the users' old answers when they try again
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 child is None: # child should not be None but it can happen due to bugs or permission issues if child is None: # child should not be None but it can happen due to bugs or permission issues
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="choice-selector"> <div class="choice-selector">
<input id="choice-{{ self.html_id }}-{{ forloop.counter }}" type="radio" <input id="choice-{{ self.html_id }}-{{ forloop.counter }}" type="radio"
name="{{ self.name }}" value="{{ choice.value }}" name="{{ self.name }}" value="{{ choice.value }}"
{% if self.student_choice == choice.value %} checked{% endif %} {% if self.student_choice == choice.value and not hide_prev_answer %} checked{% endif %}
/> />
</div> </div>
<label class="choice-label" for="choice-{{ self.html_id }}-{{ forloop.counter }}"> <label class="choice-label" for="choice-{{ self.html_id }}-{{ forloop.counter }}">
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="choice-selector"> <div class="choice-selector">
<input id="choice-{{ self.html_id }}-{{ forloop.counter }}" type="checkbox" <input id="choice-{{ self.html_id }}-{{ forloop.counter }}" type="checkbox"
name="{{ self.name }}" value="{{ choice.value }}" name="{{ self.name }}" value="{{ choice.value }}"
{% if choice.value in self.student_choices %} checked{% endif %} {% if choice.value in self.student_choices and not hide_prev_answer %} checked{% endif %}
/> />
</div> </div>
<label class="choice-label" for="choice-{{ self.html_id }}-{{ forloop.counter }}"> <label class="choice-label" for="choice-{{ self.html_id }}-{{ forloop.counter }}">
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="choice-selector"> <div class="choice-selector">
<input id="choice-{{ self.html_id }}-{{i}}" type="radio" <input id="choice-{{ self.html_id }}-{{i}}" type="radio"
name="{{ self.name }}" value="{{i}}" name="{{ self.name }}" value="{{i}}"
{% if self.student_choice == i %} checked{%else%} data-student-choice='{{self.student_choice}}'{% endif %} {% if self.student_choice == i and not hide_prev_answer %} checked{%else%} data-student-choice='{{self.student_choice}}'{% endif %}
/> />
</div> </div>
<label class="choice-label" for="choice-{{ self.html_id }}-{{i}}"> <label class="choice-label" for="choice-{{ self.html_id }}-{{i}}">
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="choice-selector"> <div class="choice-selector">
<input id="choice-{{ self.html_id }}-custom{{ forloop.counter }}" type="radio" <input id="choice-{{ self.html_id }}-custom{{ forloop.counter }}" type="radio"
name="{{ self.name }}" value="{{ choice.value }}" name="{{ self.name }}" value="{{ choice.value }}"
{% if self.student_choice == choice.value %} checked{%else%} data-student-choice='{{self.student_choice}}'{% endif %} {% if self.student_choice == choice.value and not hide_prev_answer %} checked{%else%} data-student-choice='{{self.student_choice}}'{% endif %}
/> />
</div> </div>
<label class="choice-label" for="choice-{{ self.html_id }}-custom{{ forloop.counter }}"> <label class="choice-label" for="choice-{{ self.html_id }}-custom{{ forloop.counter }}">
......
...@@ -425,6 +425,9 @@ class StepBuilderTest(MentoringAssessmentBaseTest, MultipleSliderBlocksTestMixin ...@@ -425,6 +425,9 @@ class StepBuilderTest(MentoringAssessmentBaseTest, MultipleSliderBlocksTestMixin
None, step_builder, controls, 'This is a different answer', CORRECT, saved_value='This is the answer' None, step_builder, controls, 'This is a different answer', CORRECT, saved_value='This is the answer'
) )
# Step 2 # Step 2
# Reload the page, which should have no effect
self.browser.execute_script("$(document).html(' ');")
step_builder, controls = self.go_to_assessment()
# Submit MCQ, go to next step # Submit MCQ, go to next step
self.single_choice_question(None, step_builder, controls, 'Yes', CORRECT) self.single_choice_question(None, step_builder, controls, 'Yes', CORRECT)
# Step 3 # Step 3
......
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