ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUserQuestionResult.php
Go to the documentation of this file.
1<?php
2
11{
12 public static $USER_SOLUTION_IDENTIFIER_KEY = "key";
13 public static $USER_SOLUTION_IDENTIFIER_VALUE = "value";
14
15
19 protected $question;
20
24 protected $active_id;
25
29 protected $pass;
30
35
39 protected $solutions = array();
40
47 {
48 $this->question = $question;
49 $this->active_id = $active_id;
50 $this->pass = $pass;
51 }
52
57 public function addKeyValue($key, $value)
58 {
59 $this->solutions[] = array(
60 self::$USER_SOLUTION_IDENTIFIER_KEY => $key,
61 self::$USER_SOLUTION_IDENTIFIER_VALUE => $value
62 );
63 }
64
68 public function removeByKey($key)
69 {
70 foreach ($this->solutions as $array_key => $solution) {
71 if ($solution[self::$USER_SOLUTION_IDENTIFIER_KEY] == $key) {
72 unset($this->solutions[$array_key]);
73 break;
74 }
75 }
76 }
77
84 public function getUserSolutionsByIdentifier($identifier)
85 {
86 if (
87 $identifier != self::$USER_SOLUTION_IDENTIFIER_KEY &&
88 $identifier != self::$USER_SOLUTION_IDENTIFIER_VALUE
89 ) {
90 throw new Exception(sprintf("Unkown Identifier %s", $identifier));
91 }
92
93 $solutions = array();
94 foreach ($this->solutions as $solution) {
95 $solutions[] = $solution[$identifier];
96 }
97 return $solutions;
98 }
99
103 public function getSolutions()
104 {
105 return $this->solutions;
106 }
107
113 public function getSolutionForKey($key)
114 {
115 foreach ($this->solutions as $solution) {
116 if ($solution[self::$USER_SOLUTION_IDENTIFIER_KEY] == $key) {
117 return $solution;
118 }
119 }
120 return null;
121 }
122
127 {
128 $this->reached_percentage = $reached_percentage;
129 }
130
134 public function getReachedPercentage()
135 {
137 }
138
142 public function hasSolutions()
143 {
144 return count($this->solutions) > 0;
145 }
146}
An exception for terminatinating execution or to throw for unit testing.
Class ilUserQuestionResult.
__construct($question, $active_id, $pass)
setReachedPercentage($reached_percentage)
$key
Definition: croninfo.php:18