ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SequenceManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Survey\Sequence;
22
25
27{
28 protected \ilObjSurvey $survey;
29 protected \ilLogger $log;
30 protected int $survey_id;
33
34 public function __construct(
37 int $survey_id,
39 ) {
40 $this->question_repo = $repo->sequence();
41 $this->domain = $domain;
42 $this->survey_id = $survey_id; // not object id
43 $this->log = $domain->log();
44 $this->survey = $survey;
45 }
46
47 public function appendQuestion(
48 int $survey_question_id,
49 bool $duplicate = true,
50 bool $force_duplicate = false
51 ): int {
52 $this->log->debug("append question, id: " . $survey_question_id . ", duplicate: " . $duplicate . ", force: " . $force_duplicate);
53
54 // create duplicate if pool question (or forced for question blocks copy)
55 if ($duplicate) {
56 // this does nothing if this is not a pool question and $a_force_duplicate is false
57 $survey_question_id = $this->survey->duplicateQuestionForSurvey($survey_question_id, $force_duplicate);
58 }
59
60 // check if question is not already in the survey, see #22018
61 if ($this->survey->isQuestionInSurvey($survey_question_id)) {
62 return $survey_question_id;
63 }
64
65 // append to survey
66 $next_id = $this->question_repo->insert($this->survey_id, $survey_question_id);
67
68 $this->log->debug("insert svy_svy_qst, id: " . $next_id . ", qfi: " . $survey_question_id);
69
70 return $survey_question_id;
71 }
72
73}
appendQuestion(int $survey_question_id, bool $duplicate=true, bool $force_duplicate=false)
__construct(InternalRepoService $repo, InternalDomainService $domain, int $survey_id, \ilObjSurvey $survey)