ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestSequence Class Reference

Test sequence handler. More...

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

Public Member Functions

 ilTestSequence ($active_id, $pass, $randomtest)
 ilTestSequence constructor
 getActiveId ()
 createNewSequence ($max, $shuffle)
 loadQuestions (ilTestQuestionSetConfig $testQuestionSetConfig=null, $taxonomyFilterSelection=array())
 Loads the question mapping.
 loadFromDb ()
 Loads the sequence data for a given active id.
 saveToDb ()
 Saves the sequence data for a given pass to the database.
 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.
 getQuestionForSequence ($sequence)
getSequenceSummary ($obligationsFilter=false)
 getPass ()
 setPass ($pass)
 hasSequence ()
 hasHiddenQuestions ()
 clearHiddenQuestions ()
 hasStarted (ilTestSession $testSession)
 openQuestionExists ()
 getQuestionIds ()
 questionExists ($questionId)

Data Fields

 $sequencedata
 $questions
 $active_id
 $pass
 $isRandomTest

Protected Member Functions

 getCorrectedSequence ($with_hidden_questions=FALSE)

Private Member Functions

 loadQuestionSequence ()
 loadCheckedQuestions ()
 saveQuestionSequence ()
 saveNewlyCheckedQuestion ()
 ilDB $ilDB
 hideCorrectAnsweredQuestions (ilObjTest $testOBJ, $activeId, $pass)

Private Attributes

 $alreadyCheckedQuestions
 $newlyCheckedQuestion

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:
class.ilTestSequence.php 58242 2015-02-27 15:21:19Z gitmgr

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

Member Function Documentation

ilTestSequence::clearHiddenQuestions ( )

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

Referenced by ilLOTestQuestionAdapter\hideQuestions().

{
$this->sequencedata["hidden"] = array();
}

+ Here is the caller graph for this function:

ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

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

References pcArrayShuffle().

{
$newsequence = array();
if ($max > 0)
{
for ($i = 1; $i <= $max; $i++)
{
array_push($newsequence, $i);
}
if ($shuffle) $newsequence = $this->pcArrayShuffle($newsequence);
}
$this->sequencedata["sequence"] = $newsequence;
}

+ Here is the call graph for this function:

ilTestSequence::getActiveId ( )

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

References $active_id.

{
}
ilTestSequence::getCorrectedSequence (   $with_hidden_questions = FALSE)
protected

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

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

{
$correctedsequence = $this->sequencedata["sequence"];
if (!$with_hidden_questions)
{
if (is_array($this->sequencedata["hidden"]))
{
foreach ($this->sequencedata["hidden"] as $question_id)
{
$foundsequence = array_search($question_id, $this->questions);
if ($foundsequence !== FALSE)
{
$sequencekey = array_search($foundsequence, $correctedsequence);
if ($sequencekey !== FALSE)
{
unset($correctedsequence[$sequencekey]);
}
}
}
}
}
if (is_array($this->sequencedata["postponed"]))
{
foreach ($this->sequencedata["postponed"] as $question_id)
{
$foundsequence = array_search($question_id, $this->questions);
if ($foundsequence !== FALSE)
{
$sequencekey = array_search($foundsequence, $correctedsequence);
if ($sequencekey !== FALSE)
{
unset($correctedsequence[$sequencekey]);
array_push($correctedsequence, $foundsequence);
}
}
}
}
return array_values($correctedsequence);
}

+ Here is the caller graph for this function:

ilTestSequence::getFirstSequence ( )

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

References getCorrectedSequence().

Referenced by hasStarted(), and openQuestionExists().

