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

Survey phrases GUI class. More...

+ Collaboration diagram for ilSurveyPhrasesGUI:

Public Member Functions

 __construct ($a_object)
 ilSurveyPhrasesGUI constructor
executeCommand ()
 execute command
 getCommand ($cmd)
 Retrieves the ilCtrl command.
 deletePhrase ()
 Creates a confirmation form to delete personal phases from the database.
 phrases ()
 Displays a form to manage the user created phrases.
 cancelDeletePhrase ()
 cancel delete phrases
 confirmDeletePhrase ()
 confirm delete phrases
 deletePhrasesForm ($checked_phrases)
 Creates a confirmation form to delete personal phases from the database.
 cancelEditPhrase ()
 saveEditPhrase ()
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 newPhrase ()
 editPhrase ()
 phraseEditor ($checkonly=FALSE)

Data Fields

 $object
 $gui_object
 $lng
 $tpl
 $ctrl
 $ilias
 $tree
 $ref_id

Protected Member Functions

 getCategoriesForPhrase ($phrase_id)
 getPhraseTitle ($phrase_id)

Detailed Description

Survey phrases GUI class.

The ilSurveyPhrases GUI class creates the GUI output for survey phrases (collections of survey categories) of ordinal survey question types.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 35 of file class.ilSurveyPhrasesGUI.php.

Constructor & Destructor Documentation

ilSurveyPhrasesGUI::__construct (   $a_object)

ilSurveyPhrasesGUI constructor

Definition at line 50 of file class.ilSurveyPhrasesGUI.php.

References $ilCtrl, $ilias, $lng, $tpl, and $tree.

{
include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
$this->lng =& $lng;
$this->tpl =& $tpl;
$this->ctrl =& $ilCtrl;
$this->ilias =& $ilias;
$this->gui_object =& $a_object;
$this->object = new ilSurveyPhrases();
$this->tree =& $tree;
$this->ref_id = $a_object->ref_id;
$this->ctrl->saveParameter($this, "p_id");
}

Member Function Documentation

ilSurveyPhrasesGUI::cancelDeletePhrase ( )

cancel delete phrases

Definition at line 154 of file class.ilSurveyPhrasesGUI.php.

{
$this->ctrl->redirect($this, "phrases");
}
ilSurveyPhrasesGUI::cancelEditPhrase ( )

Definition at line 227 of file class.ilSurveyPhrasesGUI.php.

{
$this->ctrl->redirect($this, 'phrases');
}
ilSurveyPhrasesGUI::confirmDeletePhrase ( )

confirm delete phrases

Definition at line 162 of file class.ilSurveyPhrasesGUI.php.

References $_POST, and ilUtil\sendSuccess().

{
$phrases = $_POST['phrase'];
$this->object->deletePhrases($phrases);
ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
$this->ctrl->redirect($this, "phrases");
}

+ Here is the call graph for this function:

ilSurveyPhrasesGUI::deletePhrase ( )

Creates a confirmation form to delete personal phases from the database.

Definition at line 95 of file class.ilSurveyPhrasesGUI.php.

References $_POST, deletePhrasesForm(), phrases(), ilUtil\sendInfo(), and ilUtil\sendQuestion().

{
$checked_phrases = $_POST['phrase'];
if (count($checked_phrases))
{
ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_phrases"));
$this->deletePhrasesForm($checked_phrases);
return;
}
else
{
ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
$this->phrases();
return;
}
}

+ Here is the call graph for this function:

ilSurveyPhrasesGUI::deletePhrasesForm (   $checked_phrases)

Creates a confirmation form to delete personal phases from the database.

Parameters
array$checked_phrasesAn array with the id's of the phrases checked for deletion

Definition at line 211 of file class.ilSurveyPhrasesGUI.php.

References ilSurveyPhrases\_getAvailablePhrases(), and ilSurveyPhrases\_getCategoriesForPhrase().

Referenced by deletePhrase().

