Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-31829 question engine SQL typo breaks some regrades.

Also, some MySQL-only code had not been updated.

This problem only affected a small minority of question attempts, like
this:
1. Suppose you have a shortanswer question with correct answer 'Toad'
and some hints.
2. Suppose a student attempts this using the interactive behaviour and
on the first try responds 'Frog', and on the second try responds 'Toad'.
3. Then suppose the teacher edits the question to make 'Frog' correct.
4. Then, when the quiz is regraded, the question_attempt_step for the
second try will need to be deleted. That is where the buggy code was.
  • Loading branch information...
commit b37cff4f0db7e6a013ef6ee908e1a8bd618c1119 1 parent f24a1a7
@timhunt timhunt authored
Showing with 2 additions and 25 deletions.
  1. +2 −25 question/engine/datalib.php
View
27 question/engine/datalib.php
@@ -769,22 +769,6 @@ protected function delete_usage_records_for_mysql(qubaid_condition $qubaids) {
}
/**
- * This function is a work-around for poor MySQL performance with
- * DELETE FROM x WHERE id IN (SELECT ...). We have to use a non-standard
- * syntax to get good performance. See MDL-29520.
- * @param string $test sql fragment.
- * @param array $params used by $test.
- */
- protected function delete_attempt_steps_for_mysql($test, $params) {
- // TODO once MDL-29589 is fixed, eliminate this method, and instead use the new $DB API.
- $this->db->execute('
- DELETE qas, qasd
- FROM {question_attempt_steps} qas
- LEFT JOIN {question_attempt_step_data} qasd ON qasd.attemptstepid = qas.id
- WHERE qas.questionattemptid ' . $test, $params);
- }
-
- /**
* Delete all the steps for a question attempt.
* @param int $qaids question_attempt id.
* @param context $context the context that the $quba belongs to.
@@ -795,19 +779,12 @@ public function delete_steps($stepids, $context) {
}
list($test, $params) = $this->db->get_in_or_equal($stepids, SQL_PARAMS_NAMED);
- if ($deletefiles) {
- $this->delete_response_files($context->id, $test, $params);
- }
-
- if ($this->db->get_dbfamily() == 'mysql') {
- $this->delete_attempt_steps_for_mysql($test, $params);
- return;
- }
+ $this->delete_response_files($context->id, $test, $params);
$this->db->delete_records_select('question_attempt_step_data',
"attemptstepid $test", $params);
$this->db->delete_records_select('question_attempt_steps',
- "attemptstepid $test", $params);
+ "id $test", $params);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.