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

Modules/Test/classes/class.ilTestEvaluationData.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 
00034 class ilTestEvaluationData
00035 {
00041         var $questionTitles;
00042 
00048         var $participants;
00049 
00055         var $statistics;
00056 
00062         var $filterby;
00063 
00069         var $filtertext;
00070         
00075         var $datasets;
00076 
00077         public function __sleep()
00078         {
00079                 return array('questionTitles', 'participants', 'statistics', 'filterby', 'filtertext', 'datasets');
00080         }
00081 
00087         function ilTestEvaluationData()
00088         {
00089                 $this->participants = array();
00090                 $this->questionTitles = array();
00091         }
00092         
00093         function setDatasets($datasets)
00094         {
00095                 $this->datasets = $datasets;
00096         }
00097         
00098         function getDatasets()
00099         {
00100                 return $this->datasets;
00101         }
00102         
00103         function addQuestionTitle($question_id, $question_title)
00104         {
00105                 $this->questionTitles[$question_id] = $question_title;
00106         }
00107         
00108         function getQuestionTitles()
00109         {
00110                 return $this->questionTitles;
00111         }
00112         
00113         function getQuestionTitle($question_id)
00114         {
00115                 if (array_key_exists($question_id, $this->questionTitles))
00116                 {
00117                         return $this->questionTitles[$question_id];
00118                 }
00119                 else
00120                 {
00121                         return "";
00122                 }
00123         }
00124         
00125         function calculateStatistics()
00126         {
00127                 include_once "./Modules/Test/classes/class.ilTestStatistics.php";
00128                 $this->statistics = new ilTestStatistics($this);
00129         }
00130 
00131         private function getMembershipByType($a_usr_id,$a_type)
00132         {
00133                 global $ilDB;
00134                 
00135                 $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua AS ua ".
00136                         "JOIN rbac_fa AS fa ON ua.rol_id = fa.rol_id ".
00137                         "JOIN tree AS t1 ON t1.child = fa.parent ".
00138                         "JOIN object_reference AS obr ON t1.parent = obr.ref_id ".
00139                         "JOIN object_data AS obd ON obr.obj_id = obd.obj_id ".
00140                         "WHERE obd.type = ".$ilDB->quote($a_type)." ".
00141                         "AND fa.assign = 'y' ".
00142                         "AND ua.usr_id = ".$ilDB->quote($a_usr_id)." ";
00143                 $res = $ilDB->query($query);
00144                 
00145                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00146                 {
00147                         $ref_ids[] = $row->obj_id;
00148                 }
00149                 
00150                 return $ref_ids ? $ref_ids : array();                   
00151         }
00152         
00153         function getParticipants()
00154         {
00155                 if (strlen($this->filterby) && strlen($this->filtertext))
00156                 {
00157                         $filteredParticipants = array();
00158                         $courseids = array();
00159                         $groupids = array();
00160                         global $ilDB;
00161                         switch ($this->filterby)
00162                         {
00163                                 case "group":
00164                                         $query = sprintf("SELECT obj_id FROM object_data WHERE type = 'grp' AND title LIKE %s",
00165                                                 $ilDB->quote("%$filtertext%")
00166                                         );
00167                                         $result = $ilDB->query($query);
00168                                         while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00169                                         {
00170                                                 array_push($groupids, $row["obj_id"]);
00171                                         }
00172                                         break;
00173                                 case "course":
00174                                         $query = sprintf("SELECT obj_id FROM object_data WHERE type = 'crs' AND title LIKE %s",
00175                                                 $ilDB->quote("%$filtertext%")
00176                                         );
00177                                         $result = $ilDB->query($query);
00178                                         while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00179                                         {
00180                                                 array_push($courseids, $row["obj_id"]);
00181                                         }
00182                                         break;
00183                         }
00184                         foreach ($this->participants as $active_id => $participant)
00185                         {
00186                                 $remove = FALSE;
00187                                 switch ($this->filterby)
00188                                 {
00189                                         case "name":
00190                                                 if (!(strpos(strtolower($participant->getName()), strtolower($this->filtertext)) !== FALSE)) $remove = TRUE;
00191                                                 break;
00192                                         case "group":
00193                                                 $groups = $this->getMembershipByType($participant->getUserID(), "grp");
00194                                                 $foundfilter = FALSE;
00195                                                 if (count(array_intersect($groupids, $groups))) $foundfilter = TRUE;
00196                                                 if (!$foundfilter) $remove = TRUE;
00197                                                 break;
00198                                         case "course":
00199                                                 $courses = $this->getMembershipByType($participant->getUserID(), "crs");
00200                                                 $foundfilter = FALSE;
00201                                                 if (count(array_intersect($courseids, $courses))) $foundfilter = TRUE;
00202                                                 if (!$foundfilter) $remove = TRUE;
00203                                                 break;
00204                                 }
00205                                 if (!$remove) $filteredParticipants[$active_id] = $participant;
00206                         }
00207                         return $filteredParticipants;
00208                 }
00209                 else
00210                 {
00211                         return $this->participants;
00212                 }
00213         }
00214         
00215         function resetFilter()
00216         {
00217                 $this->filterby = "";
00218                 $this->filtertext = "";
00219         }
00220         
00221         /*
00222         * Set an output filter for getParticipants
00223         *
00224         * @param string $by name, course, group
00225         * @param string $text Filter text
00226         */
00227         function setFilter($by, $text)
00228         {
00229                 $this->filterby = $by;
00230                 $this->filtertext = $text;
00231         }
00232         
00233         function addParticipant($active_id, $participant)
00234         {
00235                 $this->participants[$active_id] = $participant;
00236         }
00237         
00238         function &getParticipant($active_id)
00239         {
00240                 return $this->participants[$active_id];
00241         }
00242         
00243         function participantExists($active_id)
00244         {
00245                 return array_key_exists($active_id, $this->participants);
00246         }
00247         
00248         function &getStatistics()
00249         {
00250                 return $this->statistics;
00251         }
00252 
00253         function getParticipantIds()
00254         {
00255                 return array_keys($this->participants);
00256         }
00257 } // END ilTestEvaluationData
00258 
00259 ?>

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