ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestSequence Class Reference

Test sequence handler. More...

+ Inheritance diagram for ilTestSequence:
+ Collaboration diagram for ilTestSequence:

Public Member Functions

 __construct ($active_id, $pass, $randomtest)
 ilTestSequence constructor More...
 
 getActiveId ()
 
 createNewSequence ($max, $shuffle)
 
 loadQuestions (ilTestQuestionSetConfig $testQuestionSetConfig=null, $taxonomyFilterSelection=array())
 Loads the question mapping. More...
 
 loadFromDb ()
 Loads the sequence data for a given active id. More...
 
 saveToDb ()
 Saves the sequence data for a given pass to the database. More...
 
 postponeQuestion ($question_id)
 
 hideQuestion ($question_id)
 
 isPostponedQuestion ($question_id)
 
 isHiddenQuestion ($question_id)
 
 isPostponedSequence ($sequence)
 
 isHiddenSequence ($sequence)
 
 postponeSequence ($sequence)
 
 hideSequence ($sequence)
 
 setQuestionChecked ($questionId)
 
 isQuestionChecked ($questionId)
 
 getPositionOfSequence ($sequence)
 
 getUserQuestionCount ()
 
 getOrderedSequence ()
 
 getOrderedSequenceQuestions ()
 
 getUserSequence ()
 
 getUserSequenceQuestions ()
 
 getSequenceForQuestion ($question_id)
 
 getFirstSequence ()
 
 getLastSequence ()
 
 getNextSequence ($sequence)
 
 getPreviousSequence ($sequence)
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getQuestionForSequence ($sequence)
 
 getSequenceSummary ($obligationsFilterEnabled=false)
 
 getPass ()
 
 setPass ($pass)
 
 hasSequence ()
 
 hasHiddenQuestions ()
 
 clearHiddenQuestions ()
 
 hasStarted (ilTestSession $testSession)
 
 openQuestionExists ()
 
 getQuestionIds ()
 
 questionExists ($questionId)
 
 setQuestionOptional ($questionId)
 
 isQuestionOptional ($questionId)
 
 hasOptionalQuestions ()
 
 getOptionalQuestions ()
 
 clearOptionalQuestions ()
 
 reorderOptionalQuestionsToSequenceEnd ()
 
 isAnsweringOptionalQuestionsConfirmed ()
 
 setAnsweringOptionalQuestionsConfirmed ($answeringOptionalQuestionsConfirmed)
 
 isConsiderHiddenQuestionsEnabled ()
 
 setConsiderHiddenQuestionsEnabled ($considerHiddenQuestionsEnabled)
 
 isConsiderOptionalQuestionsEnabled ()
 
 setConsiderOptionalQuestionsEnabled ($considerOptionalQuestionsEnabled)
 

Data Fields

 $sequencedata
 
 $questions
 
 $active_id
 
 $pass
 
 $isRandomTest
 

Protected Member Functions

 getCorrectedSequence ()
 

Private Member Functions

 loadQuestionSequence ()
 
 loadCheckedQuestions ()
 
 loadOptionalQuestions ()
 
 saveQuestionSequence ()
 
 saveNewlyCheckedQuestion ()
 ilDBInterface $ilDB More...
 
 saveOptionalQuestions ()
 ilDBInterface $ilDB More...
 
 ensureQuestionNotInSequence ($sequence, $questionId)
 
 hideCorrectAnsweredQuestions (ilObjTest $testOBJ, $activeId, $pass)
 

Private Attributes

 $alreadyCheckedQuestions
 
 $newlyCheckedQuestion
 
 $optionalQuestions
 
 $answeringOptionalQuestionsConfirmed
 
 $considerHiddenQuestionsEnabled
 
 $considerOptionalQuestionsEnabled
 

Detailed Description

Test sequence handler.

This class manages the sequence settings for a given user

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 16 of file class.ilTestSequence.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSequence::__construct (   $active_id,
  $pass,
  $randomtest 
)

ilTestSequence constructor

The constructor takes possible arguments an creates an instance of the ilTestSequence object.

Parameters
object$a_objectA reference to the test container object public

Definition at line 92 of file class.ilTestSequence.php.

References $active_id, $pass, and array.

93  {
94  $this->active_id = $active_id;
95  $this->pass = $pass;
96  $this->isRandomTest = $randomtest;
97  $this->sequencedata = array(
98  "sequence" => array(),
99  "postponed" => array(),
100  "hidden" => array()
101  );
102 
103  $this->alreadyCheckedQuestions = array();
104  $this->newlyCheckedQuestion = null;
105 
106  $this->optionalQuestions = array();
107  $this->answeringOptionalQuestionsConfirmed = false;
108 
109  $this->considerHiddenQuestionsEnabled = false;
110  $this->considerOptionalQuestionsEnabled = true;
111  }
Create styles array
The data for the language used.

Member Function Documentation

