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.
◆ __construct()
assClozeGapCombination::__construct |
( |
private readonly ilDBInterface |
$db | ) |
|
◆ clearGapCombinationsFromDb()
assClozeGapCombination::clearGapCombinationsFromDb |
( |
|
$question_id | ) |
|
◆ combinationExistsForQid()
assClozeGapCombination::combinationExistsForQid |
( |
|
$question_id | ) |
|
Definition at line 173 of file class.assClozeGapCombination.php.
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) {
◆ fetchResult()
assClozeGapCombination::fetchResult |
( |
int |
$question_id, |
|
|
int |
$combination_id |
|
) |
| |
|
private |
Definition at line 217 of file class.assClozeGapCombination.php.
Referenced by getMaxPointsForCombination().
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]
Class ilPDOStatement is a Wrapper Class for PDOStatement.
◆ getCleanCombinationArray()
assClozeGapCombination::getCleanCombinationArray |
( |
int |
$question_id | ) |
|
Definition at line 69 of file class.assClozeGapCombination.php.
References loadFromDb().
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'];
loadFromDb(int $question_id)
◆ getGapsWhichAreUsedInCombination()
assClozeGapCombination::getGapsWhichAreUsedInCombination |
( |
|
$question_id | ) |
|
Definition at line 186 of file class.assClozeGapCombination.php.
References $data.
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'];
◆ getMaxPointsForCombination()
assClozeGapCombination::getMaxPointsForCombination |
( |
int |
$question_id, |
|
|
int |
$combination_id = -1 |
|
) |
| |
◆ importGapCombinationToDb()
assClozeGapCombination::importGapCombinationToDb |
( |
int |
$question_id, |
|
|
array |
$gap_combinations |
|
) |
| |
Definition at line 130 of file class.assClozeGapCombination.php.
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']
◆ loadFromDb()
assClozeGapCombination::loadFromDb |
( |
int |
$question_id | ) |
|
Definition at line 27 of file class.assClozeGapCombination.php.
References $data.
Referenced by getCleanCombinationArray().
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);
◆ saveGapCombinationToDb()
assClozeGapCombination::saveGapCombinationToDb |
( |
int |
$question_id, |
|
|
array |
$gap_combinations, |
|
|
array |
$gap_values |
|
) |
| |
Definition at line 81 of file class.assClozeGapCombination.php.
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]),
The documentation for this class was generated from the following file: