ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilExcCriteriaCatalogue.php
Go to the documentation of this file.
1
<?
php
2
3
/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11
class
ilExcCriteriaCatalogue
12
{
16
protected
$db
;
17
18
protected
$id
;
// [int]
19
protected
$parent
;
// [int]
20
protected
$title
;
// [string]
21
protected
$pos
;
// [int]
22
23
public
function
__construct
($a_id = null)
24
{
25
global
$DIC
;
26
27
$this->db = $DIC->database();
28
$this->
read
($a_id);
29
}
30
31
public
static
function
getInstancesByParentId
($a_parent_id)
32
{
33
global
$DIC
;
34
35
$ilDB
= $DIC->database();
36
37
$res
= array();
38
39
$set =
$ilDB
->query(
"SELECT *"
.
40
" FROM exc_crit_cat"
.
41
" WHERE parent = "
.
$ilDB
->quote($a_parent_id,
"integer"
) .
42
" ORDER BY pos"
);
43
while
(
$row
=
$ilDB
->fetchAssoc($set)) {
44
$obj =
new
self
();
45
$obj->importFromDB(
$row
);
46
$res
[$obj->getId()] = $obj;
47
}
48
49
return
$res
;
50
}
51
52
53
//
54
// properties
55
//
56
57
public
function
getId
()
58
{
59
return
$this->id
;
60
}
61
62
protected
function
setId
($a_id)
63
{
64
$this->
id
= (int) $a_id;
65
}
66
67
public
function
setParent
($a_value)
68
{
69
$this->
parent
= ($a_value !== null)
70
? (
int
) $a_value
71
: null;
72
}
73
74
public
function
getParent
()
75
{
76
return
$this->parent
;
77
}
78
79
public
function
setTitle
($a_value)
80
{
81
$this->title = ($a_value !== null)
82
? trim($a_value)
83
: null;
84
}
85
86
public
function
getTitle
()
87
{
88
return
$this->title
;
89
}
90
91
public
function
setPosition
($a_value)
92
{
93
$this->pos = (int) $a_value;
94
}
95
96
public
function
getPosition
()
97
{
98
return
$this->pos
;
99
}
100
101
102
//
103
// CRUD
104
//
105
106
protected
function
importFromDB
(array $a_row)
107
{
108
$this->
setId
($a_row[
"id"
]);
109
$this->
setParent
($a_row[
"parent"
]);
110
$this->
setTitle
($a_row[
"title"
]);
111
$this->
setPosition
($a_row[
"pos"
]);
112
}
113
114
protected
function
getDBProperties
()
115
{
116
return
array(
117
"title"
=> array(
"text"
, $this->
getTitle
())
118
,
"pos"
=> array(
"integer"
, $this->
getPosition
())
119
);
120
}
121
protected
function
getLastPosition
()
122
{
123
$ilDB
=
$this->db
;
124
125
if
(!$this->
getParent
()) {
126
return
;
127
}
128
129
$set =
$ilDB
->query(
"SELECT MAX(pos) pos"
.
130
" FROM exc_crit_cat"
.
131
" WHERE parent = "
.
$ilDB
->quote($this->getParent(),
"integer"
));
132
$row
=
$ilDB
->fetchAssoc($set);
133
return
(
int
)
$row
[
"pos"
];
134
}
135
136
protected
function
read
($a_id)
137
{
138
$ilDB
=
$this->db
;
139
140
$a_id = (int) $a_id;
141
if
($a_id) {
142
$set =
$ilDB
->query(
"SELECT *"
.
143
" FROM exc_crit_cat"
.
144
" WHERE id = "
.
$ilDB
->quote($a_id,
"integer"
));
145
if
(
$ilDB
->numRows($set)) {
146
$row
=
$ilDB
->fetchAssoc($set);
147
$this->
importFromDB
(
$row
);
148
}
149
}
150
}
151
152
public
function
save
()
153
{
154
$ilDB
=
$this->db
;
155
156
if
($this->
id
) {
157
return
$this->
update
();
158
}
159
160
$this->
id
=
$ilDB
->nextId(
"exc_crit_cat"
);
161
162
$fields = $this->
getDBProperties
();
163
$fields[
"parent"
] = array(
"integer"
, $this->
getParent
());
164
$fields[
"pos"
] = array(
"integer"
, $this->
getLastPosition
() + 10);
165
$fields[
"id"
] = array(
"integer"
, $this->
id
);
166
167
$ilDB
->insert(
"exc_crit_cat"
, $fields);
168
}
169
170
public
function
update
()
171
{
172
$ilDB
=
$this->db
;
173
174
if
(!$this->
id
) {
175
return
$this->
save
();
176
}
177
178
$primary = array(
"id"
=> array(
"integer"
, $this->
id
));
179
$ilDB
->update(
"exc_crit_cat"
, $this->
getDBProperties
(), $primary);
180
}
181
182
public
function
delete
()
183
{
184
$ilDB
=
$this->db
;
185
186
if
(!$this->
id
) {
187
return
;
188
}
189
190
include_once
"Modules/Exercise/classes/class.ilExcCriteria.php"
;
191
ilExcCriteria::deleteByParent
($this->
id
);
192
193
$ilDB
->manipulate(
"DELETE FROM exc_crit_cat"
.
194
" WHERE id = "
.
$ilDB
->quote($this->id,
"integer"
));
195
}
196
197
public
static
function
deleteByParent
($a_parent_id)
198
{
199
global
$DIC
;
200
201
$ilDB
= $DIC->database();
202
203
if
(!(
int
) $a_parent_id) {
204
return
;
205
}
206
207
$ilDB
->manipulate(
"DELETE FROM exc_crit"
.
208
" WHERE parent = "
.
$ilDB
->quote($a_parent_id,
"integer"
));
209
}
210
211
public
function
cloneObject
($a_target_parent_id)
212
{
213
$new_obj =
new
self
();
214
$new_obj->setParent($a_target_parent_id);
215
$new_obj->setTitle($this->
getTitle
());
216
$new_obj->setPosition($this->
getPosition
());
217
$new_obj->save();
218
219
include_once
"Modules/Exercise/classes/class.ilExcCriteria.php"
;
220
foreach
(
ilExcCriteria::getInstancesByParentId
($this->
getId
()) as $crit) {
221
$crit->cloneObject($new_obj->getId());
222
}
223
224
return
$new_obj->getId();
225
}
226
}
ilExcCriteriaCatalogue\$pos
$pos
Definition:
class.ilExcCriteriaCatalogue.php:21
ilExcCriteriaCatalogue
Class ilExcCriteriaCatalogue.
Definition:
class.ilExcCriteriaCatalogue.php:11
ilExcCriteriaCatalogue\read
read($a_id)
Definition:
class.ilExcCriteriaCatalogue.php:136
ilExcCriteriaCatalogue\$title
$title
Definition:
class.ilExcCriteriaCatalogue.php:20
ilExcCriteriaCatalogue\deleteByParent
static deleteByParent($a_parent_id)
Definition:
class.ilExcCriteriaCatalogue.php:197
ilExcCriteriaCatalogue\update
update()
Definition:
class.ilExcCriteriaCatalogue.php:170
$DIC
global $DIC
Definition:
saml.php:7
ilExcCriteriaCatalogue\cloneObject
cloneObject($a_target_parent_id)
Definition:
class.ilExcCriteriaCatalogue.php:211
ilExcCriteriaCatalogue\getPosition
getPosition()
Definition:
class.ilExcCriteriaCatalogue.php:96
ilExcCriteriaCatalogue\$id
$id
Definition:
class.ilExcCriteriaCatalogue.php:18
ilExcCriteriaCatalogue\getLastPosition
getLastPosition()
Definition:
class.ilExcCriteriaCatalogue.php:121
ilExcCriteriaCatalogue\$parent
$parent
Definition:
class.ilExcCriteriaCatalogue.php:19
ilExcCriteria\deleteByParent
static deleteByParent($a_parent_id)
Definition:
class.ilExcCriteria.php:302
ilExcCriteriaCatalogue\setTitle
setTitle($a_value)
Definition:
class.ilExcCriteriaCatalogue.php:79
ilExcCriteriaCatalogue\setPosition
setPosition($a_value)
Definition:
class.ilExcCriteriaCatalogue.php:91
parent
ilExcCriteriaCatalogue\__construct
__construct($a_id=null)
Definition:
class.ilExcCriteriaCatalogue.php:23
ilExcCriteriaCatalogue\setId
setId($a_id)
Definition:
class.ilExcCriteriaCatalogue.php:62
ilExcCriteriaCatalogue\getParent
getParent()
Definition:
class.ilExcCriteriaCatalogue.php:74
ilExcCriteriaCatalogue\getTitle
getTitle()
Definition:
class.ilExcCriteriaCatalogue.php:86
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilExcCriteria\getInstancesByParentId
static getInstancesByParentId($a_parent_id)
Definition:
class.ilExcCriteria.php:55
ilExcCriteriaCatalogue\$db
$db
Definition:
class.ilExcCriteriaCatalogue.php:16
$row
$row
Definition:
migrateto20.php:360
ilExcCriteriaCatalogue\getInstancesByParentId
static getInstancesByParentId($a_parent_id)
Definition:
class.ilExcCriteriaCatalogue.php:31
ilExcCriteriaCatalogue\save
save()
Definition:
class.ilExcCriteriaCatalogue.php:152
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilExcCriteriaCatalogue\setParent
setParent($a_value)
Definition:
class.ilExcCriteriaCatalogue.php:67
php
ilExcCriteriaCatalogue\getDBProperties
getDBProperties()
Definition:
class.ilExcCriteriaCatalogue.php:114
ilExcCriteriaCatalogue\getId
getId()
Definition:
class.ilExcCriteriaCatalogue.php:57
ilExcCriteriaCatalogue\importFromDB
importFromDB(array $a_row)
Definition:
class.ilExcCriteriaCatalogue.php:106
Modules
Exercise
classes
class.ilExcCriteriaCatalogue.php
Generated on Thu Jan 16 2025 19:02:02 for ILIAS by
1.8.13 (using
Doxyfile
)