ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
 
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 31 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 48 of file class.ilMatchingPairWizardInputGUI.php.

49 {
50 parent::__construct($a_title, $a_postvar);
51
52 global $DIC;
53
54 $this->forms_helper = new ilTestLegacyFormsHelper();
55 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
56 $this->renderer = $DIC->ui()->renderer();
57 }
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 143 of file class.ilMatchingPairWizardInputGUI.php.

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

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 134 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 177 of file class.ilMatchingPairWizardInputGUI.php.

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

124 : void
125 {
126 $this->allowMove = $a_allow_move;
127 }

◆ setDefinitions()

ilMatchingPairWizardInputGUI::setDefinitions (   $a_definitions)

Set definitions.

Parameters
array$a_definitionsDefinitions

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

104 : void
105 {
106 $this->definitions = $a_definitions;
107 }

◆ setPairs()

ilMatchingPairWizardInputGUI::setPairs (   $a_pairs)

Set pairs.

Parameters
array$a_pairsPairs

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

114 : void
115 {
116 $this->pairs = $a_pairs;
117 }

◆ setTerms()

ilMatchingPairWizardInputGUI::setTerms (   $a_terms)

Set terms.

Parameters
array$a_termsTerms

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

94 : void
95 {
96 $this->terms = $a_terms;
97 }

◆ setValue()

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

Reimplemented from ilTextInputGUI.

Reimplemented in ilAssMatchingPairCorrectionsInputGUI.

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

59 : void
60 {
61 $this->pairs = [];
62 $this->terms = [];
63 $this->definitions = [];
64
65 $to_int = $this->refinery->kindlyTo()->int();
66 $points = $this->forms_helper->transformPoints($a_value);
67 $terms = $this->forms_helper->transformArray($a_value, 'term', $to_int);
68 $definitions = $this->forms_helper->transformArray($a_value, 'definition', $to_int);
69
70 foreach ($terms as $index => $term) {
71 $this->pairs[] = new assAnswerMatchingPair(
72 new assAnswerMatchingTerm('', '', $term),
73 new assAnswerMatchingDefinition('', '', $definitions[$index] ?? 0),
74 $points[$index]
75 );
76 }
77
78 $term_ids = explode(',', $a_value['term_id']);
79 foreach ($term_ids as $id) {
80 $this->terms[] = new assAnswerMatchingTerm('', '', (int) $id);
81 }
82
83 $definition_ids = explode(',', $a_value['definition_id']);
84 foreach ($definition_ids as $id) {
85 $this->definitions[] = new assAnswerMatchingDefinition('', '', (int) $id);
86 }
87 }
$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 34 of file class.ilMatchingPairWizardInputGUI.php.

Referenced by getAllowMove().

◆ $definitions

ilMatchingPairWizardInputGUI::$definitions = []
protected

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

Referenced by checkInput(), and setValue().

◆ $forms_helper

ilTestLegacyFormsHelper ilMatchingPairWizardInputGUI::$forms_helper
protected

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

◆ $glyph_factory

GlyphFactory ilMatchingPairWizardInputGUI::$glyph_factory
protected

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

◆ $pairs

ilMatchingPairWizardInputGUI::$pairs = []
protected

◆ $renderer

Renderer ilMatchingPairWizardInputGUI::$renderer
protected

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

◆ $terms

ilMatchingPairWizardInputGUI::$terms = []
protected

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

Referenced by checkInput(), and setValue().


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