ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssQuestionPreviewSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
12 {
13  private $contextRefId = null;
14 
18  protected $reachedPointsEnabled = false;
19 
20  private $genericFeedbackEnabled = false;
21 
22  private $specificFeedbackEnabled = false;
23 
24  private $hintProvidingEnabled = false;
25 
26  private $bestSolutionEnabled = false;
27 
28  public function __construct($contextRefId)
29  {
30  $this->contextRefId = $contextRefId;
31  }
32 
33  public function init()
34  {
35  if ($this->isTestRefId()) {
37  } else {
39  }
40  }
41 
42  public function isTestRefId()
43  {
44  $objectType = ilObject::_lookupType($this->contextRefId, true);
45 
46  return $objectType == 'tst';
47  }
48 
49  private function initSettingsWithTestObject()
50  {
51  /* @var ilObjTest $testOBJ */
52  $testOBJ = ilObjectFactory::getInstanceByRefId($this->contextRefId);
53  $testOBJ->loadFromDb();
54 
55  $this->setGenericFeedbackEnabled($testOBJ->getGenericAnswerFeedback());
56  $this->setSpecificFeedbackEnabled($testOBJ->getSpecificAnswerFeedback());
57  $this->setHintProvidingEnabled($testOBJ->isOfferingQuestionHintsEnabled());
58  $this->setBestSolutionEnabled($testOBJ->getInstantFeedbackSolution());
59  $this->setReachedPointsEnabled($testOBJ->getAnswerFeedbackPoints());
60  }
61 
62  private function initSettingsFromPostParameters()
63  {
64  // get from post or from toolbar instance if possible
65 
66  $this->setGenericFeedbackEnabled(true);
67  $this->setSpecificFeedbackEnabled(true);
68  $this->setHintProvidingEnabled(true);
69  $this->setBestSolutionEnabled(true);
70  $this->setReachedPointsEnabled(true);
71  }
72 
73  public function setContextRefId($contextRefId)
74  {
75  $this->contextRefId = $contextRefId;
76  }
77 
78  public function getContextRefId()
79  {
80  return $this->contextRefId;
81  }
82 
86  public function isReachedPointsEnabled() : bool
87  {
89  }
90 
95  {
96  $this->reachedPointsEnabled = $reachedPointsEnabled;
97  }
98 
100  {
101  $this->genericFeedbackEnabled = $genericFeedbackEnabled;
102  }
103 
104  public function isGenericFeedbackEnabled()
105  {
107  }
108 
110  {
111  $this->specificFeedbackEnabled = $specificFeedbackEnabled;
112  }
113 
114  public function isSpecificFeedbackEnabled()
115  {
117  }
118 
120  {
121  $this->hintProvidingEnabled = $hintProvidingEnabled;
122  }
123 
124  public function isHintProvidingEnabled()
125  {
127  }
128 
130  {
131  $this->bestSolutionEnabled = $bestSolutionEnabled;
132  }
133 
134  public function isBestSolutionEnabled()
135  {
137  }
138 
140  {
141  if ($this->isGenericFeedbackEnabled()) {
142  return true;
143  }
144 
145  if ($this->isSpecificFeedbackEnabled()) {
146  return true;
147  }
148 
149  if ($this->isBestSolutionEnabled()) {
150  return true;
151  }
152 
153  return false;
154  }
155 
157  {
158  return $this->isHintProvidingEnabled();
159  }
160 }
setReachedPointsEnabled(bool $reachedPointsEnabled)
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id