ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 setValue ($a_value)
 Set Value.
 setValueByArray ($a_values)
 setUseEqualPointsOnly ($a_value)
 Set usage of equal points.
 getUseEqualPointsOnly ()
 Get usage of equal points.
 setValues ($a_values)
 Set Values.
 getValues ()
 Get Values.
 setRandomQuestionPools ($a_values)
 Set random question pools.
 setUseQuestionCount ($a_value)
 Get usage of question count.
 getUseQuestionCount ()
 Get usage of question count.
 checkInput ()
 Check input, strip slashes etc.
 insert (&$a_tpl)
 Insert property html.
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 checkSubItemsInput ()
 Check SubItems.
 getSubForm ()
 Get sub form html.
 getItemByPostVar ($a_post_var)
 Get item by post var.
- Public Member Functions inherited from ilFormPropertyGUI
executeCommand ()
 Execute command.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setPostVar ($a_postvar)
 Set Post Variable.
 getPostVar ()
 Get Post Variable.
 getFieldId ()
 Get Post Variable.
 setInfo ($a_info)
 Set Information Text.
 getInfo ()
 Get Information Text.
 setAlert ($a_alert)
 Set Alert Text.
 getAlert ()
 Get Alert Text.
 setRequired ($a_required)
 Set Required.
 getRequired ()
 Get Required.
 setDisabled ($a_disabled)
 Set Disabled.
 getDisabled ()
 Get Disabled.
 setParentForm ($a_parentform)
 Set Parent Form.
 getParentForm ()
 Get Parent Form.
 setParent ($a_val)
 Set Parent GUI object.
 getParent ()
 Get Parent GUI object.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 serializeData ()
 serialize data
 unserializeData ($a_data)
 unserialize data
 writeToSession ()
 Write to session.
 clearFromSession ()
 Clear session value.
 readFromSession ()
 Read from session.
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties)

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

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type.

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:
class.ilRandomTestInputGUI.php 20796 2009-07-30 15:46:10Z hschottm

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

Constructor & Destructor Documentation

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

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

References ilFormPropertyGUI\setRequired().

{
parent::__construct($a_title, $a_postvar);
$this->setRequired(true);
}

+ Here is the call graph for this function:

Member Function Documentation

ilRandomTestInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

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

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

{
global $lng;
$foundvalues = $_POST[$this->getPostVar()];
if (is_array($foundvalues))
{
if (is_array($foundvalues['count']))
{
// check question count
if ($this->getUseQuestionCount())
{
foreach ($foundvalues['count'] as $idx => $answervalue)
{
if ((strlen($answervalue)) == 0)
{
$this->setAlert($lng->txt("msg_input_is_required"));
return FALSE;
}
if (!is_numeric($answervalue))
{
$this->setAlert($lng->txt("form_msg_numeric_value_required"));
return FALSE;
}
if ($answervalue < 1)
{
$this->setAlert($lng->txt("msg_question_count_too_low"));
return FALSE;
}
if ($answervalue > $this->random_pools[$foundvalues['qpl'][$idx]]['count'])
{
$this->setAlert($lng->txt("tst_random_selection_question_count_too_high"));
return FALSE;
}
}
}
}
else
{
if ($this->getUseQuestionCount())
{
$this->setAlert($lng->txt("msg_question_count_too_low"));
return FALSE;
}
}
// check pool selection
if (is_array($foundvalues['qpl']))
{
foreach ($foundvalues['qpl'] as $qpl)
{
if ($qpl < 1)
{
$this->setAlert($lng->txt("msg_input_is_required"));
return FALSE;
}
}
}
}
else
{
$this->setAlert($lng->txt("msg_input_is_required"));
return FALSE;
}
return $this->checkSubItemsInput();
}

+ Here is the call graph for this function:

ilRandomTestInputGUI::getUseEqualPointsOnly ( )

Get usage of equal points.

Returns
boolean Usage of equal points

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

References $equal_points.

{
}
ilRandomTestInputGUI::getUseQuestionCount ( )

Get usage of question count.

Returns
boolean Usage of question count

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

References $question_count.

Referenced by checkInput(), and insert().

{
}

+ Here is the caller graph for this function:

ilRandomTestInputGUI::getValues ( )

Get Values.

Returns
array Values

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

References $values.

{
return $this->values;
}
ilRandomTestInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

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

