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

Basic class for all survey question types. More...

+ Inheritance diagram for SurveyQuestionGUI:
+ Collaboration diagram for SurveyQuestionGUI:

Public Member Functions

 __construct ($a_id=-1)
 setQuestionTabs ()
executeCommand ()
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
 getQuestionType ()
 Returns the question type string.
 setBackUrl ($a_url)
 setQuestionTabsForClass ($guiclass)
 getPrintView ($question_title=1, $show_questiontext=1)
 preview ()
 Creates a preview of the question.
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 material ($checkonly=FALSE)
 Material tab of the survey questions.
 deleteMaterial ()
 addMaterial ()
 Add materials to a question.
 removeMaterial ()
 cancelExplorer ()
 addPG ()
 addST ()
 addGIT ()
 linkChilds ()
 savePhrase ($a_reload=false)
 Creates an output to save the current answers as a phrase.
 confirmSavePhrase ()
 Save a new phrase to the database.

Static Public Member Functions

static & _getQuestionGUI ($questiontype, $question_id=-1)
 Creates a question gui representation.

Data Fields

 $object

Protected Member Functions

 initObject ()
 outQuestionText ($template)
 initEditForm ()
 addCommandButtons ($a_form)
 editQuestion (ilPropertyFormGUI $a_form=null)
 saveSync ()
 saveReturn ()
 saveForm ()
 save ($a_return=false, $a_sync=false)
 copySyncForm ()
 syncCopies ()
 originalSyncForm ()
 sync ()
 cancelSync ()
 redirectAfterSaving ($a_return=false)
 Redirect to calling survey or to edit form.
 cancel ()
 validateEditForm (ilPropertyFormGUI $a_form)
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 importEditFormValues (ilPropertyFormGUI $a_form)
 getMaterialOutput ()
 Creates the HTML output of the question material(s)
 renderChart ($a_id, $a_variables)
 initPhrasesForm ()
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases.
 addSelectedPhrase ()

Protected Attributes

 $tpl
 $lng
 $ctrl
 $cumulated
 $parent_url

Detailed Description

Basic class for all survey question types.

The SurveyQuestionGUI class defines and encapsulates basic methods and attributes for survey question types to be used for all parent classes.

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:
class.SurveyQuestionGUI.php 60294 2015-08-05 12:11:16Z gitmgr

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

Constructor & Destructor Documentation

SurveyQuestionGUI::__construct (   $a_id = -1)

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

References $_GET, $ilCtrl, $lng, $tpl, and initObject().

{
global $lng, $tpl, $ilCtrl;
$this->lng = $lng;
$this->tpl = $tpl;
$this->ctrl = $ilCtrl;
$this->ctrl->saveParameter($this, "q_id");
$this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
$this->cumulated = array();
$this->initObject();
if($a_id > 0)
{
$this->object->loadFromDb($a_id);
}
}

+ Here is the call graph for this function:

Member Function Documentation

SurveyQuestionGUI::_getClassNameForQType (   $q_type)

Definition at line 112 of file class.SurveyQuestionGUI.php.

Referenced by _getGUIClassNameForId().

{
return $q_type;
}

+ Here is the caller graph for this function:

SurveyQuestionGUI::_getGUIClassNameForId (   $a_q_id)

Definition at line 103 of file class.SurveyQuestionGUI.php.

References _getClassNameForQType().

Referenced by ilSurveyQuestionsTableGUI\fillRow().

