ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMatchingPairWizardInputGUI Class Reference

This class represents a key value pair wizard property in a property form. More...

+ Inheritance diagram for ilMatchingPairWizardInputGUI:
+ Collaboration diagram for ilMatchingPairWizardInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValue ($a_value)
 
 setTerms ($a_terms)
 Set terms. More...
 
 setDefinitions ($a_definitions)
 Set definitions. More...
 
 setPairs ($a_pairs)
 Set pairs. More...
 
 setAllowMove ($a_allow_move)
 Set allow move. More...
 
 getAllowMove ()
 Get allow move. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (ilTemplate $a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilTextInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setValue ($a_value)
 
 getValue ()
 
 setValidationFailureMessage (string $a_msg)
 
 getValidationFailureMessage ()
 
 setValidationRegexp (string $a_value)
 
 getValidationRegexp ()
 
 setMaxLength (?int $a_maxlength)
 
 getMaxLength ()
 
 setSize (int $a_size)
 
 setInlineStyle (string $a_style)
 
 getInlineStyle ()
 
 setCssClass (string $a_class)
 
 getCssClass ()
 
 setValueByArray (array $a_values)
 
 getSize ()
 
 setSuffix (string $a_value)
 
 getSuffix ()
 
 setInputType (string $a_type)
 set input type More...
 
 getInputType ()
 
 setSubmitFormOnEnter (bool $a_val)
 
 getSubmitFormOnEnter ()
 
 checkInput ()
 
 getInput ()
 
 getDataSource ()
 
 setDataSource (string $href, string $a_delimiter=null)
 
 setDataSourceSubmitOnSelection (bool $a_stat)
 
 getDataSourceSubmitOnSelection ()
 
 setDataSourceSubmitUrl (string $a_url)
 
 getDataSourceSubmitUrl ()
 
 setMultiValues (array $a_values)
 
 render (string $a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 setDisableHtmlAutoComplete (bool $autocomplete)
 
 isHtmlAutoCompleteDisabled ()
 
 getPostValueForComparison ()
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 

Protected Attributes

 $pairs = []
 
 $allowMove = false
 
 $terms = []
 
 $definitions = []
 
GlyphFactory $glyph_factory
 
Renderer $renderer
 
- Protected Attributes inherited from ilTextInputGUI
 $value = null
 
int $maxlength = 200
 
int $size = 40
 
string $validationRegexp = ""
 
string $validationFailureMessage = ''
 
string $suffix = ""
 
string $style_css = ""
 
string $css_class = ""
 
string $ajax_datasource = ""
 
string $ajax_datasource_delimiter = null
 
bool $ajax_datasource_commit = false
 
string $ajax_datasource_commit_url = ""
 
bool $submit_form_on_enter = false
 
bool $autocomplete_disabled = false
 
string $input_type = ""
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Detailed Description

This class represents a key value pair wizard property in a property form.

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

Definition at line 29 of file class.ilMatchingPairWizardInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMatchingPairWizardInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 45 of file class.ilMatchingPairWizardInputGUI.php.

References $DIC, and ILIAS\MetaData\Repository\Validation\Data\__construct().

46  {
47  parent::__construct($a_title, $a_postvar);
48 
49  global $DIC;
50  $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
51  $this->renderer = $DIC->ui()->renderer();
52  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilMatchingPairWizardInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 134 of file class.ilMatchingPairWizardInputGUI.php.

References $DIC, ilFormPropertyGUI\$lng, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), ilArrayUtil\stripSlashesRecursive(), and ilLanguage\txt().

134  : bool
135  {
136  global $DIC;
137  $lng = $DIC['lng'];
138 
139  if (is_array($_POST[$this->getPostVar()])) {
140  $foundvalues = ilArrayUtil::stripSlashesRecursive($_POST[$this->getPostVar()]);
141  } else {
142  $foundvalues = $_POST[$this->getPostVar()];
143  }
144  if (is_array($foundvalues)) {
145  // check answers
146  if (isset($foundvalues['term']) && is_array($foundvalues['term'])) {
147  foreach ($foundvalues['term'] as $val) {
148  if ($this->getRequired() && $val < 1) {
149  $this->setAlert($lng->txt("msg_input_is_required"));
150  return false;
151  }
152  }
153  foreach ($foundvalues['definition'] as $val) {
154  if ($this->getRequired() && $val < 1) {
155  $this->setAlert($lng->txt("msg_input_is_required"));
156  return false;
157  }
158  }
159  $max = 0;
160  foreach ($foundvalues['points'] as $val) {
161  if ($this->getRequired() && (strlen($val)) === 0) {
162  $this->setAlert($lng->txt("msg_input_is_required"));
163  return false;
164  }
165  $val = str_replace(",", ".", $val);
166  if (!is_numeric($val)) {
167  $this->setAlert($lng->txt("form_msg_numeric_value_required"));
168  return false;
169  }
170 
171  $val = (float) $val;
172  if ($val > 0) {
173  $max += $val;
174  }
175  }
176  if ($max <= 0) {
177  $this->setAlert($lng->txt("enter_enough_positive_points"));
178  return false;
179  }
180  } else {
181  if ($this->getRequired()) {
182  $this->setAlert($lng->txt("msg_input_is_required"));
183  return false;
184  }
185  }
186  } else {
187  if ($this->getRequired()) {
188  $this->setAlert($lng->txt("msg_input_is_required"));
189  return false;
190  }
191  }
192  return $this->checkSubItemsInput();
193  }
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ getAllowMove()

ilMatchingPairWizardInputGUI::getAllowMove ( )

Get allow move.

Returns
boolean Allow move

Definition at line 125 of file class.ilMatchingPairWizardInputGUI.php.

References $allowMove.

Referenced by insert().

125  : bool
126  {
127  return $this->allowMove;
128  }
+ Here is the caller graph for this function:

◆ insert()

ilMatchingPairWizardInputGUI::insert ( ilTemplate  $a_tpl)

Insert property html.

Returns
void Size

Definition at line 199 of file class.ilMatchingPairWizardInputGUI.php.

References $DIC, ilFormPropertyGUI\$global_tpl, ilFormPropertyGUI\$lng, getAllowMove(), ilFormPropertyGUI\getPostVar(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilLanguage\txt().

199  : void
200  {
201  global $DIC;
202  $lng = $DIC['lng'];
203  $global_tpl = $DIC['tpl'];
204  $global_tpl->addJavascript("./Modules/TestQuestionPool/templates/default/answerwizardinput.js");
205  $global_tpl->addJavascript("./Modules/TestQuestionPool/templates/default/matchingpairwizard.js");
206 
207  $tpl = new ilTemplate("tpl.prop_matchingpairinput.html", true, true, "Modules/TestQuestionPool");
208  $i = 0;
209 
210  foreach ($this->pairs as $pair) {
211  $counter = 1;
212  $tpl->setCurrentBlock("option_term");
213  $tpl->setVariable("TEXT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($lng->txt('please_select')));
214  $tpl->setVariable("VALUE_OPTION", 0);
215  $tpl->parseCurrentBlock();
216  foreach ($this->terms as $term) {
217  $tpl->setCurrentBlock("option_term");
218  $tpl->setVariable("VALUE_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($term->getIdentifier()));
219  $tpl->setVariable("TEXT_OPTION", $lng->txt('term') . " " . $counter);
220  if ($pair->getTerm()->getIdentifier() == $term->getIdentifier()) {
221  $tpl->setVariable('SELECTED_OPTION', ' selected="selected"');
222  }
223  $tpl->parseCurrentBlock();
224  $counter++;
225  }
226  $counter = 1;
227  $tpl->setCurrentBlock("option_definition");
228  $tpl->setVariable("TEXT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($lng->txt('please_select')));
229  $tpl->setVariable("VALUE_OPTION", 0);
230  $tpl->parseCurrentBlock();
231  foreach ($this->definitions as $definition) {
232  $tpl->setCurrentBlock("option_definition");
233  $tpl->setVariable("VALUE_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($definition->getIdentifier()));
234  $tpl->setVariable("TEXT_OPTION", $lng->txt('definition') . " " . $counter);
235  if ($pair->getDefinition()->getIdentifier() == $definition->getIdentifier()) {
236  $tpl->setVariable('SELECTED_OPTION', ' selected="selected"');
237  }
238  $tpl->parseCurrentBlock();
239  $counter++;
240  }
241 
242 
243  $tpl->setCurrentBlock('points_value');
244  $tpl->setVariable('POINTS_VALUE', $pair->getPoints());
245  $tpl->parseCurrentBlock();
246 
247  if ($this->getAllowMove()) {
248  $tpl->setCurrentBlock("move");
249  $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
250  $tpl->setVariable("UP_BUTTON", $this->renderer->render(
251  $this->glyph_factory->up()->withAction('#')
252  ));
253  $tpl->setVariable("DOWN_BUTTON", $this->renderer->render(
254  $this->glyph_factory->down()->withAction('#')
255  ));
256  $tpl->parseCurrentBlock();
257  }
258 
259  $tpl->setCurrentBlock("row");
260  $tpl->setVariable("ROW_NUMBER", $i);
261 
262  $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
263  $tpl->setVariable("ADD_BUTTON", $this->renderer->render(
264  $this->glyph_factory->add()->withAction('#')
265  ));
266  $tpl->setVariable("REMOVE_BUTTON", $this->renderer->render(
267  $this->glyph_factory->remove()->withAction('#')
268  ));
269 
270  $tpl->setVariable("POST_VAR", $this->getPostVar());
271 
272  $tpl->parseCurrentBlock();
273 
274  $i++;
275  }
276 
277  $tpl->setCurrentBlock('term_ids');
278  $ids = array();
279  foreach ($this->terms as $term) {
280  array_push($ids, $term->getIdentifier());
281  }
282  $tpl->setVariable("POST_VAR", $this->getPostVar());
283  $tpl->setVariable("TERM_IDS", join(",", $ids));
284  $tpl->parseCurrentBlock();
285 
286  $tpl->setCurrentBlock('definition_ids');
287  $ids = array();
288  foreach ($this->definitions as $definition) {
289  array_push($ids, $definition->getIdentifier());
290  }
291  $tpl->setVariable("POST_VAR", $this->getPostVar());
292  $tpl->setVariable("DEFINITION_IDS", join(",", $ids));
293  $tpl->parseCurrentBlock();
294 
295  $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
296  $tpl->setVariable("TEXT_POINTS", $lng->txt('points'));
297  $tpl->setVariable("TEXT_DEFINITION", $lng->txt('definition'));
298  $tpl->setVariable("TEXT_TERM", $lng->txt('term'));
299  $tpl->setVariable("TEXT_ACTIONS", $lng->txt('actions'));
300 
301  $a_tpl->setCurrentBlock("prop_generic");
302  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
303  $a_tpl->parseCurrentBlock();
304  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
global $DIC
Definition: feed.php:28
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
ilGlobalTemplateInterface $global_tpl
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ setAllowMove()

ilMatchingPairWizardInputGUI::setAllowMove (   $a_allow_move)

Set allow move.

Parameters
boolean$a_allow_moveAllow move

Definition at line 115 of file class.ilMatchingPairWizardInputGUI.php.

115  : void
116  {
117  $this->allowMove = $a_allow_move;
118  }

◆ setDefinitions()

ilMatchingPairWizardInputGUI::setDefinitions (   $a_definitions)

Set definitions.

Parameters
array$a_definitionsDefinitions

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

95  : void
96  {
97  $this->definitions = $a_definitions;
98  }

◆ setPairs()

ilMatchingPairWizardInputGUI::setPairs (   $a_pairs)

Set pairs.

Parameters
array$a_pairsPairs

Definition at line 105 of file class.ilMatchingPairWizardInputGUI.php.

105  : void
106  {
107  $this->pairs = $a_pairs;
108  }

◆ setTerms()

ilMatchingPairWizardInputGUI::setTerms (   $a_terms)

Set terms.

Parameters
array$a_termsTerms

Definition at line 85 of file class.ilMatchingPairWizardInputGUI.php.

85  : void
86  {
87  $this->terms = $a_terms;
88  }

◆ setValue()

ilMatchingPairWizardInputGUI::setValue (   $a_value)

Definition at line 54 of file class.ilMatchingPairWizardInputGUI.php.

References $id.

54  : void
55  {
56  $this->pairs = array();
57  $this->terms = array();
58  $this->definitions = array();
59  if (is_array($a_value)) {
60  if (isset($a_value['term']) && is_array($a_value['term'])) {
61  foreach ($a_value['term'] as $idx => $term) {
62  $this->pairs[] = new assAnswerMatchingPair(
63  new assAnswerMatchingTerm('', '', $term),
64  new assAnswerMatchingDefinition('', '', $a_value['definition'][$idx]),
65  (float) $a_value['points'][$idx]
66  );
67  }
68  }
69  $term_ids = explode(",", $a_value['term_id']);
70  foreach ($term_ids as $id) {
71  $this->terms[] = new assAnswerMatchingTerm('', '', $id);
72  }
73  $definition_ids = explode(",", $a_value['definition_id']);
74  foreach ($definition_ids as $id) {
75  $this->definitions[] = new assAnswerMatchingDefinition('', '', $id);
76  }
77  }
78  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $allowMove

ilMatchingPairWizardInputGUI::$allowMove = false
protected

Definition at line 32 of file class.ilMatchingPairWizardInputGUI.php.

Referenced by getAllowMove().

◆ $definitions

ilMatchingPairWizardInputGUI::$definitions = []
protected

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

◆ $glyph_factory

GlyphFactory ilMatchingPairWizardInputGUI::$glyph_factory
protected

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

◆ $pairs

ilMatchingPairWizardInputGUI::$pairs = []
protected

◆ $renderer

Renderer ilMatchingPairWizardInputGUI::$renderer
protected

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

◆ $terms

ilMatchingPairWizardInputGUI::$terms = []
protected

Definition at line 33 of file class.ilMatchingPairWizardInputGUI.php.


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