Skip to content

Commit

Permalink
Merge branch 'MDL-84532-405' of https://github.com/mihailges/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_405_STABLE
  • Loading branch information
andrewnicols committed Mar 7, 2025
2 parents daf6885 + d617d8b commit 5f77e55
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions question/type/ordering/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function xmldb_qtype_ordering_upgrade($oldversion) {
// We need to find all ordering question configurations that currently store the unsupported "0" (all) option
// for the 'selectcount' setting and the total number of answers that are related to each of these ordering
// questions.
$sql = "SELECT qoo.*, COUNT(DISTINCT(qa.id)) AS answerscount
$sql = "SELECT qoo.id, COUNT(DISTINCT(qa.id)) AS answerscount
FROM {qtype_ordering_options} qoo
JOIN {question_answers} qa ON qa.question = qoo.questionid
WHERE selectcount = :selectcount
Expand All @@ -311,9 +311,8 @@ function xmldb_qtype_ordering_upgrade($oldversion) {
// to the total number of answers related to this question. This way, we are making sure that the original
// behavior is preserved and all existing items (answers) related to the question will be included in the
// subset.
$questionoption->selectcount = $questionoption->answerscount;
unset($questionoption->answerscount);
$DB->update_record('qtype_ordering_options', $questionoption);
$DB->set_field('qtype_ordering_options', 'selectcount', $questionoption->answerscount,
['id' => $questionoption->id]);
}
$questionoptions->close();

Expand Down Expand Up @@ -341,7 +340,7 @@ function xmldb_qtype_ordering_upgrade($oldversion) {
// We need to find all ordering question configurations that currently store the unsupported "0" (all) option
// for the 'selectcount' setting and the total number of answers that are related to each of these ordering
// questions.
$sql = "SELECT qoo.*, COUNT(DISTINCT(qa.id)) AS answerscount
$sql = "SELECT qoo.id, COUNT(DISTINCT(qa.id)) AS answerscount
FROM {qtype_ordering_options} qoo
JOIN {question_answers} qa ON qa.question = qoo.questionid
WHERE selectcount = :selectcount
Expand All @@ -352,9 +351,8 @@ function xmldb_qtype_ordering_upgrade($oldversion) {
// to the total number of answers related to this question. This way, we are making sure that the original
// behavior is preserved and all existing items (answers) related to the question will be included in the
// subset.
$questionoption->selectcount = $questionoption->answerscount;
unset($questionoption->answerscount);
$DB->update_record('qtype_ordering_options', $questionoption);
$DB->set_field('qtype_ordering_options', 'selectcount', $questionoption->answerscount,
['id' => $questionoption->id]);
}
$questionoptions->close();

Expand Down

0 comments on commit 5f77e55

Please sign in to comment.