public function checkInput()
 {
     $error = false;
     $json = json_decode(ilUtil::stripSlashes($_POST['gap_json_post']));
     $_POST['gap'] = ilUtil::stripSlashesRecursive($_POST['gap']);
     $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 : '';
             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;
                         } 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)) {
                             $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) {
                 $_POST['gap_' . $key . 'numeric'] = ilUtil::stripSlashes($_POST['gap_' . $key . 'numeric'], FALSE);
                 $_POST['gap_' . $key . 'numeric_lower'] = ilUtil::stripSlashes($_POST['gap_' . $key . 'numeric_lower'], FALSE);
                 $_POST['gap_' . $key . 'numeric_upper'] = ilUtil::stripSlashes($_POST['gap_' . $key . 'numeric_upper'], FALSE);
                 $_POST['gap_' . $key . 'numeric_points'] = ilUtil::stripSlashes($_POST['gap_' . $key . 'numeric_points']);
                 $mark_errors = array('answer' => false, 'lower' => false, 'upper' => false, 'points' => false);
                 $eval = new EvalMath();
                 $eval->suppress_errors = true;
                 $formula = $_POST['gap_' . $key . '_numeric'];
                 $result = $eval->e(str_replace(',', '.', $_POST['gap_' . $key . '_numeric'], $formula));
                 if ($result === false) {
                     $error = true;
                 }
                 $lower = $_POST['gap_' . $key . '_numeric_lower'];
                 $assClozeTestObject = new assClozeTest();
                 $has_valid_chars = $assClozeTestObject->checkForValidFormula($lower);
                 $result = $eval->e(str_replace(',', '.', $lower), FALSE);
                 if ($result === false || !$has_valid_chars) {
                     $error = true;
                 }
                 $_POST['gap_' . $key . '_numeric_lower'] = $result;
                 $result = $eval->e(str_replace(',', '.', $_POST['gap_' . $key . '_numeric_upper']), FALSE);
                 if ($result === false) {
                     $error = true;
                 }
                 $_POST['gap_' . $key . '_numeric_upper'] = $result;
                 $points = $_POST['gap_' . $key . '_numeric_points'];
                 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;
 }