ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilDataCollectionRatingField.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once 'class.ilDataCollectionRecordField.php';
6 require_once("./Services/Rating/classes/class.ilRatingGUI.php");
7 
20 
24  protected $rated;
25 
29  protected $dcl_obj_id;
30 
32  parent::__construct($record, $field);
33  $dclTable = ilDataCollectionCache::getTableCache($this->getField()->getTableId());
34  $this->dcl_obj_id = $dclTable->getCollectionObject()->getId();
35  }
36 
40  protected function loadValue(){
41  // explicitly do nothing. we don't have to load the value as it is saved somewhere else.
42  }
43 
44  public function setValue($value){
45  // explicitly do nothing. the value is handled via the model and gui of ilRating.
46  }
47 
48  public function doUpdate(){
49  // explicitly do nothing. the value is handled via the model and gui of ilRating.
50  }
51 
52  public function doRead(){
53  // explicitly do nothing. the value is handled via the model and gui of ilRating.
54  }
55 
56  public function getFormInput(){
57  global $lng;
58  return $lng->txt("dcl_editable_in_table_gui");
59  }
60 
61  public function getHTML(){
62  global $ilCtrl;
63  $rgui = new ilRatingGUI();
64  $rgui->setObject($this->getRecord()->getId(), "dcl_record",
65  $this->getField()->getId(), "dcl_field");
66  $ilCtrl->setParameterByClass("ilratinggui", "field_id", $this->getField()->getId());
67  $ilCtrl->setParameterByClass("ilratinggui", "record_id", $this->getRecord()->getId());
68  $html = $rgui->getHTML();
69 
70  return $html;
71  }
72 
73  public function getExportValue(){
74  $val = ilRating::getOverallRatingForObject($this->getRecord()->getId(), "dcl_record",
75  $this->getField()->getId(), "dcl_field");
76  return round($val["avg"],1)." (".$val["cnt"].")";
77  }
78 
79  public function getValue(){
80  return ilRating::getOverallRatingForObject($this->getRecord()->getId(), "dcl_record",
81  $this->getField()->getId(), "dcl_field");
82  }
83 
87  public function delete()
88  {
89  global $ilDB;
90 
91  $ilDB->manipulate("DELETE FROM il_rating WHERE ".
92  "obj_id = ".$ilDB->quote((int) $this->getRecord()->getId(), "integer")." AND ".
93  "obj_type = ".$ilDB->quote("dcl_record", "text")." AND ".
94  "sub_obj_id = ".$ilDB->quote((int) $this->getField()->getId(), "integer")." AND ".
95  $ilDB->equals("sub_obj_type", "dcl_field", "text", true));
96 
97  $query2 = "DELETE FROM il_dcl_record_field WHERE id = ".$ilDB->quote($this->getId(), "integer");
98  $ilDB->manipulate($query2);
99  }
100 }
101 ?>