ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilLSPostCondition.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
30  public const OPERATOR_LP = 'learning_progress';
31  public const OPERATOR_ALWAYS = 'always';
32  public const OPERATOR_FAILED = 'failed';
33  public const OPERATOR_FINISHED = 'finished';
34  public const OPERATOR_NOT_FINISHED = 'not_finished';
35  public const OPERATOR_PASSED = 'passed';
36 
37  protected static $known_operators = [
38  self::OPERATOR_ALWAYS,
39  self::OPERATOR_FAILED,
40  self::OPERATOR_FINISHED,
41  self::OPERATOR_NOT_FINISHED,
42  self::OPERATOR_PASSED,
43  self::OPERATOR_LP
44  ];
45 
46  protected int $ref_id;
47  protected string $operator;
48  protected ?string $value;
49 
50  public function __construct(
51  int $ref_id,
52  string $operator,
53  ?string $value = null
54  ) {
55  if (!in_array($operator, self::$known_operators)) {
56  throw new \InvalidArgumentException(
57  "Unknown operator: $operator"
58  );
59  }
60 
61  $this->ref_id = $ref_id;
62  $this->operator = $operator;
63  $this->value = $value;
64  }
65 
66  public function getRefId(): int
67  {
68  return $this->ref_id;
69  }
70 
71  public function withRefId(int $ref_id): self
72  {
73  $clone = clone $this;
74  $clone->ref_id = $ref_id;
75  return $clone;
76  }
77 
78  public function getConditionOperator(): string
79  {
80  return $this->operator;
81  }
82 
83  public function withConditionOperator(string $operator): ilLSPostCondition
84  {
85  if (!in_array($operator, self::$known_operators)) {
86  throw new \InvalidArgumentException(
87  "Unknown operator: $operator"
88  );
89  }
90 
91  $clone = clone $this;
92  $clone->operator = $operator;
93  return $clone;
94  }
95 
96  public function getValue(): ?string
97  {
98  return $this->value;
99  }
100 
101  public function withValue(string $value): ilLSPostCondition
102  {
103  $clone = clone $this;
104  $clone->value = $value;
105  return $clone;
106  }
107 }
withConditionOperator(string $operator)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(int $ref_id, string $operator,?string $value=null)
A PostCondition does restrict the progression of a user through the learning sequence.