• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObjAssessmentFolder.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 require_once "class.ilObject.php";
00034 
00035 class ilObjAssessmentFolder extends ilObject
00036 {
00037         var $setting;
00038         
00045         function ilObjAssessmentFolder($a_id = 0,$a_call_by_reference = true)
00046         {
00047                 include_once "./Services/Administration/classes/class.ilSetting.php";
00048                 $this->setting = new ilSetting("assessment");
00049                 $this->type = "assf";
00050                 $this->ilObject($a_id,$a_call_by_reference);
00051         }
00052 
00059         function update()
00060         {
00061                 if (!parent::update())
00062                 {
00063                         return false;
00064                 }
00065 
00066                 // put here object specific stuff
00067 
00068                 return true;
00069         }
00070 
00071 
00078         function delete()
00079         {
00080                 // always call parent delete function first!!
00081                 if (!parent::delete())
00082                 {
00083                         return false;
00084                 }
00085 
00086                 //put here your module specific stuff
00087 
00088                 return true;
00089         }
00090 
00100         function initDefaultRoles()
00101         {
00102                 global $rbacadmin;
00103 
00104                 // create a local role folder
00105                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00106 
00107                 // create moderator role and assign role to rolefolder...
00108                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00109                 //$roles[] = $roleObj->getId();
00110 
00111                 //unset($rfoldObj);
00112                 //unset($roleObj);
00113 
00114                 return $roles ? $roles : array();
00115         }
00116 
00130         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00131         {
00132                 global $tree;
00133 
00134                 switch ($a_event)
00135                 {
00136                         case "link":
00137 
00138                                 //var_dump("<pre>",$a_params,"</pre>");
00139                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00140                                 //exit;
00141                                 break;
00142 
00143                         case "cut":
00144 
00145                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00146                                 //exit;
00147                                 break;
00148 
00149                         case "copy":
00150 
00151                                 //var_dump("<pre>",$a_params,"</pre>");
00152                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00153                                 //exit;
00154                                 break;
00155 
00156                         case "paste":
00157 
00158                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00159                                 //exit;
00160                                 break;
00161 
00162                         case "new":
00163 
00164                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00165                                 //exit;
00166                                 break;
00167                 }
00168 
00169                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00170                 if ($a_node_id==$_GET["ref_id"])
00171                 {
00172                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00173                         $parent_type = $parent_obj->getType();
00174                         if($parent_type == $this->getType())
00175                         {
00176                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00177                         }
00178                 }
00179 
00180                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00181         }
00182 
00186         function _enableAssessmentLogging($a_enable)
00187         {
00188                 $setting = new ilSetting("assessment");
00189 
00190                 if ($a_enable)
00191                 {
00192                         $setting->set("assessment_logging", 1);
00193                 }
00194                 else
00195                 {
00196                         $setting->set("assessment_logging", 0);
00197                 }
00198         }
00199 
00203         function _setLogLanguage($a_language)
00204         {
00205                 $setting = new ilSetting("assessment");
00206 
00207                 $setting->set("assessment_log_language", $a_language);
00208         }
00209 
00213         function _enabledAssessmentLogging()
00214         {
00215                 $setting = new ilSetting("assessment");
00216 
00217                 return (boolean) $setting->get("assessment_logging");
00218         }
00219         
00223         function _getForbiddenQuestionTypes()
00224         {
00225                 $setting = new ilSetting("assessment");
00226                 $types = $setting->get("forbidden_questiontypes");
00227                 $result = array();
00228                 if (strlen(trim($types)) == 0)
00229                 {
00230                         $result = array();
00231                 }
00232                 else
00233                 {
00234                         $result = unserialize($types);
00235                 }
00236                 return $result;
00237         }
00238 
00244         function _setForbiddenQuestionTypes($a_types)
00245         {
00246                 $setting = new ilSetting("assessment");
00247                 $types = "";
00248                 if (is_array($a_types) && (count($a_types) > 0))
00249                 {
00250                         $types = serialize($a_types);
00251                 }
00252                 $setting->set("forbidden_questiontypes", $types);
00253         }
00254         
00258         function _getLogLanguage()
00259         {
00260                 $setting = new ilSetting("assessment");
00261 
00262                 $lang = $setting->get("assessment_log_language");
00263                 if (strlen($lang) == 0)
00264                 {
00265                         $lang = "en";
00266                 }
00267                 return $lang;
00268         }
00269 
00273         function _getManualScoring()
00274         {
00275                 $setting = new ilSetting("assessment");
00276 
00277                 $types = $setting->get("assessment_manual_scoring");
00278                 return explode(",", $types);
00279         }
00280 
00284         function _getManualScoringTypes()
00285         {
00286                 global $ilDB;
00287                 
00288                 $query = "SELECT * FROM qpl_question_type";
00289                 $result = $ilDB->query($query);
00290                 $dbtypes = array();
00291                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00292                 {
00293                         $dbtypes[$row["question_type_id"]] = $row["type_tag"];
00294                 }
00295                 $setting = new ilSetting("assessment");
00296                 $types = $setting->get("assessment_manual_scoring");
00297                 $ids = explode(",", $types);
00298                 foreach ($ids as $key => $value)
00299                 {
00300                         $ids[$key] = $dbtypes[$value];
00301                 }
00302                 return $ids;
00303         }
00304 
00310         function _setManualScoring($type_ids)
00311         {
00312                 $setting = new ilSetting("assessment");
00313                 if ((!is_array($type_ids)) || (count($type_ids) == 0))
00314                 {
00315                         $setting->delete("assessment_manual_scoring");
00316                 }
00317                 else
00318                 {
00319                         $setting->set("assessment_manual_scoring", implode($type_ids, ","));
00320                 }
00321         }
00322 
00335         function _addLog($user_id, $object_id, $logtext, $question_id = "", $original_id = "", $test_only = FALSE, $ref_id = NULL)
00336         {
00337                 global $ilUser, $ilDB;
00338                 if (strlen($question_id) == 0)
00339                 {
00340                         $question_id = "NULL";
00341                 }
00342                 else
00343                 {
00344                         $question_id = $ilDB->quote($question_id . "");
00345                 }
00346                 if (strlen($original_id) == 0)
00347                 {
00348                         $original_id = "NULL";
00349                 }
00350                 else
00351                 {
00352                         $original_id = $ilDB->quote($original_id . "");
00353                 }
00354                 $only = "0";
00355                 if ($test_only == TRUE)
00356                 {
00357                         $only = "1";
00358                 }
00359                 $test_ref_id = "NULL";
00360                 if ($ref_id > 0)
00361                 {
00362                         $test_ref_id = $ilDB->quote($ref_id . "");
00363                 }
00364                 $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)",
00365                         $ilDB->quote($user_id . ""),
00366                         $ilDB->quote($object_id . ""),
00367                         $ilDB->quote($logtext . ""),
00368                         $question_id,
00369                         $original_id,
00370                         $ilDB->quote($only . ""),
00371                         $test_ref_id
00372                 );
00373                 $result = $ilDB->query($query);
00374         }
00375         
00386         function &getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
00387         {
00388                 $log = array();
00389                 if ($test_only == TRUE)
00390                 {
00391                         $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",
00392                                 $this->ilias->db->quote($test_id . ""),
00393                                 $this->ilias->db->quote($ts_from . ""),
00394                                 $this->ilias->db->quote($ts_to . ""),
00395                                 $this->ilias->db->quote("1")
00396                         );
00397                 }
00398                 else
00399                 {
00400                         $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",
00401                                 $this->ilias->db->quote($test_id . ""),
00402                                 $this->ilias->db->quote($ts_from . ""),
00403                                 $this->ilias->db->quote($ts_to . "")
00404                         );
00405                 }
00406                 $result = $this->ilias->db->query($query);
00407                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00408                 {
00409                         if (!array_key_exists($row["TIMESTAMP14"], $log))
00410                         {
00411                                 $log[$row["TIMESTAMP14"]] = array();
00412                         }
00413                         array_push($log[$row["TIMESTAMP14"]], $row);
00414                 }
00415                 krsort($log);
00416                 // flatten array
00417                 $log_array = array();
00418                 foreach ($log as $key => $value)
00419                 {
00420                         foreach ($value as $index => $row)
00421                         {
00422                                 array_push($log_array, $row);
00423                         }
00424                 }
00425                 return $log_array;
00426         }
00427         
00438         function &_getLog($ts_from, $ts_to, $test_id, $test_only = FALSE)
00439         {
00440                 global $ilDB;
00441                 
00442                 $log = array();
00443                 if ($test_only == TRUE)
00444                 {
00445                         $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",
00446                                 $ilDB->quote($test_id . ""),
00447                                 $ilDB->quote($ts_from . ""),
00448                                 $ilDB->quote($ts_to . ""),
00449                                 $ilDB->quote("1")
00450                         );
00451                 }
00452                 else
00453                 {
00454                         $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",
00455                                 $ilDB->quote($test_id . ""),
00456                                 $ilDB->quote($ts_from . ""),
00457                                 $ilDB->quote($ts_to . "")
00458                         );
00459                 }
00460                 $result = $ilDB->query($query);
00461                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00462                 {
00463                         if (!array_key_exists($row["TIMESTAMP14"], $log))
00464                         {
00465                                 $log[$row["TIMESTAMP14"]] = array();
00466                         }
00467                         $type_href = "";
00468                         if (array_key_exists("ref_id", $row))
00469                         {
00470                                 if ($row["ref_id"] > 0)
00471                                 {
00472                                         $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",
00473                                                 $ilDB->quote($row["ref_id"])
00474                                         );
00475                                         $typequeryresult = $ilDB->query($typequery);
00476                                         if ($typequeryresult->numRows() == 1)
00477                                         {
00478                                                 $typerow = $typequeryresult->fetchRow(DB_FETCHMODE_ASSOC);
00479                                                 switch ($typerow["type"])
00480                                                 {
00481                                                         case "tst":
00482                                                                 $type_href = sprintf("goto.php?target=tst_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
00483                                                                 break;
00484                                                         case "cat":
00485                                                                 $type_href = sprintf("goto.php?target=cat_%s&amp;client_id=" . CLIENT_ID, $row["ref_id"]);
00486                                                                 break;
00487                                                 }
00488                                         }
00489                                 }
00490                         }
00491                         $row["href"] = $type_href;
00492                         array_push($log[$row["TIMESTAMP14"]], $row);
00493                 }
00494                 krsort($log);
00495                 // flatten array
00496                 $log_array = array();
00497                 foreach ($log as $key => $value)
00498                 {
00499                         foreach ($value as $index => $row)
00500                         {
00501                                 array_push($log_array, $row);
00502                         }
00503                 }
00504                 return $log_array;
00505         }
00506         
00515         function getNrOfLogEntries($test_obj_id)
00516         {
00517                 $query = sprintf("SELECT COUNT(obj_fi) AS logcount FROM ass_log WHERE obj_fi = %s",
00518                         $this->ilias->db->quote($test_obj_id . "")
00519                 );
00520                 $result = $this->ilias->db->query($query);
00521                 if ($result->numRows())
00522                 {
00523                         $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00524                         return $row["logcount"];
00525                 }
00526                 else
00527                 {
00528                         return 0;
00529                 }
00530         }
00531         
00540         function getFullPath($ref_id)
00541         {
00542                 global $tree;
00543                 $path = $tree->getPathFull($ref_id);
00544                 $pathelements = array();
00545                 foreach ($path as $id => $data)
00546                 {
00547                         if ($id == 0)
00548                         {
00549                                 array_push($pathelements, ilUtil::prepareFormOutput($this->lng->txt("repository")));
00550                         }
00551                         else
00552                         {
00553                                 array_push($pathelements, "<a href=\"./goto.php?target=" . $data["type"] . "_" . $data["ref_id"] . "&amp;client=" . CLIENT_ID . "\">" .
00554                                         ilUtil::prepareFormOutput($data["title"]) . "</a>");
00555                         }
00556                 }
00557                 return implode("&nbsp;&gt;&nbsp;", $pathelements);
00558         }
00559         
00567         function deleteLogEntries($a_array)
00568         {
00569                 global $ilDB;
00570                 global $ilUser;
00571                 
00572                 foreach ($a_array as $object_id)
00573                 {
00574                         $query = sprintf("DELETE FROM ass_log WHERE obj_fi = %s",
00575                                 $ilDB->quote($object_id . "")
00576                         );
00577                         $ilDB->query($query);
00578                         $this->_addLog($ilUser->getId(), $object_id, $this->lng->txt("assessment_log_deleted"));
00579                 }
00580         }
00581 } // END class.ilObjAssessmentFolder
00582 ?>

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1