{
include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
$table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
$data = array();
foreach ($checked_phrases as $phrase_id)
{
$phrase_array = $phrases[$phrase_id];
$categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
}
$table_gui->setData($data);
$this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::editPhrase ( )

Definition at line 288 of file class.ilSurveyPhrasesGUI.php.

References $_POST, and ilUtil\sendFailure().

{
if (!array_key_exists('phrase', $_POST))
{
ilUtil::sendFailure($this->lng->txt('no_phrase_selected'), true);
$this->ctrl->redirect($this, 'phrases');
}
if ((array_key_exists('phrase', $_POST)) && count($_POST['phrase']) > 1)
{
ilUtil::sendFailure($this->lng->txt('select_max_one_item'), true);
$this->ctrl->redirect($this, 'phrases');
}
$phrase_id = (array_key_exists('phrase', $_POST)) ? $_POST['phrase'][key($_POST['phrase'])] : null;
if ($phrase_id)
{
$this->ctrl->setParameter($this, 'p_id', $phrase_id);
}
$this->ctrl->redirect($this, 'phraseEditor');
}

+ Here is the call graph for this function:

& ilSurveyPhrasesGUI::executeCommand ( )

execute command

Definition at line 69 of file class.ilSurveyPhrasesGUI.php.

References $cmd, $ret, and getCommand().

{
$cmd = $this->ctrl->getCmd();
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->getCommand($cmd);
switch($next_class)
{
default:
$ret =& $this->$cmd();
break;
}
return $ret;
}

+ Here is the call graph for this function:

ilSurveyPhrasesGUI::getCategoriesForPhrase (   $phrase_id)
protected

Definition at line 170 of file class.ilSurveyPhrasesGUI.php.

References $ilDB, and $result.

Referenced by phraseEditor().

{
global $ilDB;
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
$categories = new SurveyCategories();
$result = $ilDB->queryF("SELECT svy_category.title, svy_category.neutral, svy_phrase_cat.sequence FROM svy_phrase_cat, svy_category WHERE svy_phrase_cat.phrase_fi = %s AND svy_phrase_cat.category_fi = svy_category.category_id ORDER BY svy_phrase_cat.sequence ASC",
array('integer'),
array($phrase_id)
);
if ($result->numRows() > 0)
{
while ($data = $ilDB->fetchAssoc($result))
{
$categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
}
}
return $categories;
}

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

Definition at line 87 of file class.ilSurveyPhrasesGUI.php.

References $cmd.

Referenced by executeCommand().

{
return $cmd;
}

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::getPhraseTitle (   $phrase_id)
protected

Definition at line 190 of file class.ilSurveyPhrasesGUI.php.

References $ilDB, $result, and $row.

Referenced by phraseEditor().

{
global $ilDB;
$result = $ilDB->queryF("SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
array('integer'),
array($phrase_id)
);
if ($result->numRows() > 0)
{
$row = $ilDB->fetchAssoc($result);
return $row['title'];
}
return null;
}

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::newPhrase ( )

Definition at line 283 of file class.ilSurveyPhrasesGUI.php.

{
$this->ctrl->redirect($this, 'phraseEditor');
}
ilSurveyPhrasesGUI::phraseEditor (   $checkonly = FALSE)

Definition at line 308 of file class.ilSurveyPhrasesGUI.php.

References $_GET, $errors, getCategoriesForPhrase(), getPhraseTitle(), ilFormPropertyGUI\setRequired(), and ilTextInputGUI\setValue().

Referenced by writePostData().

{
$save = (strcmp($this->ctrl->getCmd(), "saveEditPhrase") == 0) ? TRUE : FALSE;
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this, 'phraseEditor'));
$form->setTitle($this->lng->txt('edit_phrase'));
$form->setMultipart(FALSE);
$form->setTableWidth("100%");
$form->setId("phraseeditor");
$phrase_id = $_GET['p_id'];
// title
$title = new ilTextInputGUI($this->lng->txt("title"), "title");
$title->setValue($this->getPhraseTitle($phrase_id));
$title->setRequired(TRUE);
$form->addItem($title);
// Answers
include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
$answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
$answers->setRequired(true);
$answers->setAllowMove(true);
$answers->setShowWizard(false );
$answers->setShowSavePhrase(false);
$answers->setUseOtherAnswer(false);
$answers->setShowNeutralCategory(true);
$answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
$categories =& $this->getCategoriesForPhrase($phrase_id);
if (!$categories->getCategoryCount())
{
$categories->addCategory("");
}
$answers->setValues($categories);
$answers->setDisabledScale(true);
$form->addItem($answers);
$form->addCommandButton("saveEditPhrase", $this->lng->txt("save"));
$form->addCommandButton("cancelEditPhrase", $this->lng->txt("cancel"));
$errors = false;
if ($save)
{
$form->setValuesByPost();
$errors = !$form->checkInput();
$form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
if ($errors) $checkonly = false;
}
if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
return $errors;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::phrases ( )

