Commit 742c2238 by E. Kolpakov

Showing feedback for last submission

parent bfd829e9
......@@ -189,6 +189,9 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
'score': 1 if self.status == 'correct' else 0,
}
def get_last_result(self):
return self.get_results(None)
def submit(self, submission):
"""
The parent block is handling a student submission, including a new answer for this
......
......@@ -105,6 +105,9 @@ class MCQBlock(SubmittingXBlockMixin, QuestionnaireAbstractBlock):
def get_results(self, previous_result):
return self.calculate_results(previous_result['submission'])
def get_last_result(self):
return self.get_results({'submission': self.student_choice}) if self.student_choice else {}
def submit(self, submission):
log.debug(u'Received MCQ submission: "%s"', submission)
result = self.calculate_results(submission)
......
......@@ -470,19 +470,15 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
Gets previous submissions results as if submit was called with exactly the same values as last time.
"""
results = []
completed, show_message = True, False
choices = dict(self.student_results)
completed = True
show_message = bool(self.student_results)
# In standard mode, all children is visible simultaneously, so need collecting responses from all of them
for child_id in self.steps:
child = self.runtime.get_block(child_id)
if child.name and child.name in choices:
show_message = True
child_result = child.get_results(choices[child.name])
results.append([child.name, child_result])
completed = completed and (child_result['status'] == 'correct')
else:
completed = False
child_result = child.get_last_result()
results.append([child.name, child_result])
completed = completed and (child_result.get('status', None) == 'correct')
return results, completed, show_message
......
......@@ -89,6 +89,9 @@ class MRQBlock(QuestionnaireAbstractBlock):
result['completed'] = True
return result
def get_last_result(self):
return self.get_results({'submissions': self.student_choices}) if self.student_choices else {}
def submit(self, submissions):
log.debug(u'Received MRQ submissions: "%s"', submissions)
......
......@@ -87,13 +87,6 @@ class ProblemBuilderBaseTest(SeleniumXBlockTest, PopupCheckMixin):
def click_choice(self, container, choice_text):
""" Click on the choice label with the specified text """
for label in container.find_elements_by_css_selector('.choices .choice label'):
if choice_text in label.text:
label.click()
break
def click_choice(self, container, choice_text):
""" Click on the choice label with the specified text """
for label in container.find_elements_by_css_selector('.choice label'):
if choice_text in label.text:
label.click()
......
......@@ -159,7 +159,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
def test_feedbacks_and_messages_is_not_shown_on_first_load(self):
mentoring = self.load_scenario("feedback_persistence.xml")
answer, mcq, mrq, rating = self._get_controls(mentoring)
_, mcq, mrq, rating = self._get_controls(mentoring)
messages = self._get_messages_element(mentoring)
for i in range(3):
......@@ -225,4 +225,4 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
mentoring = self.go_to_view("student_view")
answer, mcq, mrq, rating = self._get_controls(mentoring)
messages = self._get_messages_element(mentoring)
self._standard_checks(answer, mcq, mrq, rating, messages)
\ No newline at end of file
self._standard_checks(answer, mcq, mrq, rating, messages)
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