Commit 742c2238 by E. Kolpakov

Showing feedback for last submission

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