{
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
$q_type = SurveyQuestion::_getQuestiontype($a_q_id);
return $class_name;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static& SurveyQuestionGUI::_getQuestionGUI (   $questiontype,
  $question_id = -1 
)
static

Creates a question gui representation.

Creates a question gui representation and returns the alias to the question gui note: please do not use $this inside this method to allow static calls

Parameters
string$question_typeThe question type as it is used in the language database
integer$question_idThe database ID of an existing question to load it into ASS_QuestionGUI
Returns
object The alias to the question object public

Definition at line 90 of file class.SurveyQuestionGUI.php.

References SurveyQuestion\_includeClass().

Referenced by ilSurveyPageGUI\addQuestion(), ilObjSurveyQuestionPoolGUI\createQuestionObject(), ilSurveyEditorGUI\executeCommand(), ilObjSurveyQuestionPoolGUI\executeCommand(), ilSurveyEditorGUI\executeCreateQuestionObject(), ilObjSurvey\getQuestionGUI(), and ilObjSurveyQuestionPoolGUI\previewObject().

{
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
if ((!$questiontype) and ($question_id > 0))
{
$questiontype = SurveyQuestion::_getQuestiontype($question_id);
}
SurveyQuestion::_includeClass($questiontype, 1);
$question_type_gui = $questiontype . "GUI";
$question = new $question_type_gui($question_id);
return $question;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::addCommandButtons (   $a_form)
protected

Definition at line 278 of file class.SurveyQuestionGUI.php.

References ilObject\_lookupType().

Referenced by initEditForm().

{
$a_form->addCommandButton("saveReturn", $this->lng->txt("save_return"));
$a_form->addCommandButton("save", $this->lng->txt("save"));
// pool question?
if(ilObject::_lookupType($this->object->getObjId()) == "spl")
{
if($this->object->hasCopies())
{
$a_form->addCommandButton("saveSync", $this->lng->txt("svy_save_sync"));
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
abstractprotected
SurveyQuestionGUI::addGIT ( )

Definition at line 849 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, and ilUtil\sendSuccess().

{
$this->object->addInternalLink("il__git_" . $_GET["git"]);
unset($_SESSION["link_new_type"]);
unset($_SESSION["search_link_type"]);
ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
$this->ctrl->redirect($this, "material");
}

+ Here is the call graph for this function:

SurveyQuestionGUI::addMaterial ( )

Add materials to a question.

Definition at line 771 of file class.SurveyQuestionGUI.php.

References $_GET, $_POST, $_SESSION, ilPanelGUI\getInstance(), and material().

{
global $tree, $ilTabs, $ilToolbar;
$ilTabs->activateTab("material");
$ilToolbar->addButton($this->lng->txt("cancel"),
$this->ctrl->getLinkTarget($this, "material"));
if (strlen($_SESSION["link_new_type"]) || !$this->material(true))
{
include_once("./Modules/SurveyQuestionPool/classes/class.ilMaterialExplorer.php");
switch ($_POST["internalLinkType"])
{
case "lm":
$_SESSION["link_new_type"] = "lm";
$_SESSION["search_link_type"] = "lm";
break;
case "glo":
$_SESSION["link_new_type"] = "glo";
$_SESSION["search_link_type"] = "glo";
break;
case "st":
$_SESSION["link_new_type"] = "lm";
$_SESSION["search_link_type"] = "st";
break;
case "pg":
$_SESSION["link_new_type"] = "lm";
$_SESSION["search_link_type"] = "pg";
break;
}
$exp = new ilMaterialExplorer($this, 'addMaterial', $_SESSION["link_new_type"]);
$exp->setPathOpen((int)$_GET["ref_id"]);
if (!$exp->handleCommand())
{
include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
$panel->setHeading($this->lng->txt("select_object_to_link"));
$panel->setBody($exp->getHTML());
$this->tpl->setContent($panel->getHTML());
}
}
}

+ Here is the call graph for this function:

SurveyQuestionGUI::addPG ( )

Definition at line 831 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, and ilUtil\sendSuccess().

{
$this->object->addInternalLink("il__pg_" . $_GET["pg"]);
unset($_SESSION["link_new_type"]);
unset($_SESSION["search_link_type"]);
ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
$this->ctrl->redirect($this, "material");
}

+ Here is the call graph for this function:

SurveyQuestionGUI::addPhrase ( ilPropertyFormGUI  $a_form = null)
protected

Creates an output for the addition of phrases.

Definition at line 1005 of file class.SurveyQuestionGUI.php.

References $result, initPhrasesForm(), and saveForm().

Referenced by addSelectedPhrase().

{
global $ilTabs;
$ilTabs->activateTab("edit_properties");
if(!$a_form)
{
$result = $this->saveForm();
if($result)
{
$this->object->saveToDb();
}
$a_form = $this->initPhrasesForm();
}
$this->tpl->setContent($a_form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::addSelectedPhrase ( )
protected

Definition at line 1025 of file class.SurveyQuestionGUI.php.

References $valid, addPhrase(), initPhrasesForm(), and ilUtil\sendSuccess().

{
$form = $this->initPhrasesForm();
if($form->checkInput())
{
$phrase_id = $form->getInput("phrases");
$valid = true;
if (strcmp($this->object->getPhrase($phrase_id), "dp_standard_numbers") != 0)
{
$this->object->addPhrase($phrase_id);
}
else
{
$min = $form->getInput("lower_limit");
$max = $form->getInput("upper_limit");
if($max <= $min)
{
$max_field = $form->getItemByPostVar("upper_limit");
$max_field->setAlert($this->lng->txt("upper_limit_must_be_greater"));
$valid = false;
}
else
{
$this->object->addStandardNumbers($min, $max);
}
}
if($valid)
{
$this->object->saveToDb();
ilUtil::sendSuccess($this->lng->txt('phrase_added'), true);
$this->ctrl->redirect($this, 'editQuestion');
}
}
$form->setValuesByPost();
$this->addPhrase($form);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::addST ( )

Definition at line 840 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, and ilUtil\sendSuccess().

{
$this->object->addInternalLink("il__st_" . $_GET["st"]);
unset($_SESSION["link_new_type"]);
unset($_SESSION["search_link_type"]);
ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
$this->ctrl->redirect($this, "material");
}

+ Here is the call graph for this function:

SurveyQuestionGUI::cancel ( )
protected

Definition at line 526 of file class.SurveyQuestionGUI.php.

References ilUtil\redirect().

{
if ($this->parent_url)
{
ilUtil::redirect($this->parent_url);
}
else
{
$this->ctrl->redirectByClass("ilobjsurveyquestionpoolgui", "questions");
}
}

+ Here is the call graph for this function:

SurveyQuestionGUI::cancelExplorer ( )

Definition at line 824 of file class.SurveyQuestionGUI.php.

References $_SESSION, and ilUtil\sendInfo().

{
unset($_SESSION["link_new_type"]);
ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
$this->ctrl->redirect($this, 'material');
}

+ Here is the call graph for this function:

SurveyQuestionGUI::cancelSync ( )
protected

Definition at line 483 of file class.SurveyQuestionGUI.php.

References $_REQUEST, redirectAfterSaving(), and ilUtil\sendInfo().

{
ilUtil::sendInfo($this->lng->txt("question_changed_in_survey_only"), true);
$this->redirectAfterSaving($_REQUEST["rtrn"]);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::confirmSavePhrase ( )

Save a new phrase to the database.

public

Definition at line 1130 of file class.SurveyQuestionGUI.php.

References $_POST, $valid, savePhrase(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
$title = $_POST["phrase_title"];
$valid = true;
if (!trim($title))
{
ilUtil::sendFailure($this->lng->txt("qpl_savephrase_empty"));
$valid = false;
}
else if ($this->object->phraseExists($title))
{
ilUtil::sendFailure($this->lng->txt("qpl_savephrase_exists"));
$valid = false;
}
if($valid)
{
$this->object->savePhrase($title);
ilUtil::sendSuccess($this->lng->txt("phrase_saved"), true);
$this->ctrl->redirect($this, "editQuestion");
}
$this->savePhrase(true);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::copySyncForm ( )
protected

Definition at line 390 of file class.SurveyQuestionGUI.php.

Referenced by syncCopies().

{
global $ilTabs;
$ilTabs->activateTab("edit_properties");
include_once "Modules/SurveyQuestionPool/classes/class.ilSurveySyncTableGUI.php";
$tbl = new ilSurveySyncTableGUI($this, "copySyncForm", $this->object);
$this->tpl->setContent($tbl->getHTML());
}

+ Here is the caller graph for this function:

SurveyQuestionGUI::deleteMaterial ( )

Definition at line 754 of file class.SurveyQuestionGUI.php.

References $_POST, ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
if (is_array($_POST['idx']))
{
$this->object->deleteMaterials($_POST['idx']);
ilUtil::sendSuccess($this->lng->txt('materials_deleted'), true);
}
else
{
ilUtil::sendFailure($this->lng->txt('no_checkbox'), true);
}
$this->ctrl->redirect($this, 'material');
}

+ Here is the call graph for this function:

SurveyQuestionGUI::editQuestion ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 293 of file class.SurveyQuestionGUI.php.

References initEditForm().

Referenced by removeMaterial(), save(), and saveForm().

{
global $ilTabs;
$ilTabs->activateTab("edit_properties");
if(!$a_form)
{
$a_form = $this->initEditForm();
}
$this->tpl->setContent($a_form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& SurveyQuestionGUI::executeCommand ( )

Definition at line 66 of file class.SurveyQuestionGUI.php.

References $cmd, and $ret.

{
$cmd = $this->ctrl->getCmd();
$next_class = $this->ctrl->getNextClass($this);
switch($next_class)
{
default:
$ret =& $this->$cmd();
break;
}
return $ret;
}
SurveyQuestionGUI::getCumulatedResultsDetails (   $survey_id,
  $counter,
  $finished_ids 
)
abstract
SurveyQuestionGUI::getMaterialOutput ( )
protected

Creates the HTML output of the question material(s)

Definition at line 587 of file class.SurveyQuestionGUI.php.

References $_GET, SurveyQuestion\_getInternalLinkHref(), and ilUtil\prepareFormOutput().

Referenced by SurveyTextQuestionGUI\getWorkingForm(), SurveyMetricQuestionGUI\getWorkingForm(), SurveySingleChoiceQuestionGUI\getWorkingForm(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), and SurveyMatrixQuestionGUI\getWorkingForm().

{
if (count($this->object->getMaterial()))
{
$template = new ilTemplate("tpl.il_svy_qpl_material.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
foreach ($this->object->getMaterial() as $material)
{
$template->setCurrentBlock('material');
switch ($material->type)
{
case 0:
$href = SurveyQuestion::_getInternalLinkHref($material->internal_link, $_GET['ref_id']);
$template->setVariable('MATERIAL_TYPE', 'internallink');
$template->setVariable('MATERIAL_HREF', $href);
break;
}
$template->setVariable('MATERIAL_TITLE', (strlen($material->title)) ? ilUtil::prepareFormOutput($material->title) : $this->lng->txt('material'));
$template->setVariable('TEXT_AVAILABLE_MATERIALS', $this->lng->txt('material'));
$template->parseCurrentBlock();
}
return $template->get();
}
return "";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::getPrintView (   $question_title = 1,
  $show_questiontext = 1 
)
abstract
SurveyQuestionGUI::getQuestionType ( )

Returns the question type string.

Returns
string The question type string public

Definition at line 123 of file class.SurveyQuestionGUI.php.

Referenced by setQuestionTabsForClass().

{
return $this->object->getQuestionType();
}

+ Here is the caller graph for this function:

SurveyQuestionGUI::getWorkingForm (   $working_data = "",
  $question_title = 1,
  $show_questiontext = 1,
  $error_message = "",
  $survey_id = null 
)
abstract

Reimplemented in SurveyMatrixQuestionGUI, SurveyMultipleChoiceQuestionGUI, SurveySingleChoiceQuestionGUI, SurveyMetricQuestionGUI, and SurveyTextQuestionGUI.

Referenced by preview().

+ Here is the caller graph for this function:

SurveyQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
abstractprotected

Reimplemented in SurveyMatrixQuestionGUI, SurveyMultipleChoiceQuestionGUI, SurveyMetricQuestionGUI, SurveyTextQuestionGUI, and SurveySingleChoiceQuestionGUI.

Referenced by saveForm().

+ Here is the caller graph for this function:

SurveyQuestionGUI::initEditForm ( )
protected

Definition at line 212 of file class.SurveyQuestionGUI.php.

References ilObjAdvancedEditing\_getUsedHTMLTags(), addCommandButtons(), addFieldsToEditForm(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilCheckboxInputGUI\setValue().

Referenced by editQuestion(), and saveForm().

{
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this, "save"));
$form->setTitle($this->lng->txt($this->getQuestionType()));
$form->setMultipart(FALSE);
$form->setTableWidth("100%");
// $form->setId("essay");
// title
$title = new ilTextInputGUI($this->lng->txt("title"), "title");
$title->setRequired(TRUE);
$form->addItem($title);
// label
$label = new ilTextInputGUI($this->lng->txt("label"), "label");
$label->setInfo($this->lng->txt("label_info"));
$label->setRequired(false);
$form->addItem($label);
// author
$author = new ilTextInputGUI($this->lng->txt("author"), "author");
$author->setRequired(TRUE);
$form->addItem($author);
// description
$description = new ilTextInputGUI($this->lng->txt("description"), "description");
$description->setRequired(FALSE);
$form->addItem($description);
// questiontext
$question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
$question->setRequired(TRUE);
$question->setRows(10);
$question->setCols(80);
$question->setUseRte(TRUE);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
$question->addPlugin("latex");
$question->addButton("latex");
$question->addButton("pastelatex");
$question->setRTESupport($this->object->getId(), "spl", "survey");
$form->addItem($question);
// obligatory
$shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
$shuffle->setValue(1);
$shuffle->setRequired(FALSE);
$form->addItem($shuffle);
$this->addFieldsToEditForm($form);
$this->addCommandButtons($form);
// values
$title->setValue($this->object->getTitle());
$label->setValue($this->object->label);
$author->setValue($this->object->getAuthor());
$description->setValue($this->object->getDescription());
$question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
$shuffle->setChecked($this->object->getObligatory());
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::initObject ( )
abstractprotected
SurveyQuestionGUI::initPhrasesForm ( )
protected

Definition at line 961 of file class.SurveyQuestionGUI.php.

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

Referenced by addPhrase(), and addSelectedPhrase().

{
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this, "addSelectedPhrase"));
$form->setTitle($this->lng->txt("add_phrase"));
// $form->setDescription($this->lng->txt("add_phrase_introduction"));
$group = new ilRadioGroupInputGUI($this->lng->txt("phrase"), "phrases");
$group->setRequired(true);
$form->addItem($group);
include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
foreach (ilSurveyPhrases::_getAvailablePhrases() as $phrase_id => $phrase_array)
{
$categories = ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
$opt = new ilRadioOption($phrase_array["title"], $phrase_id);
$opt->setInfo(join($categories, ","));
$group->addOption($opt);
if($phrase_array["org_title"] == "dp_standard_numbers")
{
$min = new ilNumberInputGUI($this->lng->txt("lower_limit"), "lower_limit");
$min->setRequired(true);
$min->setSize(5);
$opt->addSubItem($min);
$max = new ilNumberInputGUI($this->lng->txt("upper_limit"), "upper_limit");
$max->setRequired(true);
$max->setSize(5);
$opt->addSubItem($max);
}
}
$form->addCommandButton("addSelectedPhrase", $this->lng->txt("add_phrase"));
$form->addCommandButton("editQuestion", $this->lng->txt("cancel"));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::linkChilds ( )

Definition at line 858 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, ilLMPageObject\getPageList(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
global $ilTabs;
$selectable_items = array();
$source_id = $_GET["source_id"];
switch ($_SESSION["search_link_type"])
{
case "pg":
include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
$cont_obj_gui =& new ilObjContentObjectGUI("", $source_id, true);
$cont_obj = $cont_obj_gui->object;
$pages = ilLMPageObject::getPageList($cont_obj->getId());
foreach($pages as $page)
{
if($page["type"] == $_SESSION["search_link_type"])
{
$selectable_items[] = array(
"item_type" => $page["type"]
,"item_id" => $page["obj_id"]
,"title" => $page["title"]
);
}
}
break;
case "st":
include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
$cont_obj_gui =& new ilObjContentObjectGUI("", $source_id, true);
$cont_obj = $cont_obj_gui->object;
// get all chapters
$ctree =& $cont_obj->getLMTree();
$nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
foreach($nodes as $node)
{
if($node["type"] == $_SESSION["search_link_type"])
{
$selectable_items[] = array(
"item_type" => $node["type"]
,"item_id" => $node["obj_id"]
,"title" => $node["title"]
);
}
}
break;
case "glo":
include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
$glossary =& new ilObjGlossary($source_id, true);
// get all glossary items
$terms = $glossary->getTermList();
foreach($terms as $term)
{
$selectable_items[] = array(
"item_type" => "GIT"
,"item_id" => $term["id"]
,"title" => $term["term"]
);
}
break;
case "lm":
$this->object->addInternalLink("il__lm_" . $source_id);
break;
}
if(sizeof($selectable_items))
{
$ilTabs->activateTab("material");
$this->ctrl->setParameter($this, "q_id", $this->object->getId());
$this->ctrl->setParameter($this, "source_id", $source_id);
include_once "Modules/SurveyQuestionPool/classes/tables/class.SurveyMaterialsSourceTableGUI.php";
$tbl = new SurveyMaterialsSourceTableGUI($this, "linkChilds", "addMaterial");
$tbl->setData($selectable_items);
$this->tpl->setContent($tbl->getHTML());
}
else
{
if($_SESSION["search_link_type"] == "lm")
{
ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
unset($_SESSION["link_new_type"]);
unset($_SESSION["search_link_type"]);
$this->ctrl->redirect($this, "material");
}
else
{
ilUtil::sendFailure($this->lng->txt("material_added_empty"), true);
$this->ctrl->redirect($this, "addMaterial");
}
}
}

+ Here is the call graph for this function:

SurveyQuestionGUI::material (   $checkonly = FALSE)

Material tab of the survey questions.

Definition at line 688 of file class.SurveyQuestionGUI.php.

References $_GET, $errors, SurveyQuestion\_getInternalLinkHref(), ilUtil\prepareFormOutput(), and ilFormPropertyGUI\setRequired().

Referenced by addMaterial().

{
global $rbacsystem, $ilTabs;
$ilTabs->activateTab("material");
$add_html = '';
if ($rbacsystem->checkAccess('write', $_GET['ref_id']))
{
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt('add_material'));
$form->setMultipart(FALSE);
$form->setTableWidth("100%");
$form->setId("material");
// material
$material = new ilRadioGroupInputGUI($this->lng->txt("material"), "internalLinkType");
$material->setRequired(true);
$material->addOption(new ilRadioOption($this->lng->txt('obj_lm'), "lm"));
$material->addOption(new ilRadioOption($this->lng->txt('obj_st'), "st"));
$material->addOption(new ilRadioOption($this->lng->txt('obj_pg'), "pg"));
$material->addOption(new ilRadioOption($this->lng->txt('glossary_term'), "glo"));
$form->addItem($material);
$form->addCommandButton("addMaterial", $this->lng->txt("add"));
$errors = false;
if ($checkonly)
{
$form->setValuesByPost();
$errors = !$form->checkInput();
if ($errors) $checkonly = false;
}
$add_html = $form->getHTML();
}
$mat_html = "";
if (count($this->object->getMaterial()))
{
include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyMaterialsTableGUI.php";
$table_gui = new ilSurveyMaterialsTableGUI($this, 'material', (($rbacsystem->checkAccess('write', $_GET['ref_id']) ? true : false)));
$data = array();
foreach ($this->object->getMaterial() as $material)
{
switch ($material->type)
{
case 0:
$href = SurveyQuestion::_getInternalLinkHref($material->internal_link, $_GET['ref_id']);
$type = $this->lng->txt('internal_link');
break;
}
$title = (strlen($material->title)) ? ilUtil::prepareFormOutput($material->title) : $this->lng->txt('material');
array_push($data, array('href' => $href, 'title' => $title, 'type' => $type));
}
$table_gui->setData($data);
$mat_html = $table_gui->getHTML();
}
if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $add_html . $mat_html);
return $errors;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::originalSyncForm ( )
protected

Definition at line 452 of file class.SurveyQuestionGUI.php.

{
global $ilTabs;
$ilTabs->activateTab("edit_properties");
$this->ctrl->saveParameter($this, "rtrn");
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setHeaderText($this->lng->txt("confirm_sync_questions"));
$cgui->setFormAction($this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
$cgui->setCancel($this->lng->txt("no"), "cancelSync");
$cgui->setConfirm($this->lng->txt("yes"), "sync");
$this->tpl->setContent($cgui->getHTML());
}
SurveyQuestionGUI::outQuestionText (   $template)
protected

Definition at line 128 of file class.SurveyQuestionGUI.php.

Referenced by SurveyTextQuestionGUI\getPrintView(), SurveySingleChoiceQuestionGUI\getPrintView(), SurveyMetricQuestionGUI\getPrintView(), SurveyMultipleChoiceQuestionGUI\getPrintView(), SurveyMatrixQuestionGUI\getPrintView(), SurveyTextQuestionGUI\getWorkingForm(), SurveyMetricQuestionGUI\getWorkingForm(), SurveySingleChoiceQuestionGUI\getWorkingForm(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), and SurveyMatrixQuestionGUI\getWorkingForm().

{
$questiontext = $this->object->getQuestiontext();
if (preg_match("/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches))
{
$questiontext = $matches[1];
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
if ($this->object->getObligatory($survey_id))
{
$template->setVariable("OBLIGATORY_TEXT", ' *');
}
}

+ Here is the caller graph for this function:

SurveyQuestionGUI::preview ( )

Creates a preview of the question.

private

Definition at line 553 of file class.SurveyQuestionGUI.php.

References $tpl, ilPanelGUI\getInstance(), and getWorkingForm().

{
global $ilTabs;
$ilTabs->activateTab("preview");
$tpl = new ilTemplate("tpl.il_svy_qpl_preview.html", true, true, "Modules/SurveyQuestionPool");
if ($this->object->getObligatory())
{
$tpl->setCurrentBlock("required");
$tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
$tpl->parseCurrentBlock();
}
$tpl->setVariable("QUESTION_OUTPUT", $this->getWorkingForm());
include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
$panel->setBody($tpl->get());
$this->tpl->setContent($panel->getHTML());
}

+ Here is the call graph for this function:

SurveyQuestionGUI::redirectAfterSaving (   $a_return = false)
protected

Redirect to calling survey or to edit form.

Parameters
bool$a_return

Definition at line 494 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, and ilUtil\redirect().

Referenced by cancelSync(), save(), sync(), and syncCopies().

{
// return?
if($a_return)
{
// to calling survey
if($this->parent_url)
{
$addurl = "";
if (strlen($_GET["new_for_survey"]))
{
$addurl = "&new_id=" . $_GET["q_id"];
}
ilUtil::redirect(str_replace("&amp;", "&", $this->parent_url) . $addurl);
}
// to pool
else
{
$this->ctrl->setParameterByClass("ilObjSurveyQuestionPoolGUI", "q_id_table_nav", $_SESSION['q_id_table_nav']);
$this->ctrl->redirectByClass("ilObjSurveyQuestionPoolGUI", "questions");
}
}
// stay in form
else
{
$this->ctrl->setParameterByClass($_GET["cmdClass"], "q_id", $this->object->getId());
$this->ctrl->setParameterByClass($_GET["cmdClass"], "sel_question_types", $_GET["sel_question_types"]);
$this->ctrl->setParameterByClass($_GET["cmdClass"], "new_for_survey", $_GET["new_for_survey"]);
$this->ctrl->redirectByClass($_GET["cmdClass"], "editQuestion");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::removeMaterial ( )

Definition at line 817 of file class.SurveyQuestionGUI.php.

References editQuestion().

{
$this->object->material = array();
$this->object->saveToDb();
$this->editQuestion();
}

+ Here is the call graph for this function:

SurveyQuestionGUI::renderChart (   $a_id,
  $a_variables 
)
protected

Reimplemented in SurveyMetricQuestionGUI.

Definition at line 619 of file class.SurveyQuestionGUI.php.

References ilChartGrid\DATA_BARS, ilChart\getInstanceByType(), ilUtil\prepareFormOutput(), and ilChart\TYPE_GRID.

Referenced by SurveySingleChoiceQuestionGUI\getCumulatedResultsDetails(), SurveyMultipleChoiceQuestionGUI\getCumulatedResultsDetails(), and SurveyMatrixQuestionGUI\getCumulatedResultsDetails().

{
include_once "Services/Chart/classes/class.ilChart.php";
$chart->setsize(700, 400);
$legend = new ilChartLegend();
$chart->setLegend($legend);
$chart->setYAxisToInteger(true);
$data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
$data->setLabel($this->lng->txt("users_answered"));
$data->setBarOptions(0.5, "center");
$max = 5;
if(sizeof($a_variables) <= $max)
{
if($a_variables)
{
$labels = array();
foreach($a_variables as $idx => $points)
{
$data->addPoint($idx, $points["selected"]);
$labels[$idx] = ($idx+1).". ".ilUtil::prepareFormOutput($points["title"]);
}
$chart->addData($data);
$chart->setTicks($labels, false, true);
}
return "<div style=\"margin:10px\">".$chart->getHTML()."</div>";
}
else
{
$chart_legend = array();
$labels = array();
foreach($a_variables as $idx => $points)
{
$data->addPoint($idx, $points["selected"]);
$labels[$idx] = ($idx+1).".";
$chart_legend[($idx+1)] = ilUtil::prepareFormOutput($points["title"]);
}
$chart->addData($data);
$chart->setTicks($labels, false, true);
$legend = "<table>";
foreach($chart_legend as $number => $caption)
{
$legend .= "<tr valign=\"top\"><td>".$number.".</td><td>".$caption."</td></tr>";
}
$legend .= "</table>";
return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>".
$chart->getHTML()."</td><td class=\"small\" style=\"padding-left:15px\">".
$legend."</td></tr></table></div>";
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::save (   $a_return = false,
  $a_sync = false 
)
protected

Definition at line 344 of file class.SurveyQuestionGUI.php.

References $ilUser, SurveyQuestion\_isComplete(), SurveyQuestion\_isWriteable(), editQuestion(), redirectAfterSaving(), saveForm(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

Referenced by saveReturn(), and saveSync().

{
global $ilUser;
if($this->saveForm())
{
// #13784
if ($a_return &&
!SurveyQuestion::_isComplete($this->object->getId()))
{
ilUtil::sendFailure($this->lng->txt("survey_error_insert_incomplete_question"));
return $this->editQuestion();
}
$ilUser->setPref("svy_lastquestiontype", $this->object->getQuestionType());
$ilUser->writePref("svy_lastquestiontype", $this->object->getQuestionType());
$originalexists = $this->object->_questionExists($this->object->original_id);
$this->ctrl->setParameter($this, "q_id", $this->object->getId());
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
// pool question?
if($a_sync)
{
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
$this->ctrl->redirect($this, 'copySyncForm');
}
else
{
// form: update original pool question, too?
if ($originalexists &&
SurveyQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
{
if($a_return)
{
$this->ctrl->setParameter($this, 'rtrn', 1);
}
$this->ctrl->redirect($this, 'originalSyncForm');
}
}
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
$this->redirectAfterSaving($a_return);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::saveForm ( )
protected

Definition at line 316 of file class.SurveyQuestionGUI.php.

References editQuestion(), importEditFormValues(), initEditForm(), and validateEditForm().

Referenced by addPhrase(), save(), and savePhrase().

{
$form = $this->initEditForm();
if($form->checkInput())
{
if ($this->validateEditForm($form))
{
$this->object->setTitle($form->getInput("title"));
$this->object->label = ($form->getInput("label"));
$this->object->setAuthor($form->getInput("author"));
$this->object->setDescription($form->getInput("description"));
$this->object->setQuestiontext($form->getInput("question"));
$this->object->setObligatory($form->getInput("obligatory"));
$this->importEditFormValues($form);
// will save both core and extended data
$this->object->saveToDb();
return true;
}
}
$form->setValuesByPost();
$this->editQuestion($form);
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::savePhrase (   $a_reload = false)

Creates an output to save the current answers as a phrase.

public

Definition at line 1072 of file class.SurveyQuestionGUI.php.

References $_SESSION, $result, $txt, and saveForm().

Referenced by confirmSavePhrase().

{
global $ilTabs, $ilToolbar;
$ilTabs->activateTab("edit_properties");
if (!$a_reload)
{
$result = $this->saveForm();
if ($result)
{
$this->object->saveToDb();
}
}
include_once("./Services/Form/classes/class.ilTextInputGUI.php");
$txt = new ilTextInputGUI($this->lng->txt("enter_phrase_title"), "phrase_title");
$ilToolbar->addInputItem($txt, true);
$ilToolbar->addFormButton($this->lng->txt("confirm"), "confirmSavePhrase");
$ilToolbar->setFormAction($this->ctrl->getFormAction($this));
include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
$table_gui = new ilSurveySavePhraseTableGUI($this, 'editQuestion');
$table_gui->setDescription($this->lng->txt("save_phrase_introduction"));
// matrix?
if(method_exists($this->object, "getCategories"))
{
$categories = $this->object->getCategories();
}
else
{
$categories = $this->object->getColumns();
}
$data = array();
for ($i = 0; $i < $categories->getCategoryCount(); $i++)
{
$cat = $categories->getCategory($i);
$data[] = array(
"answer" => $cat->title,
"other" => $cat->other,
"scale" => $cat->scale,
"neutral" => $cat->neutral
);
}
$table_gui->setData($data);
$_SESSION['save_phrase_data'] = $data; // :TODO: see savePhrase()
$this->tpl->setContent($table_gui->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::saveReturn ( )
protected

Definition at line 311 of file class.SurveyQuestionGUI.php.

References save().

{
$this->save(true);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::saveSync ( )
protected

Definition at line 306 of file class.SurveyQuestionGUI.php.

References $_REQUEST, and save().

{
$this->save($_REQUEST["rtrn"], true);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::setBackUrl (   $a_url)

Definition at line 142 of file class.SurveyQuestionGUI.php.

{
$this->parent_url = $a_url;
}
SurveyQuestionGUI::setQuestionTabsForClass (   $guiclass)

Definition at line 147 of file class.SurveyQuestionGUI.php.

References $_GET, $_SESSION, and getQuestionType().

Referenced by SurveyMultipleChoiceQuestionGUI\setQuestionTabs(), SurveyTextQuestionGUI\setQuestionTabs(), SurveySingleChoiceQuestionGUI\setQuestionTabs(), SurveyMetricQuestionGUI\setQuestionTabs(), and SurveyMatrixQuestionGUI\setQuestionTabs().

{
global $rbacsystem,$ilTabs;
$this->ctrl->setParameterByClass($guiclass, "sel_question_types", $this->getQuestionType());
$this->ctrl->setParameterByClass($guiclass, "q_id", $_GET["q_id"]);
if ($this->parent_url)
{
$addurl = "";
if (strlen($_GET["new_for_survey"]))
{
$addurl = "&new_id=" . $_GET["q_id"];
}
$ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), $this->parent_url . $addurl);
}
else
{
$this->ctrl->setParameterByClass("ilObjSurveyQuestionPoolGUI", "q_id_table_nav", $_SESSION['q_id_table_nav']);
$ilTabs->setBackTarget($this->lng->txt("spl"), $this->ctrl->getLinkTargetByClass("ilObjSurveyQuestionPoolGUI", "questions"));
}
if ($_GET["q_id"])
{
$ilTabs->addNonTabbedLink("preview",
$this->lng->txt("preview"),
$this->ctrl->getLinkTargetByClass($guiclass, "preview"));
}
if ($rbacsystem->checkAccess('edit', $_GET["ref_id"]))
{
$ilTabs->addTab("edit_properties",
$this->lng->txt("properties"),
$this->ctrl->getLinkTargetByClass($guiclass, "editQuestion"));
if(stristr($guiclass, "matrix"))
{
$ilTabs->addTab("layout",
$this->lng->txt("layout"),
$this->ctrl->getLinkTargetByClass($guiclass, "layout"));
}
}
if ($_GET["q_id"])
{
$ilTabs->addTab("material",
$this->lng->txt("material"),
$this->ctrl->getLinkTargetByClass($guiclass, "material"));
}
if ($this->object->getId() > 0)
{
$title = $this->lng->txt("edit") . " &quot;" . $this->object->getTitle() . "&quot";
}
else
{
$title = $this->lng->txt("create_new") . " " . $this->lng->txt($this->getQuestionType());
}
$this->tpl->setVariable("HEADER", $title);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyQuestionGUI::sync ( )
protected

Definition at line 471 of file class.SurveyQuestionGUI.php.

References $_REQUEST, redirectAfterSaving(), and ilUtil\sendSuccess().

{
$original_id = $this->object->original_id;
if ($original_id)
{
$this->object->syncWithOriginal();
}
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
$this->redirectAfterSaving($_REQUEST["rtrn"]);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::syncCopies ( )
protected

Definition at line 402 of file class.SurveyQuestionGUI.php.

References $_POST, $_REQUEST, $lng, $ref_id, ilObject\_getAllReferences(), copySyncForm(), redirectAfterSaving(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

{
global $lng, $ilAccess;
if(!sizeof($_POST["qid"]))
{
ilUtil::sendFailure($lng->txt("select_one"));
return $this->copySyncForm();
}
foreach($this->object->getCopyIds(true) as $survey_id => $questions)
{
// check permissions for "parent" survey
$can_write = false;
$ref_ids = ilObject::_getAllReferences($survey_id);
foreach($ref_ids as $ref_id)
{
if($ilAccess->checkAccess("edit", "", $ref_id))
{
$can_write = true;
break;
}
}
if($can_write)
{
foreach($questions as $qid)
{
if(in_array($qid, $_POST["qid"]))
{
$id = $this->object->getId();
$this->object->setId($qid);
$this->object->setOriginalId($id);
$this->object->saveToDb();
$this->object->setId($id);
$this->object->setOriginalId(null);
// see: SurveyQuestion::syncWithOriginal()
// what about material?
}
}
}
}
ilUtil::sendSuccess($lng->txt("survey_sync_success"), true);
$this->redirectAfterSaving($_REQUEST["rtrn"]);
}

+ Here is the call graph for this function:

SurveyQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented in SurveyMultipleChoiceQuestionGUI.

Definition at line 538 of file class.SurveyQuestionGUI.php.

Referenced by saveForm().

{
return true;
}

+ Here is the caller graph for this function:

Field Documentation

SurveyQuestionGUI::$ctrl
protected

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

SurveyQuestionGUI::$cumulated
protected

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

SurveyQuestionGUI::$lng
protected

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

Referenced by __construct(), and syncCopies().

SurveyQuestionGUI::$object

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

SurveyQuestionGUI::$parent_url
protected

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

SurveyQuestionGUI::$tpl
protected

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

Referenced by __construct(), and preview().


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