ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjAssessmentFolder.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Object/classes/class.ilObject.php";
5require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
6
18{
21
25
27
29
36 function ilObjAssessmentFolder($a_id = 0,$a_call_by_reference = true)
37 {
38 include_once "./Services/Administration/classes/class.ilSetting.php";
39 $this->setting = new ilSetting("assessment");
40 $this->type = "assf";
41 $this->ilObject($a_id,$a_call_by_reference);
42 }
43
50 function update()
51 {
52 if (!parent::update())
53 {
54 return false;
55 }
56
57 // put here object specific stuff
58
59 return true;
60 }
61
62
69 function delete()
70 {
71 // always call parent delete function first!!
72 if (!parent::delete())
73 {
74 return false;
75 }
76
77 //put here your module specific stuff
78
79 return true;
80 }
81
82
96 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
97 {
98 global $tree;
99
100 switch ($a_event)
101 {
102 case "link":
103
104 //var_dump("<pre>",$a_params,"</pre>");
105 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
106 //exit;
107 break;
108
109 case "cut":
110
111 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
112 //exit;
113 break;
114
115 case "copy":
116
117 //var_dump("<pre>",$a_params,"</pre>");
118 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
119 //exit;
120 break;
121
122 case "paste":
123
124 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
125 //exit;
126 break;
127
128 case "new":
129
130 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
131 //exit;
132 break;
133 }
134
135 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
136 if ($a_node_id==$_GET["ref_id"])
137 {
138 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
139 $parent_type = $parent_obj->getType();
140 if($parent_type == $this->getType())
141 {
142 $a_node_id = (int) $tree->getParentId($a_node_id);
143 }
144 }
145
146 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
147 }
148
152 function _enableAssessmentLogging($a_enable)
153 {
154 $setting = new ilSetting("assessment");
155
156 if ($a_enable)
157 {
158 $setting->set("assessment_logging", 1);
159 }
160 else
161 {
162 $setting->set("assessment_logging", 0);
163 }
164 }
165
169 function _setLogLanguage($a_language)
170 {
171 $setting = new ilSetting("assessment");
172
173 $setting->set("assessment_log_language", $a_language);
174 }
175
180 {
181 $setting = new ilSetting("assessment");
182
183 return (boolean) $setting->get("assessment_logging");
184 }
185
190 {
191 $setting = new ilSetting("assessment");
192 $types = $setting->get("forbidden_questiontypes");
193 $result = array();
194 if (strlen(trim($types)) == 0)
195 {
196 $result = array();
197 }
198 else
199 {
200 $result = unserialize($types);
201 }
202 return $result;
203 }
204
210 function _setForbiddenQuestionTypes($a_types)
211 {
212 $setting = new ilSetting("assessment");
213 $types = "";
214 if (is_array($a_types) && (count($a_types) > 0))
215 {
216 $types = serialize($a_types);
217 }
218 $setting->set("forbidden_questiontypes", $types);
219 }
220
225 {
226 $setting = new ilSetting("assessment");
227
228 $lang = $setting->get("assessment_log_language");
229 if (strlen($lang) == 0)
230 {
231 $lang = "en";
232 }
233 return $lang;
234 }
235
246 {
247 if( count(self::_getManualScoring()) > 0 )
248 {
249 return true;
250 }
251
252 return false;
253 }
254
259 {
260 $setting = new ilSetting("assessment");
261
262 $types = $setting->get("assessment_manual_scoring");
263 return explode(",", $types);
264 }
265
270 {
271 global $ilDB;
272
273 $result = $ilDB->query("SELECT * FROM qpl_qst_type");
274 $dbtypes = array();
275 while ($row = $ilDB->fetchAssoc($result))
276 {
277 $dbtypes[$row["question_type_id"]] = $row["type_tag"];
278 }
279 $setting = new ilSetting("assessment");
280 $types = $setting->get("assessment_manual_scoring");
281 $ids = explode(",", $types);
282 foreach ($ids as $key => $value)
283 {
284 $ids[$key] = $dbtypes[$value];
285 }
286 return $ids;
287 }
288
294 function _setManualScoring($type_ids)
295 {
296 $setting = new ilSetting("assessment");
297 if ((!is_array($type_ids)) || (count($type_ids) == 0))
298 {
299 $setting->delete("assessment_manual_scoring");
300 }
301 else
302 {
303 $setting->set("assessment_manual_scoring", implode($type_ids, ","));
304 }
305 }
306
307 public static function getScoringAdjustableQuestions()
308 {
309 $setting = new ilSetting("assessment");
310
311 $types = $setting->get("assessment_scoring_adjustment");
312 return explode(",", $types);
313 }
314
315 public static function setScoringAdjustableQuestions($type_ids)
316 {
317 $setting = new ilSetting("assessment");
318 if ((!is_array($type_ids)) || (count($type_ids) == 0))
319 {
320 $setting->delete("assessment_scoring_adjustment");
321 }
322 else
323 {
324 $setting->set("assessment_scoring_adjustment", implode($type_ids, ","));
325 }
326 }
327
328 public static function getScoringAdjustmentEnabled()
329 {
330 $setting = new ilSetting("assessment");
331 return $setting->get('assessment_adjustments_enabled');
332 }
333
334 public static function setScoringAdjustmentEnabled($active)
335 {
336 $setting = new ilSetting('assessment');
337 $setting->set('assessment_adjustments_enabled', (bool) $active);
338 }
339
350 function _addLog($user_id, $object_id, $logtext, $question_id = "", $original_id = "", $test_only = FALSE, $test_ref_id = NULL)
351 {
352 global $ilUser, $ilDB;
353 if (strlen($question_id) == 0) $question_id = NULL;
354 if (strlen($original_id) == 0) $original_id = NULL;
355 if (strlen($test_ref_id) == 0) $test_ref_id = NULL;
356 $only = ($test_only == TRUE) ? 1 : 0;
357 $next_id = $ilDB->nextId('ass_log');
358 $affectedRows = $ilDB->manipulateF("INSERT INTO ass_log (ass_log_id, user_fi, obj_fi, logtext, question_fi, original_fi, test_only, ref_id, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
359 array('integer', 'integer', 'integer', 'text', 'integer', 'integer', 'text', 'integer', 'integer'),
360 array(
361 $next_id,
362 $user_id,
363 $object_id,
364 $logtext,
365 $question_id,
366 $original_id,
367 $only,
368 $test_ref_id,
369 time()
370 )
371 );
372 }
373
382 function &getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
383 {
384 global $ilDB;
385
386 $log = array();
387 if ($test_only == TRUE)
388 {
389 $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
390 array('integer','integer','integer','text'),
391 array(
392 $test_id,
393 $ts_from,
394 $ts_to,
395 1
396 )
397 );
398 }
399 else
400 {
401 $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
402 array('integer','integer','integer'),
403 array(
404 $test_id,
405 $ts_from,
406 $ts_to
407 )
408 );
409 }
410 while ($row = $ilDB->fetchAssoc($result))
411 {
412 if (!array_key_exists($row["tstamp"], $log))
413 {
414 $log[$row["tstamp"]] = array();
415 }
416 array_push($log[$row["tstamp"]], $row);
417 }
418 krsort($log);
419 // flatten array
420 $log_array = array();
421 foreach ($log as $key => $value)
422 {
423 foreach ($value as $index => $row)
424 {
425 array_push($log_array, $row);
426 }
427 }
428 return $log_array;
429 }
430
439 function &_getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
440 {
441 global $ilDB;
442
443 $log = array();
444 if ($test_only == TRUE)
445 {
446 $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
447 array('integer', 'integer', 'integer', 'text'),
448 array($test_id, $ts_from, $ts_to, 1)
449 );
450 }
451 else
452 {
453 $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
454 array('integer', 'integer', 'integer'),
455 array($test_id, $ts_from, $ts_to)
456 );
457 }
458 while ($row = $ilDB->fetchAssoc($result))
459 {
460 if (!array_key_exists($row["tstamp"], $log))
461 {
462 $log[$row["tstamp"]] = array();
463 }
464 $type_href = "";
465 if (array_key_exists("ref_id", $row))
466 {
467 if ($row["ref_id"] > 0)
468 {
469 $type = ilObject::_lookupType($row['ref_id'], true);
470 switch ($type)
471 {
472 case "tst":
473 $type_href = sprintf("goto.php?target=tst_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
474 break;
475 case "cat":
476 $type_href = sprintf("goto.php?target=cat_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
477 break;
478 }
479 }
480 }
481 $row["href"] = $type_href;
482 array_push($log[$row["tstamp"]], $row);
483 }
484 krsort($log);
485 // flatten array
486 $log_array = array();
487 foreach ($log as $key => $value)
488 {
489 foreach ($value as $index => $row)
490 {
491 array_push($log_array, $row);
492 }
493 }
494 return $log_array;
495 }
496
503 function getNrOfLogEntries($test_obj_id)
504 {
505 global $ilDB;
506 $result = $ilDB->queryF("SELECT COUNT(obj_fi) logcount FROM ass_log WHERE obj_fi = %s",
507 array('integer'),
508 array($test_obj_id)
509 );
510 if ($result->numRows())
511 {
512 $row = $ilDB->fetchAssoc($result);
513 return $row["logcount"];
514 }
515 else
516 {
517 return 0;
518 }
519 }
520
528 {
529 global $tree;
530 $path = $tree->getPathFull($ref_id);
531 $pathelements = array();
532 foreach ($path as $id => $data)
533 {
534 if ($id == 0)
535 {
536 array_push($pathelements, ilUtil::prepareFormOutput($this->lng->txt("repository")));
537 }
538 else
539 {
540 array_push($pathelements, "<a href=\"./goto.php?target=" . $data["type"] . "_" . $data["ref_id"] . "&amp;client=" . CLIENT_ID . "\">" .
541 ilUtil::prepareFormOutput($data["title"]) . "</a>");
542 }
543 }
544 return implode("&nbsp;&gt;&nbsp;", $pathelements);
545 }
546
552 function deleteLogEntries($a_array)
553 {
554 global $ilDB;
555 global $ilUser;
556
557 foreach ($a_array as $object_id)
558 {
559 $affectedRows = $ilDB->manipulateF("DELETE FROM ass_log WHERE obj_fi = %s",
560 array('integer'),
561 array($object_id)
562 );
563 $this->_addLog($ilUser->getId(), $object_id, $this->lng->txt("assessment_log_deleted"));
564 }
565 }
566
574 {
575 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
576
577 global $ilSetting;
578
579 $isPageEditorEnabled = $ilSetting->get(
580 'enable_tst_page_edit', self::ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
581 );
582
583 return $isPageEditorEnabled;
584 }
585
587 {
588 return $this->setting->get('ass_process_lock_mode', self::ASS_PROC_LOCK_MODE_NONE);
589 }
590
591 public function setAssessmentProcessLockMode($lockMode)
592 {
593 $this->setting->set('ass_process_lock_mode', $lockMode);
594 }
595
596 public static function getValidAssessmentProcessLockModes()
597 {
598 return array(self::ASS_PROC_LOCK_MODE_NONE, self::ASS_PROC_LOCK_MODE_FILE, self::ASS_PROC_LOCK_MODE_DB);
599 }
600
602 {
603 return $this->setting->get(
604 'ass_skl_trig_num_answ_barrier', self::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER
605 );
606 }
607
608 public function setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
609 {
610 $this->setting->set('ass_skl_trig_num_answ_barrier', $skillTriggeringNumAnswersBarrier);
611 }
612
613 public function fetchScoringAdjustableTypes($allQuestionTypes)
614 {
615 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
616 $scoringAdjustableQuestionTypes = array();
617
618 foreach($allQuestionTypes as $type => $typeData)
619 {
620 $questionGui = assQuestionGUI::_getQuestionGUI($typeData['type_tag']);
621
622 if( $this->questionSupportsScoringAdjustment($questionGui) )
623 {
624 $scoringAdjustableQuestionTypes[$type] = $typeData;
625 }
626 }
627
628 return $scoringAdjustableQuestionTypes;
629 }
630
631 private function questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
632 {
633 return ($question_object instanceof ilGuiQuestionScoringAdjustable
634 || $question_object instanceof ilGuiAnswerScoringAdjustable)
635 && ($question_object->object instanceof ilObjQuestionScoringAdjustable
636 || $question_object->object instanceof ilObjAnswerScoringAdjustable);
637 }
638}
$result
$_GET["client_id"]
Basic GUI class for assessment questions.
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
Class ilObjAssessmentFolder.
getFullPath($ref_id)
Returns the full path output of an object.
deleteLogEntries($a_array)
Deletes the log entries for a given array of test object IDs.
_getForbiddenQuestionTypes()
Returns the forbidden questiontypes for ILIAS.
_enableAssessmentLogging($a_enable)
enable assessment logging
getNrOfLogEntries($test_obj_id)
Returns the number of log entries for a given test id.
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not
& _getLog($ts_from, $ts_to, $test_id, $test_only=FALSE)
Retrieve assessment log datasets from the database.
setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
_addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=FALSE, $test_ref_id=NULL)
Add an assessment log entry.
_setManualScoring($type_ids)
Set the manual scoring settings.
_getLogLanguage()
retrieve the log language for assessment logging
questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
_getManualScoringTypes()
Retrieve the manual scoring settings as type strings.
& getLog($ts_from, $ts_to, $test_id, $test_only=FALSE)
Retrieve assessment log datasets from the database.
_setLogLanguage($a_language)
set the log language
static setScoringAdjustableQuestions($type_ids)
ilObjAssessmentFolder($a_id=0, $a_call_by_reference=true)
Constructor @access public.
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_ENABLED
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
fetchScoringAdjustableTypes($allQuestionTypes)
_setForbiddenQuestionTypes($a_types)
Sets the forbidden questiontypes for ILIAS.
_getManualScoring()
Retrieve the manual scoring settings.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
static _lookupType($a_id, $a_reference=false)
lookup object type
ILIAS Setting Class.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$data
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
Interface ilObjAnswerScoringAdjustable.
Interface ilObjQuestionScoringAdjustable.
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15