ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRandomTestInputGUI Class Reference

This class represents a random test input property in a property form. More...

+ Inheritance diagram for ilRandomTestInputGUI:
+ Collaboration diagram for ilRandomTestInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValue ($a_value)
 Set Value. More...
 
 setValueByArray ($a_values)
 
 setUseEqualPointsOnly ($a_value)
 Set usage of equal points. More...
 
 getUseEqualPointsOnly ()
 Get usage of equal points. More...
 
 setValues ($a_values)
 Set Values. More...
 
 getValues ()
 Get Values. More...
 
 setRandomQuestionPools ($a_values)
 Set random question pools. More...
 
 setUseQuestionCount ($a_value)
 Get usage of question count. More...
 
 getUseQuestionCount ()
 Get usage of question count. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (&$a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 

Protected Attributes

 $values = array()
 
 $equal_points = false
 
 $question_count = true
 
 $random_pools = array()
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Detailed Description

This class represents a random test input property in a property form.

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

Definition at line 11 of file class.ilRandomTestInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 24 of file class.ilRandomTestInputGUI.php.

References ilFormPropertyGUI\setRequired().

25  {
26  parent::__construct($a_title, $a_postvar);
27  $this->setRequired(true);
28  }
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilRandomTestInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

References $_POST, $lng, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), getUseQuestionCount(), and ilFormPropertyGUI\setAlert().

129  {
130  global $lng;
131 
132  $foundvalues = $_POST[$this->getPostVar()];
133  if (is_array($foundvalues))
134  {
135  if (is_array($foundvalues['count']))
136  {
137  if (count($foundvalues['qpl']) != count(array_unique($foundvalues['qpl'])))
138  {
139  $this->setAlert($lng->txt("msg_randompool_duplicate_qpl"));
140  return false;
141  }
142  // check question count
143  if ($this->getUseQuestionCount())
144  {
145  foreach ($foundvalues['count'] as $idx => $answervalue)
146  {
147  if ((strlen($answervalue)) == 0)
148  {
149  $this->setAlert($lng->txt("msg_input_is_required"));
150  return FALSE;
151  }
152  if (!is_numeric($answervalue))
153  {
154  $this->setAlert($lng->txt("form_msg_numeric_value_required"));
155  return FALSE;
156  }
157  if ($answervalue < 1)
158  {
159  $this->setAlert($lng->txt("msg_question_count_too_low"));
160  return FALSE;
161  }
162  if ($answervalue > $this->random_pools[$foundvalues['qpl'][$idx]]['count'])
163  {
164  $this->setAlert($lng->txt("tst_random_selection_question_count_too_high"));
165  return FALSE;
166  }
167  }
168  }
169  }
170  else
171  {
172  if ($this->getUseQuestionCount())
173  {
174  $this->setAlert($lng->txt("msg_question_count_too_low"));
175  return FALSE;
176  }
177  }
178  // check pool selection
179  if (is_array($foundvalues['qpl']))
180  {
181  foreach ($foundvalues['qpl'] as $qpl)
182  {
183  if ($qpl < 1)
184  {
185  $this->setAlert($lng->txt("msg_input_is_required"));
186  return FALSE;
187  }
188  }
189  }
190  }
191  else
192  {
193  $this->setAlert($lng->txt("msg_input_is_required"));
194  return FALSE;
195  }
196  return $this->checkSubItemsInput();
197  }
$_POST['username']
Definition: cron.php:12
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getUseQuestionCount()
Get usage of question count.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ getUseEqualPointsOnly()

ilRandomTestInputGUI::getUseEqualPointsOnly ( )

Get usage of equal points.

Returns
boolean Usage of equal points

Definition at line 68 of file class.ilRandomTestInputGUI.php.

References $equal_points.

◆ getUseQuestionCount()

ilRandomTestInputGUI::getUseQuestionCount ( )

Get usage of question count.

Returns
boolean Usage of question count

Definition at line 118 of file class.ilRandomTestInputGUI.php.

References $question_count.

Referenced by checkInput(), and insert().

+ Here is the caller graph for this function:

◆ getValues()

ilRandomTestInputGUI::getValues ( )

Get Values.

Returns
array Values

Definition at line 88 of file class.ilRandomTestInputGUI.php.

References $values.

◆ insert()

ilRandomTestInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

Definition at line 204 of file class.ilRandomTestInputGUI.php.

References $lng, $random_pools, $tpl, ilFormPropertyGUI\getDisabled(), ilUtil\getImagePath(), ilFormPropertyGUI\getPostVar(), getUseQuestionCount(), and ilUtil\prepareFormOutput().

