ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSurveyPhrases Class Reference

Survey phrases class. More...

+ Collaboration diagram for ilSurveyPhrases:

Public Member Functions

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

Static Public Member Functions

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

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

ilSurveyPhrases::__construct ( )

ilSurveyPhrases constructor

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

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

Member Function Documentation

ilSurveyPhrases::__get (   $value)

Object getter.

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

{
switch ($value)
{
default:
if (array_key_exists($value, $this->arrData))
{
return $this->arrData[$value];
}
else
{
return null;
}
break;
}
}
ilSurveyPhrases::__set (   $key,
  $value 
)

Object setter.

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

{
switch ($key)
{
default:
$this->arrData[$key] = $value;
break;
}
}
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, and $row.

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

{
global $ilUser;
global $ilDB;
global $lng;
$phrases = array();
$result = $ilDB->queryF("SELECT * FROM svy_phrase WHERE defaultvalue = %s OR owner_fi = %s ORDER BY title",
array('text', 'integer'),
array('1', $ilUser->getId())
);
while ($row = $ilDB->fetchObject($result))
{
if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
{
if (!$useronly)
{
$phrases[$row->phrase_id] = array(
"title" => $lng->txt($row->title),
"owner" => $row->owner_fi,
"org_title" => $row->title
);
}
}
else
{
if ($ilUser->getId() == $row->owner_fi)
{
$phrases[$row->phrase_id] = array(
"title" => $row->title,
"owner" => $row->owner_fi
);
}
}
}
return $phrases;
}

+ Here is the caller graph for this function:

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, and $row.

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

{
global $ilDB;
global $lng;
$categories = array();
$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",
array('integer'),
array($phrase_id)
);
while ($row = $ilDB->fetchObject($result))
{
if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
{
$categories[$row->category_id] = $lng->txt($row->title);
}
else
{
$categories[$row->category_id] = $row->title;
}
}
return $categories;
}

+ Here is the caller graph for this function:

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.

{
global $ilDB;
if ((is_array($phrase_array)) && (count($phrase_array)))
{
$affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase WHERE " . $ilDB->in('phrase_id', $phrase_array, false, 'integer'));
$affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase_cat WHERE " . $ilDB->in('phrase_fi', $phrase_array, false, 'integer'));
}
}
ilSurveyPhrases::savePhrase ( )

Saves a set of categories to a default phrase.

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

References $ilDB, and $ilUser.

{
global $ilUser;
global $ilDB;
$next_id = $ilDB->nextId('svy_phrase');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer','text','text','integer','integer'),
array($next_id, $this->title, 1, $ilUser->getId(), time())
);
$phrase_id = $next_id;
$counter = 1;
for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
{
$cat = $this->categories->getCategory($i);
$next_id = $ilDB->nextId('svy_category');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','text','text','integer','integer','text'),
array($next_id, $cat->title, 1, $ilUser->getId(), time(), $cat->neutral)
);
$category_id = $next_id;
$next_id = $ilDB->nextId('svy_phrase_cat');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (%s, %s, %s, %s)",
array('integer', 'integer', 'integer','integer'),
array($next_id, $phrase_id, $category_id, $counter)
);
$counter++;
}
}
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 $ilDB, and $ilUser.

{
global $ilUser;
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_phrase SET title = %s, tstamp = %s WHERE phrase_id = %s",
array('text','integer','integer'),
array($this->title, time(), $phrase_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_phrase_cat WHERE phrase_fi = %s",
array('integer'),
array($phrase_id)
);
$counter = 1;
for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
{
$cat = $this->categories->getCategory($i);
$next_id = $ilDB->nextId('svy_category');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','text','text','integer','integer','text'),
array($next_id, $cat->title, 1, $ilUser->getId(), time(), $cat->neutral)
);
$category_id = $next_id;
$next_id = $ilDB->nextId('svy_phrase_cat');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (%s, %s, %s, %s)",
array('integer', 'integer', 'integer','integer'),
array($next_id, $phrase_id, $category_id, $counter)
);
$counter++;
}
}

Field Documentation

ilSurveyPhrases::$arrData
protected

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


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