Survey phrases class. More...
Public Member Functions | |
| ilSurveyPhrases () | |
| ilSurveyPhrases constructor | |
| & | _getAvailablePhrases ($useronly=0) |
| Gets the available phrases from the database. | |
| & | _getCategoriesForPhrase ($phrase_id) |
| Gets the available categories for a given phrase. | |
| deletePhrases ($phrase_array) | |
| Delete phrases from the database. | |
Survey phrases class.
The ilSurveyPhrases class manages survey phrases (collections of survey categories) for ordinal survey question types.
Definition at line 34 of file class.ilSurveyPhrases.php.
| & ilSurveyPhrases::_getAvailablePhrases | ( | $ | useronly = 0 |
) |
Gets the available phrases from the database.
Gets the available phrases from the database
| boolean | $useronly Returns only the user defined phrases if set to true. The default is false. |
Definition at line 56 of file class.ilSurveyPhrases.php.
References $lng.
Referenced by SurveyOrdinalQuestionGUI::addPhrase(), and SurveyMatrixQuestionGUI::addPhrase().
{
global $ilUser;
global $ilDB;
global $lng;
$phrases = array();
$query = sprintf("SELECT * FROM survey_phrase WHERE defaultvalue = '1' OR owner_fi = %s ORDER BY title",
$ilDB->quote($ilUser->getId())
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
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
);
}
}
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:| & ilSurveyPhrases::_getCategoriesForPhrase | ( | $ | phrase_id | ) |
Gets the available categories for a given phrase.
Gets the available categories for a given phrase
| integer | $phrase_id The database id of the given phrase |
Definition at line 102 of file class.ilSurveyPhrases.php.
References $lng.
Referenced by SurveyOrdinalQuestionGUI::addPhrase(), and SurveyMatrixQuestionGUI::addPhrase().
{
global $ilDB;
global $lng;
$categories = array();
$query = sprintf("SELECT survey_category.* FROM survey_category, survey_phrase_category WHERE survey_phrase_category.category_fi = survey_category.category_id AND survey_phrase_category.phrase_fi = %s ORDER BY survey_phrase_category.sequence",
$ilDB->quote($phrase_id)
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
{
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.
Delete phrases from the database
| array | $phrase_array An array containing phrase id's to delete public |
Definition at line 134 of file class.ilSurveyPhrases.php.
{
global $ilDB;
if ((is_array($phrase_array)) && (count($phrase_array)))
{
$query = "DELETE FROM survey_phrase WHERE phrase_id IN ('" . join($phrase_array, "','") . "')";
$result = $ilDB->query($query);
$query = "DELETE FROM survey_phrase_category WHERE phrase_fi IN ('" . join($phrase_array, "','") . "')";
$result = $ilDB->query($query);
}
}
| ilSurveyPhrases::ilSurveyPhrases | ( | ) |
ilSurveyPhrases constructor
The constructor takes possible arguments an creates an instance of the ilSurveyPhrases object.
public
Definition at line 43 of file class.ilSurveyPhrases.php.
{
}
1.7.1