questtype ?Submit?: use database transaction for adding terms

This commit is contained in:
oliver 2016-04-17 14:35:45 +02:00
commit 794462e3e9

View file

@ -281,6 +281,8 @@
*/ */
private function addTerms($submissionId, $terms) private function addTerms($submissionId, $terms)
{ {
$this->db->setAutocommit(false);
try {
// Calculate IDF: n (n_term) // Calculate IDF: n (n_term)
$uniqueTerms = array(); $uniqueTerms = array();
foreach($terms as &$term) foreach($terms as &$term)
@ -314,6 +316,14 @@
); );
} }
} }
catch(\Exception $e) {
$this->db->rollback();
$this->db->setAutocommit(true);
throw $e;
}
$this->db->setAutocommit(true);
}
/** /**