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'])) {
35 $this->value_combination = $value;
44 $editOrOpen = $this->value;
45 if (isset($editOrOpen[
'author'])) {
49 return (
array) $this->value_combination;
54 $return_array =
array();
56 foreach ($value as
$row) {
57 if ($row[
'row_id'] == 0) {
58 $return_array[$row[
'cid']][0][] = $row[
'gap_fi'];
60 $return_array[$row[
'cid']][1][$row[
'row_id']][] = $row[
'answer'];
61 $return_array[$row[
'cid']][2][$row[
'row_id']] = $row[
'points'];
72 $gaps_used_in_combination =
array();
73 if (array_key_exists(
'gap_combination',
$_POST)) {
76 $gap_with_points =
array();
78 for (
$i=0;
$i < count(
$_POST[
'gap_combination'][
'select']);
$i++) {
79 foreach (
$_POST[
'gap_combination'][
'select'][
$i] as
$key => $item) {
80 if ($item ==
'none_selected_minus_one') {
83 $gaps_used_in_combination[$item] = $item;
84 $check_points_for_best_scoring =
false;
85 foreach (
$_POST[
'gap_combination_values'][
$i] as
$index => $answeritems) {
86 foreach ($answeritems as $answeritem) {
87 if ($answeritem ==
'none_selected_minus_one') {
93 $check_points_for_best_scoring =
true;
96 if (!$check_points_for_best_scoring) {
107 $gapsize =
$_POST[
'gap_' . $key .
'_gapsize'];
108 $json[0][
$key]->text_field_length = $gapsize > 0 ? $gapsize :
'';
109 $select_at_least_on_positive =
false;
113 foreach ($gapText[
'answer'] as
$row => $answer) {
114 if (!isset($answer) || $answer ==
'') {
119 if (array_key_exists(
'points', $gapText)) {
120 foreach ($gapText[
'points'] as
$row => $points) {
121 if (isset($points) && $points !=
'' && is_numeric($points)) {
122 $points_sum += $points;
124 $select_at_least_on_positive =
true;
130 if (is_array($gap_with_points) && array_key_exists($key, $gap_with_points)) {
131 $points_sum += $gap_with_points[
$key];
133 if ($points_sum <= 0) {
134 if (!array_key_exists($key, $gaps_used_in_combination) && (!$getType ==
'select' || $select_at_least_on_positive ==
false)) {
140 if (!isset(
$_POST[
'shuffle_' . $key])) {
150 include_once(
"./Services/Math/classes/class.EvalMath.php");
152 $eval->suppress_errors =
true;
154 $mark_errors =
array(
'answer' =>
false,
'lower' =>
false,
'upper' =>
false,
'points' =>
false);
155 foreach (
array(
'answer' =>
'_numeric',
156 'lower' =>
'_numeric_lower',
157 'upper' =>
'_numeric_upper',
158 'points' =>
'_numeric_points') as $part => $suffix) {
160 $val = str_replace(
',',
'.', $val);
161 if ($eval->e($val) ===
false) {
162 $mark_errors[$part] =
true;
166 if ($part ==
'points') {
171 if (is_array($gap_with_points) && array_key_exists($key, $gap_with_points)) {
172 $points += $gap_with_points[
$key];
175 if (!isset($points) || $points ==
'' || !is_numeric($points) || $points == 0) {
176 if (!array_key_exists($key, $gaps_used_in_combination)) {
181 $json[0][
$key]->values[0]->error = $mark_errors;
185 $_POST[
'gap_json_post'] = json_encode($json);
200 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
202 $modal->setHeading($lng->txt(
''));
203 $modal->setId(
"ilGapModal");
207 $custom_template =
new ilTemplate(
'tpl.il_as_cloze_gap_builder.html',
true,
true,
'Modules/TestQuestionPool');
208 $custom_template->setVariable(
"MY_MODAL", $modal->getHTML());
209 $custom_template->setVariable(
'GAP_JSON', json_encode(
array($this->
getValue())));
210 $custom_template->setVariable(
'GAP', $lng->txt(
'gap'));
211 $custom_template->setVariable(
'GAP_COMBINATION_JSON', json_encode($this->
getValueCombination()));
212 $custom_template->setVariable(
'TEXT_GAP', $lng->txt(
'text_gap'));
213 $custom_template->setVariable(
'SELECT_GAP', $lng->txt(
'select_gap'));
214 $custom_template->setVariable(
'NUMERIC_GAP', $lng->txt(
'numeric_gap'));
215 $custom_template->setVariable(
'GAP_SIZE', $lng->txt(
'cloze_fixed_textlength'));
216 $custom_template->setVariable(
'GAP_SIZE_INFO', $lng->txt(
'cloze_gap_size_info'));
217 $custom_template->setVariable(
'ANSWER_TEXT', $lng->txt(
'answer_text'));
218 $custom_template->setVariable(
'POINTS', $lng->txt(
'points'));
219 $custom_template->setVariable(
'VALUE', $lng->txt(
'value'));
220 $custom_template->setVariable(
'UPPER_BOUND', $lng->txt(
'range_upper_limit'));
221 $custom_template->setVariable(
'LOWER_BOUND', $lng->txt(
'range_lower_limit'));
222 $custom_template->setVariable(
'ACTIONS', $lng->txt(
'actions'));
223 $custom_template->setVariable(
'REMOVE_GAP', $lng->txt(
'remove_gap'));
224 $custom_template->setVariable(
'SHUFFLE_ANSWERS', $lng->txt(
'shuffle_answers'));
225 $custom_template->setVariable(
'POINTS_ERROR', $lng->txt(
'enter_enough_positive_points'));
226 $custom_template->setVariable(
'MISSING_VALUE', $lng->txt(
'msg_input_is_required'));
227 $custom_template->setVariable(
'NOT_A_FORMULA', $lng->txt(
'err_no_formula'));
228 $custom_template->setVariable(
'NOT_A_NUMBER', $lng->txt(
'err_no_numeric_value'));
229 $custom_template->setVariable(
'CLOSE', $lng->txt(
'close'));
230 $custom_template->setVariable(
'DELETE_GAP', $lng->txt(
'are_you_sure'));
231 $custom_template->setVariable(
'PLEASE_SELECT', $lng->txt(
'please_select'));
232 $custom_template->setVariable(
'BEST_POSSIBLE_SOLUTION_HEADER', $lng->txt(
'tst_best_solution_is'));
233 $custom_template->setVariable(
'BEST_POSSIBLE_SOLUTION', $lng->txt(
'value'));
234 $custom_template->setVariable(
'MAX_POINTS', $lng->txt(
'max_points'));
235 $custom_template->setVariable(
'OUT_OF_BOUND', $lng->txt(
'out_of_range'));
236 $custom_template->setVariable(
'TYPE', $lng->txt(
'type'));
237 $custom_template->setVariable(
'VALUES', $lng->txt(
'values'));
238 $custom_template->setVariable(
'GAP_COMBINATION', $lng->txt(
'gap_combination'));
239 $custom_template->setVariable(
'COPY', $lng->txt(
'copy_of'));
240 $custom_template->setVariable(
'OK', $lng->txt(
'ok'));
241 $custom_template->setVariable(
'CANCEL', $lng->txt(
'cancel'));
242 $custom_template->setVariable(
'WHITESPACE_FRONT', $lng->txt(
'cloze_textgap_whitespace_before'));
243 $custom_template->setVariable(
'WHITESPACE_BACK', $lng->txt(
'cloze_textgap_whitespace_after'));
244 $custom_template->setVariable(
'WHITESPACE_MULTIPLE', $lng->txt(
'cloze_textgap_multiple_whitespace'));
246 $template->
setVariable(
'PROP_GENERIC', $custom_template->get());
const CLOZE_TEXT
Cloze question constants.
setVariable($variable, $value='')
Sets a variable value.
special template class to simplify handling of ITX/PEAR
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static getInstance()
Get instance.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...