ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

References array.

42  {
43  $this->arrData = array();
44  }
Create styles array
The data for the language used.

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.

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

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

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
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
global $ilDB
+ 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.

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

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

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  }
$result
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
global $ilDB
+ 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.

References $ilDB.

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  }
global $ilDB

◆ savePhrase()

ilSurveyPhrases::savePhrase ( )

Saves a set of categories to a default phrase.

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

References $counter, $ilDB, $ilUser, array, and time.

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  }
$counter
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ 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 public

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

References $counter, $ilDB, $ilUser, array, and time.

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  }
$counter
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

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: