ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
DBUpdateTestResultCalculator Class Reference
+ Collaboration diagram for DBUpdateTestResultCalculator:

Static Public Member Functions

static _updateTestResultCache ($active_id, $passScoring)
 

Data Fields

const QUESTION_SET_TYPE_FIXED = 'FIXED_QUEST_SET'
 type setting value for fixed question set More...
 
const QUESTION_SET_TYPE_RANDOM = 'RANDOM_QUEST_SET'
 type setting value for random question set More...
 
const QUESTION_SET_TYPE_DYNAMIC = 'DYNAMIC_QUEST_SET'
 type setting value for dynamic question set (continues testing mode) More...
 

Static Private Member Functions

static _getQuestionCountAndPointsForPassOfParticipant ($active_id, $pass, $questionSetType)
 
static _getWorkingTimeOfParticipantForPass ($active_id, $pass)
 
static getExamId ($active_id, $pass, $obj_id)
 
static _getResultPass ($active_id, $passScoring)
 
static _getBestPass ($active_id)
 
static _getMaxPass ($active_id)
 

Detailed Description

Definition at line 13 of file class.DBUpdateTestResultCalculator.php.

Member Function Documentation

◆ _getBestPass()

static DBUpdateTestResultCalculator::_getBestPass (   $active_id)
staticprivate

Definition at line 318 of file class.DBUpdateTestResultCalculator.php.

319 {
320 global $ilDB;
321
322 $result = $ilDB->queryF("SELECT * FROM tst_pass_result WHERE active_fi = %s",
323 array('integer'),
324 array($active_id)
325 );
326 if ($result->numRows())
327 {
328 $bestrow = null;
329 $bestfactor = 0;
330 while ($row = $ilDB->fetchAssoc($result))
331 {
332 if($row["maxpoints"] > 0)
333 {
334 $factor = $row["points"] / $row["maxpoints"];
335 }
336 else
337 {
338 $factor = 0;
339 }
340
341 if($factor > $bestfactor)
342 {
343 $bestrow = $row;
344 $bestfactor = $factor;
345 }
346 }
347 if (is_array($bestrow))
348 {
349 return $bestrow["pass"];
350 }
351 else
352 {
353 return 0;
354 }
355 }
356 else
357 {
358 return 0;
359 }
360 }
$result
global $ilDB

References $ilDB, $result, and $row.

Referenced by _getResultPass().

+ Here is the caller graph for this function:

◆ _getMaxPass()

static DBUpdateTestResultCalculator::_getMaxPass (   $active_id)
staticprivate

Definition at line 362 of file class.DBUpdateTestResultCalculator.php.

363 {
364 global $ilDB;
365 $result = $ilDB->queryF("SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
366 array('integer'),
367 array($active_id)
368 );
369 if ($result->numRows())
370 {
371 $row = $ilDB->fetchAssoc($result);
372 $max = $row["maxpass"];
373 }
374 else
375 {
376 $max = NULL;
377 }
378 return $max;
379 }

References $ilDB, $result, and $row.

Referenced by _getResultPass().

+ Here is the caller graph for this function:

◆ _getQuestionCountAndPointsForPassOfParticipant()

static DBUpdateTestResultCalculator::_getQuestionCountAndPointsForPassOfParticipant (   $active_id,
  $pass,
  $questionSetType 
)
staticprivate

Definition at line 117 of file class.DBUpdateTestResultCalculator.php.

