ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSurveyPhrases Class Reference

Survey phrases class. More...

+ Collaboration diagram for ilSurveyPhrases:

Public Member Functions

 __construct ()
 ilSurveyPhrases constructor More...
 
 deletePhrases ($phrase_array)
 Delete phrases from the database. More...
 
 updatePhrase ($phrase_id)
 Saves a set of categories to a default phrase. More...
 
 savePhrase ()
 Saves a set of categories to a default phrase. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 

Static Public Member Functions

static & _getAvailablePhrases ($useronly=0)
 Gets the available phrases from the database. More...
 
static & _getCategoriesForPhrase ($phrase_id)
 Gets the available categories for a given phrase. More...
 

Protected Attributes

 $arrData
 

Detailed Description

Survey phrases class.

The ilSurveyPhrases class manages survey phrases (collections of survey categories) for ordinal survey question types.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 34 of file class.ilSurveyPhrases.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyPhrases::__construct ( )

ilSurveyPhrases constructor

Definition at line 41 of file class.ilSurveyPhrases.php.

42 {
43 $this->arrData = array();
44 }

Member Function Documentation

◆ __get()

ilSurveyPhrases::__get (   $value)

Object getter.

Definition at line 214 of file class.ilSurveyPhrases.php.

215 {
216 switch ($value)
217 {
218 default:
219 if (array_key_exists($value, $this->arrData))
220 {
221 return $this->arrData[$value];
222 }
223 else
224 {
225 return null;
226 }
227 break;
228 }
229 }

◆ __set()

ilSurveyPhrases::__set (   $key,
  $value 
)

Object setter.

Definition at line 234 of file class.ilSurveyPhrases.php.

235 {
236 switch ($key)
237 {
238 default:
239 $this->arrData[$key] = $value;
240 break;
241 }
242 }

◆ _getAvailablePhrases()

static & ilSurveyPhrases::_getAvailablePhrases (   $useronly = 0)
static

Gets the available phrases from the database.

Parameters
boolean$useronlyReturns only the user defined phrases if set to true. The default is false.
Returns
array All available phrases as key/value pairs

Definition at line 52 of file class.ilSurveyPhrases.php.

53 {
54 global $ilUser;
55 global $ilDB;
56 global $lng;
57
58 $phrases = array();
59 $result = $ilDB->queryF("SELECT * FROM svy_phrase WHERE defaultvalue = %s OR owner_fi = %s ORDER BY title",
60 array('text', 'integer'),
61 array('1', $ilUser->getId())
62 );
63 while ($row = $ilDB->fetchObject($result))
64 {
65 if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
66 {
67 if (!$useronly)
68 {
69 $phrases[$row->phrase_id] = array(
70 "title" => $lng->txt($row->title),
71 "owner" => $row->owner_fi,
72 "org_title" => $row->title
73 );
74 }
75 }
76 else
77 {
78 if ($ilUser->getId() == $row->owner_fi)
79 {
80 $phrases[$row->phrase_id] = array(
81 "title" => $row->title,
82 "owner" => $row->owner_fi
83 );
84 }
85 }
86 }
87 return $phrases;
88 }
$result
global $lng
Definition: privfeed.php:40
global $ilDB
global $ilUser
Definition: imgupload.php:15

References $ilDB, $ilUser, $lng, $result, and $row.

Referenced by ilSurveyPhrasesGUI\deletePhrasesForm(), SurveyQuestionGUI\initPhrasesForm(), and ilSurveyPhrasesGUI\phrases().

+ Here is the caller graph for this function:

◆ _getCategoriesForPhrase()

static & ilSurveyPhrases::_getCategoriesForPhrase (   $phrase_id)
static

Gets the available categories for a given phrase.

Parameters
integer$phrase_idThe database id of the given phrase
Returns
array All available categories

Definition at line 96 of file class.ilSurveyPhrases.php.

