33 require_once
"./classes/class.ilObject.php";
47 include_once
"./Services/Administration/classes/class.ilSetting.php";
48 $this->setting =
new ilSetting(
"assessment");
50 $this->
ilObject($a_id,$a_call_by_reference);
61 if (!parent::update())
81 if (!parent::delete())
114 return $roles ? $roles : array();
130 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
170 if ($a_node_id==
$_GET[
"ref_id"])
172 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
173 $parent_type = $parent_obj->getType();
174 if($parent_type == $this->
getType())
176 $a_node_id = (int) $tree->getParentId($a_node_id);
180 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
192 $setting->set(
"assessment_logging", 1);
196 $setting->set(
"assessment_logging", 0);
207 $setting->set(
"assessment_log_language", $a_language);
217 return (
boolean)
$setting->get(
"assessment_logging");
226 $types =
$setting->get(
"forbidden_questiontypes");
228 if (strlen(trim($types)) == 0)
248 if (is_array($a_types) && (count($a_types) > 0))
250 $types = serialize($a_types);
252 $setting->set(
"forbidden_questiontypes", $types);
263 if (strlen(
$lang) == 0)
277 $types =
$setting->get(
"assessment_manual_scoring");
278 return explode(
",", $types);
288 $query =
"SELECT * FROM qpl_question_type";
289 $result = $ilDB->query($query);
293 $dbtypes[$row[
"question_type_id"]] = $row[
"type_tag"];
296 $types =
$setting->get(
"assessment_manual_scoring");
297 $ids = explode(
",", $types);
298 foreach ($ids as $key => $value)
300 $ids[$key] = $dbtypes[$value];
313 if ((!is_array($type_ids)) || (count($type_ids) == 0))
315 $setting->delete(
"assessment_manual_scoring");
319 $setting->set(
"assessment_manual_scoring", implode($type_ids,
","));
335 function _addLog($user_id, $object_id, $logtext, $question_id =
"", $original_id =
"", $test_only = FALSE,
$ref_id = NULL)
337 global $ilUser, $ilDB;
338 if (strlen($question_id) == 0)
340 $question_id =
"NULL";
344 $question_id = $ilDB->quote($question_id .
"");
346 if (strlen($original_id) == 0)
348 $original_id =
"NULL";
352 $original_id = $ilDB->quote($original_id .
"");
355 if ($test_only == TRUE)
359 $test_ref_id =
"NULL";
362 $test_ref_id = $ilDB->quote(
$ref_id .
"");
364 $query = sprintf(
"INSERT INTO ass_log (ass_log_id, user_fi, obj_fi, logtext, question_fi, original_fi, test_only, ref_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, NULL)",
365 $ilDB->quote($user_id .
""),
366 $ilDB->quote($object_id .
""),
367 $ilDB->quote($logtext .
""),
370 $ilDB->quote($only .
""),
373 $result = $ilDB->query($query);
386 function &
getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
389 if ($test_only == TRUE)
391 $query = sprintf(
"SELECT *, TIMESTAMP + 0 AS timestamp14 FROM ass_log WHERE obj_fi = %s AND TIMESTAMP + 0 > %s AND TIMESTAMP + 0 < %s AND test_only = %s ORDER BY timestamp14",
392 $this->ilias->db->quote($test_id .
""),
393 $this->ilias->db->quote($ts_from .
""),
394 $this->ilias->db->quote($ts_to .
""),
395 $this->ilias->db->quote(
"1")
400 $query = sprintf(
"SELECT *, TIMESTAMP + 0 AS timestamp14 FROM ass_log WHERE obj_fi = %s AND TIMESTAMP + 0 > %s AND TIMESTAMP + 0 < %s ORDER BY timestamp14",
401 $this->ilias->db->quote($test_id .
""),
402 $this->ilias->db->quote($ts_from .
""),
403 $this->ilias->db->quote($ts_to .
"")
406 $result = $this->ilias->db->query($query);
409 if (!array_key_exists($row[
"timestamp14"],
$log))
411 $log[$row[
"timestamp14"]] = array();
413 array_push(
$log[$row[
"timestamp14"]], $row);
417 $log_array = array();
418 foreach (
$log as $key => $value)
420 foreach ($value as $index => $row)
422 array_push($log_array, $row);
438 function &
_getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
443 if ($test_only == TRUE)
445 $query = sprintf(
"SELECT *, TIMESTAMP + 0 AS timestamp14 FROM ass_log WHERE obj_fi = %s AND TIMESTAMP + 0 > %s AND TIMESTAMP + 0 < %s AND test_only = %s ORDER BY timestamp14",
446 $ilDB->quote($test_id .
""),
447 $ilDB->quote($ts_from .
""),
448 $ilDB->quote($ts_to .
""),
454 $query = sprintf(
"SELECT *, TIMESTAMP + 0 AS timestamp14 FROM ass_log WHERE obj_fi = %s AND TIMESTAMP + 0 > %s AND TIMESTAMP + 0 < %s ORDER BY timestamp14",
455 $ilDB->quote($test_id .
""),
456 $ilDB->quote($ts_from .
""),
457 $ilDB->quote($ts_to .
"")
460 $result = $ilDB->query($query);
463 if (!array_key_exists($row[
"timestamp14"],
$log))
465 $log[$row[
"timestamp14"]] = array();
468 if (array_key_exists(
"ref_id", $row))
470 if ($row[
"ref_id"] > 0)
472 $typequery = sprintf(
"SELECT object_data.type FROM object_data, object_reference WHERE object_reference.ref_id = %s AND object_reference.obj_id = object_data.obj_id",
473 $ilDB->quote($row[
"ref_id"])
475 $typequeryresult = $ilDB->query($typequery);
476 if ($typequeryresult->numRows() == 1)
479 switch ($typerow[
"type"])
482 $type_href = sprintf(
"goto.php?target=tst_%s&client_id=" . CLIENT_ID, $row[
"ref_id"]);
485 $type_href = sprintf(
"goto.php?target=cat_%s&client_id=" . CLIENT_ID, $row[
"ref_id"]);
491 $row[
"href"] = $type_href;
492 array_push(
$log[$row[
"timestamp14"]], $row);
496 $log_array = array();
497 foreach (
$log as $key => $value)
499 foreach ($value as $index => $row)
501 array_push($log_array, $row);
517 $query = sprintf(
"SELECT COUNT(obj_fi) AS logcount FROM ass_log WHERE obj_fi = %s",
518 $this->ilias->db->quote($test_obj_id .
"")
520 $result = $this->ilias->db->query($query);
521 if ($result->numRows())
524 return $row[
"logcount"];
543 $path = $tree->getPathFull(
$ref_id);
544 $pathelements = array();
553 array_push($pathelements,
"<a href=\"./goto.php?target=" .
$data[
"type"] .
"_" .
$data[
"ref_id"] .
"&client=" . CLIENT_ID .
"\">" .
557 return implode(
" > ", $pathelements);
572 foreach ($a_array as $object_id)
574 $query = sprintf(
"DELETE FROM ass_log WHERE obj_fi = %s",
575 $ilDB->quote($object_id .
"")
577 $ilDB->query($query);
578 $this->
_addLog($ilUser->getId(), $object_id, $this->lng->txt(
"assessment_log_deleted"));