ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjAssessmentFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once "./classes/class.ilObjectGUI.php";
25 
37 {
43 
44  function ilObjAssessmentFolderGUI($a_data,$a_id,$a_call_by_reference)
45  {
46  global $rbacsystem;
47 
48  $this->type = "assf";
49  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
50 
51  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
52  {
53  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_assf"),$this->ilias->error_obj->WARNING);
54  }
55  }
56 
57  function &executeCommand()
58  {
59  $next_class = $this->ctrl->getNextClass($this);
60  $cmd = $this->ctrl->getCmd();
61  $this->prepareOutput();
62 
63  switch($next_class)
64  {
65  case 'ilpermissiongui':
66  include_once("./classes/class.ilPermissionGUI.php");
67  $perm_gui =& new ilPermissionGUI($this);
68  $ret =& $this->ctrl->forwardCommand($perm_gui);
69  break;
70 
71  default:
72  if($cmd == "" || $cmd == "view")
73  {
74  $cmd = "settings";
75  }
76  $cmd .= "Object";
77  $this->$cmd();
78 
79  break;
80  }
81  return true;
82  }
83 
84 
89  function saveObject()
90  {
91  global $rbacadmin;
92 
93  // create and insert forum in objecttree
94  $newObj = parent::saveObject();
95 
96  // setup rolefolder & default local roles
97  //$roles = $newObj->initDefaultRoles();
98 
99  // ...finally assign role to creator of object
100  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
101 
102  // put here object specific stuff
103 
104  // always send a message
105  ilUtil::sendInfo($this->lng->txt("object_added"),true);
106 
107  $this->ctrl->redirect($this);
108  }
109 
110 
114  function settingsObject()
115  {
116  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.assessment_settings.html");
117 
118  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
119  $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
120  $manscoring = $this->object->_getManualScoring();
121  foreach ($questiontypes as $type_name => $qtype)
122  {
123  $type_id = $qtype["question_type_id"];
124  $this->tpl->setCurrentBlock("manual_scoring");
125  $this->tpl->setVariable("VALUE_MANUAL_SCORING", $type_id);
126  $this->tpl->setVariable("TXT_MANUAL_SCORING", $type_name);
127  if (in_array($type_id, $manscoring))
128  {
129  $this->tpl->setVariable("CHECKED_MANUAL_SCORING", " checked=\"checked\"");
130  }
131  $this->tpl->parseCurrentBlock();
132 
133  $this->tpl->setCurrentBlock("allowed_questiontypes");
134  $this->tpl->setVariable("VALUE_ALLOWED_QUESTIONTYPES", $type_id);
135  $this->tpl->setVariable("TEXT_ALLOWED_QUESTIONTYPES", $type_name);
136  $forbidden_types = $this->object->_getForbiddenQuestionTypes();
137  if (!in_array($type_id, $forbidden_types))
138  {
139  $this->tpl->setVariable("CHECKED_ALLOWED_QUESTIONTYPES", " checked=\"checked\"");
140  }
141  $this->tpl->parseCurrentBlock();
142  }
143 
144  $this->tpl->setCurrentBlock("adm_content");
145  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
146  $this->tpl->setVariable("TXT_LOGGING", $this->lng->txt("assessment_log_logging"));
147  $this->tpl->setVariable("TXT_ACTIVATE_ASSESSMENT_LOGGING", $this->lng->txt("activate_assessment_logging"));
148  $this->tpl->setVariable("TXT_ASSESSMENT_SETTINGS", $this->lng->txt("assessment_settings"));
149  $this->tpl->setVariable("TXT_REPORTING_LANGUAGE", $this->lng->txt("assessment_settings_reporting_language"));
150  $languages = $this->lng->getInstalledLanguages();
151  $default_language = $this->object->_getLogLanguage();
152  if (!in_array($default_language, $languages))
153  {
154  $default_language = "en";
155  }
156  foreach ($languages as $key)
157  {
158  $this->tpl->setCurrentBlock("reporting_lang_row");
159  $this->tpl->setVariable("LANG_VALUE", $key);
160  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("lang_" . $key));
161  if (strcmp($default_language, $key) == 0)
162  {
163  $this->tpl->setVariable("LANG_SELECTED", " selected=\"selected\"");
164  }
165  $this->tpl->parseCurrentBlock();
166  }
167 
168  $this->tpl->setVariable("TXT_QUESTIONTYPES_HEADER", $this->lng->txt("assf_questiontypes"));
169  $this->tpl->setVariable("TXT_ALLOWED_QUESTIONTYPES", $this->lng->txt("assf_allowed_questiontypes"));
170  $this->tpl->setVariable("TXT_ALLOWED_QUESTIONTYPES_DESCRIPTION", $this->lng->txt("assf_allowed_questiontypes_desc"));
171  $this->tpl->setVariable("TXT_MANUAL_SCORING_DESCRIPTION", $this->lng->txt("assessment_log_manual_scoring_desc"));
172  $this->tpl->setVariable("TXT_MANUAL_SCORING_ACTIVATE", $this->lng->txt("assessment_log_manual_scoring_activate"));
173  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
174 
175  if($this->object->_enabledAssessmentLogging())
176  {
177  $this->tpl->setVariable("ASSESSMENT_LOGGING_CHECKED", " checked=\"checked\"");
178  }
179 
180  $this->tpl->parseCurrentBlock();
181  }
182 
187  {
188  if ($_POST["chb_assessment_logging"] == 1)
189  {
190  $this->object->_enableAssessmentLogging(1);
191  }
192  else
193  {
194  $this->object->_enableAssessmentLogging(0);
195  }
196  $this->object->_setLogLanguage($_POST["reporting_language"]);
197  $this->object->_setManualScoring($_POST["chb_manual_scoring"]);
198  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
199  $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
200  $forbidden_types = array();
201  foreach ($questiontypes as $name => $row)
202  {
203  if (!in_array($row["question_type_id"], $_POST["chb_allowed_questiontypes"]))
204  {
205  array_push($forbidden_types, $row["question_type_id"]);
206  }
207  }
208  $this->object->_setForbiddenQuestionTypes($forbidden_types);
209  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
210 
211  $this->ctrl->redirect($this,'settings');
212  }
213 
217  function showLogObject()
218  {
219  $this->logsObject();
220  }
221 
225  function exportLogObject()
226  {
227  $this->logsObject();
228  }
229 
233  function logsObject()
234  {
235  $this->lng->loadLanguageModule("jscalendar");
236  $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
237  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.assessment_logs.html");
238  $this->tpl->setCurrentBlock("calendar_javascript");
239  $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
240  $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
241  $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
242  $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
243  $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
244  $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
245  $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
246  $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
247  $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
248  $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
249  $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
250  $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
251  $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
252  $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
253  $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
254  $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
255  $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
256  $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
257  $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
258  $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
259  $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
260  $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
261  $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
262  $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
263  $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
264  $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
265  $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
266  $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
267  $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
268  $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
269  $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
270  $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
271  $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
272  $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
273  $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
274  $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
275  $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
276  $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
277  $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
278  $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
279  $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
280  $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
281  $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
282  $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
283  $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
284  $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
285  $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
286  $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
287  $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
288  $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
289  $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
290  $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
291  $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
292  $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
293  $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
294  $this->tpl->setVariable("WK", $this->lng->txt("wk"));
295  $this->tpl->setVariable("TIME", $this->lng->txt("time"));
296  $this->tpl->parseCurrentBlock();
297  $this->tpl->setCurrentBlock("CalendarJS");
298  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Modules/Test/js/calendar/calendar.js");
299  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Modules/Test/js/calendar/calendar-setup.js");
300  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Modules/Test/js/calendar/calendar.css");
301  $this->tpl->parseCurrentBlock();
302  $this->tpl->setCurrentBlock("javascript_call_calendar");
303  $this->tpl->setVariable("INPUT_FIELDS_STARTING_DATE", "starting_date");
304  $this->tpl->setVariable("INPUT_FIELDS_ENDING_DATE", "ending_date");
305  $this->tpl->setVariable("INPUT_FIELDS_REPORTING_DATE", "reporting_date");
306  $this->tpl->parseCurrentBlock();
307  include_once "./Modules/Test/classes/class.ilObjTest.php";
308  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
309  $available_tests =& ilObjTest::_getAvailableTests(1);
310  foreach ($available_tests as $key => $value)
311  {
312  $this->tpl->setCurrentBlock("sel_test_row");
313  $this->tpl->setVariable("TXT_OPTION", ilUtil::prepareFormOutput($value) . " [" . $this->object->getNrOfLogEntries($key) . " " . $this->lng->txt("assessment_log_log_entries") . "]");
314  $this->tpl->setVariable("VALUE_OPTION", $key);
315  if (($_POST["sel_test"] > -1) && ($_POST["sel_test"] == $key))
316  {
317  $this->tpl->setVariable("SELECTED_OPTION", " selected=\"selected\"");
318  }
319  $this->tpl->parseCurrentBlock();
320  }
321 
322  if ((strcmp($this->ctrl->getCmd(), "showLog") == 0) ||
323  (strcmp($this->ctrl->getCmd(), "exportLog") == 0))
324  {
325  include_once "./Services/Utilities/classes/class.ilUtil.php";
326  $separator = ";";
327  $csv = array();
328  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
329  {
330  $row = array(
331  $this->lng->txt("assessment_log_datetime"),
332  $this->lng->txt("user"),
333  $this->lng->txt("assessment_log_text"),
334  $this->lng->txt("question")
335  );
336  array_push($csv, ilUtil::processCSVRow($row, TRUE, $separator));
337  }
338  $ts_from = sprintf("%04d%02d%02d%02d%02d%02d", $_POST["log_from_date"]["y"], $_POST["log_from_date"]["m"], $_POST["log_from_date"]["d"], $_POST["log_from_time"]["h"], $_POST["log_from_time"]["m"], 0);
339  $ts_to = sprintf("%04d%02d%02d%02d%02d%02d", $_POST["log_to_date"]["y"], $_POST["log_to_date"]["m"], $_POST["log_to_date"]["d"], $_POST["log_to_time"]["h"], $_POST["log_to_time"]["m"], 0);
340  $log_output =& $this->object->getLog($ts_from, $ts_to, $_POST["sel_test"]);
341  $users = array();
342  foreach ($log_output as $key => $log)
343  {
344  if (array_key_exists("value1", $log))
345  {
346  $tblrow = array("tblrow1light", "tblrow2light");
347  }
348  else
349  {
350  $tblrow = array("tblrow1", "tblrow2");
351  }
352  $title = "";
353  if (!array_key_exists($log["user_fi"], $users))
354  {
355  $users[$log["user_fi"]] = ilObjUser::_lookupName($log["user_fi"]);
356  }
357  $this->tpl->setCurrentBlock("output_row");
358  $this->tpl->setVariable("ROW_CLASS", $tblrow[$key % 2]);
359  $date = new ilDateTime($log["timestamp14"],IL_CAL_TIMESTAMP);
360  $this->tpl->setVariable("TXT_DATETIME",$date->get(IL_CAL_FKT_DATE,'Y-m-d H:i'));
361  $csvrow = array();
362  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
363  {
364  $date = new ilDate($log['timestamp14'],IL_CAL_TIMESTAMP);
365  array_push($csvrow, $date->get(IL_CAL_FKT_DATE,'Y-m-d H:i'));
366 
367  }
368  if ($log["question_fi"] || $log["original_fi"])
369  {
370  $title = assQuestion::_getQuestionTitle($log["question_fi"]);
371  if (strlen($title) == 0)
372  {
373  $title = assQuestion::_getQuestionTitle($log["original_fi"]);
374  }
375  $title = $this->lng->txt("assessment_log_question") . ": " . $title;
376  }
377  $this->tpl->setVariable("TXT_USER", trim($users[$log["user_fi"]]["title"] . " " . $users[$log["user_fi"]]["firstname"] . " " . $users[$log["user_fi"]]["lastname"]));
378  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
379  {
380  array_push($csvrow, trim($users[$log["user_fi"]]["title"] . " " . $users[$log["user_fi"]]["firstname"] . " " . $users[$log["user_fi"]]["lastname"]));
381  }
382  if (array_key_exists("value1", $log))
383  {
384  if (strlen($title))
385  {
386  $this->tpl->setVariable("TXT_LOGTEXT", ilUtil::prepareFormOutput($this->lng->txt("assessment_log_user_answer") . " (" . $title . ")"));
387  }
388  else
389  {
390  $this->tpl->setVariable("TXT_LOGTEXT", ilUtil::prepareFormOutput($this->lng->txt("assessment_log_user_answer")));
391  }
392  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
393  {
394  array_push($csvrow, $this->lng->txt("assessment_log_user_answer"));
395  array_push($csvrow, $title);
396  }
397  }
398  else
399  {
400  if (strlen($title))
401  {
402  $this->tpl->setVariable("TXT_LOGTEXT", trim(ilUtil::prepareFormOutput($log["logtext"]) . " (" . $title . ")"));
403  }
404  else
405  {
406  $this->tpl->setVariable("TXT_LOGTEXT", trim(ilUtil::prepareFormOutput($log["logtext"])));
407  }
408  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
409  {
410  array_push($csvrow, trim($log["logtext"]));
411  array_push($csvrow, $title);
412  }
413  }
414  $this->tpl->parseCurrentBlock();
415  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
416  {
417  array_push($csv, ilUtil::processCSVRow($csvrow, TRUE, $separator));
418  }
419  }
420  if (count($log_output) == 0)
421  {
422  $this->tpl->setCurrentBlock("empty_row");
423  $this->tpl->setVariable("TXT_NOLOG", $this->lng->txt("assessment_log_no_log"));
424  $this->tpl->parseCurrentBlock();
425  }
426  else
427  {
428  if (strcmp($this->ctrl->getCmd(), "exportLog") == 0)
429  {
430  $csvoutput = "";
431  foreach ($csv as $row)
432  {
433  $csvoutput .= join($row, $separator) . "\n";
434  }
435  ilUtil::deliverData($csvoutput, str_replace(" ", "_", "log_" . $ts_from . "_" . $ts_to . "_" . $available_tests[$_POST["sel_test"]]).".csv");
436  return;
437  }
438  }
439  $this->tpl->setCurrentBlock("log_output");
440  $this->tpl->setVariable("HEADER_DATETIME", $this->lng->txt("assessment_log_datetime"));
441  $this->tpl->setVariable("HEADER_USER", $this->lng->txt("user"));
442  $this->tpl->setVariable("HEADER_LOGTEXT", $this->lng->txt("assessment_log_text"));
443  $this->tpl->parseCurrentBlock();
444  }
445 
446  $this->tpl->setCurrentBlock("adm_content");
447  $this->tpl->setVariable("FORMACTION",
448  $this->ctrl->getFormAction($this));
449  $this->tpl->setVariable("TXT_ASSESSMENT_LOG", $this->lng->txt("assessment_log"));
450  $this->tpl->setVariable("TXT_LOG_FROM", $this->lng->txt("from"));
451  if (!is_array($_POST["log_from_date"]))
452  {
453  $date_input = ilUtil::makeDateSelect("log_from_date", "", "1", "1", 2004);
454  $time_input = ilUtil::makeTimeSelect("log_from_time", TRUE, 0, 0);
455  }
456  else
457  {
458  $date_input = ilUtil::makeDateSelect("log_from_date", $_POST["log_from_date"]["y"], $_POST["log_from_date"]["m"], $_POST["log_from_date"]["d"], 2004);
459  $time_input = ilUtil::makeTimeSelect("log_from_time", TRUE, $_POST["log_from_time"]["h"], $_POST["log_from_time"]["m"]);
460  }
461  $this->tpl->setVariable("INPUT_LOG_FROM", $date_input." / ".$time_input);
462  $this->tpl->setVariable("IMG_CALENDAR", ilUtil::getImagePath("calendar.png"));
463  $this->tpl->setVariable("TXT_LOG_FROM_CALENDAR", $this->lng->txt("assessment_log_open_calendar"));
464  $this->tpl->setVariable("INPUT_FIELDS_LOG_FROM", "log_from_date");
465  $this->tpl->setVariable("TXT_LOG_TO", $this->lng->txt("to"));
466  if (!is_array($_POST["log_to_date"]))
467  {
468  $date_input = ilUtil::makeDateSelect("log_to_date", "", "", "", 2004);
469  $time_input = ilUtil::makeTimeSelect("log_to_time");
470  }
471  else
472  {
473  $date_input = ilUtil::makeDateSelect("log_to_date", $_POST["log_to_date"]["y"], $_POST["log_to_date"]["m"], $_POST["log_to_date"]["d"], 2004);
474  $time_input = ilUtil::makeTimeSelect("log_to_time", TRUE, $_POST["log_to_time"]["h"], $_POST["log_to_time"]["m"]);
475  }
476  $this->tpl->setVariable("INPUT_LOG_TO", $date_input." / ".$time_input);
477  $this->tpl->setVariable("TXT_LOG_TO_CALENDAR", $this->lng->txt("assessment_log_open_calendar"));
478  $this->tpl->setVariable("INPUT_FIELDS_LOG_TO", "log_to_date");
479  $this->tpl->setVariable("TXT_CREATE", $this->lng->txt("show"));
480  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
481  $this->tpl->setVariable("TXT_TEST", $this->lng->txt("assessment_log_for_test"));
482  $this->tpl->setVariable("TXT_SELECT_TEST", $this->lng->txt("assessment_log_select_test"));
483  $this->tpl->parseCurrentBlock();
484  }
485 
491  function deleteLogObject()
492  {
493  if (is_array($_POST["chb_test"]) && (count($_POST["chb_test"])))
494  {
495  $this->object->deleteLogEntries($_POST["chb_test"]);
496  ilUtil::sendInfo($this->lng->txt("ass_log_deleted"));
497  }
498  else
499  {
500  ilUtil::sendInfo($this->lng->txt("ass_log_delete_no_selection"));
501  }
502  $this->logAdminObject();
503  }
504 
510  function logAdminObject()
511  {
512  global $ilUser;
513 
514  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.assessment_log_admin.html");
515 
516  // get test titles with ref_id
517  include_once "./Modules/Test/classes/class.ilObjTest.php";
518  $available_tests =& ilObjTest::_getAvailableTests(FALSE);
519  $count = count($available_tests);
520  if ($count)
521  {
522  $data = array();
523  $i=0;
524  foreach ($available_tests as $ref_id => $title)
525  {
526  $path = $this->object->getFullPath($ref_id);
527  $obj_id = $this->object->_lookupObjectId($ref_id);
528  $nr = $this->object->getNrOfLogEntries($obj_id);
529  array_push($data, array("<input type=\"checkbox\" name=\"chb_test[]\" value=\"$obj_id\" />", $title, $nr, $path));
530  }
531 
532  $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
533  $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
534  $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : "title";
535 
536  $maxentries = $ilUser->getPref("hits_per_page");
537  if ($maxentries < 1)
538  {
539  $maxentries = 9999;
540  }
541 
542  include_once("./Services/Table/classes/class.ilTableGUI.php");
543  $table = new ilTableGUI(0, FALSE);
544  $table->setTitle($this->lng->txt("ass_log_available_tests"));
545 
546  $header_names = array(
547  "",
548  $this->lng->txt("title"),
549  $this->lng->txt("ass_log_count_datasets"),
550  $this->lng->txt("ass_log_path")
551  );
552  $table->setHeaderNames($header_names);
553 
554  $table->enable("auto_sort");
555  $table->enable("sort");
556  $table->enable("select_all");
557  $table->enable("action");
558  $table->setLimit($maxentries);
559 
560  $table->addActionButton("deleteLog", $this->lng->txt("ass_log_delete_entries"));
561 
562  $table->setFormName("formLogAdmin");
563  $table->setSelectAllCheckbox("chb_test");
564  $header_params = $this->ctrl->getParameterArray($this, "logAdmin");
565  $header_vars = array("", "title", "count", "path");
566  $table->setHeaderVars($header_vars, $header_params);
567  $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
568 
569  $table->setOffset($offset);
570  $table->setMaxCount(count($available_tests));
571  $table->setOrderColumn($ordercolumn);
572  $table->setOrderDirection($orderdirection);
573  $table->setData($data);
574 
575  // footer
576  $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
577 
578  // render table
579  $tableoutput = $table->render();
580  $this->tpl->setVariable("TABLE_DATA", $tableoutput);
581  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "deleteLog"));
582  }
583  }
584 
585  function getAdminTabs(&$tabs_gui)
586  {
587  $this->getTabs($tabs_gui);
588  }
589 
590  function getLogdataSubtabs()
591  {
592  global $ilTabs;
593 
594  // log output
595  $ilTabs->addSubTabTarget("ass_log_output",
596  $this->ctrl->getLinkTarget($this, "logs"),
597  array("logs", "showLog", "exportLog")
598  , "");
599 
600  // log administration
601  $ilTabs->addSubTabTarget("ass_log_admin",
602  $this->ctrl->getLinkTarget($this, "logAdmin"),
603  array("logAdmin", "deleteLog"),
604  "", "");
605 
606  }
607 
613  function defaultsObject()
614  {
615  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
616 
617  $assessmentSetting = new ilSetting("assessment");
618  $use_javascript = array_key_exists("use_javascript", $_GET) ? $_GET["use_javascript"] : $assessmentSetting->get("use_javascript");
619  $imap_line_color = array_key_exists("imap_line_color", $_GET) ? $_GET["imap_line_color"] : $assessmentSetting->get("imap_line_color");
620  if (strlen($imap_line_color) == 0) $imap_line_color = "FF0000";
621 
622  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
623  {
624  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
625  }
626 
627  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
628  $form = new ilPropertyFormGUI();
629  $form->setFormAction($ilCtrl->getFormAction($this));
630  $form->setTitle($lng->txt("assessment_defaults"));
631 
632  // Enable javascript
633  $enable = new ilCheckboxInputGUI($lng->txt("assessment_use_javascript"), "use_javascript");
634  $enable->setChecked($use_javascript);
635  $enable->setInfo($lng->txt("assessment_use_javascript_desc"));
636  $form->addItem($enable);
637 
638  $linepicker = new ilColorPickerInputGUI($lng->txt("assessment_imap_line_color"), "imap_line_color");
639  $linepicker->setValue($imap_line_color);
640  $form->addItem($linepicker);
641 
642  $form->addCommandButton("saveDefaults", $lng->txt("save"));
643  $form->addCommandButton("defaults", $lng->txt("cancel"));
644 
645  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
646  }
647 
654  {
655  global $ilCtrl;
656 
657  $assessmentSetting = new ilSetting("assessment");
658  if ($_POST["use_javascript"])
659  {
660  $assessmentSetting->set("use_javascript", "1");
661  }
662  else
663  {
664  $assessmentSetting->set("use_javascript", "0");
665  }
666  if (strlen($_POST["imap_line_color"]) == 6)
667  {
668  $assessmentSetting->set("imap_line_color", $_POST["imap_line_color"]);
669  }
670  $ilCtrl->redirect($this, "defaults");
671  }
672 
673 
679  function getTabs(&$tabs_gui)
680  {
681  global $rbacsystem;
682 
683  switch ($this->ctrl->getCmd())
684  {
685  case "logs":
686  case "showLog":
687  case "exportLog":
688  case "logAdmin":
689  case "deleteLog":
690  $this->getLogdataSubtabs();
691  break;
692  }
693 
694  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
695  {
696  $tabs_gui->addTarget("settings",
697  $this->ctrl->getLinkTarget($this, "settings"), array("settings","","view"), "", "");
698 
699  $tabs_gui->addTarget("logs",
700  $this->ctrl->getLinkTarget($this, "logs"),
701  array("logs","showLog", "exportLog", "logAdmin", "deleteLog"),
702  "", "");
703 
704  $tabs_gui->addTarget("defaults",
705  $this->ctrl->getLinkTarget($this, "defaults"), array("defaults","saveDefaults"), "", "");
706  }
707 
708  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
709  {
710  $tabs_gui->addTarget("perm_settings",
711  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
712  }
713  }
714 } // END class.ilObjAssessmentFolderGUI
715 ?>