97 {
98 global $ilDB;
99 global $lng;
100
101 $categories = array();
102 $result = $ilDB->queryF("SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s ORDER BY svy_phrase_cat.sequence",
103 array('integer'),
104 array($phrase_id)
105 );
106 while ($row = $ilDB->fetchObject($result))
107 {
108 if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
109 {
110 $categories[$row->category_id] = $lng->txt($row->title);
111 }
112 else
113 {
114 $categories[$row->category_id] = $row->title;
115 }
116 }
117 return $categories;
118 }

References $ilDB, $lng, $result, and $row.

Referenced by ilSurveyPhrasesGUI\deletePhrasesForm(), SurveyQuestionGUI\initPhrasesForm(), and ilSurveyPhrasesGUI\phrases().

+ Here is the caller graph for this function:

◆ deletePhrases()

ilSurveyPhrases::deletePhrases (   $phrase_array)

Delete phrases from the database.

Parameters
array$phrase_arrayAn array containing phrase id's to delete

Definition at line 125 of file class.ilSurveyPhrases.php.

126 {
127 global $ilDB;
128
129 if ((is_array($phrase_array)) && (count($phrase_array)))
130 {
131 $affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase WHERE " . $ilDB->in('phrase_id', $phrase_array, false, 'integer'));
132 $affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase_cat WHERE " . $ilDB->in('phrase_fi', $phrase_array, false, 'integer'));
133 }
134 }

References $ilDB.

◆ savePhrase()

ilSurveyPhrases::savePhrase ( )

Saves a set of categories to a default phrase.

Definition at line 180 of file class.ilSurveyPhrases.php.

181 {
182 global $ilUser;
183 global $ilDB;
184
185 $next_id = $ilDB->nextId('svy_phrase');
186 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
187 array('integer','text','text','integer','integer'),
188 array($next_id, $this->title, 1, $ilUser->getId(), time())
189 );
190 $phrase_id = $next_id;
191
192 $counter = 1;
193 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
194 {
195 $cat = $this->categories->getCategory($i);
196 $next_id = $ilDB->nextId('svy_category');
197 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
198 array('integer','text','text','integer','integer','text'),
199 array($next_id, $cat->title, 1, $ilUser->getId(), time(), $cat->neutral)
200 );
201 $category_id = $next_id;
202 $next_id = $ilDB->nextId('svy_phrase_cat');
203 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (%s, %s, %s, %s)",
204 array('integer', 'integer', 'integer','integer'),
205 array($next_id, $phrase_id, $category_id, $counter)
206 );
207 $counter++;
208 }
209 }

References $ilDB, and $ilUser.

◆ updatePhrase()

ilSurveyPhrases::updatePhrase (   $phrase_id)

Saves a set of categories to a default phrase.

Parameters
array$phrasesThe database ids of the seleted phrases
string$titleThe title of the default phrase @access public

Definition at line 143 of file class.ilSurveyPhrases.php.

144 {
145 global $ilUser;
146 global $ilDB;
147
148 $affectedRows = $ilDB->manipulateF("UPDATE svy_phrase SET title = %s, tstamp = %s WHERE phrase_id = %s",
149 array('text','integer','integer'),
150 array($this->title, time(), $phrase_id)
151 );
152
153 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_phrase_cat WHERE phrase_fi = %s",
154 array('integer'),
155 array($phrase_id)
156 );
157
158 $counter = 1;
159 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
160 {
161 $cat = $this->categories->getCategory($i);
162 $next_id = $ilDB->nextId('svy_category');
163 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
164 array('integer','text','text','integer','integer','text'),
165 array($next_id, $cat->title, 1, $ilUser->getId(), time(), $cat->neutral)
166 );
167 $category_id = $next_id;
168 $next_id = $ilDB->nextId('svy_phrase_cat');
169 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (%s, %s, %s, %s)",
170 array('integer', 'integer', 'integer','integer'),
171 array($next_id, $phrase_id, $category_id, $counter)
172 );
173 $counter++;
174 }
175 }

References $ilDB, and $ilUser.

Field Documentation

◆ $arrData

ilSurveyPhrases::$arrData
protected

Definition at line 36 of file class.ilSurveyPhrases.php.


The documentation for this class was generated from the following file: