9 SELECT combinations.combination_id,
14 combinations.best_solution,
15 combinations.question_fi,
17 FROM qpl_a_cloze_combi_res AS combinations
18 INNER JOIN qpl_a_cloze AS cloze
19 WHERE combinations.question_fi = cloze.question_fi
20 AND combinations.gap_fi = cloze.gap_id
21 AND combinations.question_fi = %s
22 ORDER BY combination_id, row_id, gap_fi ASC
28 $return_array = array();
29 while ($data = $ilDB->fetchAssoc(
$result))
31 if( isset($return_array[$data[
'combination_id'].
'::'.$data[
'gap_fi']]) )
36 $return_array[$data[
'combination_id'].
'::'.$data[
'row_id'].
'::'.$data[
'gap_fi']]=array(
37 'cid' => $data[
'combination_id'],
38 'gap_fi' => $data[
'gap_fi'],
39 'answer' => $data[
'answer'],
40 'points' => $data[
'points'],
41 'row_id' => $data[
'row_id'],
42 'type' => $data[
'cloze_type'],
43 'best_solution' => $data[
'best_solution']
47 return array_values($return_array);
53 $combination_from_db = $assClozeGapCombinationObj->loadFromDb($question_id);
54 $clean_array = array();
55 foreach($combination_from_db as $key => $value)
57 $clean_array[$value[
'cid']][$value[
'row_id']][$value[
'gap_fi']][
'answer'] = $value[
'answer'];
58 $clean_array[$value[
'cid']][$value[
'row_id']][
'points'] = $value[
'points'];
59 $clean_array[$value[
'cid']][$value[
'row_id']][$value[
'gap_fi']][
'type'] = $value[
'type'];
67 $best_solutions = array();
68 for($i = 0; $i < count($gap_combinations[
'points']); $i++)
71 for($j = 0; $j < count($gap_combinations[
'points'][$i]); $j++)
73 if($highest_points < $gap_combinations[
'points'][$i][$j])
75 $highest_points = $gap_combinations[
'points'][$i][$j];
76 $best_solutions[$i] = $j;
80 for($i = 0; $i < count($gap_values); $i++)
82 for($j = 0; $j < count($gap_values[$i]); $j++)
84 for($k = 0; $k < count($gap_values[$i][$j]); $k++)
86 if($best_solutions[$i] == $j )
94 $ilDB->manipulateF(
'INSERT INTO qpl_a_cloze_combi_res
95 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
108 $gap_combinations[
'select'][$i][$k],
110 $gap_values[$i][$j][$k],
111 $gap_combinations[
'points'][$i][$j],
123 foreach($gap_combinations as $key =>
$row)
129 if($question_id != -1)
131 $ilDB->manipulateF(
'INSERT INTO qpl_a_cloze_combi_res
132 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
149 $row[
'best_solution']
159 $ilDB->manipulateF(
'DELETE FROM qpl_a_cloze_combi_res WHERE question_fi = %s',
161 array( $question_id )
169 $result = $ilDB->queryF(
'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s ORDER BY gap_fi ASC',
187 $result = $ilDB->queryF(
'SELECT gap_fi, combination_id FROM `qpl_a_cloze_combi_res` WHERE question_fi = %s GROUP BY gap_fi, combination_id',
194 while ($data = $ilDB->fetchAssoc(
$result))
196 $gaps[$data[
'gap_fi']] = $data[
'combination_id'];
206 if($combination_id == -1)
208 $result = $ilDB->queryF(
'SELECT combination_id, points FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 GROUP BY combination_id, points',
215 while ($data = $ilDB->fetchAssoc(
$result))
217 $points += $data[
'points'];
224 $result = $ilDB->queryF(
'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',
225 array(
'integer',
'integer'),
226 array($question_id, $combination_id)
231 while ($data = $ilDB->fetchAssoc(
$result))
233 $points += $data[
'points'];
245 $result = $ilDB->queryF(
'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 ORDER BY gap_fi',
251 $return_string =
'<br>';
254 while ($data = $ilDB->fetchAssoc(
$result))
256 if($combination_id != $data[
'combination_id'])
258 $combination_id = $data[
'combination_id'];
259 $return_string .= $points;
260 $return_string .=
'<br>';
261 $return_string .= $data[
'answer'].
'|';
265 $return_string .= $data[
'answer'].
'|';
268 $points =
' (' . $data[
'points'] .
' '. $lng->txt(
'points') .
')';
270 return rtrim($return_string ,
'|') . $points;