Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 298... Línea 298...
298
        $dbman->change_field_default($table, $field);
298
        $dbman->change_field_default($table, $field);
Línea 299... Línea 299...
299
 
299
 
300
        // We need to find all ordering question configurations that currently store the unsupported "0" (all) option
300
        // We need to find all ordering question configurations that currently store the unsupported "0" (all) option
301
        // for the 'selectcount' setting and the total number of answers that are related to each of these ordering
301
        // for the 'selectcount' setting and the total number of answers that are related to each of these ordering
302
        // questions.
302
        // questions.
303
        $sql = "SELECT qoo.*, COUNT(DISTINCT(qa.id)) AS answerscount
303
        $sql = "SELECT qoo.id, COUNT(DISTINCT(qa.id)) AS answerscount
304
                FROM {qtype_ordering_options} qoo
304
                FROM {qtype_ordering_options} qoo
305
                JOIN {question_answers} qa ON qa.question = qoo.questionid
305
                JOIN {question_answers} qa ON qa.question = qoo.questionid
306
                WHERE selectcount = :selectcount
306
                WHERE selectcount = :selectcount
307
                GROUP BY qoo.id";
307
                GROUP BY qoo.id";
308
        $questionoptions = $DB->get_recordset_sql($sql, ['selectcount' => 0]);
308
        $questionoptions = $DB->get_recordset_sql($sql, ['selectcount' => 0]);
309
        foreach ($questionoptions as $questionoption) {
309
        foreach ($questionoptions as $questionoption) {
310
            // Update the value of the 'selectcount' configuration option for the current ordering question and set it
310
            // Update the value of the 'selectcount' configuration option for the current ordering question and set it
311
            // to the total number of answers related to this question. This way, we are making sure that the original
311
            // to the total number of answers related to this question. This way, we are making sure that the original
312
            // behavior is preserved and all existing items (answers) related to the question will be included in the
312
            // behavior is preserved and all existing items (answers) related to the question will be included in the
313
            // subset.
313
            // subset.
314
            $questionoption->selectcount = $questionoption->answerscount;
314
            $DB->set_field('qtype_ordering_options', 'selectcount', $questionoption->answerscount,
315
            unset($questionoption->answerscount);
-
 
316
            $DB->update_record('qtype_ordering_options', $questionoption);
315
                ['id' => $questionoption->id]);
317
        }
316
        }
Línea 318... Línea 317...
318
        $questionoptions->close();
317
        $questionoptions->close();
319
 
318
 
320
        // Currently, a 'qtype_ordering_selectcount' user preference is set (or updated, if it already exists) each time
319
        // Currently, a 'qtype_ordering_selectcount' user preference is set (or updated, if it already exists) each time
321
        // a new ordering question is created. If there are user preferences that store the removed "0" (all) option, they
320
        // a new ordering question is created. If there are user preferences that store the removed "0" (all) option, they
322
        // need to be updated. In this case, replace it with "2" (minimum number of items required to create a subset).
321
        // need to be updated. In this case, replace it with "2" (minimum number of items required to create a subset).
-
 
322
        $wheresql = 'name = ? AND ' . $DB->sql_compare_text('value') . ' = ?';
Línea 323... Línea 323...
323
        $DB->set_field('user_preferences', 'value', 2,
323
        $params = ['qtype_ordering_selectcount', '0'];
324
            ['name' => 'qtype_ordering_selectcount', 'value' => 0]);
324
        $DB->set_field_select('user_preferences', 'value', 2, $wheresql, $params);
Línea 325... Línea 325...
325
 
325
 
Línea 339... Línea 339...
339
        $dbman->change_field_default($table, $field);
339
        $dbman->change_field_default($table, $field);
Línea 340... Línea 340...
340
 
340
 
341
        // We need to find all ordering question configurations that currently store the unsupported "0" (all) option
341
        // We need to find all ordering question configurations that currently store the unsupported "0" (all) option
342
        // for the 'selectcount' setting and the total number of answers that are related to each of these ordering
342
        // for the 'selectcount' setting and the total number of answers that are related to each of these ordering
343
        // questions.
343
        // questions.
344
        $sql = "SELECT qoo.*, COUNT(DISTINCT(qa.id)) AS answerscount
344
        $sql = "SELECT qoo.id, COUNT(DISTINCT(qa.id)) AS answerscount
345
                FROM {qtype_ordering_options} qoo
345
                FROM {qtype_ordering_options} qoo
346
                JOIN {question_answers} qa ON qa.question = qoo.questionid
346
                JOIN {question_answers} qa ON qa.question = qoo.questionid
347
                WHERE selectcount = :selectcount
347
                WHERE selectcount = :selectcount
348
                GROUP BY qoo.id";
348
                GROUP BY qoo.id";
349
        $questionoptions = $DB->get_recordset_sql($sql, ['selectcount' => 0]);
349
        $questionoptions = $DB->get_recordset_sql($sql, ['selectcount' => 0]);
350
        foreach ($questionoptions as $questionoption) {
350
        foreach ($questionoptions as $questionoption) {
351
            // Update the value of the 'selectcount' configuration option for the current ordering question and set it
351
            // Update the value of the 'selectcount' configuration option for the current ordering question and set it
352
            // to the total number of answers related to this question. This way, we are making sure that the original
352
            // to the total number of answers related to this question. This way, we are making sure that the original
353
            // behavior is preserved and all existing items (answers) related to the question will be included in the
353
            // behavior is preserved and all existing items (answers) related to the question will be included in the
354
            // subset.
354
            // subset.
355
            $questionoption->selectcount = $questionoption->answerscount;
355
            $DB->set_field('qtype_ordering_options', 'selectcount', $questionoption->answerscount,
356
            unset($questionoption->answerscount);
-
 
357
            $DB->update_record('qtype_ordering_options', $questionoption);
356
                ['id' => $questionoption->id]);
358
        }
357
        }
Línea 359... Línea 358...
359
        $questionoptions->close();
358
        $questionoptions->close();
360
 
359
 
361
        // Currently, a 'qtype_ordering_selectcount' user preference is set (or updated, if it already exists) each time
360
        // Currently, a 'qtype_ordering_selectcount' user preference is set (or updated, if it already exists) each time
362
        // a new ordering question is created. If there are user preferences that store the removed "0" (all) option, they
361
        // a new ordering question is created. If there are user preferences that store the removed "0" (all) option, they
363
        // need to be updated. In this case, replace it with "2" (minimum number of items required to create a subset).
362
        // need to be updated. In this case, replace it with "2" (minimum number of items required to create a subset).
-
 
363
        $wheresql = 'name = ? AND ' . $DB->sql_compare_text('value') . ' = ?';
Línea 364... Línea 364...
364
        $DB->set_field('user_preferences', 'value', 2,
364
        $params = ['qtype_ordering_selectcount', '0'];
365
            ['name' => 'qtype_ordering_selectcount', 'value' => 0]);
365
        $DB->set_field_select('user_preferences', 'value', 2, $wheresql, $params);
Línea 366... Línea 366...
366
 
366
 
367
        upgrade_plugin_savepoint(true, 2024040401, 'qtype', 'ordering');
367
        upgrade_plugin_savepoint(true, 2024040401, 'qtype', 'ordering');
Línea -... Línea 368...
-
 
368
    }
-
 
369
 
-
 
370
    // Automatically generated Moodle v4.4.0 release upgrade line.
-
 
371
    // Put any upgrade step following this.
-
 
372
 
-
 
373
    // Automatically generated Moodle v4.5.0 release upgrade line.
368
    }
374
    // Put any upgrade step following this.
369
 
375