{
global $lng;
$tpl = new ilTemplate("tpl.prop_randomtestinput.html", true, true, "Modules/Test");
$i = 0;
foreach ($this->values as $value)
{
if (array_key_exists($value->qpl, $this->random_pools)) unset($pools[$value->qpl]);
}
foreach ($this->values as $value)
{
if ($this->getUseQuestionCount())
{
if (is_object($value))
{
$tpl->setCurrentBlock("prop_text_propval");
$tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->count));
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock('question_count');
$tpl->setVariable("SIZE", 3);
$tpl->setVariable("QUESTION_COUNT_ID", $this->getPostVar() . "[count][$i]");
$tpl->setVariable("QUESTION_COUNT_ROW_NUMBER", $i);
$tpl->setVariable("POST_VAR", $this->getPostVar());
$tpl->setVariable("MAXLENGTH", 5);
if ($this->getDisabled())
{
$tpl->setVariable("DISABLED_QUESTION_COUNT", " disabled=\"disabled\"");
}
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock("option");
$tpl->setVariable("OPTION_VALUE", 0);
$tpl->setVariable("OPTION_TEXT", ilUtil::prepareFormOutput($lng->txt('select_questionpool_option')));
$tpl->parseCurrentBlock();
foreach ($this->random_pools as $qpl => $pool)
{
if (($value->qpl == $qpl) || (array_key_exists($qpl, $pools)))
{
$tpl->setCurrentBlock("option");
if ($value->qpl == $qpl)
{
$tpl->setVariable("OPTION_SELECTED", ' selected="selected"');
}
$tpl->setVariable("OPTION_VALUE", $qpl);
$tpl->setVariable("OPTION_TEXT", ilUtil::prepareFormOutput($pool['title']));
$tpl->parseCurrentBlock();
}
}
$tpl->setCurrentBlock("row");
$class = ($i % 2 == 0) ? "even" : "odd";
if ($i == 0) $class .= " first";
if ($i == count($this->values)-1) $class .= " last";
$tpl->setVariable("ROW_CLASS", $class);
$tpl->setVariable("POST_VAR", $this->getPostVar());
$tpl->setVariable("ROW_NUMBER", $i);
$tpl->setVariable("ID", $this->getPostVar() . "[$i]");
$tpl->setVariable("CMD_ADD", "cmd[add" . $this->getPostVar() . "][$i]");
$tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getPostVar() . "][$i]");
$tpl->setVariable("ADD_BUTTON", ilUtil::getImagePath('edit_add.png'));
$tpl->setVariable("REMOVE_BUTTON", ilUtil::getImagePath('edit_remove.png'));
$tpl->parseCurrentBlock();
$i++;
}
$tpl->setVariable("ELEMENT_ID", $this->getPostVar());
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $tpl->get());
$a_tpl->parseCurrentBlock();
// global $tpl;
// include_once "./Services/YUI/classes/class.ilYuiUtil.php";
// ilYuiUtil::initDomEvent();
// $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");
}

+ Here is the call graph for this function:

ilRandomTestInputGUI::setRandomQuestionPools (   $a_values)

Set random question pools.

Parameters
array$a_valuesValue

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

{
$this->random_pools = $a_values;
}
ilRandomTestInputGUI::setUseEqualPointsOnly (   $a_value)

Set usage of equal points.

Parameters
boolean$a_valueUsage of equal points

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

Referenced by ilObjTestGUI\randomQuestionsObject().

{
$this->equal_points = $a_value;
}

+ Here is the caller graph for this function:

ilRandomTestInputGUI::setUseQuestionCount (   $a_value)

Get usage of question count.

Parameters
boolean$a_valueUsage of question count

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

{
$this->question_count = $a_value;
}
ilRandomTestInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

{
$this->values = array();
include_once "./Modules/Test/classes/class.ilRandomTestData.php";
if (is_array($a_value['qpl']))
{
foreach ($a_value['qpl'] as $idx => $qpl)
{
array_push($this->values, new ilRandomTestData($a_value['count'][$idx], $qpl));
}
}
}

+ Here is the caller graph for this function:

ilRandomTestInputGUI::setValueByArray (   $a_values)

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

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

{
$this->setValue($a_values[$this->getPostVar()]);
}

+ Here is the call graph for this function:

ilRandomTestInputGUI::setValues (   $a_values)

Set Values.

Parameters
array$a_valueValue

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

{
$this->values = $a_values;
}

Field Documentation

ilRandomTestInputGUI::$equal_points = false
protected

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

Referenced by getUseEqualPointsOnly().

ilRandomTestInputGUI::$question_count = true
protected

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

Referenced by getUseQuestionCount().

ilRandomTestInputGUI::$random_pools = array()
protected

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

Referenced by insert().

ilRandomTestInputGUI::$values = array()
protected

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

Referenced by getValues().


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