This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning
Definition at line 19 of file class.assClozeGapCombination.php.
◆ clearGapCombinationsFromDb()
| static assClozeGapCombination::clearGapCombinationsFromDb |
( |
|
$question_id | ) |
|
|
static |
◆ combinationExistsForQid()
| assClozeGapCombination::combinationExistsForQid |
( |
|
$question_id | ) |
|
Definition at line 175 of file class.assClozeGapCombination.php.
175 : bool
176 {
179
180 $result =
$ilDB->queryF(
181 'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s ORDER BY gap_fi ASC',
182 array('integer'),
183 array($question_id)
184 );
185 if ($result->numRows() > 0) {
186 return true;
187 } else {
188 return false;
189 }
190 }
References $DIC, and $ilDB.
◆ getBestSolutionCombination()
| assClozeGapCombination::getBestSolutionCombination |
( |
|
$question_id | ) |
|
Definition at line 246 of file class.assClozeGapCombination.php.
247 {
251
252 $result =
$ilDB->queryF(
253 'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 ORDER BY gap_fi',
254 array('integer'),
255 array($question_id)
256 );
257 if ($result->numRows() > 0) {
258 $return_string = '<br>';
259 $combination_id = 0;
260 $points = 0;
262 if ($combination_id !=
$data[
'combination_id']) {
263 $combination_id =
$data[
'combination_id'];
264 $return_string .= $points;
265 $return_string .= '<br>';
266 $return_string .=
$data[
'answer'] .
'|';
267 } else {
268 $return_string .=
$data[
'answer'] .
'|';
269 }
270
271 $points =
' (' .
$data[
'points'] .
' ' .
$lng->txt(
'points') .
')';
272 }
273 return rtrim($return_string, '|') . $points;
274 } else {
275 return 0;
276 }
277 }
References $data, $DIC, $ilDB, and $lng.
◆ getCleanCombinationArray()
| assClozeGapCombination::getCleanCombinationArray |
( |
|
$question_id | ) |
|
Definition at line 66 of file class.assClozeGapCombination.php.
66 : array
67 {
69 $combination_from_db = $assClozeGapCombinationObj->loadFromDb($question_id);
70 $clean_array = array();
71 foreach ($combination_from_db as
$key => $value) {
72 $clean_array[$value['cid']][$value['row_id']][$value['gap_fi']]['answer'] = $value['answer'];
73 $clean_array[$value['cid']][$value['row_id']]['points'] = $value['points'];
74 $clean_array[$value['cid']][$value['row_id']][$value['gap_fi']]['type'] = $value['type'];
75 }
76 return $clean_array;
77 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
References ILIAS\LTI\ToolProvider\$key.
◆ getGapsWhichAreUsedInCombination()
| assClozeGapCombination::getGapsWhichAreUsedInCombination |
( |
|
$question_id | ) |
|
Definition at line 192 of file class.assClozeGapCombination.php.
192 : array
193 {
196
197 $result =
$ilDB->queryF(
198 'SELECT gap_fi, combination_id FROM ' .
$ilDB->quoteIdentifier(
'qpl_a_cloze_combi_res') .
' WHERE question_fi = %s GROUP BY gap_fi, combination_id',
199 array('integer'),
200 array($question_id)
201 );
202 $gaps = array();
203 if ($result->numRows() > 0) {
205 $gaps[
$data[
'gap_fi']] =
$data[
'combination_id'];
206 }
207 }
208 return $gaps;
209 }
References $data, $DIC, and $ilDB.
◆ getMaxPointsForCombination()
| assClozeGapCombination::getMaxPointsForCombination |
( |
int |
$question_id, |
|
|
int |
$combination_id = -1 |
|
) |
| |
Definition at line 211 of file class.assClozeGapCombination.php.
211 : float
212 {
215
216 if ($combination_id == -1) {
217 $result =
$ilDB->queryF(
218 'SELECT combination_id, points FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 GROUP BY combination_id, points',
219 array('integer'),
220 array($question_id)
221 );
222 if ($result->numRows() > 0) {
223 $points = 0;
225 $points +=
$data[
'points'];
226 }
227 return $points;
228 }
229 } else {
230 $result =
$ilDB->queryF(
231 'SELECT combination_id, points FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND combination_id = %s AND best_solution=1 GROUP BY combination_id, points',
232 array('integer', 'integer'),
233 array($question_id, $combination_id)
234 );
235 if ($result->numRows() > 0) {
236 $points = 0;
238 $points +=
$data[
'points'];
239 }
240 return $points;
241 }
242 }
243 return 0;
244 }
References $data, $DIC, and $ilDB.
◆ importGapCombinationToDb()
| static assClozeGapCombination::importGapCombinationToDb |
( |
|
$question_id, |
|
|
|
$gap_combinations |
|
) |
| |
|
static |
Definition at line 127 of file class.assClozeGapCombination.php.
127 : void
128 {
131
132 foreach ($gap_combinations as
$key => $row) {
133 if (is_object($row)) {
134 $row = get_object_vars($row);
135 }
136 if ($question_id != -1) {
138 'INSERT INTO qpl_a_cloze_combi_res
139 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
140 array(
141 'integer',
142 'integer',
143 'integer',
144 'integer',
145 'text',
146 'float',
147 'integer'
148 ),
149 array(
150 $row['cid'],
151 $question_id,
152 $row['gap_fi'],
153 $row['row_id'],
154 $row['answer'],
155 $row['points'],
156 $row['best_solution']
157 )
158 );
159 }
160 }
161 }
References $DIC, $ilDB, and ILIAS\LTI\ToolProvider\$key.
Referenced by assClozeTestImport\fromXML().
◆ loadFromDb()
| assClozeGapCombination::loadFromDb |
( |
|
$question_id | ) |
|
Definition at line 21 of file class.assClozeGapCombination.php.
21 : array
22 {
25 $result =
$ilDB->queryF(
26 '
27 SELECT combinations.combination_id,
28 combinations.gap_fi,
29 combinations.answer,
30 combinations.row_id,
31 combinations.points,
32 combinations.best_solution,
33 combinations.question_fi,
34 cloze.cloze_type
35 FROM qpl_a_cloze_combi_res AS combinations
36 INNER JOIN qpl_a_cloze AS cloze
37 WHERE combinations.question_fi = cloze.question_fi
38 AND combinations.gap_fi = cloze.gap_id
39 AND combinations.question_fi = %s
40 ORDER BY combination_id, row_id, gap_fi ASC
41 ',
42 array('integer'),
43 array($question_id)
44 );
45
46 $return_array = array();
48 if (isset($return_array[
$data[
'combination_id'] .
'::' .
$data[
'gap_fi']])) {
49 continue;
50 }
51
52 $return_array[
$data[
'combination_id'] .
'::' .
$data[
'row_id'] .
'::' .
$data[
'gap_fi']] = array(
53 'cid' =>
$data[
'combination_id'],
54 'gap_fi' =>
$data[
'gap_fi'],
55 'answer' =>
$data[
'answer'],
56 'points' =>
$data[
'points'],
57 'row_id' =>
$data[
'row_id'],
58 'type' =>
$data[
'cloze_type'],
59 'best_solution' =>
$data[
'best_solution']
60 );
61 }
62
63 return array_values($return_array);
64 }
References $data, $DIC, and $ilDB.
◆ saveGapCombinationToDb()
| assClozeGapCombination::saveGapCombinationToDb |
( |
|
$question_id, |
|
|
|
$gap_combinations, |
|
|
|
$gap_values |
|
) |
| |
Definition at line 79 of file class.assClozeGapCombination.php.
79 : void
80 {
83 $best_solutions = array();
84 for (
$i = 0;
$i < count($gap_combinations[
'points']);
$i++) {
85 $highest_points = 0;
86 for ($j = 0; $j < count($gap_combinations[
'points'][
$i]); $j++) {
87 if ($highest_points < $gap_combinations[
'points'][
$i][$j]) {
88 $highest_points = $gap_combinations[
'points'][
$i][$j];
89 $best_solutions[
$i] = $j;
90 }
91 }
92 }
93 for (
$i = 0;
$i < count($gap_values);
$i++) {
94 for ($j = 0; $j < count($gap_values[
$i]); $j++) {
95 for ($k = 0; $k < count($gap_values[
$i][$j]); $k++) {
96 if ($best_solutions[
$i] == $j) {
97 $best_solution = 1;
98 } else {
99 $best_solution = 0;
100 }
102 'INSERT INTO qpl_a_cloze_combi_res
103 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
104 array(
105 'integer',
106 'integer',
107 'integer',
108 'integer',
109 'text',
110 'float',
111 'integer'
112 ),
113 array(
115 $question_id,
116 $gap_combinations[
'select'][
$i][$k],
117 $j,
118 $gap_values[
$i][$j][$k],
119 (
float) str_replace(
',',
'.', $gap_combinations[
'points'][
$i][$j]),
120 $best_solution
121 )
122 );
123 }
124 }
125 }
126 }
References $DIC, $i, and $ilDB.
The documentation for this class was generated from the following file: