25         $result = 
$ilDB->queryF(
    27                                                                         SELECT  combinations.combination_id,    32                                                                                         combinations.best_solution,    33                                                                                         combinations.question_fi,    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    46         $return_array = array();
    48             if (isset($return_array[
$data[
'combination_id'] . 
'::' . 
$data[
'gap_fi']])) {
    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']
    63         return array_values($return_array);
    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'];
    83         $best_solutions = array();
    84         for ($i = 0; $i < count($gap_combinations[
'points']); $i++) {
    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;
    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) {
   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)',
   116                             $gap_combinations[
'select'][$i][$k],
   118                             $gap_values[$i][$j][$k],
   119                             (
float) str_replace(
',', 
'.', $gap_combinations[
'points'][$i][$j]),
   130         $ilDB = $DIC[
'ilDB'];
   132         foreach ($gap_combinations as 
$key => $row) {
   133             if (is_object($row)) {
   134                 $row = get_object_vars($row);
   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)',
   156                         $row[
'best_solution']
   166         $ilDB = $DIC[
'ilDB'];
   169             'DELETE FROM qpl_a_cloze_combi_res WHERE question_fi = %s',
   171             array( $question_id )
   178         $ilDB = $DIC[
'ilDB'];
   180         $result = 
$ilDB->queryF(
   181             'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s ORDER BY gap_fi ASC',
   185         if ($result->numRows() > 0) {
   195         $ilDB = $DIC[
'ilDB'];
   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',
   203         if ($result->numRows() > 0) {
   205                 $gaps[
$data[
'gap_fi']] = $data[
'combination_id'];
   214         $ilDB = $DIC[
'ilDB'];
   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',
   222             if ($result->numRows() > 0) {
   225                     $points += 
$data[
'points'];
   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)
   235             if ($result->numRows() > 0) {
   238                     $points += 
$data[
'points'];
   249         $ilDB = $DIC[
'ilDB'];
   252         $result = 
$ilDB->queryF(
   253             'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 ORDER BY gap_fi',
   257         if ($result->numRows() > 0) {
   258             $return_string = 
'<br>';
   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'] . 
'|';
   268                     $return_string .= 
$data[
'answer'] . 
'|';
   271                 $points = 
' (' . 
$data[
'points'] . 
' ' . 
$lng->txt(
'points') . 
')';
   273             return rtrim($return_string, 
'|') . $points;
 
getMaxPointsForCombination(int $question_id, int $combination_id=-1)
 
static importGapCombinationToDb($question_id, $gap_combinations)
 
saveGapCombinationToDb($question_id, $gap_combinations, $gap_values)
 
getBestSolutionCombination($question_id)
 
getCleanCombinationArray($question_id)
 
combinationExistsForQid($question_id)
 
static clearGapCombinationsFromDb($question_id)
 
getGapsWhichAreUsedInCombination($question_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...