29 $result = $this->db->queryF(
30 'SELECT combinations.combination_id, 35 combinations.best_solution, 36 combinations.question_fi, 38 FROM qpl_a_cloze_combi_res AS combinations 39 INNER JOIN qpl_a_cloze AS cloze 40 WHERE combinations.question_fi = cloze.question_fi 41 AND combinations.gap_fi = cloze.gap_id 42 AND combinations.question_fi = %s 43 ORDER BY combination_id, row_id, gap_fi ASC 50 while (
$data = $this->db->fetchAssoc($result)) {
51 if (isset($return_array[
$data[
'combination_id'] .
'::' .
$data[
'gap_fi']])) {
55 $return_array[$data[
'combination_id'] .
'::' . $data[
'row_id'] .
'::' . $data[
'gap_fi']] = [
56 'cid' => $data[
'combination_id'],
57 'gap_fi' => $data[
'gap_fi'],
58 'answer' => $data[
'answer'],
59 'points' => $data[
'points'],
60 'row_id' => $data[
'row_id'],
61 'type' => $data[
'cloze_type'],
62 'best_solution' => $data[
'best_solution']
66 return array_values($return_array);
71 $combination_from_db = $this->
loadFromDb($question_id);
73 foreach ($combination_from_db as $key => $value) {
74 $clean_array[$value[
'cid']][$value[
'row_id']][$value[
'gap_fi']][
'answer'] = $value[
'answer'];
75 $clean_array[$value[
'cid']][$value[
'row_id']][
'points'] = $value[
'points'];
76 $clean_array[$value[
'cid']][$value[
'row_id']][$value[
'gap_fi']][
'type'] = $value[
'type'];
83 array $gap_combinations,
87 for ($i = 0; $i < count($gap_combinations[
'points']); $i++) {
89 for ($j = 0; $j < count($gap_combinations[
'points'][$i]); $j++) {
90 if ($highest_points < $gap_combinations[
'points'][$i][$j]) {
91 $highest_points = $gap_combinations[
'points'][$i][$j];
92 $best_solutions[$i] = $j;
96 for ($i = 0; $i < count($gap_values); $i++) {
97 for ($j = 0; $j < count($gap_values[$i]); $j++) {
98 for ($k = 0; $k < count($gap_values[$i][$j]); $k++) {
99 if ($best_solutions[$i] == $j) {
104 $this->db->manipulateF(
105 'INSERT INTO qpl_a_cloze_combi_res 106 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
119 $gap_combinations[
'select'][$i][$k],
121 $gap_values[$i][$j][$k],
122 (
float) str_replace(
',',
'.', $gap_combinations[
'points'][$i][$j]),
132 foreach ($gap_combinations as $row) {
133 if (is_object($row)) {
134 $row = get_object_vars($row);
136 if ($question_id != -1) {
137 $this->db->manipulateF(
138 'INSERT INTO qpl_a_cloze_combi_res 139 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) 140 VALUES (%s, %s, %s, %s, %s, %s, %s)',
157 $row[
'best_solution']
166 $this->db->manipulateF(
167 'DELETE FROM qpl_a_cloze_combi_res WHERE question_fi = %s',
175 $result = $this->db->queryF(
176 'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s ORDER BY gap_fi ASC',
180 if ($result->numRows() > 0) {
188 $result = $this->db->queryF(
189 'SELECT gap_fi, combination_id FROM ' 190 . $this->db->quoteIdentifier(
'qpl_a_cloze_combi_res')
191 .
' WHERE question_fi = %s GROUP BY gap_fi, combination_id',
196 if ($result->numRows() > 0) {
197 while (
$data = $this->db->fetchAssoc($result)) {
198 $gaps[
$data[
'gap_fi']] = $data[
'combination_id'];
206 int $combination_id = -1
208 $result = $this->
fetchResult($question_id, $combination_id);
211 while ((
$data = $this->db->fetchAssoc($result)) !==
null) {
212 $points +=
$data[
'points'];
221 if ($combination_id === -1) {
222 return $this->db->queryF(
223 'SELECT combination_id, points' . PHP_EOL
224 .
'FROM qpl_a_cloze_combi_res' . PHP_EOL
225 .
'WHERE question_fi = %s' . PHP_EOL
226 .
'AND best_solution=1' . PHP_EOL
227 .
'GROUP BY combination_id, points',
232 return $this->db->queryF(
233 'SELECT combination_id, points' . PHP_EOL
234 .
'FROM qpl_a_cloze_combi_res' . PHP_EOL
235 .
'WHERE question_fi = %s' . PHP_EOL
236 .
'AND combination_id = %s' . PHP_EOL
237 .
'AND best_solution=1' . PHP_EOL
238 .
'GROUP BY combination_id, points',
239 [
'integer',
'integer'],
240 [$question_id, $combination_id]
getMaxPointsForCombination(int $question_id, int $combination_id=-1)
loadFromDb(int $question_id)
getCleanCombinationArray(int $question_id)
Class ilPDOStatement is a Wrapper Class for PDOStatement.
importGapCombinationToDb(int $question_id, array $gap_combinations)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
fetchResult(int $question_id, int $combination_id)
combinationExistsForQid($question_id)
saveGapCombinationToDb(int $question_id, array $gap_combinations, array $gap_values)
getGapsWhichAreUsedInCombination($question_id)
clearGapCombinationsFromDb($question_id)
__construct(private readonly ilDBInterface $db)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...