◆ clearHiddenQuestions()

ilTestSequence::clearHiddenQuestions ( )

Definition at line 719 of file class.ilTestSequence.php.

References array.

Referenced by ilLOTestQuestionAdapter\hideQuestions().

720  {
721  $this->sequencedata["hidden"] = array();
722  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ clearOptionalQuestions()

ilTestSequence::clearOptionalQuestions ( )

Definition at line 796 of file class.ilTestSequence.php.

References array.

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

797  {
798  $this->optionalQuestions = array();
799  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ createNewSequence()

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

Definition at line 118 of file class.ilTestSequence.php.

References array, and pcArrayShuffle().

119  {
120  $newsequence = array();
121  if ($max > 0)
122  {
123  for ($i = 1; $i <= $max; $i++)
124  {
125  array_push($newsequence, $i);
126  }
127  if ($shuffle) $newsequence = $this->pcArrayShuffle($newsequence);
128  }
129  $this->sequencedata["sequence"] = $newsequence;
130  }
Create styles array
The data for the language used.
pcArrayShuffle($array)
Shuffles the values of a given array.
+ Here is the call graph for this function:

◆ ensureQuestionNotInSequence()

ilTestSequence::ensureQuestionNotInSequence (   $sequence,
  $questionId 
)
private

Definition at line 485 of file class.ilTestSequence.php.

Referenced by getCorrectedSequence().

486  {
487  $questionKey = array_search($questionId, $this->questions);
488 
489  if( $questionKey === false )
490  {
491  return $sequence;
492  }
493 
494  $sequenceKey = array_search($questionKey, $sequence);
495 
496  if( $sequenceKey === FALSE )
497  {
498  return $sequence;
499  }
500 
501  unset($sequence[$sequenceKey]);
502 
503  return $sequence;
504  }
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestSequence::getActiveId ( )

Implements ilTestSequenceSummaryProvider.

Definition at line 113 of file class.ilTestSequence.php.

References $active_id.

114  {
115  return $this->active_id;
116  }

◆ getCorrectedSequence()

ilTestSequence::getCorrectedSequence ( )
protected

Definition at line 506 of file class.ilTestSequence.php.

References ensureQuestionNotInSequence(), isConsiderHiddenQuestionsEnabled(), and isConsiderOptionalQuestionsEnabled().

Referenced by getFirstSequence(), getLastSequence(), getNextSequence(), getPositionOfSequence(), getPreviousSequence(), getSequenceSummary(), getUserQuestionCount(), getUserSequence(), and getUserSequenceQuestions().

507  {
508  $correctedsequence = $this->sequencedata["sequence"];
509  if( !$this->isConsiderHiddenQuestionsEnabled() )
510  {
511  if (is_array($this->sequencedata["hidden"]))
512  {
513  foreach ($this->sequencedata["hidden"] as $question_id)
514  {
515  $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $question_id);
516  }
517  }
518  }
519  if( !$this->isConsiderOptionalQuestionsEnabled() )
520  {
521  foreach($this->optionalQuestions as $questionId)
522  {
523  $correctedsequence = $this->ensureQuestionNotInSequence($correctedsequence, $questionId);
524  }
525  }
526  if (is_array($this->sequencedata["postponed"]))
527  {
528  foreach ($this->sequencedata["postponed"] as $question_id)
529  {
530  $foundsequence = array_search($question_id, $this->questions);
531  if ($foundsequence !== FALSE)
532  {
533  $sequencekey = array_search($foundsequence, $correctedsequence);
534  if ($sequencekey !== FALSE)
535  {
536  unset($correctedsequence[$sequencekey]);
537  array_push($correctedsequence, $foundsequence);
538  }
539  }
540  }
541  }
542  return array_values($correctedsequence);
543  }
ensureQuestionNotInSequence($sequence, $questionId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFirstSequence()

ilTestSequence::getFirstSequence ( )

Definition at line 550 of file class.ilTestSequence.php.

References getCorrectedSequence().

Referenced by hasStarted(), and openQuestionExists().

551  {
552  $correctedsequence = $this->getCorrectedSequence();
553  if (count($correctedsequence))
554  {
555  return reset($correctedsequence);
556  }
557  else
558  {
559  return FALSE;
560  }
561  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastSequence()

ilTestSequence::getLastSequence ( )

Definition at line 563 of file class.ilTestSequence.php.

References getCorrectedSequence().

564  {
565  $correctedsequence = $this->getCorrectedSequence();
566  if (count($correctedsequence))
567  {
568  return end($correctedsequence);
569  }
570  else
571  {
572  return FALSE;
573  }
574  }
+ Here is the call graph for this function:

◆ getNextSequence()

ilTestSequence::getNextSequence (   $sequence)

Definition at line 576 of file class.ilTestSequence.php.

References getCorrectedSequence().

577  {
578  $correctedsequence = $this->getCorrectedSequence();
579  $sequencekey = array_search($sequence, $correctedsequence);
580  if ($sequencekey !== FALSE)
581  {
582  $nextsequencekey = $sequencekey + 1;
583  if (array_key_exists($nextsequencekey, $correctedsequence))
584  {
585  return $correctedsequence[$nextsequencekey];
586  }
587  }
588  return FALSE;
589  }
+ Here is the call graph for this function:

◆ getOptionalQuestions()

ilTestSequence::getOptionalQuestions ( )

Definition at line 791 of file class.ilTestSequence.php.

References $optionalQuestions.

792  {
794  }

◆ getOrderedSequence()

ilTestSequence::getOrderedSequence ( )

Definition at line 425 of file class.ilTestSequence.php.

References array, isConsiderHiddenQuestionsEnabled(), isConsiderOptionalQuestionsEnabled(), and isHiddenSequence().

426  {
427  $sequenceKeys = array();
428 
429  foreach(array_keys($this->questions) as $sequenceKey)
430  {
431  if( $this->isHiddenSequence($sequenceKey) && !$this->isConsiderHiddenQuestionsEnabled() )
432  {
433  continue;
434  }
435 
436  if( $this->isSequenceOptional($sequenceKey) && !$this->isConsiderOptionalQuestionsEnabled() )
437  {
438  continue;
439  }
440 
441  $sequenceKeys[] = $sequenceKey;
442  }
443 
444  return $sequenceKeys;
445  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getOrderedSequenceQuestions()

ilTestSequence::getOrderedSequenceQuestions ( )

Definition at line 447 of file class.ilTestSequence.php.

References $questions, array, isConsiderHiddenQuestionsEnabled(), isConsiderOptionalQuestionsEnabled(), isHiddenQuestion(), and isQuestionOptional().

448  {
449  $questions = array();
450 
451  foreach($this->questions as $questionId)
452  {
453  if( $this->isHiddenQuestion($questionId) && !$this->isConsiderHiddenQuestionsEnabled() )
454  {
455  continue;
456  }
457 
458  if( $this->isQuestionOptional($questionId) && !$this->isConsiderOptionalQuestionsEnabled() )
459  {
460  continue;
461  }
462 
463  $questions[] = $questionId;
464  }
465 
466  return $questions;
467  }
isQuestionOptional($questionId)
Create styles array
The data for the language used.
isHiddenQuestion($question_id)
+ Here is the call graph for this function:

◆ getPass()

ilTestSequence::getPass ( )

Definition at line 685 of file class.ilTestSequence.php.

References $pass.

686  {
687  return $this->pass;
688  }

◆ getPositionOfSequence()

ilTestSequence::getPositionOfSequence (   $sequence)

Definition at line 406 of file class.ilTestSequence.php.

References getCorrectedSequence().

407  {
408  $correctedsequence = $this->getCorrectedSequence();
409  $sequencekey = array_search($sequence, $correctedsequence);
410  if ($sequencekey !== FALSE)
411  {
412  return $sequencekey + 1;
413  }
414  else
415  {
416  return "";
417  }
418  }
+ Here is the call graph for this function:

◆ getPreviousSequence()

ilTestSequence::getPreviousSequence (   $sequence)

Definition at line 591 of file class.ilTestSequence.php.

References getCorrectedSequence().

592  {
593  $correctedsequence = $this->getCorrectedSequence();
594  $sequencekey = array_search($sequence, $correctedsequence);
595  if ($sequencekey !== FALSE)
596  {
597  $prevsequencekey = $sequencekey - 1;
598  if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence)))
599  {
600  return $correctedsequence[$prevsequencekey];
601  }
602  }
603  return FALSE;
604  }
+ Here is the call graph for this function:

◆ getQuestionForSequence()

ilTestSequence::getQuestionForSequence (   $sequence)

Definition at line 626 of file class.ilTestSequence.php.

Referenced by getSequenceSummary(), getUserSequenceQuestions(), and reorderOptionalQuestionsToSequenceEnd().

627  {
628  if ($sequence < 1) return FALSE;
629  if (array_key_exists($sequence, $this->questions))
630  {
631  return $this->questions[$sequence];
632  }
633  else
634  {
635  return FALSE;
636  }
637  }
+ Here is the caller graph for this function:

◆ getQuestionIds()

ilTestSequence::getQuestionIds ( )

Implements ilTestQuestionSequence.

Definition at line 766 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\hideQuestions(), ilLOTestQuestionAdapter\setQuestionsOptional(), ilLOTestQuestionAdapter\updateRandomQuestions(), and ilLOTestQuestionAdapter\updateSeparateTestQuestions().

767  {
768  return array_values($this->questions);
769  }
+ Here is the caller graph for this function:

◆ getSequenceForQuestion()

ilTestSequence::getSequenceForQuestion (   $question_id)

Definition at line 545 of file class.ilTestSequence.php.

546  {
547  return array_search($question_id, $this->questions);
548  }

◆ getSequenceSummary()

ilTestSequence::getSequenceSummary (   $obligationsFilterEnabled = false)

Implements ilTestSequenceSummaryProvider.

Definition at line 639 of file class.ilTestSequence.php.

References $pass, $row, ilObjTest\_getSolvedQuestions(), ilObjTest\_instanciateQuestion(), array, getCorrectedSequence(), getQuestionForSequence(), isPostponedQuestion(), and ilObjTest\isQuestionObligatory().

640  {
641  $correctedsequence = $this->getCorrectedSequence();
642  $result_array = array();
643  include_once "./Modules/Test/classes/class.ilObjTest.php";
644  $solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
645  $key = 1;
646  foreach ($correctedsequence as $sequence)
647  {
648  $question =& ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
649  if (is_object($question))
650  {
651  $worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
652  $solved = 0;
653  if (array_key_exists($question->getId(), $solved_questions))
654  {
655  $solved = $solved_questions[$question->getId()]["solved"];
656  }
657  $is_postponed = $this->isPostponedQuestion($question->getId());
658 
659  $row = array(
660  "nr" => "$key",
661  "title" => $question->getTitle(),
662  "qid" => $question->getId(),
663  "visited" => $worked_through,
664  "solved" => (($solved)?"1":"0"),
665  "description" => $question->getComment(),
666  "points" => $question->getMaximumPoints(),
667  "worked_through" => $worked_through,
668  "postponed" => $is_postponed,
669  "sequence" => $sequence,
670  "obligatory" => ilObjTest::isQuestionObligatory($question->getId()),
671  'isAnswered' => $question->isAnswered($this->active_id, $this->pass)
672  );
673 
674  if( !$obligationsFilterEnabled || $row['obligatory'] )
675  {
676  array_push($result_array, $row);
677  }
678 
679  $key++;
680  }
681  }
682  return $result_array;
683  }
isPostponedQuestion($question_id)
getQuestionForSequence($sequence)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static isQuestionObligatory($question_id)
checks wether the question with given id is marked as obligatory or not
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getUserQuestionCount()

ilTestSequence::getUserQuestionCount ( )

Definition at line 420 of file class.ilTestSequence.php.

References getCorrectedSequence().

421  {
422  return count($this->getCorrectedSequence());
423  }
+ Here is the call graph for this function:

◆ getUserSequence()

ilTestSequence::getUserSequence ( )

Definition at line 469 of file class.ilTestSequence.php.

References getCorrectedSequence().

470  {
471  return $this->getCorrectedSequence();
472  }
+ Here is the call graph for this function:

◆ getUserSequenceQuestions()

ilTestSequence::getUserSequenceQuestions ( )

Definition at line 474 of file class.ilTestSequence.php.

References array, getCorrectedSequence(), and getQuestionForSequence().

475  {
476  $seq = $this->getCorrectedSequence();
477  $found = array();
478  foreach ($seq as $sequence)
479  {
480  array_push($found, $this->getQuestionForSequence($sequence));
481  }
482  return $found;
483  }
getQuestionForSequence($sequence)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ hasHiddenQuestions()

ilTestSequence::hasHiddenQuestions ( )

Definition at line 707 of file class.ilTestSequence.php.

708  {
709  if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0))
710  {
711  return TRUE;
712  }
713  else
714  {
715  return FALSE;
716  }
717  }

