Make sure InstructorTask is committed.
This commit is contained in:
@@ -658,11 +658,11 @@ class CapaModuleTest(unittest.TestCase):
|
||||
|
||||
# Simulate answering a problem that raises the exception
|
||||
with patch('capa.capa_problem.LoncapaProblem.rescore_existing_answers') as mock_rescore:
|
||||
mock_rescore.side_effect = exception_class(u'test error u\03a9')
|
||||
mock_rescore.side_effect = exception_class(u'test error \u03a9')
|
||||
result = module.rescore_problem()
|
||||
|
||||
# Expect an AJAX alert message in 'success'
|
||||
expected_msg = u'Error: test error u\03a9'
|
||||
expected_msg = u'Error: test error \u03a9'
|
||||
self.assertEqual(result['success'], expected_msg)
|
||||
|
||||
# Expect that the number of attempts is NOT incremented
|
||||
|
||||
@@ -91,7 +91,7 @@ class InstructorTask(models.Model):
|
||||
task_input=json_task_input,
|
||||
task_state=QUEUING,
|
||||
requester=requester)
|
||||
instructor_task.save()
|
||||
instructor_task.save_now()
|
||||
|
||||
return instructor_task
|
||||
|
||||
@@ -125,6 +125,7 @@ class InstructorTask(models.Model):
|
||||
|
||||
Truncation is indicated by adding "..." to the end of the value.
|
||||
"""
|
||||
tag = '...'
|
||||
task_progress = {'exception': type(exception).__name__, 'message': str(exception.message)}
|
||||
if traceback_string is not None:
|
||||
# truncate any traceback that goes into the InstructorTask model:
|
||||
@@ -135,17 +136,17 @@ class InstructorTask(models.Model):
|
||||
too_long = len(json_output) - 1023
|
||||
if too_long > 0:
|
||||
if traceback_string is not None:
|
||||
if too_long >= len(traceback_string) - len('...'):
|
||||
if too_long >= len(traceback_string) - len(tag):
|
||||
# remove the traceback entry entirely (so no key or value)
|
||||
del task_progress['traceback']
|
||||
too_long -= (len(traceback_string) + len('traceback'))
|
||||
else:
|
||||
# truncate the traceback:
|
||||
task_progress['traceback'] = traceback_string[:-(too_long + 3)] + "..."
|
||||
too_long = -1
|
||||
task_progress['traceback'] = traceback_string[:-(too_long + len(tag))] + tag
|
||||
too_long = 0
|
||||
if too_long > 0:
|
||||
# we need to shorten the message:
|
||||
task_progress['message'] = task_progress['message'][:-(too_long + 3)] + "..."
|
||||
task_progress['message'] = task_progress['message'][:-(too_long + len(tag))] + tag
|
||||
json_output = json.dumps(task_progress)
|
||||
return json_output
|
||||
|
||||
|
||||
@@ -109,10 +109,10 @@ class InstructorTaskSubmitTest(InstructorTaskModuleTestCase):
|
||||
location = InstructorTaskModuleTestCase.problem_location(problem_url_name)
|
||||
if student is not None:
|
||||
instructor_task = task_function(self.create_task_request(self.instructor),
|
||||
self.course.id, location, student)
|
||||
self.course.id, location, student)
|
||||
else:
|
||||
instructor_task = task_function(self.create_task_request(self.instructor),
|
||||
self.course.id, location)
|
||||
self.course.id, location)
|
||||
|
||||
# test resubmitting, by updating the existing record:
|
||||
instructor_task = InstructorTask.objects.get(id=instructor_task.id)
|
||||
|
||||
@@ -205,8 +205,8 @@ function goto( mode)
|
||||
</p>
|
||||
<p>
|
||||
You may use just the "urlname" if a problem, or "modulename/urlname" if not.
|
||||
(For example, if the location is <tt>i4x://university/course/problem/problemname</tt>,
|
||||
then just provide the <tt>problemname</tt>.
|
||||
(For example, if the location is <tt>i4x://university/course/problem/problemname</tt>,
|
||||
then just provide the <tt>problemname</tt>.
|
||||
If the location is <tt>i4x://university/course/notaproblem/someothername</tt>, then
|
||||
provide <tt>notaproblem/someothername</tt>.)
|
||||
</p>
|
||||
@@ -241,8 +241,8 @@ function goto( mode)
|
||||
</p>
|
||||
<p>
|
||||
You may use just the "urlname" if a problem, or "modulename/urlname" if not.
|
||||
(For example, if the location is <tt>i4x://university/course/problem/problemname</tt>,
|
||||
then just provide the <tt>problemname</tt>.
|
||||
(For example, if the location is <tt>i4x://university/course/problem/problemname</tt>,
|
||||
then just provide the <tt>problemname</tt>.
|
||||
If the location is <tt>i4x://university/course/notaproblem/someothername</tt>, then
|
||||
provide <tt>notaproblem/someothername</tt>.)
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user