3 require_once
'Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php';
4 require_once
'Services/Form/classes/class.ilTextInputGUI.php';
5 require_once
'Modules/TestQuestionPool/classes/class.assClozeGap.php';
6 require_once
'Modules/TestQuestionPool/classes/class.assClozeTest.php';
16 $this->value = $a_value;
25 $editOrOpen = $this->value;
26 if(isset($editOrOpen[
'author']))
36 $this->value_combination = $value;
45 $editOrOpen = $this->value;
46 if(isset($editOrOpen[
'author']))
51 return (array) $this->value_combination;
56 $return_array = array();
59 foreach($value as
$row)
61 if($row[
'row_id'] == 0)
63 $return_array[$row[
'cid']][0][] = $row[
'gap_fi'];
65 $return_array[$row[
'cid']][1][$row[
'row_id']][] = $row[
'answer'];
66 $return_array[$row[
'cid']][2][$row[
'row_id']] = $row[
'points'];
78 $gaps_used_in_combination = array();
79 if(array_key_exists(
'gap_combination',
$_POST))
83 $gap_with_points = array();
85 for($i=0; $i < count(
$_POST[
'gap_combination'][
'select']); $i++)
87 foreach(
$_POST[
'gap_combination'][
'select'][$i] as $key => $item)
89 if($item ==
'none_selected_minus_one')
93 $gaps_used_in_combination[$item] = $item;
94 $check_points_for_best_scoring =
false;
95 foreach(
$_POST[
'gap_combination_values'][$i] as $index => $answeritems)
97 foreach($answeritems as $answeritem )
99 if($answeritem ==
'none_selected_minus_one')
104 $points =
$_POST[
'gap_combination'][
'points'][$i][$index];
107 $check_points_for_best_scoring =
true;
110 if(!$check_points_for_best_scoring)
121 foreach(
$_POST[
'gap'] as $key => $item)
124 $getType =
$_POST[
'clozetype_' . $key];
125 $gapsize =
$_POST[
'gap_' . $key .
'_gapsize'];
126 $json[0][$key]->text_field_length = $gapsize > 0 ? $gapsize :
'';
127 $select_at_least_on_positive =
false;
131 $gapText =
$_POST[
'gap_' . $key];
132 foreach($gapText[
'answer'] as
$row => $answer)
134 if(!isset($answer) || $answer ==
'')
140 if(array_key_exists(
'points', $gapText))
142 foreach($gapText[
'points'] as
$row => $points)
144 if(isset($points) && $points !=
'' && is_numeric($points))
146 $points_sum += $points;
149 $select_at_least_on_positive =
true;
157 if(is_array($gap_with_points) && array_key_exists($key, $gap_with_points))
159 $points_sum += $gap_with_points[$key];
163 if(!array_key_exists($key, $gaps_used_in_combination) && (!$getType ==
'select' || $select_at_least_on_positive ==
false))
171 if(!isset(
$_POST[
'shuffle_' . $key]))
185 include_once(
"./Services/Math/classes/class.EvalMath.php");
187 $eval->suppress_errors =
true;
189 $mark_errors = array(
'answer' =>
false,
'lower' =>
false,
'upper' =>
false,
'points' =>
false);
190 foreach (array(
'answer' =>
'_numeric',
191 'lower' =>
'_numeric_lower',
192 'upper' =>
'_numeric_upper',
193 'points' =>
'_numeric_points') as $part => $suffix)
196 $val = str_replace(
',',
'.', $val);
197 if ($eval->e($val) === FALSE)
199 $mark_errors[$part] =
true;
203 if ($part ==
'points')
209 if(is_array($gap_with_points) && array_key_exists($key, $gap_with_points))
211 $points += $gap_with_points[$key];
214 if(!isset($points) || $points ==
'' || !is_numeric($points) || $points == 0)
216 if(!array_key_exists($key, $gaps_used_in_combination))
222 $json[0][$key]->values[0]->error = $mark_errors;
226 $_POST[
'gap_json_post'] = json_encode($json);
241 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
243 $modal->setHeading($lng->txt(
''));
244 $modal->setId(
"ilGapModal");
248 $custom_template =
new ilTemplate(
'tpl.il_as_cloze_gap_builder.html',
true,
true,
'Modules/TestQuestionPool');
249 $custom_template->setVariable(
"MY_MODAL", $modal->getHTML());
250 $custom_template->setVariable(
'GAP_JSON', json_encode(array($this->
getValue())));
251 $custom_template->setVariable(
'GAP', $lng->txt(
'gap'));
252 $custom_template->setVariable(
'GAP_COMBINATION_JSON', json_encode($this->
getValueCombination()));
253 $custom_template->setVariable(
'TEXT_GAP', $lng->txt(
'text_gap'));
254 $custom_template->setVariable(
'SELECT_GAP', $lng->txt(
'select_gap'));
255 $custom_template->setVariable(
'NUMERIC_GAP', $lng->txt(
'numeric_gap'));
256 $custom_template->setVariable(
'GAP_SIZE', $lng->txt(
'cloze_fixed_textlength'));
257 $custom_template->setVariable(
'GAP_SIZE_INFO', $lng->txt(
'cloze_gap_size_info'));
258 $custom_template->setVariable(
'ANSWER_TEXT', $lng->txt(
'answer_text'));
259 $custom_template->setVariable(
'POINTS', $lng->txt(
'points'));
260 $custom_template->setVariable(
'VALUE', $lng->txt(
'value'));
261 $custom_template->setVariable(
'UPPER_BOUND', $lng->txt(
'range_upper_limit'));
262 $custom_template->setVariable(
'LOWER_BOUND', $lng->txt(
'range_lower_limit'));
263 $custom_template->setVariable(
'ACTIONS', $lng->txt(
'actions'));
264 $custom_template->setVariable(
'REMOVE_GAP', $lng->txt(
'remove_gap'));
265 $custom_template->setVariable(
'SHUFFLE_ANSWERS', $lng->txt(
'shuffle_answers'));
266 $custom_template->setVariable(
'POINTS_ERROR', $lng->txt(
'enter_enough_positive_points'));
267 $custom_template->setVariable(
'MISSING_VALUE', $lng->txt(
'msg_input_is_required'));
268 $custom_template->setVariable(
'NOT_A_FORMULA', $lng->txt(
'err_no_formula'));
269 $custom_template->setVariable(
'NOT_A_NUMBER', $lng->txt(
'err_no_numeric_value'));
270 $custom_template->setVariable(
'CLOSE', $lng->txt(
'close'));
271 $custom_template->setVariable(
'DELETE_GAP', $lng->txt(
'are_you_sure'));
272 $custom_template->setVariable(
'PLEASE_SELECT', $lng->txt(
'please_select'));
273 $custom_template->setVariable(
'BEST_POSSIBLE_SOLUTION_HEADER', $lng->txt(
'tst_best_solution_is'));
274 $custom_template->setVariable(
'BEST_POSSIBLE_SOLUTION', $lng->txt(
'value'));
275 $custom_template->setVariable(
'MAX_POINTS', $lng->txt(
'max_points'));
276 $custom_template->setVariable(
'OUT_OF_BOUND', $lng->txt(
'out_of_range'));
277 $custom_template->setVariable(
'TYPE', $lng->txt(
'type'));
278 $custom_template->setVariable(
'VALUES', $lng->txt(
'values'));
279 $custom_template->setVariable(
'GAP_COMBINATION', $lng->txt(
'gap_combination'));
280 $custom_template->setVariable(
'COPY', $lng->txt(
'copy_of'));
281 $custom_template->setVariable(
'OK', $lng->txt(
'ok'));
282 $custom_template->setVariable(
'CANCEL', $lng->txt(
'cancel'));
283 $custom_template->setVariable(
'WHITESPACE_FRONT', $lng->txt(
'cloze_textgap_whitespace_before'));
284 $custom_template->setVariable(
'WHITESPACE_BACK', $lng->txt(
'cloze_textgap_whitespace_after'));
285 $custom_template->setVariable(
'WHITESPACE_MULTIPLE', $lng->txt(
'cloze_textgap_multiple_whitespace'));
287 $template->
setVariable(
'PROP_GENERIC', $custom_template->get());