4 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
30 $this->mark_steps = array();
49 $txt_failed_short =
"failed",
50 $txt_failed_official =
"failed",
51 $percentage_failed = 0,
53 $txt_passed_short =
"passed",
54 $txt_passed_official =
"passed",
55 $percentage_passed = 50,
60 $this->
addMarkStep($txt_failed_short, $txt_failed_official, $percentage_failed, $failed_passed);
61 $this->
addMarkStep($txt_passed_short, $txt_passed_official, $percentage_passed, $passed_passed);
75 public function addMarkStep( $txt_short =
"", $txt_official =
"", $percentage = 0, $passed = 0)
77 require_once
'./Modules/Test/classes/class.assMark.php';
78 $mark =
new ASS_Mark($txt_short, $txt_official, $percentage, $passed);
79 array_push($this->mark_steps, $mark);
93 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
96 $result = $ilDB->queryF(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
105 $oldmarks[
$row[
"minimum_level"]] =
$row;
110 if (!$test_id)
return;
112 $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
116 if (count($this->mark_steps) == 0)
return;
119 foreach ($this->mark_steps as $key => $value)
121 $next_id = $ilDB->nextId(
'tst_mark');
122 $ilDB->manipulateF(
"INSERT INTO tst_mark (mark_id, test_fi, short_name, official_name, minimum_level, passed, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
123 array(
'integer',
'integer',
'text',
'text',
'float',
'text',
'integer'),
127 $value->getShortName(),
128 $value->getOfficialName(),
129 $value->getMinimumLevel(),
137 $result = $ilDB->queryF(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
147 $newmarks[
$row[
"minimum_level"]] =
$row;
150 foreach ($oldmarks as $level =>
$row)
152 if (array_key_exists($level, $newmarks))
154 $difffields = array();
155 foreach (
$row as $key => $value)
157 if (strcmp($value, $newmarks[$level][$key]) != 0)
165 array_push($difffields,
"$key: $value => " .$newmarks[$level][$key]);
170 if (count($difffields))
184 foreach ($newmarks as $level =>
$row)
186 if (!array_key_exists($level, $oldmarks))
207 if (!$test_id)
return;
208 $result = $ilDB->queryF(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level",
215 while ($data = $ilDB->fetchAssoc(
$result))
217 $this->
addMarkStep($data[
"short_name"], $data[
"official_name"], $data[
"minimum_level"], $data[
"passed"]);
229 $this->mark_steps = array();
239 function level_sort($a, $b)
241 if ($a->getMinimumLevel() == $b->getMinimumLevel())
243 $res = strcmp($a->getShortName(), $b->getShortName());
246 return strcmp($a->getOfficialName(), $b->getOfficialName());
253 return ($a->getMinimumLevel() < $b->getMinimumLevel()) ? -1 : 1;
255 usort($this->mark_steps,
'level_sort');
267 if ($index < 0)
return;
268 if (count($this->mark_steps) < 1)
return;
269 if ($index >= count($this->mark_steps))
return;
270 unset($this->mark_steps[$index]);
271 $this->mark_steps = array_values($this->mark_steps);
283 foreach ($indexes as $key => $index)
285 if (!(($index < 0) or (count($this->mark_steps) < 1)))
287 unset($this->mark_steps[$index]);
290 $this->mark_steps = array_values($this->mark_steps);
304 for ($i = count($this->mark_steps) - 1; $i >= 0; $i--)
306 $curMinLevel = $this->mark_steps[$i]->getMinimumLevel();
308 if( $percentage > $curMinLevel || (
string)$percentage == (
string)$curMinLevel )
310 return $this->mark_steps[$i];
329 $result = $ilDB->queryF(
"SELECT * FROM tst_mark WHERE test_fi = %s ORDER BY minimum_level DESC",
337 if ($percentage >=
$row[
"minimum_level"])
358 $result = $ilDB->queryF(
"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",
364 if ($percentage >=
$row[
"minimum_level"])
382 public function _getMatchingMarkFromActiveId($active_id, $percentage)
386 $result = $ilDB->queryF(
"SELECT tst_mark.* FROM tst_active, tst_mark, tst_tests WHERE tst_mark.test_fi = tst_tests.test_id AND tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s ORDER BY minimum_level DESC",
394 if ($percentage >=
$row[
"minimum_level"])
411 $minimum_percentage = 100;
413 for ($i = 0; $i < count($this->mark_steps); $i++)
415 if ($this->mark_steps[$i]->getMinimumLevel() < $minimum_percentage)
417 $minimum_percentage = $this->mark_steps[$i]->getMinimumLevel();
419 if ($this->mark_steps[$i]->getPassed())
425 if ($minimum_percentage != 0)
427 return "min_percentage_ne_0";
432 return "no_passed_mark";
445 public function logAction($test_id, $logtext =
"")
449 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";