ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilAssQuestionPreviewSettings.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  private $contextRefId = null;
28 
32  protected $reachedPointsEnabled = false;
33 
34  private $genericFeedbackEnabled = false;
35 
36  private $specificFeedbackEnabled = false;
37 
38  private $hintProvidingEnabled = false;
39 
40  private $bestSolutionEnabled = false;
41 
42  public function __construct($contextRefId)
43  {
44  $this->contextRefId = $contextRefId;
45  }
46 
47  public function init(): void
48  {
49  if ($this->isTestRefId()) {
51  } else {
53  }
54  }
55 
56  public function isTestRefId(): bool
57  {
58  $objectType = ilObject::_lookupType($this->contextRefId, true);
59 
60  return $objectType == 'tst';
61  }
62 
63  private function initSettingsWithTestObject(): void
64  {
65  /* @var ilObjTest $testOBJ */
66  $testOBJ = ilObjectFactory::getInstanceByRefId($this->contextRefId);
67  $testOBJ->loadFromDb();
68 
69  $this->setGenericFeedbackEnabled($testOBJ->getGenericAnswerFeedback());
70  $this->setSpecificFeedbackEnabled($testOBJ->getSpecificAnswerFeedback());
71  $this->setHintProvidingEnabled($testOBJ->isOfferingQuestionHintsEnabled());
72  $this->setBestSolutionEnabled($testOBJ->getInstantFeedbackSolution());
73  $this->setReachedPointsEnabled($testOBJ->getAnswerFeedbackPoints());
74  }
75 
76  private function initSettingsFromPostParameters(): void
77  {
78  // get from post or from toolbar instance if possible
79 
80  $this->setGenericFeedbackEnabled(true);
81  $this->setSpecificFeedbackEnabled(true);
82  $this->setHintProvidingEnabled(true);
83  $this->setBestSolutionEnabled(true);
84  $this->setReachedPointsEnabled(true);
85  }
86 
87  public function setContextRefId($contextRefId): void
88  {
89  $this->contextRefId = $contextRefId;
90  }
91 
92  public function getContextRefId()
93  {
94  return $this->contextRefId;
95  }
96 
100  public function isReachedPointsEnabled(): bool
101  {
103  }
104 
108  public function setReachedPointsEnabled(bool $reachedPointsEnabled): void
109  {
110  $this->reachedPointsEnabled = $reachedPointsEnabled;
111  }
112 
114  {
115  $this->genericFeedbackEnabled = $genericFeedbackEnabled;
116  }
117 
118  public function isGenericFeedbackEnabled(): bool
119  {
121  }
122 
124  {
125  $this->specificFeedbackEnabled = $specificFeedbackEnabled;
126  }
127 
128  public function isSpecificFeedbackEnabled(): bool
129  {
131  }
132 
133  public function setHintProvidingEnabled(bool $hintProvidingEnabled): void
134  {
135  $this->hintProvidingEnabled = $hintProvidingEnabled;
136  }
137 
138  public function isHintProvidingEnabled(): bool
139  {
141  }
142 
144  {
145  $this->bestSolutionEnabled = $bestSolutionEnabled;
146  }
147 
148  public function isBestSolutionEnabled(): bool
149  {
151  }
152 
153  public function isInstantFeedbackNavigationRequired(): bool
154  {
155  if ($this->isGenericFeedbackEnabled()) {
156  return true;
157  }
158 
159  if ($this->isSpecificFeedbackEnabled()) {
160  return true;
161  }
162 
163  if ($this->isBestSolutionEnabled()) {
164  return true;
165  }
166 
167  return false;
168  }
169 
170  public function isHintProvidingNavigationRequired(): bool
171  {
172  return $this->isHintProvidingEnabled();
173  }
174 }
setReachedPointsEnabled(bool $reachedPointsEnabled)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setHintProvidingEnabled(bool $hintProvidingEnabled)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupType(int $id, bool $reference=false)