ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once "./Services/Object/classes/class.ilObject.php";
5 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
6 
18 {
21 
22  const ASS_PROC_LOCK_MODE_NONE = 'none';
23  const ASS_PROC_LOCK_MODE_FILE = 'file';
24  const ASS_PROC_LOCK_MODE_DB = 'db';
25 
26  const SETTINGS_KEY_SKL_TRIG_NUM_ANSWERS_BARRIER = 'ass_skl_trig_num_answ_barrier';
28 
29  var $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  function update()
52  {
53  if (!parent::update())
54  {
55  return false;
56  }
57 
58  // put here object specific stuff
59 
60  return true;
61  }
62 
63  public static function getSkillTriggerAnswerNumberBarrier()
64  {
65  require_once 'Services/Administration/classes/class.ilSetting.php';
66  $assSettings = new ilSetting('assessment');
67 
68  return $assSettings->get(
69  self::SETTINGS_KEY_SKL_TRIG_NUM_ANSWERS_BARRIER,
70  self::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER
71  );
72  }
73 
80  function delete()
81  {
82  // always call parent delete function first!!
83  if (!parent::delete())
84  {
85  return false;
86  }
87 
88  //put here your module specific stuff
89 
90  return true;
91  }
92 
96  function _enableAssessmentLogging($a_enable)
97  {
98  $setting = new ilSetting("assessment");
99 
100  if ($a_enable)
101  {
102  $setting->set("assessment_logging", 1);
103  }
104  else
105  {
106  $setting->set("assessment_logging", 0);
107  }
108  }
109 
113  function _setLogLanguage($a_language)
114  {
115  $setting = new ilSetting("assessment");
116 
117  $setting->set("assessment_log_language", $a_language);
118  }
119 
123  public static function _enabledAssessmentLogging()
124  {
125  $setting = new ilSetting("assessment");
126 
127  return (boolean) $setting->get("assessment_logging");
128  }
129 
133  public static function _getForbiddenQuestionTypes()
134  {
135  $setting = new ilSetting("assessment");
136  $types = $setting->get("forbidden_questiontypes");
137  $result = array();
138  if (strlen(trim($types)) == 0)
139  {
140  $result = array();
141  }
142  else
143  {
144  $result = unserialize($types);
145  }
146  return $result;
147  }
148 
154  function _setForbiddenQuestionTypes($a_types)
155  {
156  $setting = new ilSetting("assessment");
157  $types = "";
158  if (is_array($a_types) && (count($a_types) > 0))
159  {
160  $types = serialize($a_types);
161  }
162  $setting->set("forbidden_questiontypes", $types);
163  }
164 
168  public static function _getLogLanguage()
169  {
170  $setting = new ilSetting("assessment");
171 
172  $lang = $setting->get("assessment_log_language");
173  if (strlen($lang) == 0)
174  {
175  $lang = "en";
176  }
177  return $lang;
178  }
179 
190  {
191  if( count(self::_getManualScoring()) > 0 )
192  {
193  return true;
194  }
195 
196  return false;
197  }
198 
202  public static function _getManualScoring()
203  {
204  $setting = new ilSetting("assessment");
205 
206  $types = $setting->get("assessment_manual_scoring");
207  return explode(",", $types);
208  }
209 
213  public static function _getManualScoringTypes()
214  {
215  global $ilDB;
216 
217  $result = $ilDB->query("SELECT * FROM qpl_qst_type");
218  $dbtypes = array();
219  while ($row = $ilDB->fetchAssoc($result))
220  {
221  $dbtypes[$row["question_type_id"]] = $row["type_tag"];
222  }
223  $setting = new ilSetting("assessment");
224  $types = $setting->get("assessment_manual_scoring");
225  $ids = explode(",", $types);
226  foreach ($ids as $key => $value)
227  {
228  $ids[$key] = $dbtypes[$value];
229  }
230  return $ids;
231  }
232 
238  function _setManualScoring($type_ids)
239  {
240  $setting = new ilSetting("assessment");
241  if ((!is_array($type_ids)) || (count($type_ids) == 0))
242  {
243  $setting->delete("assessment_manual_scoring");
244  }
245  else
246  {
247  $setting->set("assessment_manual_scoring", implode($type_ids, ","));
248  }
249  }
250 
251  public static function getScoringAdjustableQuestions()
252  {
253  $setting = new ilSetting("assessment");
254 
255  $types = $setting->get("assessment_scoring_adjustment");
256  return explode(",", $types);
257  }
258 
259  public static function setScoringAdjustableQuestions($type_ids)
260  {
261  $setting = new ilSetting("assessment");
262  if ((!is_array($type_ids)) || (count($type_ids) == 0))
263  {
264  $setting->delete("assessment_scoring_adjustment");
265  }
266  else
267  {
268  $setting->set("assessment_scoring_adjustment", implode($type_ids, ","));
269  }
270  }
271 
272  public static function getScoringAdjustmentEnabled()
273  {
274  $setting = new ilSetting("assessment");
275  return $setting->get('assessment_adjustments_enabled');
276  }
277 
278  public static function setScoringAdjustmentEnabled($active)
279  {
280  $setting = new ilSetting('assessment');
281  $setting->set('assessment_adjustments_enabled', (bool) $active);
282  }
283 
294  public static function _addLog($user_id, $object_id, $logtext, $question_id = "", $original_id = "", $test_only = FALSE, $test_ref_id = NULL)
295  {
296  global $ilUser, $ilDB;
297  if (strlen($question_id) == 0) $question_id = NULL;
298  if (strlen($original_id) == 0) $original_id = NULL;
299  if (strlen($test_ref_id) == 0) $test_ref_id = NULL;
300  $only = ($test_only == TRUE) ? 1 : 0;
301  $next_id = $ilDB->nextId('ass_log');
302  $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)",
303  array('integer', 'integer', 'integer', 'text', 'integer', 'integer', 'text', 'integer', 'integer'),
304  array(
305  $next_id,
306  $user_id,
307  $object_id,
308  $logtext,
309  $question_id,
310  $original_id,
311  $only,
312  $test_ref_id,
313  time()
314  )
315  );
316  }
317 
326  public static function getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
327  {
328  global $ilDB;
329 
330  $log = array();
331  if ($test_only == TRUE)
332  {
333  $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
334  array('integer','integer','integer','text'),
335  array(
336  $test_id,
337  $ts_from,
338  $ts_to,
339  1
340  )
341  );
342  }
343  else
344  {
345  $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
346  array('integer','integer','integer'),
347  array(
348  $test_id,
349  $ts_from,
350  $ts_to
351  )
352  );
353  }
354  while ($row = $ilDB->fetchAssoc($result))
355  {
356  if (!array_key_exists($row["tstamp"], $log))
357  {
358  $log[$row["tstamp"]] = array();
359  }
360  array_push($log[$row["tstamp"]], $row);
361  }
362  krsort($log);
363  // flatten array
364  $log_array = array();
365  foreach ($log as $key => $value)
366  {
367  foreach ($value as $index => $row)
368  {
369  array_push($log_array, $row);
370  }
371  }
372  return $log_array;
373  }
374 
383  public static function _getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
384  {
385  global $ilDB;
386 
387  $log = array();
388  if ($test_only == TRUE)
389  {
390  $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s AND test_only = %s ORDER BY tstamp",
391  array('integer', 'integer', 'integer', 'text'),
392  array($test_id, $ts_from, $ts_to, 1)
393  );
394  }
395  else
396  {
397  $result = $ilDB->queryF("SELECT * FROM ass_log WHERE obj_fi = %s AND tstamp > %s AND tstamp < %s ORDER BY tstamp",
398  array('integer', 'integer', 'integer'),
399  array($test_id, $ts_from, $ts_to)
400  );
401  }
402  while ($row = $ilDB->fetchAssoc($result))
403  {
404  if (!array_key_exists($row["tstamp"], $log))
405  {
406  $log[$row["tstamp"]] = array();
407  }
408  $type_href = "";
409  if (array_key_exists("ref_id", $row))
410  {
411  if ($row["ref_id"] > 0)
412  {
413  $type = ilObject::_lookupType($row['ref_id'], true);
414  switch ($type)
415  {
416  case "tst":
417  $type_href = sprintf("goto.php?target=tst_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
418  break;
419  case "cat":
420  $type_href = sprintf("goto.php?target=cat_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
421  break;
422  }
423  }
424  }
425  $row["href"] = $type_href;
426  array_push($log[$row["tstamp"]], $row);
427  }
428  krsort($log);
429  // flatten array
430  $log_array = array();
431  foreach ($log as $key => $value)
432  {
433  foreach ($value as $index => $row)
434  {
435  array_push($log_array, $row);
436  }
437  }
438  return $log_array;
439  }
440 
447  function getNrOfLogEntries($test_obj_id)
448  {
449  global $ilDB;
450  $result = $ilDB->queryF("SELECT COUNT(obj_fi) logcount FROM ass_log WHERE obj_fi = %s",
451  array('integer'),
452  array($test_obj_id)
453  );
454  if ($result->numRows())
455  {
456  $row = $ilDB->fetchAssoc($result);
457  return $row["logcount"];
458  }
459  else
460  {
461  return 0;
462  }
463  }
464 
472  {
473  global $tree;
474  $path = $tree->getPathFull($ref_id);
475  $pathelements = array();
476  foreach ($path as $id => $data)
477  {
478  if ($id == 0)
479  {
480  array_push($pathelements, ilUtil::prepareFormOutput($this->lng->txt("repository")));
481  }
482  else
483  {
484  array_push($pathelements, "<a href=\"./goto.php?target=" . $data["type"] . "_" . $data["ref_id"] . "&amp;client=" . CLIENT_ID . "\">" .
485  ilUtil::prepareFormOutput($data["title"]) . "</a>");
486  }
487  }
488  return implode("&nbsp;&gt;&nbsp;", $pathelements);
489  }
490 
496  function deleteLogEntries($a_array)
497  {
498  global $ilDB;
499  global $ilUser;
500 
501  foreach ($a_array as $object_id)
502  {
503  $affectedRows = $ilDB->manipulateF("DELETE FROM ass_log WHERE obj_fi = %s",
504  array('integer'),
505  array($object_id)
506  );
507  self::_addLog($ilUser->getId(), $object_id, $this->lng->txt("assessment_log_deleted"));
508  }
509  }
510 
518  {
519  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
520 
521  global $ilSetting;
522 
523  $isPageEditorEnabled = $ilSetting->get(
524  'enable_tst_page_edit', self::ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
525  );
526 
527  return $isPageEditorEnabled;
528  }
529 
531  {
532  return $this->setting->get('ass_process_lock_mode', self::ASS_PROC_LOCK_MODE_NONE);
533  }
534 
535  public function setAssessmentProcessLockMode($lockMode)
536  {
537  $this->setting->set('ass_process_lock_mode', $lockMode);
538  }
539 
540  public static function getValidAssessmentProcessLockModes()
541  {
542  return array(self::ASS_PROC_LOCK_MODE_NONE, self::ASS_PROC_LOCK_MODE_FILE, self::ASS_PROC_LOCK_MODE_DB);
543  }
544 
546  {
547  return $this->setting->get(
548  'ass_skl_trig_num_answ_barrier', self::DEFAULT_SKL_TRIG_NUM_ANSWERS_BARRIER
549  );
550  }
551 
552  public function setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
553  {
554  $this->setting->set('ass_skl_trig_num_answ_barrier', $skillTriggeringNumAnswersBarrier);
555  }
556 
557  public function setExportEssayQuestionsWithHtml($value)
558  {
559  $this->setting->set('export_essay_qst_with_html', $value);
560  }
561 
563  {
564  return $this->setting->get('export_essay_qst_with_html');
565  }
566 
567  public function fetchScoringAdjustableTypes($allQuestionTypes)
568  {
569  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
570  $scoringAdjustableQuestionTypes = array();
571 
572  foreach($allQuestionTypes as $type => $typeData)
573  {
574  $questionGui = assQuestionGUI::_getQuestionGUI($typeData['type_tag']);
575 
576  if( $this->questionSupportsScoringAdjustment($questionGui) )
577  {
578  $scoringAdjustableQuestionTypes[$type] = $typeData;
579  }
580  }
581 
582  return $scoringAdjustableQuestionTypes;
583  }
584 
585  private function questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
586  {
587  return ($question_object instanceof ilGuiQuestionScoringAdjustable
588  || $question_object instanceof ilGuiAnswerScoringAdjustable)
589  && ($question_object->object instanceof ilObjQuestionScoringAdjustable
590  || $question_object->object instanceof ilObjAnswerScoringAdjustable);
591  }
592 }
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
static _getManualScoringTypes()
Retrieve the manual scoring settings as type strings.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
ILIAS Setting Class.
$path
Definition: aliased.php:25
static _addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=FALSE, $test_ref_id=NULL)
Add an assessment log entry.
$result
_setLogLanguage($a_language)
set the log language
static setScoringAdjustableQuestions($type_ids)
Class ilObject Basic functions for all objects.
static _getLog($ts_from, $ts_to, $test_id, $test_only=FALSE)
Retrieve assessment log datasets from the database.
_enableAssessmentLogging($a_enable)
enable assessment logging
questionSupportsScoringAdjustment(\assQuestionGUI $question_object)
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.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_DISABLED
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...
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
Class ilObjAssessmentFolder.
static _getForbiddenQuestionTypes()
Returns the forbidden questiontypes for ILIAS.
_setForbiddenQuestionTypes($a_types)
Sets the forbidden questiontypes for ILIAS.
Interface ilObjAnswerScoringAdjustable.
getNrOfLogEntries($test_obj_id)
Returns the number of log entries for a given test id.
$ilUser
Definition: imgupload.php:18
_setManualScoring($type_ids)
Set the manual scoring settings.
Basic GUI class for assessment questions.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getManualScoring()
Retrieve the manual scoring settings.
global $ilSetting
Definition: privfeed.php:17
Interface ilObjQuestionScoringAdjustable.
setSkillTriggeringNumAnswersBarrier($skillTriggeringNumAnswersBarrier)
static getLog($ts_from, $ts_to, $test_id, $test_only=FALSE)
Retrieve assessment log datasets from the database.
global $ilDB
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not ...
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
Interface ilGuiAnswerScoringAdjustable.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Interface ilGuiQuestionScoringAdjustable.
fetchScoringAdjustableTypes($allQuestionTypes)
const ADDITIONAL_QUESTION_CONTENT_EDITING_MODE_PAGE_OBJECT_ENABLED