ILIAS  release_8 Revision v8.24
SurveyTextQuestionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for SurveyTextQuestionGUI:
+ Collaboration diagram for SurveyTextQuestionGUI:

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (array $a_working_data=null, $a_only_user_anwers=false)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 getWorkingForm (array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
 Creates the question output form for the learner. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
 executeCommand ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl (string $a_url)
 
 setQuestionTabsForClass (string $guiclass)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 preview ()
 
 getWorkingForm (array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
 
 material (bool $checkonly=false)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase (bool $a_reload=false)
 Creates an output to save the current answers as a phrase. More...
 
 confirmSavePhrase ()
 Save a new phrase to the database. More...
 

Protected Member Functions

 initObject ()
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
- Protected Member Functions inherited from SurveyQuestionGUI
 initObject ()
 
 outQuestionText (ilTemplate $template)
 
 initEditForm ()
 
 addCommandButtons (ilPropertyFormGUI $a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save (bool $a_return=false, bool $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving (bool $a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getPrintViewQuestionTitle (int $question_title=1)
 
 getQuestionTitle (int $question_title_mode=1)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 initPhrasesForm ()
 
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases. More...
 
 addSelectedPhrase ()
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, array $a_foot=null)
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static _getQuestionGUI (?string $questiontype, int $question_id=-1)
 Creates a question gui representation. More...
 
static _getGUIClassNameForId (int $a_q_id)
 
static _getClassNameForQType (string $q_type)
 
- Data Fields inherited from SurveyQuestionGUI
SurveyQuestion $object = null
 
- Protected Attributes inherited from SurveyQuestionGUI
EditingGUIRequest $request
 
EditManager $edit_manager
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilAccessHandler $access
 
ilTree $tree
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
array $cumulated = []
 
string $parent_url = ""
 
ilLogger $log
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Text survey question GUI representation The SurveyTextQuestionGUI class encapsulates the GUI representation for text 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

Definition at line 25 of file class.SurveyTextQuestionGUI.php.

Member Function Documentation

◆ addFieldsToEditForm()

SurveyTextQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

42 : void
43 {
44 // maximum number of characters
45 $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
46 $maxchars->setRequired(false);
47 $maxchars->setSize(5);
48 $maxchars->setDecimals(0);
49 $a_form->addItem($maxchars);
50
51 // textwidth
52 $textwidth = new ilNumberInputGUI($this->lng->txt("width"), "textwidth");
53 $textwidth->setRequired(true);
54 $textwidth->setSize(3);
55 $textwidth->setDecimals(0);
56 $textwidth->setMinValue(10, true);
57 $a_form->addItem($textwidth);
58
59 // textheight
60 $textheight = new ilNumberInputGUI($this->lng->txt("height"), "textheight");
61 $textheight->setRequired(true);
62 $textheight->setSize(3);
63
64 $textheight->setDecimals(0);
65 $textheight->setMinValue(1);
66 $a_form->addItem($textheight);
67
68 // values
69 if ($this->object->getMaxChars() > 0) {
70 $maxchars->setValue($this->object->getMaxChars());
71 }
72 $textwidth->setValue($this->object->getTextWidth());
73 $textheight->setValue($this->object->getTextHeight());
74 }
This class represents a number property in a property form.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getParsedAnswers()

SurveyTextQuestionGUI::getParsedAnswers ( array  $a_working_data = null,
  $a_only_user_anwers = false 
)

Definition at line 84 of file class.SurveyTextQuestionGUI.php.

87 : array {
88 $res = array();
89 if (is_array($a_working_data) && isset($a_working_data[0])) {
90 $res[] = array("textanswer" => trim($a_working_data[0]["textanswer"] ?? ""));
91 }
92
93 return $res;
94 }
$res
Definition: ltiservices.php:69

References $res.

◆ getPrintView()

SurveyTextQuestionGUI::getPrintView ( int  $question_title = 1,
bool  $show_questiontext = true,
?int  $survey_id = null,
?array  $working_data = null 
)

Reimplemented from SurveyQuestionGUI.

Definition at line 96 of file class.SurveyTextQuestionGUI.php.

101 : string {
102 $user_answer = null;
103 if ($working_data) {
104 $user_answer = $this->getParsedAnswers($working_data);
105 $user_answer = $user_answer[0]["textanswer"];
106 }
107
108 $template = new ilTemplate("tpl.il_svy_qpl_text_printview.html", true, true, "Modules/SurveyQuestionPool");
109 if ($show_questiontext) {
110 $this->outQuestionText($template);
111 }
112 if ($question_title) {
113 $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
114 }
115 $template->setVariable("QUESTION_ID", $this->object->getId());
116 $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
117 if (is_array($working_data) && trim($user_answer)) {
118 $template->setVariable("TEXT", nl2br($user_answer));
119 } else {
120 $template->setVariable("TEXTBOX_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("textbox.png")));
121 $template->setVariable("TEXTBOX", $this->lng->txt("textbox"));
122 $template->setVariable("TEXTBOX_WIDTH", $this->object->getTextWidth() * 16);
123 $template->setVariable("TEXTBOX_HEIGHT", $this->object->getTextHeight() * 16);
124 }
125 if ($this->object->getMaxChars()) {
126 $template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
127 }
128 return $template->get();
129 }
getPrintViewQuestionTitle(int $question_title=1)
outQuestionText(ilTemplate $template)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
special template class to simplify handling of ITX/PEAR
static getHtmlPath(string $relative_path)
get url of path
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

◆ getWorkingForm()

SurveyTextQuestionGUI::getWorkingForm ( array  $working_data = null,
int  $question_title = 1,
bool  $show_questiontext = true,
string  $error_message = "",
int  $survey_id = null,
bool  $compress_view = false 
)

Creates the question output form for the learner.

Reimplemented from SurveyQuestionGUI.

Definition at line 139 of file class.SurveyTextQuestionGUI.php.

146 : string {
147 $template = new ilTemplate("tpl.il_svy_out_text.html", true, true, "Modules/SurveyQuestionPool");
148 $template->setCurrentBlock("material_text");
149 $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
150 $template->parseCurrentBlock();
151
152 if ($this->object->getTextHeight() === 1) {
153 $template->setCurrentBlock("textinput");
154 if (is_array($working_data)) {
155 if (isset($working_data[0]["textanswer"])) {
156 $template->setVariable("VALUE_ANSWER", " value=\"" . ilLegacyFormElementsUtil::prepareFormOutput($working_data[0]["textanswer"]) . "\"");
157 }
158 }
159 $template->setVariable("QUESTION_ID", $this->object->getId());
160 $template->setVariable("WIDTH", $this->object->getTextWidth());
161 if ($this->object->getMaxChars()) {
162 $template->setVariable("MAXLENGTH", " maxlength=\"" . $this->object->getMaxChars() . "\"");
163 }
164 } else {
165 $template->setCurrentBlock("textarea");
166 if (is_array($working_data) && isset($working_data[0]["textanswer"])) {
167 $template->setVariable("VALUE_ANSWER", ilLegacyFormElementsUtil::prepareFormOutput($working_data[0]["textanswer"]));
168 }
169 $template->setVariable("QUESTION_ID", $this->object->getId());
170 $template->setVariable("WIDTH", $this->object->getTextWidth());
171 $template->setVariable("HEIGHT", $this->object->getTextHeight());
172 }
173 $template->parseCurrentBlock();
174 $template->setCurrentBlock("question_data_text");
175 if ($show_questiontext) {
176 $this->outQuestionText($template);
177 }
178 $template->setVariable("QUESTION_TITLE", $this->getQuestionTitle($question_title));
179 $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
180 $template->setVariable("LABEL_QUESTION_ID", $this->object->getId());
181 if (strcmp($error_message, "") !== 0) {
182 $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
183 }
184 if ($this->object->getMaxChars()) {
185 $template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
186 }
187 $template->parseCurrentBlock();
188 return $template->get();
189 }
getQuestionTitle(int $question_title_mode=1)
getMaterialOutput()
Creates the HTML output of the question material(s)
static prepareFormOutput($a_str, bool $a_strip=false)

References ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyTextQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 76 of file class.SurveyTextQuestionGUI.php.

76 : void
77 {
78 $max = $a_form->getInput("maxchars");
79 $this->object->setMaxChars((int) $max);
80 $this->object->setTextWidth($a_form->getInput("textwidth"));
81 $this->object->setTextHeight($a_form->getInput("textheight"));
82 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyTextQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 27 of file class.SurveyTextQuestionGUI.php.

27 : void
28 {
29 $this->object = new SurveyTextQuestion();
30 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setQuestionTabs()

SurveyTextQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

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

37 : void
38 {
39 $this->setQuestionTabsForClass("surveytextquestiongui");
40 }
setQuestionTabsForClass(string $guiclass)

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

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