ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
132 $lng = $DIC['lng'];
133
134 $unit = $this->getUnit();
135 if (strcmp('-qpl_qst_formulaquestion_' . $unit . '-', $lng->txt('qpl_qst_formulaquestion_' . $unit)) != 0) {
136 $unit = $lng->txt('qpl_qst_formulaquestion_' . $unit);
137 }
138 return $unit;
139 }
140
145 public static function lookupUnitFactor($a_unit_id)
146 {
147 global $DIC;
148 $ilDB = $DIC['ilDB'];
149
150 $res = $ilDB->queryF(
151 'SELECT factor FROM il_qpl_qst_fq_unit WHERE unit_id = %s',
152 array('integer'),
153 array($a_unit_id)
154 );
155
156 $row = $ilDB->fetchAssoc($res);
157
158 return $row['factor'];
159 }
160}
An exception for terminatinating execution or to throw for unit testing.
$row
global $DIC
Definition: saml.php:7
$lng
foreach($_POST as $key=> $value) $res
global $ilDB
$data
Definition: bench.php:6