ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assClozeGapCombination Class Reference
+ Collaboration diagram for assClozeGapCombination:

Public Member Functions

 loadFromDb ($question_id)
 
 getCleanCombinationArray ($question_id)
 
 saveGapCombinationToDb ($question_id, $gap_combinations, $gap_values)
 
 combinationExistsForQid ($question_id)
 
 getGapsWhichAreUsedInCombination ($question_id)
 
 getMaxPointsForCombination ($question_id, $combination_id=-1)
 
 getBestSolutionCombination ($question_id)
 

Static Public Member Functions

static importGapCombinationToDb ($question_id, $gap_combinations)
 
static clearGapCombinationsFromDb ($question_id)
 

Detailed Description

Definition at line 3 of file class.assClozeGapCombination.php.

Member Function Documentation

◆ clearGapCombinationsFromDb()

static assClozeGapCombination::clearGapCombinationsFromDb (   $question_id)
static

Definition at line 144 of file class.assClozeGapCombination.php.

145 {
146 global $ilDB;
147
148 $ilDB->manipulateF(
149 'DELETE FROM qpl_a_cloze_combi_res WHERE question_fi = %s',
150 array( 'integer' ),
151 array( $question_id )
152 );
153 }
global $ilDB

References $ilDB.

Referenced by assClozeTestImport\fromXML().

+ Here is the caller graph for this function:

◆ combinationExistsForQid()

assClozeGapCombination::combinationExistsForQid (   $question_id)

Definition at line 155 of file class.assClozeGapCombination.php.

156 {
157 global $ilDB;
158
159 $result = $ilDB->queryF(
160 'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s ORDER BY gap_fi ASC',
161 array('integer'),
162 array($question_id)
163 );
164 if ($result->numRows() > 0) {
165 return true;
166 } else {
167 return false;
168 }
169 }
$result

References $ilDB, and $result.

◆ getBestSolutionCombination()

assClozeGapCombination::getBestSolutionCombination (   $question_id)

Definition at line 223 of file class.assClozeGapCombination.php.

224 {
225 global $ilDB, $lng;
226
227 $result = $ilDB->queryF(
228 'SELECT * FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 ORDER BY gap_fi',
229 array('integer'),
230 array($question_id)
231 );
232 if ($result->numRows() > 0) {
233 $return_string ='<br>';
234 $combination_id = 0;
235 $points = 0;
236 while ($data = $ilDB->fetchAssoc($result)) {
237 if ($combination_id != $data['combination_id']) {
238 $combination_id = $data['combination_id'];
239 $return_string .= $points;
240 $return_string .= '<br>';
241 $return_string .= $data['answer'] . '|';
242 } else {
243 $return_string .= $data['answer'] . '|';
244 }
245
246 $points = ' (' . $data['points'] . ' ' . $lng->txt('points') . ')';
247 }
248 return rtrim($return_string, '|') . $points;
249 } else {
250 return 0;
251 }
252 }
global $lng
Definition: privfeed.php:17

References $data, $ilDB, $lng, and $result.

◆ getCleanCombinationArray()

assClozeGapCombination::getCleanCombinationArray (   $question_id)

Definition at line 49 of file class.assClozeGapCombination.php.

50 {
51 $assClozeGapCombinationObj = new assClozeGapCombination();
52 $combination_from_db = $assClozeGapCombinationObj->loadFromDb($question_id);
53 $clean_array = array();
54 foreach ($combination_from_db as $key => $value) {
55 $clean_array[$value['cid']][$value['row_id']][$value['gap_fi']]['answer'] = $value['answer'];
56 $clean_array[$value['cid']][$value['row_id']]['points'] = $value['points'];
57 $clean_array[$value['cid']][$value['row_id']][$value['gap_fi']]['type'] = $value['type'];
58 }
59 return $clean_array;
60 }
$key
Definition: croninfo.php:18

References $key.

◆ getGapsWhichAreUsedInCombination()

assClozeGapCombination::getGapsWhichAreUsedInCombination (   $question_id)

Definition at line 171 of file class.assClozeGapCombination.php.

172 {
173 global $ilDB;
174
175 $result = $ilDB->queryF(
176 'SELECT gap_fi, combination_id FROM ' . $ilDB->quoteIdentifier('qpl_a_cloze_combi_res') . ' WHERE question_fi = %s GROUP BY gap_fi, combination_id',
177 array('integer'),
178 array($question_id)
179 );
180 $gaps = array();
181 if ($result->numRows() > 0) {
182 while ($data = $ilDB->fetchAssoc($result)) {
183 $gaps[$data['gap_fi']] = $data['combination_id'];
184 }
185 }
186 return $gaps;
187 }

References $data, $ilDB, and $result.

◆ getMaxPointsForCombination()

assClozeGapCombination::getMaxPointsForCombination (   $question_id,
  $combination_id = -1 
)

Definition at line 189 of file class.assClozeGapCombination.php.