◆ hasOptionalQuestions()

ilTestSequence::hasOptionalQuestions ( )

Definition at line 786 of file class.ilTestSequence.php.

787  {
788  return (bool)count($this->optionalQuestions);
789  }

◆ hasSequence()

ilTestSequence::hasSequence ( )

Definition at line 695 of file class.ilTestSequence.php.

696  {
697  if ((is_array($this->sequencedata["sequence"])) && (count($this->sequencedata["sequence"]) > 0))
698  {
699  return TRUE;
700  }
701  else
702  {
703  return FALSE;
704  }
705  }

◆ hasStarted()

ilTestSequence::hasStarted ( ilTestSession  $testSession)

Definition at line 745 of file class.ilTestSequence.php.

References getFirstSequence(), and ilTestSession\getLastSequence().

746  {
747  if( $testSession->getLastSequence() < 1 )
748  {
749  return false;
750  }
751 
752  // WTF ?? heard about tests with only one question !?
753  if( $testSession->getLastSequence() == $this->getFirstSequence() )
754  {
755  return false;
756  }
757 
758  return true;
759  }
+ Here is the call graph for this function:

◆ hideCorrectAnsweredQuestions()

ilTestSequence::hideCorrectAnsweredQuestions ( ilObjTest  $testOBJ,
  $activeId,
  $pass 
)
private

