ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestSequence Class Reference

Test sequence handler. More...

+ Collaboration diagram for ilTestSequence:

Public Member Functions

 ilTestSequence ($active_id, $pass, $randomtest)
 ilTestSequence constructor
 getActiveId ()
 createNewSequence ($max, $shuffle)
 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)
 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 ()
 getPass ()
 setPass ($pass)
 hasSequence ()
 hasHiddenQuestions ()
 clearHiddenQuestions ()

Data Fields

 $sequencedata
 $questions
 $active_id
 $pass
 $isRandomTest

Protected Member Functions

 getCorrectedSequence ($with_hidden_questions=FALSE)

Private Member Functions

 loadQuestions ()
 Loads the question mapping.
 loadFromDb ()
 Loads the sequence data for a given active id.

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 24264 2010-06-15 08:06:52Z mwarkus

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

Member Function Documentation

ilTestSequence::clearHiddenQuestions ( )

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

{
$this->sequencedata["hidden"] = array();
}
ilTestSequence::createNewSequence (   $max,
  $shuffle 
)

Definition at line 98 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 93 of file class.ilTestSequence.php.

References $active_id.

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

Definition at line 355 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 400 of file class.ilTestSequence.php.

References getCorrectedSequence().

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

+ Here is the call graph for this function:

ilTestSequence::getLastSequence ( )

Definition at line 413 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 426 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 329 of file class.ilTestSequence.php.

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

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

References $questions.

{
}
ilTestSequence::getPass ( )

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

References $pass.

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

Definition at line 310 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 441 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 476 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::getSequenceForQuestion (   $question_id)

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

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

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

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

{
$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
);
array_push($result_array, $row);
$key++;
}
}
return $result_array;
}

+ Here is the call graph for this function:

ilTestSequence::getUserQuestionCount ( )

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

References getCorrectedSequence().

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

+ Here is the call graph for this function:

ilTestSequence::getUserSequence ( )

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

References getCorrectedSequence().

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

+ Here is the call graph for this function:

ilTestSequence::getUserSequenceQuestions ( )

Definition at line 344 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 550 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 538 of file class.ilTestSequence.php.

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

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

References isHiddenQuestion().

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

+ Here is the call graph for this function:

ilTestSequence::hideSequence (   $sequence)

Definition at line 298 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 79 of file class.ilTestSequence.php.

References $active_id, $pass, loadFromDb(), and loadQuestions().

{
$this->active_id = $active_id;
$this->pass = $pass;
$this->isRandomTest = $randomtest;
$this->sequencedata = array(
"sequence" => array(),
"postponed" => array(),
"hidden" => array()
);
$this->loadFromDb();
$this->loadQuestions();
}

+ Here is the call graph for this function:

ilTestSequence::isHiddenQuestion (   $question_id)

Definition at line 245 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 272 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 232 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 258 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::loadFromDb ( )
private

Loads the sequence data for a given active id.

Returns
string The filesystem path of the certificate private

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

References $ilDB, and $row.

Referenced by ilTestSequence().

{
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::loadQuestions ( )
private

Loads the question mapping.

private

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

References $data, and $ilDB.

Referenced by ilTestSequence().

{
global $ilDB;
$this->questions = array();
if ($this->isRandomTest)
{
$result = $ilDB->queryF("SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = %s ORDER BY sequence",
array('integer','integer'),
array($this->active_id, $this->pass)
);
// The following is a fix for random tests prior to ILIAS 3.8. If someone started a random test in ILIAS < 3.8, there
// is only one test pass (pass = 0) in tst_test_rnd_qst while with ILIAS 3.8 there are questions for every test pass.
// To prevent problems with tests started in an older version and continued in ILIAS 3.8, the first pass should be taken if
// no questions are present for a newer pass.
if ($result->numRows() == 0)
{
$result = $ilDB->queryF("SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = 0 ORDER BY sequence",
array('integer'),
array($this->active_id)
);
}
}
else
{
$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"];
}
}

+ Here is the caller 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 464 of file class.ilTestSequence.php.

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 216 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 286 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::saveToDb ( )

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

public

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

References $ilDB.

{
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())
));
}
ilTestSequence::setPass (   $pass)

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

References $pass.

{
$this->pass = $pass;
}

Field Documentation

ilTestSequence::$active_id

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

Referenced by getActiveId(), and ilTestSequence().

ilTestSequence::$isRandomTest

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

ilTestSequence::$pass

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

Referenced by getPass(), getSequenceSummary(), ilTestSequence(), and setPass().

ilTestSequence::$questions

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

Referenced by getOrderedSequenceQuestions().

ilTestSequence::$sequencedata

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


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