19 declare(strict_types=1);
31 private \ilDBInterface
$db;
35 return 'Fix missing clones for Introduction and Concluding Remarks.';
46 new \ilDatabaseInitializedObjective()
57 $select_page_statement = $this->db->prepare(
58 'SELECT * FROM page_object WHERE parent_type = "tst" AND page_id = ?',
65 $this->db->free($select_page_statement);
70 $result_intro = $this->db->query(
' 71 SELECT COUNT(test_id) as cnt 73 WHERE NOT introduction_page_id IS NULL 74 AND introduction_page_id IN 75 (SELECT introduction_page_id FROM tst_tests GROUP BY introduction_page_id HAVING COUNT(introduction_page_id) > 1) 77 $row_intro = $this->db->fetchObject($result_intro);
79 $result_conclusion = $this->db->query(
' 80 SELECT COUNT(test_id) as cnt 82 WHERE NOT concluding_remarks_page_id IS NULL 83 AND concluding_remarks_page_id in 84 (SELECT concluding_remarks_page_id FROM tst_tests GROUP BY concluding_remarks_page_id HAVING COUNT(concluding_remarks_page_id) > 1) 86 $row_conclusion = $this->db->fetchObject($result_conclusion);
88 return (
int) ceil(($row_intro->cnt + $row_conclusion->cnt) / self::TESTS_PER_STEP);
93 $result = $this->db->query(
95 SELECT test_id, obj_fi, introduction_page_id 97 WHERE NOT introduction_page_id IS NULL 98 AND introduction_page_id IN 99 (SELECT introduction_page_id FROM tst_tests GROUP BY introduction_page_id HAVING COUNT(introduction_page_id) > 1) 100 ORDER BY introduction_page_id 101 LIMIT ' . self::TESTS_PER_STEP
104 $first_row = $this->db->fetchObject($result);
105 if ($first_row ===
null) {
106 return self::TESTS_PER_STEP;
109 $introduction_to_clone = $this->db->fetchObject(
111 $select_page_statement,
112 [$first_row->introduction_page_id]
115 while (($row = $this->db->fetchObject($result)) !==
null) {
116 if ($row->introduction_page_id !== $introduction_to_clone?->page_id) {
117 $introduction_to_clone = $this->db->fetchObject(
119 $select_page_statement,
120 [$row->introduction_page_id]
138 return self::TESTS_PER_STEP - $result->numRows();
143 $result = $this->db->query(
145 SELECT test_id, obj_fi, concluding_remarks_page_id 147 WHERE NOT concluding_remarks_page_id IS NULL 148 AND concluding_remarks_page_id IN 149 (SELECT concluding_remarks_page_id FROM tst_tests GROUP BY concluding_remarks_page_id HAVING COUNT(concluding_remarks_page_id) > 1) 150 ORDER BY concluding_remarks_page_id 154 $first_row = $this->db->fetchObject($result);
155 if ($first_row ===
null) {
159 $concluding_remarks_to_clone = $this->db->fetchObject(
161 $select_page_statement,
162 [$first_row->concluding_remarks_page_id]
165 while (($row = $this->db->fetchObject($result)) !==
null) {
166 if ($row->concluding_remarks_page_id !== $concluding_remarks_to_clone?->page_id) {
167 $concluding_remarks_to_clone = $this->db->fetchObject(
169 $select_page_statement,
170 [$row->concluding_remarks_page_id]
191 $query = $this->db->query(
'SELECT max(page_id) as last_id FROM page_object WHERE parent_type="tst"');
192 $last_row = $this->db->fetchObject($query);
197 'page_id' => [
'integer', $last_row->last_id + 1],
198 'parent_id' => [
'integer', $test_obj_id],
199 'lang' => [
'text', $row->lang],
200 'content' => [
'clob', $row->content],
201 'parent_type' => [
'text', $row->parent_type],
202 'create_user' => [
'integer', $row->create_user],
203 'last_change_user' => [
'integer', $row->last_change_user],
204 'active' => [
'integer', $row->active],
205 'activation_start' => [
'timestamp', $row->activation_start],
206 'activation_end' => [
'timestamp', $row->activation_end],
207 'show_activation_info' => [
'integer', $row->show_activation_info],
208 'inactive_elements' => [
'integer', $row->inactive_elements],
209 'int_links' => [
'integer', $row->int_links],
212 'is_empty' => [
'integer', $row->is_empty]
219 return $last_row->last_id + 1;
migrateConcludingRemarks(\ilDBStatement $select_page_statement, int $max_steps)
step(Environment $environment)
Run one step of the migration.
A migration is a potentially long lasting operation that can be broken into discrete steps...
createPageWithNextId(int $test_obj_id, \stdClass $row)
static now()
Return current timestamp in Y-m-d H:i:s format.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
prepare(Environment $environment)
Prepare the migration by means of some environment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
migrateIntroductions(\ilDBStatement $select_page_statement)
An environment holds resources to be used in the setup process.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.