ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.assFormulaQuestionUnit.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 private $unit = '';
14 private $factor = 0.0;
15 private $baseunit = 0;
16 private $baseunit_title = '';
17 private $id = 0;
18 private $category = 0;
19 private $sequence = 0;
20
24 public function __construct()
25 {
26 }
27
31 public function initFormArray(array $data)
32 {
33 $this->id = $data['unit_id'];
34 $this->unit = $data['unit'];
35 $this->factor = $data['factor'];
36 $this->baseunit = $data['baseunit_fi'];
37 $this->baseunit_title = $data['baseunit_title'];
38 $this->category = $data['category'];
39 $this->sequence = $data['sequence'];
40 }
41
46 {
47 $this->baseunit_title = $baseunit_title;
48 }
49
53 public function getBaseunitTitle()
54 {
56 }
57
58 public function setId($id)
59 {
60 $this->id = $id;
61 }
62
63 public function getId()
64 {
65 return $this->id;
66 }
67
68 public function setUnit($unit)
69 {
70 $this->unit = $unit;
71 }
72
73 public function getUnit()
74 {
75 return $this->unit;
76 }
77
78 public function setSequence($sequence)
79 {
80 $this->sequence = $sequence;
81 }
82
83 public function getSequence()
84 {
85 return $this->sequence;
86 }
87
88 public function setFactor($factor)
89 {
90 $this->factor = $factor;
91 }
92
93 public function getFactor()
94 {
95 return $this->factor;
96 }
97
98 public function setBaseUnit($baseunit)
99 {
100 if (is_numeric($baseunit) && $baseunit > 0) {
101 $this->baseunit = $baseunit;
102 } else {
103 $this->baseunit = null;
104 }
105 }
106
107 public function getBaseUnit()
108 {
109 if (is_numeric($this->baseunit) && $this->baseunit > 0) {
110 return $this->baseunit;
111 } else {
112 return $this->id;
113 }
114 }
115
116 public function setCategory($category)
117 {
118 $this->category = $category;
119 }
120
121 public function getCategory()
122 {
123 return $this->category;
124 }
125
126 public function getDisplayString()
127 {
131 global $lng;
132
133 $unit = $this->getUnit();
134 if (strcmp('-qpl_qst_formulaquestion_' . $unit . '-', $lng->txt('qpl_qst_formulaquestion_' . $unit)) != 0) {
135 $unit = $lng->txt('qpl_qst_formulaquestion_' . $unit);
136 }
137 return $unit;
138 }
139
144 public static function lookupUnitFactor($a_unit_id)
145 {
146 global $ilDB;
147
148 $res = $ilDB->queryF(
149 'SELECT factor FROM il_qpl_qst_fq_unit WHERE unit_id = %s',
150 array('integer'),
151 array($a_unit_id)
152 );
153
154 $row = $ilDB->fetchAssoc($res);
155
156 return $row['factor'];
157 }
158}
An exception for terminatinating execution or to throw for unit testing.
global $lng
Definition: privfeed.php:17
foreach($_POST as $key=> $value) $res
global $ilDB