118 {
119 global $ilDB;
120
121 switch( $questionSetType )
122 {
124
125 $res = $ilDB->queryF("
126 SELECT COUNT(qpl_questions.question_id) qcount,
127 SUM(qpl_questions.points) qsum
128 FROM tst_active
129 INNER JOIN tst_tests
130 ON tst_tests.test_id = tst_active.test_fi
131 INNER JOIN tst_dyn_quest_set_cfg
132 ON tst_dyn_quest_set_cfg.test_fi = tst_tests.test_id
133 INNER JOIN qpl_questions
134 ON qpl_questions.obj_fi = tst_dyn_quest_set_cfg.source_qpl_fi
135 AND qpl_questions.original_id IS NULL
136 AND qpl_questions.complete = %s
137 WHERE tst_active.active_id = %s
138 ",
139 array('integer', 'integer'),
140 array(1, $active_id)
141 );
142
143 break;
144
146
147 $res = $ilDB->queryF("
148 SELECT tst_test_rnd_qst.pass,
149 COUNT(tst_test_rnd_qst.question_fi) qcount,
150 SUM(qpl_questions.points) qsum
151
152 FROM tst_test_rnd_qst,
153 qpl_questions
154
155 WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id
156 AND tst_test_rnd_qst.active_fi = %s
157 AND pass = %s
158
159 GROUP BY tst_test_rnd_qst.active_fi,
160 tst_test_rnd_qst.pass
161 ",
162 array('integer', 'integer'),
163 array($active_id, $pass)
164 );
165
166 break;
167
169
170 $res = $ilDB->queryF("
171 SELECT COUNT(tst_test_question.question_fi) qcount,
172 SUM(qpl_questions.points) qsum
173
174 FROM tst_test_question,
175 qpl_questions,
176 tst_active
177
178 WHERE tst_test_question.question_fi = qpl_questions.question_id
179 AND tst_test_question.test_fi = tst_active.test_fi
180 AND tst_active.active_id = %s
181
182 GROUP BY tst_test_question.test_fi
183 ",
184 array('integer'),
185 array($active_id)
186 );
187
188 break;
189
190 default:
191
192 throw new ilTestException("not supported question set type: $questionSetType");
193 }
194
195 $row = $ilDB->fetchAssoc($res);
196
197 if( is_array($row) )
198 {
199 return array("count" => $row["qcount"], "points" => $row["qsum"]);
200 }
201
202 return array("count" => 0, "points" => 0);
203 }
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
Base Exception for all Exceptions relating to Modules/Test.

References $ilDB, $pass, $res, $row, QUESTION_SET_TYPE_DYNAMIC, QUESTION_SET_TYPE_FIXED, and QUESTION_SET_TYPE_RANDOM.

◆ _getResultPass()

static DBUpdateTestResultCalculator::_getResultPass (   $active_id,
  $passScoring 
)
staticprivate

Definition at line 304 of file class.DBUpdateTestResultCalculator.php.

305 {
306 $counted_pass = NULL;
307 if ($passScoring == SCORE_BEST_PASS)
308 {
309 $counted_pass = self::_getBestPass($active_id);
310 }
311 else
312 {
313 $counted_pass = self::_getMaxPass($active_id);
314 }
315 return $counted_pass;
316 }

References _getBestPass(), _getMaxPass(), and SCORE_BEST_PASS.

Referenced by _updateTestResultCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getWorkingTimeOfParticipantForPass()

static DBUpdateTestResultCalculator::_getWorkingTimeOfParticipantForPass (   $active_id,
  $pass 
)
staticprivate

Definition at line 205 of file class.DBUpdateTestResultCalculator.php.

206 {
207 global $ilDB;
208
209 $result = $ilDB->queryF("SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
210 array('integer','integer'),
211 array($active_id, $pass)
212 );
213 $time = 0;
214 while ($row = $ilDB->fetchAssoc($result))
215 {
216 preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row["started"], $matches);
217 $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
218 preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row["finished"], $matches);
219 $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
220 $time += ($epoch_2 - $epoch_1);
221 }
222 return $time;
223 }

References $ilDB, $pass, $result, and $row.

◆ _updateTestResultCache()

static DBUpdateTestResultCalculator::_updateTestResultCache (   $active_id,
  $passScoring 
)
static

Definition at line 248 of file class.DBUpdateTestResultCalculator.php.

