ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionPreviewSettings.php
Go to the documentation of this file.
1<?php
2
26{
27 private $contextRefId = null;
28
32 protected $reachedPointsEnabled = false;
33 private $genericFeedbackEnabled = false;
34 private $specificFeedbackEnabled = false;
35 private $bestSolutionEnabled = false;
36
37 public function __construct($contextRefId)
38 {
39 $this->contextRefId = $contextRefId;
40 }
41
42 public function init(): void
43 {
44 if ($this->isTestRefId()) {
46 } else {
48 }
49 }
50
51 public function isTestRefId(): bool
52 {
53 $objectType = ilObject::_lookupType($this->contextRefId, true);
54
55 return $objectType == 'tst';
56 }
57
58 private function initSettingsWithTestObject(): void
59 {
60 /* @var ilObjTest $testOBJ */
61 $testOBJ = ilObjectFactory::getInstanceByRefId($this->contextRefId);
62 $testOBJ->loadFromDb();
63
64 $this->setGenericFeedbackEnabled($testOBJ->getGenericAnswerFeedback());
65 $this->setSpecificFeedbackEnabled($testOBJ->getSpecificAnswerFeedback());
66 $this->setBestSolutionEnabled($testOBJ->getInstantFeedbackSolution());
67 $this->setReachedPointsEnabled($testOBJ->getAnswerFeedbackPoints());
68 }
69
70 private function initSettingsFromPostParameters(): void
71 {
72 // get from post or from toolbar instance if possible
73
74 $this->setGenericFeedbackEnabled(true);
75 $this->setSpecificFeedbackEnabled(true);
76 $this->setBestSolutionEnabled(true);
77 $this->setReachedPointsEnabled(true);
78 }
79
80 public function setContextRefId($contextRefId): void
81 {
82 $this->contextRefId = $contextRefId;
83 }
84
85 public function getContextRefId()
86 {
88 }
89
93 public function isReachedPointsEnabled(): bool
94 {
96 }
97
102 {
103 $this->reachedPointsEnabled = $reachedPointsEnabled;
104 }
105
107 {
108 $this->genericFeedbackEnabled = $genericFeedbackEnabled;
109 }
110
111 public function isGenericFeedbackEnabled(): bool
112 {
114 }
115
117 {
118 $this->specificFeedbackEnabled = $specificFeedbackEnabled;
119 }
120
121 public function isSpecificFeedbackEnabled(): bool
122 {
124 }
125
127 {
128 $this->bestSolutionEnabled = $bestSolutionEnabled;
129 }
130
131 public function isBestSolutionEnabled(): bool
132 {
134 }
135
137 {
138 if ($this->isGenericFeedbackEnabled()) {
139 return true;
140 }
141
142 if ($this->isSpecificFeedbackEnabled()) {
143 return true;
144 }
145
146 if ($this->isBestSolutionEnabled()) {
147 return true;
148 }
149
150 return false;
151 }
152}
setReachedPointsEnabled(bool $reachedPointsEnabled)
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)