Skip to content
Snippets Groups Projects
Commit 7e21841d authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

avoid race condition when archiving solution, fixes #60

parent 0ebced78
No related branches found
No related tags found
No related merge requests found
......@@ -699,17 +699,17 @@ class VipsAssignment extends SimpleORMap
$solution->options['session_id'] = session_id();
}
// in selftests, autocorrect solution
if ($this->isSelfAssessment()) {
$this->correctSolution($solution);
}
// move old solutions into vips_solution_archive
VipsSolution::archiveBySQL(
'exercise_id = ? AND assignment_id = ? AND user_id = ?',
[$exercise->id, $this->id, $user_id]
);
// in selftests, autocorrect solution
if ($this->isSelfAssessment()) {
$this->correctSolution($solution);
}
// insert new solution into vips_solution
return $solution->store();
}
......
......@@ -126,7 +126,7 @@ class VipsSolution extends SimpleORMap
{
$db = DBManager::get();
$stmt = $db->prepare('INSERT INTO vips_solution_archive
$stmt = $db->prepare('INSERT IGNORE INTO vips_solution_archive
SELECT * FROM vips_solution WHERE ' . $sql);
$stmt->execute($params);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment