ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 ()
 Check input, strip slashes etc. More...
 
 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)
 Get item by post var. More...
 
- 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
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Attributes

 $pairs = []
 
 $allowMove = false
 
 $terms = []
 
 $definitions = []
 
ilTestLegacyFormsHelper $forms_helper
 
GlyphFactory $glyph_factory
 
ButtonFactory $button_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 32 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 50 of file class.ilMatchingPairWizardInputGUI.php.

51 {
52 parent::__construct($a_title, $a_postvar);
53
54 global $DIC;
55
56 $this->forms_helper = new ilTestLegacyFormsHelper();
57 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
58 $this->button_factory = $DIC->ui()->factory()->button();
59 $this->renderer = $DIC->ui()->renderer();
60 }
renderer()
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and renderer().

+ 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

Reimplemented from ilTextInputGUI.

Reimplemented in ilAssMatchingPairCorrectionsInputGUI.

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

146 : bool
147 {
148 $to_int = $this->refinery->kindlyTo()->int();
149 $data = $this->raw($this->getPostVar());
150
151 if (!is_array($data)) {
152 $this->setAlert($this->lng->txt('msg_input_is_required'));
153 return false;
154 }
155
156 // check points
157 $result_points = $this->forms_helper->checkPointsInputEnoughPositive($data, true);
158 if (!is_array($result_points)) {
159 $this->setAlert($this->lng->txt($result_points));
160 return false;
161 }
162
163 // check answers
164 $terms = $this->forms_helper->transformArray($data, 'term', $to_int);
165 $definitions = $this->forms_helper->transformArray($data, 'definition', $to_int);
166 foreach ([$terms, $definitions] as $value) {
167 if ($value < 1 && $this->getRequired()) {
168 $this->setAlert($this->lng->txt('msg_input_is_required'));
169 return false;
170 }
171 }
172
173 return $this->checkSubItemsInput();
174 }

References $data, $definitions, $terms, ilTextInputGUI\$value, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ILIAS\Repository\lng(), ilFormPropertyGUI\raw(), ILIAS\Repository\refinery(), and ilFormPropertyGUI\setAlert().

+ Here is the call graph for this function:

◆ getAllowMove()

ilMatchingPairWizardInputGUI::getAllowMove ( )

Get allow move.

Returns
boolean Allow move

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

References $allowMove.

Referenced by insert().

+ Here is the caller graph for this function:

◆ insert()

ilMatchingPairWizardInputGUI::insert ( ilTemplate  $a_tpl)

Insert property html.

Returns
void Size

Reimplemented from ilTextInputGUI.

Reimplemented in ilAssMatchingPairCorrectionsInputGUI.

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

