ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilClozeGapInputBuilderGUI Class Reference
+ Inheritance diagram for ilClozeGapInputBuilderGUI:
+ Collaboration diagram for ilClozeGapInputBuilderGUI:

Public Member Functions

 setValue ($a_value)
 Set Value.
 getValue ()
 Get Value.
 setValueCombination ($value)
 getValueCombination ()
 Get Value.
 setValueCombinationFromDb ($value)
 checkInput ()
 Check input, strip slashes etc.
 setValueByArray ($data)
 insert (ilTemplate $template)
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively
 checkSubItemsInput ()
 Check SubItems.
 getSubForm ()
 Get sub form html.
 getItemByPostVar ($a_post_var)
 Get item by post var.
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor.
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)
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi.
 getMulti ()
 Get Multi.
 setMultiValues (array $a_values)
 Set multi values.
 getMultiValues ()
 Get multi values.
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g.

Additional Inherited Members

- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type.
 getMultiIconsHTML ()
 Get HTML for multiple value icons.
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()

Detailed Description

Definition at line 8 of file class.ilClozeGapInputBuilderGUI.php.

Member Function Documentation

ilClozeGapInputBuilderGUI::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 73 of file class.ilClozeGapInputBuilderGUI.php.

References $_POST, $row, CLOZE_NUMERIC, CLOZE_SELECT, CLOZE_TEXT, ilUtil\stripSlashes(), and ilUtil\stripSlashesRecursive().

{
$error = false;
$json = json_decode(ilUtil::stripSlashes($_POST['gap_json_post']));
$gaps_used_in_combination = array();
if(array_key_exists('gap_combination', $_POST))
{
$_POST['gap_combination'] = ilUtil::stripSlashesRecursive($_POST['gap_combination']);
$_POST['gap_combination_values'] = ilUtil::stripSlashesRecursive($_POST['gap_combination_values']);
$gap_with_points = array();
for($i=0; $i < count($_POST['gap_combination']['select']); $i++)
{
foreach($_POST['gap_combination']['select'][$i] as $key => $item)
{
if($item == 'none_selected_minus_one')
{
return false;
}
$gaps_used_in_combination[$item] = $item;
$check_points_for_best_scoring = false;
foreach($_POST['gap_combination_values'][$i] as $index => $answeritems)
{
foreach($answeritems as $answeritem )
{
if($answeritem == 'none_selected_minus_one')
{
return false;
}
}
$points = $_POST['gap_combination']['points'][$i][$index];
if($points > 0)
{
$check_points_for_best_scoring = true;
}
}
if(!$check_points_for_best_scoring)
{
return false;
}
}
}
}
if(isset($_POST['gap']) && is_array($_POST['gap']))
{
foreach($_POST['gap'] as $key => $item)
{
$_POST['clozetype_' . $key] = ilUtil::stripSlashes($_POST['clozetype_' . $key]);
$getType = $_POST['clozetype_' . $key];
$gapsize = $_POST['gap_' . $key . '_gapsize'];
$json[0][$key]->text_field_length = $gapsize > 0 ? $gapsize : '';
$select_at_least_on_positive = false;
if($getType == CLOZE_TEXT || $getType == CLOZE_SELECT)
{
$_POST['gap_' . $key] = ilUtil::stripSlashesRecursive($_POST['gap_' . $key]);
$gapText = $_POST['gap_' . $key];
foreach($gapText['answer'] as $row => $answer)
{
if(!isset($answer) || $answer == '')
{
$error = true;
}
}
$points_sum = 0;
if(array_key_exists('points', $gapText))
{
foreach($gapText['points'] as $row => $points)
{
if(isset($points) && $points != '' && is_numeric($points))
{
$points_sum += $points;
if($points > 0)
{
$select_at_least_on_positive = true;
}
}
else
{
$error = true;
}
}
if(is_array($gap_with_points) && array_key_exists($key, $gap_with_points))
{
$points_sum += $gap_with_points[$key];
}
if($points_sum <= 0)
{
if(!array_key_exists($key, $gaps_used_in_combination) && (!$getType == 'select' || $select_at_least_on_positive == false))
{
$error = true;
}
}
if($getType == CLOZE_SELECT)
{
$_POST['shuffle_' . $key] = ilUtil::stripSlashes($_POST['shuffle_' . $key]);
if(!isset($_POST['shuffle_' . $key]))
{
$error = true;
}
}
}
else
{
$error = true;
}
}
if($getType == CLOZE_NUMERIC)
{
// fau: fixGapFormula - fix post indices, streamlined checks
include_once("./Services/Math/classes/class.EvalMath.php");
$eval = new EvalMath();
$eval->suppress_errors = true;
$mark_errors = array('answer' => false, 'lower' => false, 'upper' => false, 'points' => false);
foreach (array( 'answer' => '_numeric',
'lower' => '_numeric_lower',
'upper' => '_numeric_upper',
'points' => '_numeric_points') as $part => $suffix)
{
$val = ilUtil::stripSlashes($_POST['gap_'.$key.$suffix], FALSE);
$val = str_replace(',', '.', $val);
if ($eval->e($val) === FALSE)
{
$mark_errors[$part] = true;
$error = true;
}
if ($part == 'points')
{
$points = $val;
}
}
// fau.
if(is_array($gap_with_points) && array_key_exists($key, $gap_with_points))
{
$points += $gap_with_points[$key];
}
if(!isset($points) || $points == '' || !is_numeric($points) || $points == 0)
{
if(!array_key_exists($key, $gaps_used_in_combination))
{
$error = true;
}
}
$json[0][$key]->values[0]->error = $mark_errors;
}
}
}
$_POST['gap_json_post'] = json_encode($json);
return !$error;
}

