ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
26 const SETTINGS_KEY_SKL_TRIG_NUM_ANSWERS_BARRIER = 'ass_skl_trig_num_answ_barrier';
28
29 public $setting;
30
37 public function __construct($a_id = 0, $a_call_by_reference = true)
38 {
39 include_once "./Services/Administration/classes/class.ilSetting.php";
40 $this->setting = new ilSetting("assessment");
41 $this->type = "assf";
42 parent::__construct($a_id, $a_call_by_reference);
43 }
44
51 public function update()
52 {
53 if (!parent::update()) {
54 return false;
55 }
56
57 // put here object specific stuff
58
59 return true;
60 }
61
62 public static function getSkillTriggerAnswerNumberBarrier()
63 {
64 require_once 'Services/Administration/classes/class.ilSetting.php';
65 $assSettings = new ilSetting('assessment');
66
67 return $assSettings->get(
68 self::SETTINGS_KEY_SKL_TRIG_NUM_ANSWERS_BARRIER,
69 self::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER
70 );
71 }
72
79 public function delete()
80 {
81 // always call parent delete function first!!
82 if (!parent::delete()) {
83 return false;
84 }
85
86 //put here your module specific stuff
87
88 return true;
89 }
90
94 public function _enableAssessmentLogging($a_enable)
95 {
96 $setting = new ilSetting("assessment");
97
98 if ($a_enable) {
99 $setting->set("assessment_logging", 1);
100 } else {
101 $setting->set("assessment_logging", 0);
102 }
103 }
104
108 public function _setLogLanguage($a_language)
109 {
110 $setting = new ilSetting("assessment");
111
112 $setting->set("assessment_log_language", $a_language);
113 }
114
118 public static function _enabledAssessmentLogging()
119 {
120 $setting = new ilSetting("assessment");
121
122 return (boolean) $setting->get("assessment_logging");
123 }
124
128 public static function _getForbiddenQuestionTypes()
129 {
130 $setting = new ilSetting("assessment");
131 $types = $setting->get("forbidden_questiontypes");
132 $result = array();
133 if (strlen(trim($types)) == 0) {
134 $result = array();
135 } else {
136 $result = unserialize($types);
137 }
138 return $result;
139 }
140
146 public function _setForbiddenQuestionTypes($a_types)
147 {
148 $setting = new ilSetting("assessment");
149 $types = "";
150 if (is_array($a_types) && (count($a_types) > 0)) {
151 $types = serialize($a_types);
152 }
153 $setting->set("forbidden_questiontypes", $types);
154 }
155
159 public static function _getLogLanguage()
160 {
161 $setting = new ilSetting("assessment");
162
163 $lang = $setting->get("assessment_log_language");
164 if (strlen($lang) == 0) {
165 $lang = "en";
166 }
167 return $lang;
168 }
169
180 {
181 if (count(self::_getManualScoring()) > 0) {
182 return true;
183 }
184
185 return false;
186 }
187
191 public static function _getManualScoring()
192 {
193 $setting = new ilSetting("assessment");
194
195 $types = $setting->get("assessment_manual_scoring");
196 return explode(",", $types);
197 }
198
202 public static function _getManualScoringTypes()
203 {
204 global $ilDB;
205
206 $result = $ilDB->query("SELECT * FROM qpl_qst_type");
207 $dbtypes = array();
208 while ($row = $ilDB->fetchAssoc($result)) {
209 $dbtypes[$row["question_type_id"]] = $row["type_tag"];
210 }
211 $setting = new ilSetting("assessment");
212 $types = $setting->get("assessment_manual_scoring");
213 $ids = explode(",", $types);
214 foreach ($ids as $key => $value) {
215 $ids[$key] = $dbtypes[$value];
216 }
217 return $ids;
218 }
219
225 public function _setManualScoring($type_ids)
226 {
227 $setting = new ilSetting("assessment");
228 if ((!is_array($type_ids)) || (count($type_ids) == 0)) {
229 $setting->delete("assessment_manual_scoring");
230 } else {
231 $setting->set("assessment_manual_scoring", implode($type_ids, ","));
232 }
233 }
234
235 public static function getScoringAdjustableQuestions()
236 {
237 $setting = new ilSetting("assessment");
238
239 $types = $setting->get("assessment_scoring_adjustment");
240 return explode(",", $types);
241 }
242
243 public static function setScoringAdjustableQuestions($type_ids)
244 {
245 $setting = new ilSetting("assessment");
246 if ((!is_array($type_ids)) || (count($type_ids) == 0)) {
247 $setting->delete("assessment_scoring_adjustment");
248 } else {
249 $setting->set("assessment_scoring_adjustment", implode($type_ids, ","));
250 }
251 }
252
253 public static function getScoringAdjustmentEnabled()
254 {
255 $setting = new ilSetting("assessment");
256 return $setting->get('assessment_adjustments_enabled');
257 }
258
259 public static function setScoringAdjustmentEnabled($active)
260 {
261 $setting = new ilSetting('assessment');
262 $setting->set('assessment_adjustments_enabled', (bool) $active);
263 }
264
275 public static function _addLog($user_id, $object_id, $logtext, $question_id = "", $original_id = "", $test_only = false, $test_ref_id = null)
276 {
277 global $ilUser, $ilDB;
278 if (strlen($question_id) == 0) {
279 $question_id = null;
280 }
281 if (strlen($original_id) == 0) {
282 $original_id = null;
283 }
284 if (strlen($test_ref_id) == 0) {
285 $test_ref_id = null;
286 }
287 $only = ($test_only == true) ? 1 : 0;
288 $next_id = $ilDB->nextId('ass_log');
289 $affectedRows = $ilDB->manipulateF(
290 "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)",
291 array('integer', 'integer', 'integer', 'text', 'integer', 'integer', 'text', 'integer', 'integer'),
292 array(
293 $next_id,
294 $user_id,
295 $object_id,
296 $logtext,
297 $question_id,
298 $original_id,
299 $only,
300 $test_ref_id,
301 time()
302 )
303 );
304 }
305
314 public static function getLog($ts_from, $ts_to, $test_id, $test_only = false)
315 {
316 global $ilDB;
317
318 $log = array();
319 if ($test_only == true) {
320 $result = $ilDB->queryF(
321 "SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
322 array('integer','integer','integer','text'),
323 array(
324 $test_id,
325 $ts_from,
326 $ts_to,
327 1
328 )
329 );
330 } else {
331 $result = $ilDB->queryF(
332 "SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
333 array('integer','integer','integer'),
334 array(
335 $test_id,
336 $ts_from,
337 $ts_to
338 )
339 );
340 }
341 while ($row = $ilDB->fetchAssoc($result)) {
342 if (!array_key_exists($row["tstamp"], $log)) {
343 $log[$row["tstamp"]] = array();
344 }
345 array_push($log[$row["tstamp"]], $row);
346 }
347 krsort($log);
348 // flatten array
349 $log_array = array();
350 foreach ($log as $key => $value) {
351 foreach ($value as $index => $row) {
352 array_push($log_array, $row);
353 }
354 }
355 return $log_array;
356 }
357
366 public static function _getLog($ts_from, $ts_to, $test_id, $test_only = false)
367 {
368 global $ilDB;
369
370 $log = array();
371 if ($test_only == true) {
372 $result = $ilDB->queryF(
373 "SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
374 array('integer', 'integer', 'integer', 'text'),
375 array($test_id, $ts_from, $ts_to, 1)
376 );
377 } else {
378 $result = $ilDB->queryF(
379 "SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
380 array('integer', 'integer', 'integer'),
381 array($test_id, $ts_from, $ts_to)
382 );
383 }
384 while ($row = $ilDB->fetchAssoc($result)) {
385 if (!array_key_exists($row["tstamp"], $log)) {
386 $log[$row["tstamp"]] = array();
387 }
388 $type_href = "";
389 if (array_key_exists("ref_id", $row)) {
390 if ($row["ref_id"] > 0) {
391 $type = ilObject::_lookupType($row['ref_id'], true);
392 switch ($type) {
393 case "tst":
394 $type_href = sprintf("goto.php?target=tst_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
395 break;
396 case "cat":
397 $type_href = sprintf("goto.php?target=cat_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
398 break;
399 }
400 }
401 }
402 $row["href"] = $type_href;
403 array_push($log[$row["tstamp"]], $row);
404 }
405 krsort($log);
406 // flatten array
407 $log_array = array();
408 foreach ($log as $key => $value) {
409 foreach ($value as $index => $row) {
410 array_push($log_array, $row);
411 }
412 }
413 return $log_array;
414 }
415
422 public function getNrOfLogEntries($test_obj_id)
423 {
424 global $ilDB;
425 $result = $ilDB->queryF(
426 "SELECT COUNT(obj_fi) logcount FROM ass_log WHERE obj_fi = %s",
427 array('integer'),
428 array($test_obj_id)
429 );
430 if ($result->numRows()) {
431 $row = $ilDB->fetchAssoc($result);
432 return $row["logcount"];
433 } else {
434 return 0;
435 }
436 }
437
444 public function getFullPath($ref_id)
445 {
446 global $tree;
447 $path = $tree->getPathFull($ref_id);
448 $pathelements = array();
449 foreach ($path as $id => $data) {
450 if ($id == 0) {
451 array_push($pathelements, ilUtil::prepareFormOutput($this->lng->txt("repository")));
452 } else {
453 array_push($pathelements, "<a href=\"./goto.php?target=" . $data["type"] . "_" . $data["ref_id"] . "&amp;client=" . CLIENT_ID . "\">" .
454 ilUtil::prepareFormOutput($data["title"]) . "</a>");
455 }
456 }
457 return implode("&nbsp;&gt;&nbsp;", $pathelements);
458 }
459
465 public function deleteLogEntries($a_array)
466 {
467 global $ilDB;
468 global $ilUser;
469
470 foreach ($a_array as $object_id) {
471 $affectedRows = $ilDB->manipulateF(
472 "DELETE FROM ass_log WHERE obj_fi = %s",
473 array('integer'),
474 array($object_id)
475 );
476 self::_addLog($ilUser->getId(), $object_id, $this->lng->txt("assessment_log_deleted"));
477 }
478 }
479
487 {
488 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
489
490 global $ilSetting;
491
492 $isPageEditorEnabled = $ilSetting->get(
493 'enable_tst_page_edit',
494 self::ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
495 );
496
497 return $isPageEditorEnabled;
498 }
499
501 {
502 return $this->setting->get('ass_process_lock_mode', self::ASS_PROC_LOCK_MODE_NONE);
503 }
504
505 public function setAssessmentProcessLockMode($lockMode)
506 {
507 $this->setting->set('ass_process_lock_mode', $lockMode);
508 }
509
510 public static function getValidAssessmentProcessLockModes()
511 {
512 return array(self::ASS_PROC_LOCK_MODE_NONE, self::ASS_PROC_LOCK_MODE_FILE, self::ASS_PROC_LOCK_MODE_DB);
513 }
514
516 {
517 return $this->setting->get(
518 'ass_skl_trig_num_answ_barrier',
519 self::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER
520 );
521 }
522
523 public function setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
524 {
525 $this->setting->set('ass_skl_trig_num_answ_barrier', $skillTriggeringNumAnswersBarrier);
526 }
527
528 public function setExportEssayQuestionsWithHtml($value)
529 {
530 $this->setting->set('export_essay_qst_with_html', $value);
531 }
532
534 {
535 return $this->setting->get('export_essay_qst_with_html');
536 }
537
538 public function fetchScoringAdjustableTypes($allQuestionTypes)
539 {
540 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
541 $scoringAdjustableQuestionTypes = array();
542
543 foreach ($allQuestionTypes as $type => $typeData) {
544 $questionGui = assQuestionGUI::_getQuestionGUI($typeData['type_tag']);
545
546 if ($this->questionSupportsScoringAdjustment($questionGui)) {
547 $scoringAdjustableQuestionTypes[$type] = $typeData;
548 }
549 }
550
551 return $scoringAdjustableQuestionTypes;
552 }
553
554 private function questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
555 {
556 return ($question_object instanceof ilGuiQuestionScoringAdjustable
557 || $question_object instanceof ilGuiAnswerScoringAdjustable)
558 && ($question_object->object instanceof ilObjQuestionScoringAdjustable
559 || $question_object->object instanceof ilObjAnswerScoringAdjustable);
560 }
561}
sprintf('%.4f', $callTime)
$result
An exception for terminatinating execution or to throw for unit testing.
Basic GUI class for assessment questions.
static _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.
_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
setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
_setManualScoring($type_ids)
Set the manual scoring settings.
questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
static _addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=false, $test_ref_id=null)
Add an assessment log entry.
static _getLogLanguage()
retrieve the log language for assessment logging
static _getManualScoring()
Retrieve the manual scoring settings.
static 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)
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_ENABLED
static _getForbiddenQuestionTypes()
Returns the forbidden questiontypes for ILIAS.
static _getManualScoringTypes()
Retrieve the manual scoring settings as type strings.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getLog($ts_from, $ts_to, $test_id, $test_only=false)
Retrieve assessment log datasets from the database.
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
fetchScoringAdjustableTypes($allQuestionTypes)
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
_setForbiddenQuestionTypes($a_types)
Sets the forbidden questiontypes for ILIAS.
Class ilObject Basic functions for all objects.
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
$lang
Definition: consent.php:3
$key
Definition: croninfo.php:18
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
Interface ilObjAnswerScoringAdjustable.
Interface ilObjQuestionScoringAdjustable.
$index
Definition: metadata.php:60
update($pash, $contents, Config $config)
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$ilUser
Definition: imgupload.php:18