ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssQuestionLifecycle.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
14{
15 const DRAFT = 'draft';
16 const REVIEW = 'review';
17 const REJECTED = 'rejected';
18 const FINAL = 'final';
19 const SHARABLE = 'sharable';
20 const OUTDATED = 'outdated';
21
25 protected $identifier;
26
30 protected function __construct()
31 {
32 $this->setIdentifier(self::DRAFT);
33 }
34
38 public function getIdentifier()
39 {
40 return $this->identifier;
41 }
42
46 public function setIdentifier($identifier)
47 {
48 $this->identifier = $identifier;
49 }
50
54 public function getValidIdentifiers()
55 {
57 }
58
62 public function getMappedLomLifecycle()
63 {
64 switch ($this->getIdentifier()) {
65 case self::OUTDATED:
66
68
69 case self::SHARABLE:
70 case self::FINAL:
71
73
74 case self::REJECTED:
75 case self::REVIEW:
76 case self::DRAFT:
77 default:
78
80 }
81 }
82
88 {
89 return $this->getTranslationByIdentifier($lng, $this->getIdentifier());
90 }
91
97 {
98 switch ($identifier) {
99 case self::DRAFT:
100
101 return $lng->txt('qst_lifecycle_draft');
102
103 case self::REVIEW:
104
105 return $lng->txt('qst_lifecycle_review');
106
107 case self::REJECTED:
108
109 return $lng->txt('qst_lifecycle_rejected');
110
111 case self::FINAL:
112
113 return $lng->txt('qst_lifecycle_final');
114
115 case self::SHARABLE:
116
117 return $lng->txt('qst_lifecycle_sharable');
118
119 case self::OUTDATED:
120
121 return $lng->txt('qst_lifecycle_outdated');
122
123 default: return '';
124 }
125 }
126
132 {
133 $selectOptions = [];
134
135 foreach ($this->getValidIdentifiers() as $identifier) {
136 $selectOptions[$identifier] = $this->getTranslationByIdentifier($lng, $identifier);
137 }
138
139 return $selectOptions;
140 }
141
147 {
148 if (!in_array($identifier, $this->getValidIdentifiers())) {
150 'invalid ilias lifecycle given: ' . $identifier
151 );
152 }
153 }
154
160 public static function getInstance($identifier)
161 {
162 $lifecycle = new self();
163 $lifecycle->validateIdentifier($identifier);
164 $lifecycle->setIdentifier($identifier);
165
166 return $lifecycle;
167 }
168
172 public static function getDraftInstance()
173 {
174 $lifecycle = new self();
175 $lifecycle->setIdentifier(self::DRAFT);
176
177 return $lifecycle;
178 }
179}
An exception for terminatinating execution or to throw for unit testing.
__construct()
ilAssQuestionLifecycle constructor.
getTranslationByIdentifier(ilLanguage $lng, $identifier)
language handling
$lng