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

Services/Tracking/classes/ItemList/class.ilLPObjectItemListGUI.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 
00036 include_once 'Services/Tracking/classes/ItemList/class.ilLPItemListGUI.php';
00037 
00038 class ilLPObjectItemListGUI extends ilLPItemListGUI
00039 {
00040         var $references = array();
00041 
00042 
00043         function ilLPObjectItemListGUI($a_id,$a_type)
00044         {
00045                 parent::ilLPItemListGUI($a_id,$a_type);
00046         }
00047 
00048         function addReferences($a_references)
00049         {
00050                 $this->references = $a_references;
00051         }
00052 
00053 
00054         // Overwritten methods
00055         function __readTitle()
00056         {
00057                 global $ilObjDataCache;
00058                 $this->title = $ilObjDataCache->lookupTitle($this->getId());
00059         }
00060         function __readDescription()
00061         {
00062                 global $ilObjDataCache;
00063                 $this->description = $ilObjDataCache->lookupDescription($this->getId());
00064         }
00065         function __readStatusInfo()
00066         {
00067                 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
00068                 $this->status_info = ilLPStatusWrapper::_getStatusInfo($this->getId());
00069         }
00070 
00071         function __readMark()
00072         {
00073                 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00074                 $this->mark = ilLPMarks::_lookupMark($this->getCurrentUser(),$this->getId());
00075         }
00076 
00077         function __readComment()
00078         {
00079                 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
00080                 $this->comment = ilLPMarks::_lookupComment($this->getCurrentUser(),$this->getId());
00081         }
00082 
00083         function __readTypicalLearningTime()
00084         {
00085                 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
00086                 $this->tlt = ilLPStatusWrapper::_getTypicalLearningTime($this->getId());
00087         }
00088 
00089         function __readUserStatus()
00090         {
00091                 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
00092 
00093                 if(in_array($this->getCurrentUser(),ilLPStatusWrapper::_getInProgress($this->getId())))
00094                 {
00095                         $this->status = LP_STATUS_IN_PROGRESS;
00096                 }
00097                 elseif(in_array($this->getCurrentUser(),ilLPStatusWrapper::_getCompleted($this->getId())))
00098                 {
00099                         $this->status = LP_STATUS_COMPLETED;
00100                 }
00101                 elseif(in_array($this->getCurrentUser(),ilLPStatusWrapper::_getFailed($this->getId())))
00102                 {
00103                         $this->status = LP_STATUS_FAILED;
00104                 }
00105                 else
00106                 {
00107                         $this->status = LP_STATUS_NOT_ATTEMPTED;
00108                 }
00109         }
00110 
00111         function __readUserStatusInfo()
00112         {
00113                 global $ilObjDataCache;
00114 
00115                 $this->user_status_info = null;
00116 
00117                 switch($this->getMode())
00118                 {
00119                         case LP_MODE_TEST_PASSED:
00120                                 // Get stored test results
00121                                 $found = false;
00122                                 foreach($this->status_info['results'] as $res)
00123                                 {
00124                                         if($this->getCurrentUser() == $res['user_id'])
00125                                         {
00126                                                 $this->user_status_info = array($this->lng->txt('trac_reached_points'),
00127                                                                                                                 $this->__getPercent($res['max_points'],$res['reached_points']));
00128                                                 return true;
00129                                         }
00130                                 }
00131                                 return $this->user_status_info = array($this->lng->txt('trac_reached_points'),
00132                                                                                                            "0.00%");
00133 
00134                         case LP_MODE_TLT:
00135                                 if(!$this->status_info['tlt'])
00136                                 {
00137                                         return false;
00138                                 }
00139                                 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
00140                                 $user_data = ilLearningProgress::_getProgress($this->getCurrentUser(),$this->getId());
00141 
00142                                 return $this->user_status_info = array($this->lng->txt('trac_edit_time'),
00143                                                                                                            $this->__getPercent($this->status_info['tlt'],$user_data['spent_time']));
00144 
00145                         case LP_MODE_VISITS:
00146                                 if(!$this->status_info['visits'])
00147                                 {
00148                                         return false;
00149                                 }
00150 
00151                                 include_once './Services/Tracking/classes/class.ilLearningProgress.php';
00152                                 $user_data = ilLearningProgress::_getProgress($this->getCurrentUser(),$this->getId());
00153 
00154                                 return $this->user_status_info = array($this->lng->txt('trac_reached_visits'),
00155                                                                                                            $this->__getPercent($this->status_info['visits'],$user_data['visits']));
00156 
00157                         case LP_MODE_OBJECTIVES:
00158                                 if(!$this->status_info['num_objectives'])
00159                                 {
00160                                         return false;
00161                                 }
00162                                 $fullfilled = $this->status_info['objective_result'][$this->getCurrentUser()] ? 
00163                                         $this->status_info['objective_result'][$this->getCurrentUser()] : array();
00164                                 return $this->user_status_info = array($this->lng->txt('trac_reached_objectives'),
00165                                                                                                            $this->__getPercent($this->status_info['num_objectives'],
00166                                                                                                                                                    count($fullfilled)));
00167                         case LP_MODE_SCORM:
00168                                 if(!$this->status_info['num_scos'])
00169                                 {
00170                                         return false;
00171                                 }
00172                                 return $this->user_status_info = array($this->lng->txt('trac_edited_scos'),
00173                                                                                                            $this->__getPercent($this->status_info['num_scos'],
00174                                                                                                                                                    $this->status_info['num_completed'][$this->getCurrentUser()]));
00175 
00176                         case LP_MODE_COLLECTION:
00177                                 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
00178                                 include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
00179 
00180                                 $user_time = 0;
00181                                 if(!is_array($this->status_info['collections']) or !$this->tlt)
00182                                 {
00183                                         return false;
00184                                 }
00185                                 foreach($this->status_info['collections'] as $item)
00186                                 {
00187                                         $object_id = $ilObjDataCache->lookupObjId($item);
00188 
00189                                         // count full time if status is completed 
00190                                         if(in_array($this->getCurrentUser(),ilLPStatusWrapper::_getCompleted($object_id)))
00191                                         {
00192                                                 $user_time += ilLPStatusWrapper::_getTypicalLearningTime($object_id);
00193                                                 continue;
00194                                         }
00195 
00196                                         switch($ilObjDataCache->lookupType($object_id))
00197                                         {
00198                                                 case 'lm':
00199                                                         $progress = ilLearningProgress::_getProgress($this->getCurrentUser(),$object_id);
00200                                                         $user_time += min($progress['spent_time'],
00201                                                                                           ilLPStatusWrapper::_getTypicalLearningTime($object_id));
00202                                                         break;
00203                                         }
00204                                 }
00205 
00206                                 if($user_time)
00207                                 {
00208                                         $this->user_status_info = array($this->lng->txt('trac_processing_time'),
00209                                                                                                         $this->__getPercent($this->tlt,$user_time));
00210                                 }
00211                                 break;
00212                 }
00213         }
00214 
00215         function renderPath($a_force_details = true)
00216         {
00217                 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
00218                 include_once 'classes/class.ilLink.php';
00219 
00220                 if(!count($this->references))
00221                 {
00222                         return true;
00223                 }
00224                 foreach($this->references as $ref_id)
00225                 {
00226                         $path = '...';
00227                         $counter = 0;
00228                         $path_full = $this->tree->getPathFull($ref_id);
00229                         foreach($path_full as $data)
00230                         {
00231                                 if(++$counter < (count($path_full)-1))
00232                                 {
00233                                         continue;
00234                                 }
00235                                 $path .= " -> ";
00236                                 if($ref_id != $data['ref_id'])
00237                                 {
00238                                         $path .= $data['title'];
00239                                 }
00240                                 else
00241                                 {
00242                                         $path .= ('<a target="_top" href="'.
00243                                                           ilLink::_getLink($data['ref_id'],$data['type']).'">'.
00244                                                           $data['title'].'</a>');
00245                                 }
00246                         }
00247                         $this->tpl->setCurrentBlock("path_item");
00248 
00249                         #var_dump("<pre>",$a_force_details,ilObjUserTracking::_enabledUserRelatedData(),!$this->isAnonymized(),"<pre>");
00250 
00251                         if($a_force_details or (ilObjUserTracking::_enabledUserRelatedData() and !$this->isAnonymized()))
00252                         {
00253                                 $this->ctrl->setParameterByClass($this->getCmdClass(),'details_id',$ref_id);
00254                                 $this->tpl->setVariable("PATH_DETAILS",$this->ctrl->getLinkTargetByClass($this->getCmdClass(),'details'));
00255                                 $this->tpl->setVariable("TXT_PATH_DETAILS",$this->lng->txt('details'));
00256                         }
00257 
00258                         $this->tpl->setVariable("OCCURRENCES",$this->lng->txt('trac_occurrences'));
00259                         $this->tpl->setVariable("PATH_ITEM",$path);
00260                         $this->tpl->parseCurrentBlock();
00261                         
00262                         $this->tpl->setCurrentBlock("path");
00263                         $this->tpl->parseCurrentBlock();
00264                 }
00265                 return true;
00266         }
00267 
00268 
00269 
00270 }
00271 ?>

Generated on Fri Dec 13 2013 13:52:12 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1