Commit 1f71b148 by Stephen Sanchez

Fixing a race condition loading sections of the ORA2 UI

parent 860b28fd
...@@ -88,6 +88,7 @@ OpenAssessment.StudentTrainingView.prototype = { ...@@ -88,6 +88,7 @@ OpenAssessment.StudentTrainingView.prototype = {
var instructions = $("#openassessment__student-training--instructions", this.element); var instructions = $("#openassessment__student-training--instructions", this.element);
if (!view.rubric.showCorrections(corrections)) { if (!view.rubric.showCorrections(corrections)) {
view.load();
baseView.loadAssessmentModules(); baseView.loadAssessmentModules();
incorrect.addClass("is--hidden"); incorrect.addClass("is--hidden");
instructions.removeClass("is--hidden"); instructions.removeClass("is--hidden");
......
...@@ -6,6 +6,7 @@ from django.utils.translation import ugettext as _ ...@@ -6,6 +6,7 @@ from django.utils.translation import ugettext as _
from webob import Response from webob import Response
from xblock.core import XBlock from xblock.core import XBlock
from openassessment.assessment.api import student_training from openassessment.assessment.api import student_training
import openassessment.workflow.api as workflow_api
from openassessment.xblock.data_conversion import convert_training_examples_list_to_dict from openassessment.xblock.data_conversion import convert_training_examples_list_to_dict
from .resolve_dates import DISTANT_FUTURE from .resolve_dates import DISTANT_FUTURE
...@@ -169,6 +170,12 @@ class StudentTrainingMixin(object): ...@@ -169,6 +170,12 @@ class StudentTrainingMixin(object):
'msg': _(u"An unexpected error occurred.") 'msg': _(u"An unexpected error occurred.")
} }
else: else:
try:
self.update_workflow_status()
except workflow_api.AssessmentWorkflowError:
msg = _('Could not update workflow status.')
logger.exception(msg)
return {'success': False, 'msg': msg}
return { return {
'success': True, 'success': True,
'msg': u'', 'msg': u'',
......
...@@ -9,6 +9,7 @@ from mock import patch ...@@ -9,6 +9,7 @@ from mock import patch
import pytz import pytz
from django.db import DatabaseError from django.db import DatabaseError
from openassessment.assessment.models import StudentTrainingWorkflow from openassessment.assessment.models import StudentTrainingWorkflow
from openassessment.workflow import api as workflow_api
from .base import XBlockHandlerTestCase, scenario from .base import XBlockHandlerTestCase, scenario
@ddt.ddt @ddt.ddt
...@@ -42,6 +43,29 @@ class StudentTrainingAssessTest(XBlockHandlerTestCase): ...@@ -42,6 +43,29 @@ class StudentTrainingAssessTest(XBlockHandlerTestCase):
@scenario('data/student_training.xml', user_id="Plato") @scenario('data/student_training.xml', user_id="Plato")
@ddt.file_data('data/student_training_mixin.json') @ddt.file_data('data/student_training_mixin.json')
def test_correct_with_error(self, xblock, data):
xblock.create_submission(xblock.get_student_item_dict(), self.SUBMISSION)
self._assert_path_and_context(xblock, data["expected_template"], data["expected_context"])
# Agree with the course author's assessment
# (as defined in the scenario XML)
data = {
'options_selected': {
'Vocabulary': 'Good',
'Grammar': 'Excellent'
}
}
with patch.object(workflow_api, "update_from_assessments") as mock_workflow_update:
mock_workflow_update.side_effect = workflow_api.AssessmentWorkflowError("Oh no!")
resp = self.request(xblock, 'training_assess', json.dumps(data), response_format='json')
# Expect that we were not correct due to a workflow update error.
self.assertFalse(resp['success'], msg=resp.get('msg'))
self.assertEquals('Could not update workflow status.', resp.get('msg'))
self.assertFalse('corrections' in resp)
@scenario('data/student_training.xml', user_id="Plato")
@ddt.file_data('data/student_training_mixin.json')
def test_incorrect(self, xblock, data): def test_incorrect(self, xblock, data):
xblock.create_submission(xblock.get_student_item_dict(), self.SUBMISSION) xblock.create_submission(xblock.get_student_item_dict(), self.SUBMISSION)
self._assert_path_and_context(xblock, data["expected_template"], data["expected_context"]) self._assert_path_and_context(xblock, data["expected_template"], data["expected_context"])
......
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