249 {
250 global $ilDB;
251
252 $pass = self::_getResultPass($active_id, $passScoring);
253
254 $query = "
255 SELECT tst_pass_result.*
256 FROM tst_pass_result
257 WHERE active_fi = %s
258 AND pass = %s
259 ";
260
261 $result = $ilDB->queryF(
262 $query, array('integer','integer'), array($active_id, $pass)
263 );
264
265 $row = $ilDB->fetchAssoc($result);
266
267 $max = $row['maxpoints'];
268 $reached = $row['points'];
269
270 $obligationsAnswered = (int)$row['obligations_answered'];
271
272 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
273
274 $mark = self::_getMatchingMarkFromActiveId($active_id, $percentage);
275
276 $isPassed = ( $mark["passed"] ? 1 : 0 );
277 $isFailed = ( !$mark["passed"] ? 1 : 0 );
278
279 $query = "
280 DELETE FROM tst_result_cache
281 WHERE active_fi = %s
282 ";
283
284 $affectedRows = $ilDB->manipulateF(
285 $query, array('integer'), array($active_id)
286 );
287
288 $ilDB->insert('tst_result_cache', array(
289 'active_fi'=> array('integer', $active_id),
290 'pass'=> array('integer', strlen($pass) ? $pass : 0),
291 'max_points'=> array('float', strlen($max) ? $max : 0),
292 'reached_points'=> array('float', strlen($reached) ? $reached : 0),
293 'mark_short'=> array('text', strlen($mark["short_name"]) ? $mark["short_name"] : " "),
294 'mark_official'=> array('text', strlen($mark["official_name"]) ? $mark["official_name"] : " "),
295 'passed'=> array('integer', $isPassed),
296 'failed'=> array('integer', $isFailed),
297 'tstamp'=> array('integer', time()),
298 'hint_count'=> array('integer', $row['hint_count']),
299 'hint_points'=> array('float', $row['hint_points']),
300 'obligations_answered' => array('integer', $obligationsAnswered)
301 ));
302 }
static _getResultPass($active_id, $passScoring)

References $ilDB, $pass, $query, $result, $row, and _getResultPass().

+ Here is the call graph for this function:

◆ getExamId()

static DBUpdateTestResultCalculator::getExamId (   $active_id,
  $pass,
  $obj_id 
)
staticprivate

@TODO Move this to a proper place.

Definition at line 225 of file class.DBUpdateTestResultCalculator.php.

226 {
228 global $ilDB;
229
230 $ilSetting = new ilSetting();
231
232 $exam_id_query = 'SELECT exam_id FROM tst_pass_result WHERE active_fi = %s AND pass = %s';
233 $exam_id_result = $ilDB->queryF( $exam_id_query, array( 'integer', 'integer' ), array( $active_id, $pass ) );
234 if ($ilDB->numRows( $exam_id_result ) == 1)
235 {
236 $exam_id_row = $ilDB->fetchAssoc( $exam_id_result );
237
238 if ($exam_id_row['exam_id'] != null)
239 {
240 return $exam_id_row['exam_id'];
241 }
242 }
243
244 $inst_id = $ilSetting->get( 'inst_id', null );
245 return 'I' . $inst_id . '_T' . $obj_id . '_A' . $active_id . '_P' . $pass;
246 }
ILIAS Setting Class.
global $ilSetting
Definition: privfeed.php:40

References $ilDB, $ilSetting, and $pass.

Field Documentation

◆ QUESTION_SET_TYPE_DYNAMIC

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_DYNAMIC = 'DYNAMIC_QUEST_SET'

type setting value for dynamic question set (continues testing mode)

Definition at line 28 of file class.DBUpdateTestResultCalculator.php.

Referenced by _getQuestionCountAndPointsForPassOfParticipant().

◆ QUESTION_SET_TYPE_FIXED

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_FIXED = 'FIXED_QUEST_SET'

type setting value for fixed question set

Definition at line 18 of file class.DBUpdateTestResultCalculator.php.

Referenced by _getQuestionCountAndPointsForPassOfParticipant().

◆ QUESTION_SET_TYPE_RANDOM

const DBUpdateTestResultCalculator::QUESTION_SET_TYPE_RANDOM = 'RANDOM_QUEST_SET'

type setting value for random question set

Definition at line 23 of file class.DBUpdateTestResultCalculator.php.

Referenced by _getQuestionCountAndPointsForPassOfParticipant().


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