ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
SuggestedSolution.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
21 
27 abstract class SuggestedSolution
28 {
29  public const TYPE_LM = 'lm';
30  public const TYPE_LM_CHAPTER = 'st';
31  public const TYPE_LM_PAGE = 'pg';
32  public const TYPE_GLOSARY_TERM = 'git';
33  public const TYPE_FILE = 'file';
34 
35  public const TYPES = [
36  self::TYPE_LM => 'obj_lm',
37  self::TYPE_LM_CHAPTER => 'obj_st',
38  self::TYPE_LM_PAGE => 'obj_pg',
39  self::TYPE_GLOSARY_TERM => 'glossary_term',
40  self::TYPE_FILE => 'fileDownload'
41  ];
42 
43  protected int $id;
44  protected int $question_id;
45  protected int $subquestion_index;
46  protected string $import_id;
47  protected \DateTimeImmutable $last_update;
48 
49  public function __construct(
50  int $id,
51  int $question_id,
52  int $subquestion_index,
53  string $import_id,
54  \DateTimeImmutable $last_update
55  ) {
56  $this->id = $id;
57  $this->question_id = $question_id;
58  $this->subquestion_index = $subquestion_index;
59  $this->import_id = $import_id;
60  $this->last_update = $last_update;
61  }
62 
63  abstract public function getType(): string;
64  abstract public function getStorableValue(): string;
65 
66  public function getId(): int
67  {
68  return $this->id;
69  }
70  public function withId(int $id): static
71  {
72  $clone = clone $this;
73  $clone->id = $id;
74  return $clone;
75  }
76 
77  public function getQuestionId(): int
78  {
79  return $this->question_id;
80  }
81  public function withQuestionId(int $question_id): static
82  {
83  $clone = clone $this;
84  $clone->question_id = $question_id;
85  return $clone;
86  }
87 
88  public function getImportId(): string
89  {
90  return $this->import_id;
91  }
92  public function withImportId(string $import_id): static
93  {
94  $clone = clone $this;
95  $clone->import_id = $import_id;
96  return $clone;
97  }
98 
99  public function getSubquestionIndex(): int
100  {
102  }
103  public function withSubquestionIndex(int $subquestion_index): static
104  {
105  $clone = clone $this;
106  $clone->subquestion_index = $subquestion_index;
107  return $clone;
108  }
109 
110  public function getLastUpdate(): \DateTimeImmutable
111  {
112  return $this->last_update;
113  }
114 
115  public function isOfTypeFile(): bool
116  {
117  return $this->getType() === self::TYPE_FILE;
118  }
119 
120  public function isOfTypeLink(): bool
121  {
122  return in_array(
123  $this->getType(),
124  [
125  self::TYPE_LM,
126  self::TYPE_LM_CHAPTER,
127  self::TYPE_LM_PAGE,
128  self::TYPE_GLOSARY_TERM,
129  ]
130  );
131  }
132 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $id, int $question_id, int $subquestion_index, string $import_id, \DateTimeImmutable $last_update)