Displays a form to manage the user created phrases.

public

Definition at line 119 of file class.ilSurveyPhrasesGUI.php.

References ilSurveyPhrases\_getAvailablePhrases(), ilSurveyPhrases\_getCategoriesForPhrase(), ilLinkButton\getInstance(), and ilUtil\sendInfo().

Referenced by deletePhrase().

{
global $rbacsystem, $ilToolbar;
$this->ctrl->setParameter($this, "p_id", "");
if ($rbacsystem->checkAccess("write", $this->ref_id))
{
include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
$button->setCaption("phrase_new");
$button->setUrl($this->ctrl->getLinkTarget($this, "newPhrase"));
$ilToolbar->addButtonInstance($button);
include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
$table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
$data = array();
foreach ($phrases as $phrase_id => $phrase_array)
{
$categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
}
$table_gui->setData($data);
$this->tpl->setContent($table_gui->getHTML());
}
else
{
ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSurveyPhrasesGUI::saveEditPhrase ( )

Definition at line 232 of file class.ilSurveyPhrasesGUI.php.

References $_GET, $result, ilUtil\sendSuccess(), and writePostData().

{
$result = $this->writePostData();
if ($result == 0)
{
if ($_GET['p_id'])
{
$this->object->updatePhrase($_GET['p_id']);
ilUtil::sendSuccess($this->lng->txt('phrase_saved'), true);
}
else
{
$this->object->savePhrase();
ilUtil::sendSuccess($this->lng->txt('phrase_added'), true);
}
$this->ctrl->redirect($this, 'phrases');
}
}

+ Here is the call graph for this function:

ilSurveyPhrasesGUI::writePostData (   $always = false)

Evaluates a posted edit form and writes the form data in the question object.

Returns
integer A positive value, if one of the required fields wasn't set, else 0 private

Definition at line 257 of file class.ilSurveyPhrasesGUI.php.

References $_POST, $ilDB, and phraseEditor().

Referenced by saveEditPhrase().

{
global $ilDB;
$hasErrors = (!$always) ? $this->phraseEditor(true) : false;
if (!$hasErrors)
{
$this->object->title = $_POST["title"];
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
$categories = new SurveyCategories();
foreach ($_POST['answers']['answer'] as $key => $value)
{
if (strlen($value)) $categories->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
}
if (strlen($_POST['answers']['neutral']))
{
$categories->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
}
$this->object->categories = $categories;
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilSurveyPhrasesGUI::$ctrl

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

ilSurveyPhrasesGUI::$gui_object

Definition at line 38 of file class.ilSurveyPhrasesGUI.php.

ilSurveyPhrasesGUI::$ilias

Definition at line 42 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().

ilSurveyPhrasesGUI::$lng

Definition at line 39 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().

ilSurveyPhrasesGUI::$object

Definition at line 37 of file class.ilSurveyPhrasesGUI.php.

ilSurveyPhrasesGUI::$ref_id

Definition at line 44 of file class.ilSurveyPhrasesGUI.php.

ilSurveyPhrasesGUI::$tpl

Definition at line 40 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().

ilSurveyPhrasesGUI::$tree

Definition at line 43 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().


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