19declare(strict_types=1);
32 return 'Fix Missing Question Duplication When Creating in Test And Pool';
43 new \ilDatabaseInitializedObjective()
49 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
54 if (!$this->ilias_is_initialized) {
57 $this->ilias_is_initialized =
true;
59 $query_main =
'SELECT qst.question_id FROM tst_tests AS tst'
60 .
' INNER JOIN tst_test_question AS tst_qst'
61 .
' ON tst.test_id = tst_qst.test_fi'
62 .
' INNER JOIN qpl_questions AS qst'
63 .
' ON tst_qst.question_fi = qst.question_id'
64 .
' WHERE tst.question_set_type = "FIXED_QUEST_SET"'
65 .
' AND qst.obj_fi != tst.obj_fi'
66 .
' AND ISNULL(qst.original_id)';
67 $result_main = $this->db->query($query_main);
68 while ($question = $this->db->fetchAssoc($result_main)) {
70 $clone_id = $question_obj->duplicate(
false);
74 [
'original_id' => [
'integer', $clone_id]],
75 [
'original_id' => [
'integer', $question[
'question_id']]]
78 $test_query =
'SELECT obj_fi FROM tst_test_question INNER JOIN tst_tests ON tst_test_question.test_fi = tst_tests.test_id WHERE question_fi = %s';
79 $test_result = $this->db->queryF($test_query, [
'integer'], [$question[
'question_id']]);
84 'original_id' => [
'integer', $clone_id],
85 'obj_fi' => [
'integer', ($this->db->fetchObject($test_result))->obj_fi]
87 [
'question_id' => [
'integer', $question[
'question_id']]]
94 $query =
'SELECT COUNT(qst.question_id) AS cnt FROM tst_tests AS tst'
95 .
' INNER JOIN tst_test_question AS tst_qst'
96 .
' ON tst.test_id = tst_qst.test_fi'
97 .
' INNER JOIN qpl_questions AS qst'
98 .
' ON tst_qst.question_fi = qst.question_id'
99 .
' WHERE tst.question_set_type = "FIXED_QUEST_SET"'
100 .
' AND qst.obj_fi != tst.obj_fi'
101 .
' AND ISNULL(qst.original_id)';
102 $result = $this->db->query(
$query);
103 $row = $this->db->fetchAssoc($result);
105 return (
int) ($row[
'cnt'] ?? 0);
static _instanciateQuestion(int $question_id)
static init(string $a_type)
Init context by type.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
bool $ilias_is_initialized
prepare(Environment $environment)
Prepare the migration by means of some environment.
step(Environment $environment)
Run one step of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
static initILIAS()
ilias initialisation
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.