+ Here is the call graph for this function:

ilClozeGapInputBuilderGUI::getValue ( )

Get Value.

Returns
string Value

Definition at line 23 of file class.ilClozeGapInputBuilderGUI.php.

References $_POST, and ilUtil\stripSlashes().

Referenced by insert().

{
$editOrOpen = $this->value;
if(isset($editOrOpen['author']))
{
$json = json_decode(ilUtil::stripSlashes($_POST['gap_json_post']));
return $json[0];
}
return $this->value;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClozeGapInputBuilderGUI::getValueCombination ( )

Get Value.

Returns
string Value

Definition at line 43 of file class.ilClozeGapInputBuilderGUI.php.

References $_POST, and ilUtil\stripSlashes().

Referenced by insert().

{
$editOrOpen = $this->value;
if(isset($editOrOpen['author']))
{
$json = json_decode(ilUtil::stripSlashes($_POST['gap_json_combination_post']));
return $json;
}
return (array) $this->value_combination;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilClozeGapInputBuilderGUI::insert ( ilTemplate  $template)
Parameters
ilTemplate$template

Definition at line 238 of file class.ilClozeGapInputBuilderGUI.php.

References $lng, ilModalGUI\getInstance(), getValue(), getValueCombination(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

{
global $lng;
require_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
$modal->setHeading($lng->txt(''));
$modal->setId("ilGapModal");
//$modal->setBackdrop(ilModalGUI::BACKDROP_OFF);
$modal->setBody('');
$custom_template = new ilTemplate('tpl.il_as_cloze_gap_builder.html', true, true, 'Modules/TestQuestionPool');
$custom_template->setVariable("MY_MODAL", $modal->getHTML());
$custom_template->setVariable('GAP_JSON', json_encode(array($this->getValue())));
$custom_template->setVariable('GAP', $lng->txt('gap'));
$custom_template->setVariable('GAP_COMBINATION_JSON', json_encode($this->getValueCombination()));
$custom_template->setVariable('TEXT_GAP', $lng->txt('text_gap'));
$custom_template->setVariable('SELECT_GAP', $lng->txt('select_gap'));
$custom_template->setVariable('NUMERIC_GAP', $lng->txt('numeric_gap'));
$custom_template->setVariable('GAP_SIZE', $lng->txt('cloze_fixed_textlength'));
$custom_template->setVariable('GAP_SIZE_INFO', $lng->txt('cloze_gap_size_info'));
$custom_template->setVariable('ANSWER_TEXT', $lng->txt('answer_text'));
$custom_template->setVariable('POINTS', $lng->txt('points'));
$custom_template->setVariable('VALUE', $lng->txt('value'));
$custom_template->setVariable('UPPER_BOUND', $lng->txt('range_upper_limit'));
$custom_template->setVariable('LOWER_BOUND', $lng->txt('range_lower_limit'));
$custom_template->setVariable('ACTIONS', $lng->txt('actions'));
$custom_template->setVariable('REMOVE_GAP', $lng->txt('remove_gap'));
$custom_template->setVariable('SHUFFLE_ANSWERS', $lng->txt('shuffle_answers'));
$custom_template->setVariable('POINTS_ERROR', $lng->txt('enter_enough_positive_points'));
$custom_template->setVariable('MISSING_VALUE', $lng->txt('msg_input_is_required'));
$custom_template->setVariable('NOT_A_FORMULA', $lng->txt('err_no_formula'));
$custom_template->setVariable('NOT_A_NUMBER', $lng->txt('err_no_numeric_value'));
$custom_template->setVariable('CLOSE', $lng->txt('close'));
$custom_template->setVariable('DELETE_GAP', $lng->txt('are_you_sure'));
$custom_template->setVariable('PLEASE_SELECT', $lng->txt('please_select'));
$custom_template->setVariable('BEST_POSSIBLE_SOLUTION_HEADER', $lng->txt('tst_best_solution_is'));
$custom_template->setVariable('BEST_POSSIBLE_SOLUTION', $lng->txt('value'));
$custom_template->setVariable('MAX_POINTS', $lng->txt('max_points'));
$custom_template->setVariable('OUT_OF_BOUND', $lng->txt('out_of_range'));
$custom_template->setVariable('TYPE', $lng->txt('type'));
$custom_template->setVariable('VALUES', $lng->txt('values'));
$custom_template->setVariable('GAP_COMBINATION', $lng->txt('gap_combination'));
$custom_template->setVariable('COPY', $lng->txt('copy_of'));
$custom_template->setVariable('OK', $lng->txt('ok'));
$custom_template->setVariable('CANCEL', $lng->txt('cancel'));
$custom_template->setVariable('WHITESPACE_FRONT', $lng->txt('cloze_textgap_whitespace_before'));
$custom_template->setVariable('WHITESPACE_BACK', $lng->txt('cloze_textgap_whitespace_after'));
$custom_template->setVariable('WHITESPACE_MULTIPLE', $lng->txt('cloze_textgap_multiple_whitespace'));
$template->setCurrentBlock('prop_generic');
$template->setVariable('PROP_GENERIC', $custom_template->get());
$template->parseCurrentBlock();
}

+ Here is the call graph for this function:

ilClozeGapInputBuilderGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

ilClozeGapInputBuilderGUI::setValueByArray (   $data)

Definition at line 230 of file class.ilClozeGapInputBuilderGUI.php.

References setValue().

{
$this->setValue($data);
}

+ Here is the call graph for this function:

ilClozeGapInputBuilderGUI::setValueCombination (   $value)

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

Referenced by setValueCombinationFromDb().

{
$this->value_combination = $value;
}

+ Here is the caller graph for this function:

ilClozeGapInputBuilderGUI::setValueCombinationFromDb (   $value)

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

References $row, and setValueCombination().

{
$return_array = array();
if($value)
{
foreach($value as $row)
{
if($row['row_id'] == 0)
{
$return_array[$row['cid']][0][] = $row['gap_fi'];
}
$return_array[$row['cid']][1][$row['row_id']][] = $row['answer'];
$return_array[$row['cid']][2][$row['row_id']] = $row['points']; //= array('key' => $row['cid'], 'points' => $row['points'], 'best_solution' => $row['best_solution']);
}
$this->setValueCombination($return_array);
}
}

+ Here is the call graph for this function:


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