205  {
206  global $lng;
207 
208  $tpl = new ilTemplate("tpl.prop_randomtestinput.html", true, true, "Modules/Test");
209  $i = 0;
210  $pools = $this->random_pools;
211  foreach ($this->values as $value)
212  {
213  if (array_key_exists($value->qpl, $this->random_pools)) unset($pools[$value->qpl]);
214  }
215  foreach ($this->values as $value)
216  {
217  if ($this->getUseQuestionCount())
218  {
219  if (is_object($value))
220  {
221  $tpl->setCurrentBlock("prop_text_propval");
222  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->count));
223  $tpl->parseCurrentBlock();
224  }
225  $tpl->setCurrentBlock('question_count');
226  $tpl->setVariable("SIZE", 3);
227  $tpl->setVariable("QUESTION_COUNT_ID", $this->getPostVar() . "[count][$i]");
228  $tpl->setVariable("QUESTION_COUNT_ROW_NUMBER", $i);
229  $tpl->setVariable("POST_VAR", $this->getPostVar());
230  $tpl->setVariable("MAXLENGTH", 5);
231  if ($this->getDisabled())
232  {
233  $tpl->setVariable("DISABLED_QUESTION_COUNT", " disabled=\"disabled\"");
234  }
235  $tpl->parseCurrentBlock();
236  }
237 
238  $tpl->setCurrentBlock("option");
239  $tpl->setVariable("OPTION_VALUE", 0);
240  $tpl->setVariable("OPTION_TEXT", ilUtil::prepareFormOutput($lng->txt('select_questionpool_option')));
241  $tpl->parseCurrentBlock();
242  foreach ($this->random_pools as $qpl => $pool)
243  {
244  if (($value->qpl == $qpl) || (array_key_exists($qpl, $pools)))
245  {
246  $tpl->setCurrentBlock("option");
247  if ($value->qpl == $qpl)
248  {
249  $tpl->setVariable("OPTION_SELECTED", ' selected="selected"');
250  }
251  $tpl->setVariable("OPTION_VALUE", $qpl);
252  $tpl->setVariable("OPTION_TEXT", ilUtil::prepareFormOutput($pool['title']));
253  $tpl->parseCurrentBlock();
254  }
255  }
256 
257  $tpl->setCurrentBlock("row");
258  $class = ($i % 2 == 0) ? "even" : "odd";
259  if ($i == 0) $class .= " first";
260  if ($i == count($this->values)-1) $class .= " last";
261  $tpl->setVariable("ROW_CLASS", $class);
262  $tpl->setVariable("POST_VAR", $this->getPostVar());
263  $tpl->setVariable("ROW_NUMBER", $i);
264  $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
265  $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getPostVar() . "][$i]");
266  $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getPostVar() . "][$i]");
267  $tpl->setVariable("ADD_BUTTON", ilUtil::getImagePath('edit_add.png'));
268  $tpl->setVariable("REMOVE_BUTTON", ilUtil::getImagePath('edit_remove.png'));
269  $tpl->parseCurrentBlock();
270  $i++;
271  }
272  $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
273 
274  $a_tpl->setCurrentBlock("prop_generic");
275  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
276  $a_tpl->parseCurrentBlock();
277 
278 // global $tpl;
279 // include_once "./Services/YUI/classes/class.ilYuiUtil.php";
280 // ilYuiUtil::initDomEvent();
281 // $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");
282  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getPostVar()
Get Post Variable.
getUseQuestionCount()
Get usage of question count.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ setRandomQuestionPools()

ilRandomTestInputGUI::setRandomQuestionPools (   $a_values)

Set random question pools.

Parameters
array$a_valuesValue

Definition at line 98 of file class.ilRandomTestInputGUI.php.

99  {
100  $this->random_pools = $a_values;
101  }

◆ setUseEqualPointsOnly()

ilRandomTestInputGUI::setUseEqualPointsOnly (   $a_value)

Set usage of equal points.

Parameters
boolean$a_valueUsage of equal points

Definition at line 58 of file class.ilRandomTestInputGUI.php.

59  {
60  $this->equal_points = $a_value;
61  }

◆ setUseQuestionCount()

ilRandomTestInputGUI::setUseQuestionCount (   $a_value)

Get usage of question count.

Parameters
boolean$a_valueUsage of question count

Definition at line 108 of file class.ilRandomTestInputGUI.php.

109  {
110  $this->question_count = $a_value;
111  }

◆ setValue()

ilRandomTestInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

36  {
37  $this->values = array();
38  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
39  if (is_array($a_value['qpl']))
40  {
41  foreach ($a_value['qpl'] as $idx => $qpl)
42  {
43  array_push($this->values, new ilRandomTestData($a_value['count'][$idx], $qpl));
44  }
45  }
46  }
This class represents a random test input property in a property form.
+ Here is the caller graph for this function:

◆ setValueByArray()

ilRandomTestInputGUI::setValueByArray (   $a_values)

Definition at line 48 of file class.ilRandomTestInputGUI.php.

References ilFormPropertyGUI\getPostVar(), and setValue().

49  {
50  $this->setValue($a_values[$this->getPostVar()]);
51  }
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

◆ setValues()

ilRandomTestInputGUI::setValues (   $a_values)

Set Values.

Parameters
array$a_valueValue

Definition at line 78 of file class.ilRandomTestInputGUI.php.

79  {
80  $this->values = $a_values;
81  }

Field Documentation

◆ $equal_points

ilRandomTestInputGUI::$equal_points = false
protected

Definition at line 14 of file class.ilRandomTestInputGUI.php.

Referenced by getUseEqualPointsOnly().

◆ $question_count

ilRandomTestInputGUI::$question_count = true
protected

Definition at line 15 of file class.ilRandomTestInputGUI.php.

Referenced by getUseQuestionCount().

◆ $random_pools

ilRandomTestInputGUI::$random_pools = array()
protected

Definition at line 16 of file class.ilRandomTestInputGUI.php.

Referenced by insert().

◆ $values

ilRandomTestInputGUI::$values = array()
protected

Definition at line 13 of file class.ilRandomTestInputGUI.php.

Referenced by getValues().


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