180 : void
181 {
182 global $DIC;
183 $lng = $DIC['lng'];
184 $global_tpl = $DIC['tpl'];
185 $global_tpl->addJavascript("assets/js/answerwizardinput.js");
186 $global_tpl->addJavascript("assets/js/matchingpairwizard.js");
187
188 $tpl = new ilTemplate("tpl.prop_matchingpairinput.html", true, true, "components/ILIAS/TestQuestionPool");
189 $i = 0;
190
191 foreach ($this->pairs as $pair) {
192 $counter = 1;
193 $tpl->setCurrentBlock("option_term");
194 $tpl->setVariable("TEXT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($lng->txt('please_select')));
195 $tpl->setVariable("VALUE_OPTION", 0);
196 $tpl->parseCurrentBlock();
197 foreach ($this->terms as $term) {
198 $tpl->setCurrentBlock("option_term");
199 $tpl->setVariable("VALUE_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($term->getIdentifier()));
200 $tpl->setVariable("TEXT_OPTION", $lng->txt('term') . " " . $counter);
201 if ($pair->getTerm()->getIdentifier() == $term->getIdentifier()) {
202 $tpl->setVariable('SELECTED_OPTION', ' selected="selected"');
203 }
204 $tpl->parseCurrentBlock();
205 $counter++;
206 }
207 $counter = 1;
208 $tpl->setCurrentBlock("option_definition");
209 $tpl->setVariable("TEXT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($lng->txt('please_select')));
210 $tpl->setVariable("VALUE_OPTION", 0);
211 $tpl->parseCurrentBlock();
212 foreach ($this->definitions as $definition) {
213 $tpl->setCurrentBlock("option_definition");
214 $tpl->setVariable("VALUE_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($definition->getIdentifier()));
215 $tpl->setVariable("TEXT_OPTION", $lng->txt('definition') . " " . $counter);
216 if ($pair->getDefinition()->getIdentifier() == $definition->getIdentifier()) {
217 $tpl->setVariable('SELECTED_OPTION', ' selected="selected"');
218 }
219 $tpl->parseCurrentBlock();
220 $counter++;
221 }
222
223
224 $tpl->setCurrentBlock('points_value');
225 $tpl->setVariable('POINTS_VALUE', $pair->getPoints());
226 $tpl->parseCurrentBlock();
227
228 if ($this->getAllowMove()) {
229 $tpl->setCurrentBlock("move");
230 $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
231 $tpl->setVariable("UP_BUTTON", $this->renderer->render(
232 $this->button_factory->shy('', '')->withSymbol($this->glyph_factory->up())
233 ));
234 $tpl->setVariable("DOWN_BUTTON", $this->renderer->render(
235 $this->button_factory->shy('', '')->withSymbol($this->glyph_factory->down())
236 ));
237 $tpl->parseCurrentBlock();
238 }
239
240 $tpl->setCurrentBlock("row");
241 $tpl->setVariable("ROW_NUMBER", $i);
242
243 $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
244 $tpl->setVariable("ADD_BUTTON", $this->renderer->render(
245 $this->button_factory->shy('', '')->withSymbol($this->glyph_factory->add())
246 ));
247 $tpl->setVariable("REMOVE_BUTTON", $this->renderer->render(
248 $this->button_factory->shy('', '')->withSymbol($this->glyph_factory->remove())
249 ));
250
251 $tpl->setVariable("POST_VAR", $this->getPostVar());
252
253 $tpl->parseCurrentBlock();
254
255 $i++;
256 }
257
258 $tpl->setCurrentBlock('term_ids');
259 $ids = [];
260 foreach ($this->terms as $term) {
261 array_push($ids, $term->getIdentifier());
262 }
263 $tpl->setVariable("POST_VAR", $this->getPostVar());
264 $tpl->setVariable("TERM_IDS", join(",", $ids));
265 $tpl->parseCurrentBlock();
266
267 $tpl->setCurrentBlock('definition_ids');
268 $ids = [];
269 foreach ($this->definitions as $definition) {
270 array_push($ids, $definition->getIdentifier());
271 }
272 $tpl->setVariable("POST_VAR", $this->getPostVar());
273 $tpl->setVariable("DEFINITION_IDS", join(",", $ids));
274 $tpl->parseCurrentBlock();
275
276 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
277 $tpl->setVariable("TEXT_POINTS", $lng->txt('points'));
278 $tpl->setVariable("TEXT_DEFINITION", $lng->txt('definition'));
279 $tpl->setVariable("TEXT_TERM", $lng->txt('term'));
280 $tpl->setVariable("TEXT_ACTIONS", $lng->txt('actions'));
281
282 $a_tpl->setCurrentBlock("prop_generic");
283 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
284 $a_tpl->parseCurrentBlock();
285 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
ilGlobalTemplateInterface $global_tpl
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)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
$counter

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

+ 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 127 of file class.ilMatchingPairWizardInputGUI.php.

127 : void
128 {
129 $this->allowMove = $a_allow_move;
130 }

◆ setDefinitions()

ilMatchingPairWizardInputGUI::setDefinitions (   $a_definitions)

Set definitions.

Parameters
array$a_definitionsDefinitions

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

107 : void
108 {
109 $this->definitions = $a_definitions;
110 }

◆ setPairs()

ilMatchingPairWizardInputGUI::setPairs (   $a_pairs)

Set pairs.

Parameters
array$a_pairsPairs

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

117 : void
118 {
119 $this->pairs = $a_pairs;
120 }

◆ setTerms()

ilMatchingPairWizardInputGUI::setTerms (   $a_terms)

Set terms.

Parameters
array$a_termsTerms

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

97 : void
98 {
99 $this->terms = $a_terms;
100 }

◆ setValue()

ilMatchingPairWizardInputGUI::setValue (   $a_value)
Parameters
string | array$a_value

Reimplemented from ilTextInputGUI.

Reimplemented in ilAssMatchingPairCorrectionsInputGUI.

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

62 : void
63 {
64 $this->pairs = [];
65 $this->terms = [];
66 $this->definitions = [];
67
68 $to_int = $this->refinery->kindlyTo()->int();
69 $points = $this->forms_helper->transformPoints($a_value);
70 $terms = $this->forms_helper->transformArray($a_value, 'term', $to_int);
71 $definitions = $this->forms_helper->transformArray($a_value, 'definition', $to_int);
72
73 foreach ($terms as $index => $term) {
74 $this->pairs[] = new assAnswerMatchingPair(
75 new assAnswerMatchingTerm('', '', $term),
76 new assAnswerMatchingDefinition('', '', $definitions[$index] ?? 0),
77 $points[$index]
78 );
79 }
80
81 $term_ids = explode(',', $a_value['term_id']);
82 foreach ($term_ids as $id) {
83 $this->terms[] = new assAnswerMatchingTerm('', '', (int) $id);
84 }
85
86 $definition_ids = explode(',', $a_value['definition_id']);
87 foreach ($definition_ids as $id) {
88 $this->definitions[] = new assAnswerMatchingDefinition('', '', (int) $id);
89 }
90 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class for matching question definitions.
Class for matching question pairs.
Class for matching question terms.

References $definitions, $id, $terms, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Field Documentation

◆ $allowMove

ilMatchingPairWizardInputGUI::$allowMove = false
protected

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

Referenced by getAllowMove().

◆ $button_factory

ButtonFactory ilMatchingPairWizardInputGUI::$button_factory
protected

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

◆ $definitions

ilMatchingPairWizardInputGUI::$definitions = []
protected

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

Referenced by checkInput(), and setValue().

◆ $forms_helper

ilTestLegacyFormsHelper ilMatchingPairWizardInputGUI::$forms_helper
protected

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

◆ $glyph_factory

GlyphFactory ilMatchingPairWizardInputGUI::$glyph_factory
protected

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

◆ $pairs

ilMatchingPairWizardInputGUI::$pairs = []
protected

◆ $renderer

Renderer ilMatchingPairWizardInputGUI::$renderer
protected

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

◆ $terms

ilMatchingPairWizardInputGUI::$terms = []
protected

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

Referenced by checkInput(), and setValue().


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