Definition at line 724 of file class.ilTestSequence.php.

References $result, ilObjTest\getTestResult(), hideQuestion(), and saveToDb().

725  {
726  if( $activeId > 0 )
727  {
728  $result = $testOBJ->getTestResult($activeId, $pass, TRUE);
729 
730  foreach( $result as $sequence => $question )
731  {
732  if( is_numeric($sequence) )
733  {
734  if( $question['reached'] == $question['max'] )
735  {
736  $this->hideQuestion($question['qid']);
737  }
738  }
739  }
740 
741  $this->saveToDb();
742  }
743  }
$result
hideQuestion($question_id)
saveToDb()
Saves the sequence data for a given pass to the database.
& getTestResult($active_id, $pass=NULL, $ordered_sequence=FALSE, $considerHiddenQuestions=true, $considerOptionalQuestions=true)
Calculates the results of a test for a given user and returns an array with all test results...
+ Here is the call graph for this function:

◆ hideQuestion()

ilTestSequence::hideQuestion (   $question_id)

Definition at line 310 of file class.ilTestSequence.php.

References isHiddenQuestion().

Referenced by hideCorrectAnsweredQuestions(), and ilLOTestQuestionAdapter\hideQuestions().

311  {
312  if (!$this->isHiddenQuestion($question_id))
313  {
314  array_push($this->sequencedata["hidden"], intval($question_id));
315  }
316  }
isHiddenQuestion($question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideSequence()

ilTestSequence::hideSequence (   $sequence)

Definition at line 384 of file class.ilTestSequence.php.

References array, and isHiddenSequence().

385  {
386  if (!$this->isHiddenSequence($sequence))
387  {
388  if (array_key_exists($sequence, $this->questions))
389  {
390  if (!is_array($this->sequencedata["hidden"])) $this->sequencedata["hidden"] = array();
391  array_push($this->sequencedata["hidden"], intval($this->questions[$sequence]));
392  }
393  }
394  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isAnsweringOptionalQuestionsConfirmed()

ilTestSequence::isAnsweringOptionalQuestionsConfirmed ( )
Returns
boolean

Definition at line 823 of file class.ilTestSequence.php.

References $answeringOptionalQuestionsConfirmed.

Referenced by saveQuestionSequence(), and ilTestVirtualSequence\wasAnsweredInThisPass().

824  {
826  }
+ Here is the caller graph for this function:

◆ isConsiderHiddenQuestionsEnabled()

ilTestSequence::isConsiderHiddenQuestionsEnabled ( )
Returns
boolean

Definition at line 839 of file class.ilTestSequence.php.

References $considerHiddenQuestionsEnabled.

Referenced by getCorrectedSequence(), getOrderedSequence(), and getOrderedSequenceQuestions().

840  {
842  }
+ Here is the caller graph for this function:

◆ isConsiderOptionalQuestionsEnabled()

ilTestSequence::isConsiderOptionalQuestionsEnabled ( )
Returns
boolean

Definition at line 855 of file class.ilTestSequence.php.

References $considerOptionalQuestionsEnabled.

Referenced by getCorrectedSequence(), getOrderedSequence(), and getOrderedSequenceQuestions().

856  {
858  }
+ Here is the caller graph for this function:

◆ isHiddenQuestion()

ilTestSequence::isHiddenQuestion (   $question_id)

Definition at line 331 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions(), hideQuestion(), and ilTestVirtualSequence\wasAnsweredInThisPass().

332  {
333  if (!is_array($this->sequencedata["hidden"])) return FALSE;
334  if (!in_array($question_id, $this->sequencedata["hidden"]))
335  {
336  return FALSE;
337  }
338  else
339  {
340  return TRUE;
341  }
342  }
+ Here is the caller graph for this function:

◆ isHiddenSequence()

ilTestSequence::isHiddenSequence (   $sequence)

Definition at line 358 of file class.ilTestSequence.php.

Referenced by getOrderedSequence(), and hideSequence().

359  {
360  if (!array_key_exists($sequence, $this->questions)) return FALSE;
361  if (!is_array($this->sequencedata["hidden"])) return FALSE;
362  if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"]))
363  {
364  return FALSE;
365  }
366  else
367  {
368  return TRUE;
369  }
370  }
+ Here is the caller graph for this function:

◆ isPostponedQuestion()

ilTestSequence::isPostponedQuestion (   $question_id)

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

Referenced by getSequenceSummary(), and postponeQuestion().

319  {
320  if (!is_array($this->sequencedata["postponed"])) return FALSE;
321  if (!in_array($question_id, $this->sequencedata["postponed"]))
322  {
323  return FALSE;
324  }
325  else
326  {
327  return TRUE;
328  }
329  }
+ Here is the caller graph for this function:

◆ isPostponedSequence()

ilTestSequence::isPostponedSequence (   $sequence)

Definition at line 344 of file class.ilTestSequence.php.

Referenced by postponeSequence().

345  {
346  if (!array_key_exists($sequence, $this->questions)) return FALSE;
347  if (!is_array($this->sequencedata["postponed"])) return FALSE;
348  if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"]))
349  {
350  return FALSE;
351  }
352  else
353  {
354  return TRUE;
355  }
356  }
+ Here is the caller graph for this function:

◆ isQuestionChecked()

ilTestSequence::isQuestionChecked (   $questionId)

Definition at line 401 of file class.ilTestSequence.php.

402  {
403  return isset($this->alreadyCheckedQuestions[$questionId]);
404  }

◆ isQuestionOptional()

ilTestSequence::isQuestionOptional (   $questionId)

Definition at line 781 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions(), reorderOptionalQuestionsToSequenceEnd(), and ilTestVirtualSequence\wasAnsweredInThisPass().

782  {
783  return isset($this->optionalQuestions[$questionId]);
784  }
+ Here is the caller graph for this function:

◆ loadCheckedQuestions()

ilTestSequence::loadCheckedQuestions ( )
private

Definition at line 190 of file class.ilTestSequence.php.

References $ilDB, $res, $row, and array.

Referenced by loadFromDb().

191  {
192  global $ilDB;
193 
194  $res = $ilDB->queryF("SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
195  array('integer','integer'), array($this->active_id, $this->pass)
196  );
197 
198  while( $row = $ilDB->fetchAssoc($res) )
199  {
200  $this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
201  }
202  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ loadFromDb()

ilTestSequence::loadFromDb ( )

Loads the sequence data for a given active id.

Returns
string The filesystem path of the certificate

Definition at line 160 of file class.ilTestSequence.php.

References loadCheckedQuestions(), loadOptionalQuestions(), and loadQuestionSequence().

161  {
162  $this->loadQuestionSequence();
163  $this->loadCheckedQuestions();
164  $this->loadOptionalQuestions();
165  }
+ Here is the call graph for this function:

◆ loadOptionalQuestions()

ilTestSequence::loadOptionalQuestions ( )
private

Definition at line 204 of file class.ilTestSequence.php.

References $ilDB, $res, $row, and array.

Referenced by loadFromDb().

205  {
206  global $ilDB;
207 
208  $res = $ilDB->queryF("SELECT question_fi FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s",
209  array('integer','integer'), array($this->active_id, $this->pass)
210  );
211 
212  while( $row = $ilDB->fetchAssoc($res) )
213  {
214  $this->optionalQuestions[ $row['question_fi'] ] = $row['question_fi'];
215  }
216  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ loadQuestions()

ilTestSequence::loadQuestions ( ilTestQuestionSetConfig  $testQuestionSetConfig = null,
  $taxonomyFilterSelection = array() 
)

Loads the question mapping.

Definition at line 135 of file class.ilTestSequence.php.

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

136  {
137  global $ilDB;
138 
139  $this->questions = array();
140 
141  $result = $ilDB->queryF("SELECT tst_test_question.* FROM tst_test_question, qpl_questions, tst_active WHERE tst_active.active_id = %s AND tst_test_question.test_fi = tst_active.test_fi AND qpl_questions.question_id = tst_test_question.question_fi ORDER BY tst_test_question.sequence",
142  array('integer'),
143  array($this->active_id)
144  );
145 
146  $index = 1;
147 
148  // TODO bheyser: There might be "sequence" gaps which lead to issues with tst_sequence when deleting/adding questions before any participant starts the test
149  while ($data = $ilDB->fetchAssoc($result))
150  {
151  $this->questions[$index++] = $data["question_fi"];
152  }
153  }
$result
Create styles array
The data for the language used.
global $ilDB

◆ loadQuestionSequence()

ilTestSequence::loadQuestionSequence ( )
private

Definition at line 167 of file class.ilTestSequence.php.

References $ilDB, $result, $row, array, and setAnsweringOptionalQuestionsConfirmed().

Referenced by loadFromDb().

168  {
169  global $ilDB;
170  $result = $ilDB->queryF("SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
171  array('integer','integer'),
172  array($this->active_id, $this->pass)
173  );
174  if ($result->numRows())
175  {
176  $row = $ilDB->fetchAssoc($result);
177  $this->sequencedata = array(
178  "sequence" => unserialize($row["sequence"]),
179  "postponed" => unserialize($row["postponed"]),
180  "hidden" => unserialize($row["hidden"])
181  );
182  if (!is_array($this->sequencedata["sequence"])) $this->sequencedata["sequence"] = array();
183  if (!is_array($this->sequencedata["postponed"])) $this->sequencedata["postponed"] = array();
184  if (!is_array($this->sequencedata["hidden"])) $this->sequencedata["hidden"] = array();
185 
186  $this->setAnsweringOptionalQuestionsConfirmed((bool)$row['ans_opt_confirmed']);
187  }
188  }
$result
setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestionsConfirmed)
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openQuestionExists()

ilTestSequence::openQuestionExists ( )

Definition at line 761 of file class.ilTestSequence.php.

References getFirstSequence().

762  {
763  return $this->getFirstSequence() !== false;
764  }
+ Here is the call graph for this function:

◆ pcArrayShuffle()

ilTestSequence::pcArrayShuffle (   $array)

Shuffles the values of a given array.

Shuffles the values of a given array

Parameters
array$arrayAn array which should be shuffled public

Definition at line 614 of file class.ilTestSequence.php.

References $result, and array.

Referenced by createNewSequence().

615  {
616  $keys = array_keys($array);
617  shuffle($keys);
618  $result = array();
619  foreach ($keys as $key)
620  {
621  $result[$key] = $array[$key];
622  }
623  return $result;
624  }
$result
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ postponeQuestion()

ilTestSequence::postponeQuestion (   $question_id)

Definition at line 302 of file class.ilTestSequence.php.

References isPostponedQuestion().

303  {
304  if (!$this->isPostponedQuestion($question_id))
305  {
306  array_push($this->sequencedata["postponed"], intval($question_id));
307  }
308  }
isPostponedQuestion($question_id)
+ Here is the call graph for this function:

◆ postponeSequence()

ilTestSequence::postponeSequence (   $sequence)

Definition at line 372 of file class.ilTestSequence.php.

References array, and isPostponedSequence().

373  {
374  if (!$this->isPostponedSequence($sequence))
375  {
376  if (array_key_exists($sequence, $this->questions))
377  {
378  if (!is_array($this->sequencedata["postponed"])) $this->sequencedata["postponed"] = array();
379  array_push($this->sequencedata["postponed"], intval($this->questions[$sequence]));
380  }
381  }
382  }
Create styles array
The data for the language used.
isPostponedSequence($sequence)
+ Here is the call graph for this function:

◆ questionExists()

ilTestSequence::questionExists (   $questionId)

Definition at line 771 of file class.ilTestSequence.php.

772  {
773  return in_array($questionId, $this->questions);
774  }

◆ reorderOptionalQuestionsToSequenceEnd()

ilTestSequence::reorderOptionalQuestionsToSequenceEnd ( )

Definition at line 801 of file class.ilTestSequence.php.

References array, getQuestionForSequence(), and isQuestionOptional().

802  {
803  $optionalSequenceKeys = array();
804 
805  foreach($this->sequencedata['sequence'] as $index => $sequenceKey)
806  {
807  if( $this->isQuestionOptional($this->getQuestionForSequence($sequenceKey)) )
808  {
809  $optionalSequenceKeys[$index] = $sequenceKey;
810  unset($this->sequencedata['sequence'][$index]);
811  }
812  }
813 
814  foreach($optionalSequenceKeys as $index => $sequenceKey)
815  {
816  $this->sequencedata['sequence'][$index] = $sequenceKey;
817  }
818  }
isQuestionOptional($questionId)
getQuestionForSequence($sequence)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ saveNewlyCheckedQuestion()

ilTestSequence::saveNewlyCheckedQuestion ( )
private

ilDBInterface $ilDB

Definition at line 264 of file class.ilTestSequence.php.

References $ilDB, and array.

Referenced by saveToDb().

265  {
266  if( (int)$this->newlyCheckedQuestion )
267  {
268  global $ilDB;
269 
270  $ilDB->replace('tst_seq_qst_checked', array(
271  'active_fi' => array('integer', (int)$this->active_id),
272  'pass' => array('integer', (int)$this->pass),
273  'question_fi' => array('integer', (int)$this->newlyCheckedQuestion)
274  ), array());
275  }
276  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ saveOptionalQuestions()

ilTestSequence::saveOptionalQuestions ( )
private

ilDBInterface $ilDB

Definition at line 281 of file class.ilTestSequence.php.

References $ilDB, and array.

Referenced by saveToDb().

282  {
283  global $ilDB;
284 
285  $NOT_IN_questions = $ilDB->in('question_fi', $this->optionalQuestions, true, 'integer');
286 
287  $ilDB->queryF(
288  "DELETE FROM tst_seq_qst_optional WHERE active_fi = %s AND pass = %s AND $NOT_IN_questions",
289  array('integer', 'integer'), array($this->active_id, $this->pass)
290  );
291 
292  foreach($this->optionalQuestions as $questionId)
293  {
294  $ilDB->replace('tst_seq_qst_optional', array(
295  'active_fi' => array('integer', (int)$this->active_id),
296  'pass' => array('integer', (int)$this->pass),
297  'question_fi' => array('integer', (int)$questionId)
298  ), array());
299  }
300  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ saveQuestionSequence()

ilTestSequence::saveQuestionSequence ( )
private

Definition at line 230 of file class.ilTestSequence.php.

References $ilDB, array, isAnsweringOptionalQuestionsConfirmed(), and time.

Referenced by saveToDb().

231  {
232  global $ilDB;
233 
234  $postponed = NULL;
235  if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"])))
236  {
237  $postponed = serialize($this->sequencedata["postponed"]);
238  }
239  $hidden = NULL;
240  if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"])))
241  {
242  $hidden = serialize($this->sequencedata["hidden"]);
243  }
244 
245  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
246  array('integer','integer'),
247  array($this->active_id, $this->pass)
248  );
249 
250  $affectedRows = $ilDB->insert("tst_sequence", array(
251  "active_fi" => array("integer", $this->active_id),
252  "pass" => array("integer", $this->pass),
253  "sequence" => array("clob", serialize($this->sequencedata["sequence"])),
254  "postponed" => array("text", $postponed),
255  "hidden" => array("text", $hidden),
256  "tstamp" => array("integer", time()),
257  'ans_opt_confirmed' => array('integer', (int)$this->isAnsweringOptionalQuestionsConfirmed())
258  ));
259  }
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSequence::saveToDb ( )

Saves the sequence data for a given pass to the database.

public

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

References saveNewlyCheckedQuestion(), saveOptionalQuestions(), and saveQuestionSequence().

Referenced by hideCorrectAnsweredQuestions(), and ilLOTestQuestionAdapter\prepareTestPass().

224  {
225  $this->saveQuestionSequence();
226  $this->saveNewlyCheckedQuestion();
227  $this->saveOptionalQuestions();
228  }
saveOptionalQuestions()
ilDBInterface $ilDB
saveNewlyCheckedQuestion()
ilDBInterface $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnsweringOptionalQuestionsConfirmed()

ilTestSequence::setAnsweringOptionalQuestionsConfirmed (   $answeringOptionalQuestionsConfirmed)
Parameters
boolean$answeringOptionalQuestionsConfirmed

Definition at line 831 of file class.ilTestSequence.php.

References $answeringOptionalQuestionsConfirmed.

Referenced by loadQuestionSequence().

832  {
833  $this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
834  }
+ Here is the caller graph for this function:

◆ setConsiderHiddenQuestionsEnabled()

ilTestSequence::setConsiderHiddenQuestionsEnabled (   $considerHiddenQuestionsEnabled)
Parameters
boolean$considerHiddenQuestionsEnabled

Definition at line 847 of file class.ilTestSequence.php.

References $considerHiddenQuestionsEnabled.

848  {
849  $this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
850  }

◆ setConsiderOptionalQuestionsEnabled()

ilTestSequence::setConsiderOptionalQuestionsEnabled (   $considerOptionalQuestionsEnabled)
Parameters
boolean$considerOptionalQuestionsEnabled

Definition at line 863 of file class.ilTestSequence.php.

References $considerOptionalQuestionsEnabled.

864  {
865  $this->considerOptionalQuestionsEnabled = $considerOptionalQuestionsEnabled;
866  }

◆ setPass()

ilTestSequence::setPass (   $pass)

Definition at line 690 of file class.ilTestSequence.php.

References $pass.

691  {
692  $this->pass = $pass;
693  }

◆ setQuestionChecked()

ilTestSequence::setQuestionChecked (   $questionId)

Definition at line 396 of file class.ilTestSequence.php.

397  {
398  $this->newlyCheckedQuestion = $questionId;
399  }

◆ setQuestionOptional()

ilTestSequence::setQuestionOptional (   $questionId)

Definition at line 776 of file class.ilTestSequence.php.

Referenced by ilLOTestQuestionAdapter\setQuestionsOptional().

777  {
778  $this->optionalQuestions[$questionId] = $questionId;
779  }
+ Here is the caller graph for this function:

Field Documentation

◆ $active_id

ilTestSequence::$active_id

◆ $alreadyCheckedQuestions

ilTestSequence::$alreadyCheckedQuestions
private

Definition at line 56 of file class.ilTestSequence.php.

◆ $answeringOptionalQuestionsConfirmed

ilTestSequence::$answeringOptionalQuestionsConfirmed
private

◆ $considerHiddenQuestionsEnabled

ilTestSequence::$considerHiddenQuestionsEnabled
private

◆ $considerOptionalQuestionsEnabled

ilTestSequence::$considerOptionalQuestionsEnabled
private

◆ $isRandomTest

ilTestSequence::$isRandomTest

Definition at line 51 of file class.ilTestSequence.php.

◆ $newlyCheckedQuestion

ilTestSequence::$newlyCheckedQuestion
private

Definition at line 61 of file class.ilTestSequence.php.

◆ $optionalQuestions

ilTestSequence::$optionalQuestions
private

Definition at line 66 of file class.ilTestSequence.php.

Referenced by getOptionalQuestions().

◆ $pass

◆ $questions

ilTestSequence::$questions

Definition at line 30 of file class.ilTestSequence.php.

Referenced by getOrderedSequenceQuestions().

◆ $sequencedata

ilTestSequence::$sequencedata

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


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