ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
72  if($solution[self::$USER_SOLUTION_IDENTIFIER_KEY] == $key)
73  {
74  unset($this->solutions[$array_key]);
75  break;
76  }
77  }
78  }
79 
86  public function getUserSolutionsByIdentifier($identifier)
87  {
88  if(
89  $identifier != self::$USER_SOLUTION_IDENTIFIER_KEY &&
90  $identifier != self::$USER_SOLUTION_IDENTIFIER_VALUE
91  )
92  {
93  throw new Exception(sprintf("Unkown Identifier %s", $identifier));
94  }
95 
96  $solutions = array();
97  foreach($this->solutions as $solution)
98  {
99  $solutions[] = $solution[$identifier];
100  }
101  return $solutions;
102  }
103 
107  public function getSolutions()
108  {
109  return $this->solutions;
110  }
111 
117  public function getSolutionForKey($key)
118  {
119  foreach($this->solutions as $solution)
120  {
121  if($solution[self::$USER_SOLUTION_IDENTIFIER_KEY] == $key)
122  {
123  return $solution;
124  }
125  }
126  return null;
127  }
128 
133  {
134  $this->reached_percentage = $reached_percentage;
135  }
136 
140  public function getReachedPercentage()
141  {
143  }
144 
148  public function hasSolutions()
149  {
150  return count($this->solutions) > 0;
151  }
152 }
153