{
$correctedsequence = $this->getCorrectedSequence();
if (count($correctedsequence))
{
return reset($correctedsequence);
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestSequence::getLastSequence ( )

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

References getCorrectedSequence().

{
$correctedsequence = $this->getCorrectedSequence();
if (count($correctedsequence))
{
return end($correctedsequence);
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

ilTestSequence::getNextSequence (   $sequence)

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

References getCorrectedSequence().

{
$correctedsequence = $this->getCorrectedSequence();
$sequencekey = array_search($sequence, $correctedsequence);
if ($sequencekey !== FALSE)
{
$nextsequencekey = $sequencekey + 1;
if (array_key_exists($nextsequencekey, $correctedsequence))
{
return $correctedsequence[$nextsequencekey];
}
}
return FALSE;
}

+ Here is the call graph for this function:

ilTestSequence::getOrderedSequence ( )

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

{
return array_keys($this->questions);
}
ilTestSequence::getOrderedSequenceQuestions ( )

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

References $questions.

{
}
ilTestSequence::getPass ( )

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

References $pass.

{
return $this->pass;
}
ilTestSequence::getPositionOfSequence (   $sequence)

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

References getCorrectedSequence().

{
$correctedsequence = $this->getCorrectedSequence();
$sequencekey = array_search($sequence, $correctedsequence);
if ($sequencekey !== FALSE)
{
return $sequencekey + 1;
}
else
{
return "";
}
}

+ Here is the call graph for this function:

ilTestSequence::getPreviousSequence (   $sequence)

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

References getCorrectedSequence().

{
$correctedsequence = $this->getCorrectedSequence();
$sequencekey = array_search($sequence, $correctedsequence);
if ($sequencekey !== FALSE)
{
$prevsequencekey = $sequencekey - 1;
if (($prevsequencekey >= 0) && (array_key_exists($prevsequencekey, $correctedsequence)))
{
return $correctedsequence[$prevsequencekey];
}
}
return FALSE;
}

+ Here is the call graph for this function:

ilTestSequence::getQuestionForSequence (   $sequence)

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

Referenced by getSequenceSummary(), and getUserSequenceQuestions().

{
if ($sequence < 1) return FALSE;
if (array_key_exists($sequence, $this->questions))
{
return $this->questions[$sequence];
}
else
{
return FALSE;
}
}

+ Here is the caller graph for this function:

ilTestSequence::getQuestionIds ( )

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

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

{
return array_values($this->questions);
}

+ Here is the caller graph for this function:

ilTestSequence::getSequenceForQuestion (   $question_id)

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

{
return array_search($question_id, $this->questions);
}
& ilTestSequence::getSequenceSummary (   $obligationsFilter = false)

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

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

{
$correctedsequence = $this->getCorrectedSequence();
$result_array = array();
include_once "./Modules/Test/classes/class.ilObjTest.php";
$solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
$key = 1;
foreach ($correctedsequence as $sequence)
{
if (is_object($question))
{
$worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
$solved = 0;
if (array_key_exists($question->getId(), $solved_questions))
{
$solved = $solved_questions[$question->getId()]["solved"];
}
$is_postponed = $this->isPostponedQuestion($question->getId());
$row = array(
"nr" => "$key",
"title" => $question->getTitle(),
"qid" => $question->getId(),
"visited" => $worked_through,
"solved" => (($solved)?"1":"0"),
"description" => $question->getComment(),
"points" => $question->getMaximumPoints(),
"worked_through" => $worked_through,
"postponed" => $is_postponed,
"sequence" => $sequence,
"obligatory" => ilObjTest::isQuestionObligatory($question->getId()),
'isAnswered' => $question->isAnswered($this->active_id, $this->pass)
);
if( !$obligationsFilter || $row['obligatory'] )
{
array_push($result_array, $row);
}
$key++;
}
}
return $result_array;
}

+ Here is the call graph for this function:

ilTestSequence::getUserQuestionCount ( )

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

References getCorrectedSequence().

{
return count($this->getCorrectedSequence());
}

+ Here is the call graph for this function:

ilTestSequence::getUserSequence ( )

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

References getCorrectedSequence().

{
return $this->getCorrectedSequence(TRUE);
}

+ Here is the call graph for this function:

ilTestSequence::getUserSequenceQuestions ( )

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

References getCorrectedSequence(), and getQuestionForSequence().

{
$seq = $this->getCorrectedSequence(TRUE);
$found = array();
foreach ($seq as $sequence)
{
array_push($found, $this->getQuestionForSequence($sequence));
}
return $found;
}

+ Here is the call graph for this function:

ilTestSequence::hasHiddenQuestions ( )

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

{
if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"]) > 0))
{
return TRUE;
}
else
{
return FALSE;
}
}
ilTestSequence::hasSequence ( )

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

{
if ((is_array($this->sequencedata["sequence"])) && (count($this->sequencedata["sequence"]) > 0))
{
return TRUE;
}
else
{
return FALSE;
}
}
ilTestSequence::hasStarted ( ilTestSession  $testSession)

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

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

{
if( $testSession->getLastSequence() < 1 )
{
return false;
}
// WTF ?? heard about tests with only one question !?
if( $testSession->getLastSequence() == $this->getFirstSequence() )
{
return false;
}
return true;
}

+ Here is the call graph for this function:

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

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

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

{
if( $activeId > 0 )
{
$result = $testOBJ->getTestResult($activeId, $pass, TRUE);
foreach( $result as $sequence => $question )
{
if( is_numeric($sequence) )
{
if( $question['reached'] == $question['max'] )
{
$this->hideQuestion($question['qid']);
}
}
}
$this->saveToDb();
}
}

+ Here is the call graph for this function:

ilTestSequence::hideQuestion (   $question_id)

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

References isHiddenQuestion().

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

{
if (!$this->isHiddenQuestion($question_id))
{
array_push($this->sequencedata["hidden"], intval($question_id));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestSequence::hideSequence (   $sequence)

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

References isHiddenSequence().

{
if (!$this->isHiddenSequence($sequence))
{
if (array_key_exists($sequence, $this->questions))
{
if (!is_array($this->sequencedata["hidden"])) $this->sequencedata["hidden"] = array();
array_push($this->sequencedata["hidden"], intval($this->questions[$sequence]));
}
}
}

+ Here is the call graph for this function:

ilTestSequence::ilTestSequence (   $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 69 of file class.ilTestSequence.php.

References $active_id, and $pass.

{
$this->active_id = $active_id;
$this->pass = $pass;
$this->isRandomTest = $randomtest;
$this->sequencedata = array(
"sequence" => array(),
"postponed" => array(),
"hidden" => array()
);
$this->alreadyCheckedQuestions = array();
$this->newlyCheckedQuestion = null;
}
ilTestSequence::isHiddenQuestion (   $question_id)

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

Referenced by hideQuestion().

{
if (!is_array($this->sequencedata["hidden"])) return FALSE;
if (!in_array($question_id, $this->sequencedata["hidden"]))
{
return FALSE;
}
else
{
return TRUE;
}
}

+ Here is the caller graph for this function:

ilTestSequence::isHiddenSequence (   $sequence)

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

Referenced by hideSequence().

{
if (!array_key_exists($sequence, $this->questions)) return FALSE;
if (!is_array($this->sequencedata["hidden"])) return FALSE;
if (!in_array($this->questions[$sequence], $this->sequencedata["hidden"]))
{
return FALSE;
}
else
{
return TRUE;
}
}

+ Here is the caller graph for this function:

ilTestSequence::isPostponedQuestion (   $question_id)

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

Referenced by getSequenceSummary(), and postponeQuestion().

{
if (!is_array($this->sequencedata["postponed"])) return FALSE;
if (!in_array($question_id, $this->sequencedata["postponed"]))
{
return FALSE;
}
else
{
return TRUE;
}
}

+ Here is the caller graph for this function:

ilTestSequence::isPostponedSequence (   $sequence)

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

Referenced by postponeSequence().

{
if (!array_key_exists($sequence, $this->questions)) return FALSE;
if (!is_array($this->sequencedata["postponed"])) return FALSE;
if (!in_array($this->questions[$sequence], $this->sequencedata["postponed"]))
{
return FALSE;
}
else
{
return TRUE;
}
}

+ Here is the caller graph for this function:

ilTestSequence::isQuestionChecked (   $questionId)

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

{
return isset($this->alreadyCheckedQuestions[$questionId]);
}
ilTestSequence::loadCheckedQuestions ( )
private

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

References $ilDB, $res, and $row.

Referenced by loadFromDb().

{
global $ilDB;
$res = $ilDB->queryF("SELECT question_fi FROM tst_seq_qst_checked WHERE active_fi = %s AND pass = %s",
array('integer','integer'), array($this->active_id, $this->pass)
);
while( $row = $ilDB->fetchAssoc($res) )
{
$this->alreadyCheckedQuestions[ $row['question_fi'] ] = $row['question_fi'];
}
}

+ Here is the caller graph for this function:

ilTestSequence::loadFromDb ( )

Loads the sequence data for a given active id.

Returns
string The filesystem path of the certificate

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

References loadCheckedQuestions(), and loadQuestionSequence().

{
}

+ Here is the call graph for this function:

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

Loads the question mapping.

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

References $ilDB, and $result.

{
global $ilDB;
$this->questions = array();
$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",
array('integer'),
array($this->active_id)
);
$index = 1;
while ($data = $ilDB->fetchAssoc($result))
{
$this->questions[$index++] = $data["question_fi"];
}
}
ilTestSequence::loadQuestionSequence ( )
private

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

References $ilDB, $result, and $row.

Referenced by loadFromDb().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_sequence WHERE active_fi = %s AND pass = %s",
array('integer','integer'),
array($this->active_id, $this->pass)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$this->sequencedata = array(
"sequence" => unserialize($row["sequence"]),
"postponed" => unserialize($row["postponed"]),
"hidden" => unserialize($row["hidden"])
);
if (!is_array($this->sequencedata["sequence"])) $this->sequencedata["sequence"] = array();
if (!is_array($this->sequencedata["postponed"])) $this->sequencedata["postponed"] = array();
if (!is_array($this->sequencedata["hidden"])) $this->sequencedata["hidden"] = array();
}
}

+ Here is the caller graph for this function:

ilTestSequence::openQuestionExists ( )

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

References getFirstSequence().

{
return $this->getFirstSequence() !== false;
}

+ Here is the call graph for this function:

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 487 of file class.ilTestSequence.php.

References $result.

Referenced by createNewSequence().

{
$keys = array_keys($array);
shuffle($keys);
$result = array();
foreach ($keys as $key)
{
$result[$key] = $array[$key];
}
return $result;
}

+ Here is the caller graph for this function:

ilTestSequence::postponeQuestion (   $question_id)

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

References isPostponedQuestion().

{
if (!$this->isPostponedQuestion($question_id))
{
array_push($this->sequencedata["postponed"], intval($question_id));
}
}

+ Here is the call graph for this function:

ilTestSequence::postponeSequence (   $sequence)

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

References isPostponedSequence().

{
if (!$this->isPostponedSequence($sequence))
{
if (array_key_exists($sequence, $this->questions))
{
if (!is_array($this->sequencedata["postponed"])) $this->sequencedata["postponed"] = array();
array_push($this->sequencedata["postponed"], intval($this->questions[$sequence]));
}
}
}

+ Here is the call graph for this function:

ilTestSequence::questionExists (   $questionId)

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

{
return in_array($questionId, $this->questions);
}
ilTestSequence::saveNewlyCheckedQuestion ( )
private

ilDB $ilDB

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

References $ilDB.

Referenced by saveToDb().

{
if( (int)$this->newlyCheckedQuestion )
{
global $ilDB;
$ilDB->replace('tst_seq_qst_checked', array(
'active_fi' => array('integer', (int)$this->active_id),
'pass' => array('integer', (int)$this->pass),
'question_fi' => array('integer', (int)$this->newlyCheckedQuestion)
), array());
}
}

+ Here is the caller graph for this function:

ilTestSequence::saveQuestionSequence ( )
private

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

References $ilDB.

Referenced by saveToDb().

{
global $ilDB;
$postponed = NULL;
if ((is_array($this->sequencedata["postponed"])) && (count($this->sequencedata["postponed"])))
{
$postponed = serialize($this->sequencedata["postponed"]);
}
$hidden = NULL;
if ((is_array($this->sequencedata["hidden"])) && (count($this->sequencedata["hidden"])))
{
$hidden = serialize($this->sequencedata["hidden"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s AND pass = %s",
array('integer','integer'),
array($this->active_id, $this->pass)
);
$affectedRows = $ilDB->insert("tst_sequence", array(
"active_fi" => array("integer", $this->active_id),
"pass" => array("integer", $this->pass),
"sequence" => array("clob", serialize($this->sequencedata["sequence"])),
"postponed" => array("text", $postponed),
"hidden" => array("text", $hidden),
"tstamp" => array("integer", time())
));
}

+ Here is the caller graph for this function:

ilTestSequence::saveToDb ( )

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

public

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

References saveNewlyCheckedQuestion(), and saveQuestionSequence().

Referenced by ilLOTestQuestionAdapter\filterQuestions(), hideCorrectAnsweredQuestions(), and ilTestOutputGUI\updateContainerObjectivesWithAnsweredQuestion().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestSequence::setPass (   $pass)

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

References $pass.

{
$this->pass = $pass;
}
ilTestSequence::setQuestionChecked (   $questionId)

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

{
$this->newlyCheckedQuestion = $questionId;
}

Field Documentation

ilTestSequence::$active_id
ilTestSequence::$alreadyCheckedQuestions
private

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

ilTestSequence::$isRandomTest

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

ilTestSequence::$newlyCheckedQuestion
private

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

ilTestSequence::$questions

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

Referenced by getOrderedSequenceQuestions().

ilTestSequence::$sequencedata

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


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