24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
55 $this->mark_steps = array();
76 $txt_failed_short =
"failed",
77 $txt_failed_official =
"failed",
78 $percentage_failed = 0,
80 $txt_passed_short =
"passed",
81 $txt_passed_official =
"passed",
82 $percentage_passed = 50,
87 $this->
addMarkStep($txt_failed_short, $txt_failed_official, $percentage_failed, $failed_passed);
88 $this->
addMarkStep($txt_passed_short, $txt_passed_official, $percentage_passed, $passed_passed);
111 include_once
"./Modules/Test/classes/class.assMark.php";
112 $mark =
new ASS_Mark($txt_short, $txt_official, $percentage, $passed);
113 array_push($this->mark_steps, $mark);
130 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
133 $query = sprintf(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
134 $ilDB->quote($test_id)
136 $result = $ilDB->query($query);
137 if ($result->numRows())
139 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
141 $oldmarks[$row[
"minimum_level"]] = $row;
146 if (!$test_id)
return;
148 $query = sprintf(
"DELETE FROM tst_mark WHERE test_fi = %s",
149 $ilDB->quote($test_id)
151 $result = $ilDB->query($query);
152 if (count($this->mark_steps) == 0)
return;
155 foreach ($this->mark_steps as $key => $value)
157 $query = sprintf(
"INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
158 $ilDB->quote($test_id),
159 $ilDB->quote($value->getShortName()),
160 $ilDB->quote($value->getOfficialName()),
161 $ilDB->quote($value->getMinimumLevel()),
162 $ilDB->quote(sprintf(
"%d", $value->getPassed()))
164 $result = $ilDB->query($query);
165 if (PEAR::isError($result))
168 $ilias->raiseError($result->getMessage());
173 $query = sprintf(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
174 $ilDB->quote($test_id)
176 $result = $ilDB->query($query);
178 if ($result->numRows())
180 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
182 $newmarks[$row[
"minimum_level"]] = $row;
185 foreach ($oldmarks as $level => $row)
187 if (array_key_exists($level, $newmarks))
189 $difffields = array();
190 foreach ($row as $key => $value)
192 if (strcmp($value, $newmarks[$level][$key]) != 0)
200 array_push($difffields,
"$key: $value => " .$newmarks[$level][$key]);
205 if (count($difffields))
219 foreach ($newmarks as $level => $row)
221 if (!array_key_exists($level, $oldmarks))
245 if (!$test_id)
return;
246 $query = sprintf(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
247 $ilDB->quote($test_id)
250 $result = $ilDB->query($query);
251 if ($result->numRows() > 0)
253 while (
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
270 $this->mark_steps = array();
282 function level_sort($a, $b) {
283 if ($a->getMinimumLevel() == $b->getMinimumLevel()) {
284 $res = strcmp($a->getShortName(), $b->getShortName());
286 return strcmp($a->getOfficialName(), $b->getOfficialName());
291 return ($a->getMinimumLevel() < $b->getMinimumLevel()) ? -1 : 1;
294 usort($this->mark_steps,
'level_sort');
307 if ($index < 0)
return;
308 if (count($this->mark_steps) < 1)
return;
309 if ($index >= count($this->mark_steps))
return;
310 unset($this->mark_steps[$index]);
311 $this->mark_steps = array_values($this->mark_steps);
324 foreach ($indexes as $key => $index) {
325 if (!(($index < 0) or (count($this->mark_steps) < 1))) {
326 unset($this->mark_steps[$index]);
329 $this->mark_steps = array_values($this->mark_steps);
343 for ($i = count($this->mark_steps) - 1; $i >= 0; $i--) {
344 if ($percentage >= $this->mark_steps[$i]->getMinimumLevel()) {
345 return $this->mark_steps[$i];
365 $query = sprintf(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level DESC",
366 $ilDB->quote($test_id .
"")
368 $result = $ilDB->query($query);
369 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
371 if ($percentage >= $row[
"minimum_level"])
393 $query = sprintf(
"SELECT tst_mark.* FROM tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.obj_fi = %s ORDER BY minimum_level DESC",
394 $ilDB->quote($a_obj_id .
"")
396 $result = $ilDB->query($query);
397 while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
399 if ($percentage >= $row[
"minimum_level"])
418 $minimum_percentage = 100;
420 for ($i = 0; $i < count($this->mark_steps); $i++) {
421 if ($this->mark_steps[$i]->getMinimumLevel() < $minimum_percentage)
423 $minimum_percentage = $this->mark_steps[$i]->getMinimumLevel();
425 if ($this->mark_steps[$i]->getPassed())
430 if ($minimum_percentage != 0)
432 return "min_percentage_ne_0";
436 return "no_passed_mark";
453 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";