190 {
191 global $ilDB;
192
193 if ($combination_id == -1) {
194 $result = $ilDB->queryF(
195 'SELECT combination_id, points FROM qpl_a_cloze_combi_res WHERE question_fi = %s AND best_solution=1 GROUP BY combination_id, points',
196 array('integer'),
197 array($question_id)
198 );
199 if ($result->numRows() > 0) {
200 $points = 0;
201 while ($data = $ilDB->fetchAssoc($result)) {
202 $points += $data['points'];
203 }
204 return $points;
205 }
206 } else {
207 $result = $ilDB->queryF(
208 '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',
209 array('integer', 'integer'),
210 array($question_id, $combination_id)
211 );
212 if ($result->numRows() > 0) {
213 $points = 0;
214 while ($data = $ilDB->fetchAssoc($result)) {
215 $points += $data['points'];
216 }
217 return $points;
218 }
219 }
220 return 0;
221 }

References $data, $ilDB, and $result.

◆ importGapCombinationToDb()

static assClozeGapCombination::importGapCombinationToDb (   $question_id,
  $gap_combinations 
)
static

Definition at line 109 of file class.assClozeGapCombination.php.

110 {
111 global $ilDB;
112
113 foreach ($gap_combinations as $key => $row) {
114 if (is_object($row)) {
115 $row = get_object_vars($row);
116 }
117 if ($question_id != -1) {
118 $ilDB->manipulateF(
119 'INSERT INTO qpl_a_cloze_combi_res
120 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
121 array(
122 'integer',
123 'integer',
124 'integer',
125 'integer',
126 'text',
127 'float',
128 'integer'
129 ),
130 array(
131 $row['cid'],
132 $question_id,
133 $row['gap_fi'],
134 $row['row_id'],
135 $row['answer'],
136 $row['points'],
137 $row['best_solution']
138 )
139 );
140 }
141 }
142 }

References $ilDB, $key, and $row.

Referenced by assClozeTestImport\fromXML().

+ Here is the caller graph for this function:

◆ loadFromDb()

assClozeGapCombination::loadFromDb (   $question_id)

Definition at line 5 of file class.assClozeGapCombination.php.

6 {
7 global $ilDB;
8 $result = $ilDB->queryF(
9 '
10 SELECT combinations.combination_id,
11 combinations.gap_fi,
12 combinations.answer,
13 combinations.row_id,
14 combinations.points,
15 combinations.best_solution,
16 combinations.question_fi,
17 cloze.cloze_type
18 FROM qpl_a_cloze_combi_res AS combinations
19 INNER JOIN qpl_a_cloze AS cloze
20 WHERE combinations.question_fi = cloze.question_fi
21 AND combinations.gap_fi = cloze.gap_id
22 AND combinations.question_fi = %s
23 ORDER BY combination_id, row_id, gap_fi ASC
24 ',
25 array('integer'),
26 array($question_id)
27 );
28
29 $return_array = array();
30 while ($data = $ilDB->fetchAssoc($result)) {
31 if (isset($return_array[$data['combination_id'] . '::' . $data['gap_fi']])) {
32 continue;
33 }
34
35 $return_array[$data['combination_id'] . '::' . $data['row_id'] . '::' . $data['gap_fi']]=array(
36 'cid' => $data['combination_id'],
37 'gap_fi' => $data['gap_fi'],
38 'answer' => $data['answer'],
39 'points' => $data['points'],
40 'row_id' => $data['row_id'],
41 'type' => $data['cloze_type'],
42 'best_solution' => $data['best_solution']
43 );
44 }
45
46 return array_values($return_array);
47 }

References $data, $ilDB, and $result.

◆ saveGapCombinationToDb()

assClozeGapCombination::saveGapCombinationToDb (   $question_id,
  $gap_combinations,
  $gap_values 
)

Definition at line 62 of file class.assClozeGapCombination.php.

63 {
64 global $ilDB;
65 $best_solutions = array();
66 for ($i = 0; $i < count($gap_combinations['points']); $i++) {
67 $highest_points = 0;
68 for ($j = 0; $j < count($gap_combinations['points'][$i]); $j++) {
69 if ($highest_points < $gap_combinations['points'][$i][$j]) {
70 $highest_points = $gap_combinations['points'][$i][$j];
71 $best_solutions[$i] = $j;
72 }
73 }
74 }
75 for ($i = 0; $i < count($gap_values); $i++) {
76 for ($j = 0; $j < count($gap_values[$i]); $j++) {
77 for ($k = 0; $k < count($gap_values[$i][$j]); $k++) {
78 if ($best_solutions[$i] == $j) {
79 $best_solution = 1;
80 } else {
81 $best_solution = 0;
82 }
83 $ilDB->manipulateF(
84 'INSERT INTO qpl_a_cloze_combi_res
85 (combination_id, question_fi, gap_fi, row_id, answer, points, best_solution) VALUES (%s, %s, %s, %s, %s, %s, %s)',
86 array(
87 'integer',
88 'integer',
89 'integer',
90 'integer',
91 'text',
92 'float',
93 'integer'
94 ),
95 array(
96 $i,
97 $question_id,
98 $gap_combinations['select'][$i][$k],
99 $j,
100 $gap_values[$i][$j][$k],
101 $gap_combinations['points'][$i][$j],
102 $best_solution
103 )
104 );
105 }
106 }
107 }
108 }
$i
Definition: disco.tpl.php:19

References $i, and $ilDB.


The documentation for this class was generated from the following file: