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

Stores current objective, questions and max points. More...

+ Collaboration diagram for ilLOTestRun:

Public Member Functions

 __construct ($a_crs_id, $a_user_id, $a_test_id, $a_objective_id)
 getContainerId ()
 getUserId ()
 getTestId ()
 getObjectiveId ()
 getMaxPoints ()
 setMaxPoints ($a_points)
 getQuestions ()
 clearQuestions ()
 addQuestion ($a_id)
 questionExists ($a_question_id)
 setQuestionResult ($a_qst_id, $a_points)
 getResult ()
 Get result for objective run.
 delete ()
 Delete all entries type $ilDB.
 create ()
 update ()
 read ()
 type $ilDB

Static Public Member Functions

static lookupRunExistsForObjective ($a_test_id, $a_objective_id, $a_user_id)
 type $ilDB
static deleteRun ($a_container_id, $a_user_id, $a_test_id)
static lookupObjectives ($a_container_id, $a_user_id, $a_test_id)
static getRun ($a_container_id, $a_user_id, $a_test_id)

Protected Attributes

 $container_id = 0
 $user_id = 0
 $test_id = 0
 $objective_id = 0
 $max_points = 0
 $questions = array()

Detailed Description

Stores current objective, questions and max points.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 10 of file class.ilLOTestRun.php.

Constructor & Destructor Documentation

ilLOTestRun::__construct (   $a_crs_id,
  $a_user_id,
  $a_test_id,
  $a_objective_id 
)

Definition at line 21 of file class.ilLOTestRun.php.

References read().

{
$this->container_id = $a_crs_id;
$this->user_id = $a_user_id;
$this->test_id = $a_test_id;
$this->objective_id = $a_objective_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilLOTestRun::addQuestion (   $a_id)

Definition at line 147 of file class.ilLOTestRun.php.

{
$this->questions[$a_id] = 0;
}
ilLOTestRun::clearQuestions ( )

Definition at line 142 of file class.ilLOTestRun.php.

{
$this->questions = array();
}
ilLOTestRun::create ( )

Definition at line 209 of file class.ilLOTestRun.php.

References $ilDB, $query, getContainerId(), getMaxPoints(), getObjectiveId(), getQuestions(), getTestId(), and getUserId().

Referenced by ilObjCourseGUI\redirectLocToTestObject().

{
global $ilDB;
$query = 'INSERT INTO loc_tst_run '.
'(container_id, user_id, test_id, objective_id,max_points,questions) '.
'VALUES( '.
$ilDB->quote($this->getContainerId(),'integer').', '.
$ilDB->quote($this->getUserId(),'integer').', '.
$ilDB->quote($this->getTestId(),'integer').', '.
$ilDB->quote($this->getObjectiveId(),'integer').', '.
$ilDB->quote($this->getMaxPoints(),'integer').', '.
$ilDB->quote(serialize($this->getQuestions()),'text').' '.
')';
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOTestRun::delete ( )

Delete all entries type $ilDB.

Definition at line 197 of file class.ilLOTestRun.php.

References $ilDB, $query, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

{
global $ilDB;
$query = 'DELETE FROM loc_tst_run '.
'WHERE container_id = ' . $ilDB->quote($this->getContainerId(),'integer').' '.
'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer');
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

static ilLOTestRun::deleteRun (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static

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

References $ilDB, and $query.

Referenced by ilObjCourseGUI\redirectLocToTestObject(), and ilObjCourseGUI\resetObject().

{
global $ilDB;
$query = 'DELETE FROM loc_tst_run '.
'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
'AND test_id = '.$ilDB->quote($a_test_id,'integer').' ';
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

ilLOTestRun::getContainerId ( )

Definition at line 107 of file class.ilLOTestRun.php.

References $container_id.

Referenced by create(), delete(), and read().

{
}

+ Here is the caller graph for this function:

ilLOTestRun::getMaxPoints ( )

Definition at line 127 of file class.ilLOTestRun.php.

References $max_points.

Referenced by create(), getResult(), and update().

{
}

+ Here is the caller graph for this function:

ilLOTestRun::getObjectiveId ( )

Definition at line 122 of file class.ilLOTestRun.php.

References $objective_id.

Referenced by create(), delete(), read(), and update().

{
}

+ Here is the caller graph for this function:

ilLOTestRun::getQuestions ( )

Definition at line 137 of file class.ilLOTestRun.php.

References $questions.

Referenced by create(), and update().

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

+ Here is the caller graph for this function:

ilLOTestRun::getResult ( )

Get result for objective run.

Definition at line 172 of file class.ilLOTestRun.php.

References getMaxPoints().

{
$sum_points = 0;
foreach($this->questions as $qid => $points)
{
$sum_points += (int) $points;
}
$percentage =
($this->getMaxPoints() > 0) ?
($sum_points / $this->getMaxPoints() * 100) :
100;
return array(
'max' => $this->getMaxPoints(),
'reached' => $sum_points,
'percentage' => $percentage
);
}

+ Here is the call graph for this function:

static ilLOTestRun::getRun (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static
Returns
ilLOTestRun[]

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

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilLOTestQuestionAdapter\initTestRun().

{
global $ilDB;
$query = 'SELECT objective_id FROM loc_tst_run '.
'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
'AND test_id = '.$ilDB->quote($a_test_id,'integer').' ';
$res = $ilDB->query($query);
$run = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
}
return $run;
}

+ Here is the caller graph for this function:

ilLOTestRun::getTestId ( )

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

References $test_id.

Referenced by create(), delete(), read(), and update().

{
}

+ Here is the caller graph for this function:

ilLOTestRun::getUserId ( )

Definition at line 112 of file class.ilLOTestRun.php.

References $user_id.

Referenced by create(), delete(), read(), and update().

{
}

+ Here is the caller graph for this function:

static ilLOTestRun::lookupObjectives (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static

Definition at line 67 of file class.ilLOTestRun.php.

References $GLOBALS, $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjCourseGUI\handleActivePass(), and ilLOUtils\hasActiveRun().

{
global $ilDB;
$query = 'SELECT objective_id FROM loc_tst_run '.
'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
'AND test_id = '.$ilDB->quote($a_test_id,'integer');
$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
$res = $ilDB->query($query);
$objectives = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$objectives[] = $row->objective_id;
}
return $objectives;
}

+ Here is the caller graph for this function:

static ilLOTestRun::lookupRunExistsForObjective (   $a_test_id,
  $a_objective_id,
  $a_user_id 
)
static

type $ilDB

Parameters
type$a_test_obj_id
type$a_objective_id
type$a_user_id
Returns
boolean

Definition at line 39 of file class.ilLOTestRun.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\updateResult().

{
global $ilDB;
$query = 'SELECT * FROM loc_tst_run '.
'WHERE test_id = '.$ilDB->quote($a_test_id,'integer').' '.
'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_user_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilLOTestRun::questionExists (   $a_question_id)

Definition at line 152 of file class.ilLOTestRun.php.

{
return array_key_exists($a_question_id,(array) $this->questions);
}
ilLOTestRun::read ( )

type $ilDB

Definition at line 244 of file class.ilLOTestRun.php.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

Referenced by __construct().

{
global $ilDB;
$query = 'SELECT * FROM loc_tst_run '.
'WHERE container_id = ' . $ilDB->quote($this->getContainerId(),'integer').' '.
'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->max_points = $row->max_points;
if($row->questions)
{
$this->questions = unserialize($row->questions);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOTestRun::setMaxPoints (   $a_points)

Definition at line 132 of file class.ilLOTestRun.php.

{
$this->max_points = $a_points;
}
ilLOTestRun::setQuestionResult (   $a_qst_id,
  $a_points 
)

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

References $GLOBALS.

{
$GLOBALS['ilLog']->write(__METHOD__.': '.$a_qst_id.' '.$a_points);
if($this->questions[$a_qst_id] < $a_points)
{
$this->questions[$a_qst_id] = $a_points;
}
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($this->questions,true));
}
ilLOTestRun::update ( )

Definition at line 226 of file class.ilLOTestRun.php.

References $ilDB, $query, getMaxPoints(), getObjectiveId(), getQuestions(), getTestId(), and getUserId().

{
global $ilDB;
$query = 'UPDATE loc_tst_run SET '.
'max_points = '.$ilDB->quote($this->getMaxPoints(),'integer').', '.
'questions = '.$ilDB->quote(serialize($this->getQuestions()),'text').' '.
'WHERE container_id = '.$ilDB->quote($this->container_id,'integer').' '.
'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' ';
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

Field Documentation

ilLOTestRun::$container_id = 0
protected

Definition at line 12 of file class.ilLOTestRun.php.

Referenced by getContainerId().

ilLOTestRun::$max_points = 0
protected

Definition at line 17 of file class.ilLOTestRun.php.

Referenced by getMaxPoints().

ilLOTestRun::$objective_id = 0
protected

Definition at line 15 of file class.ilLOTestRun.php.

Referenced by getObjectiveId().

ilLOTestRun::$questions = array()
protected

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

Referenced by getQuestions().

ilLOTestRun::$test_id = 0
protected

Definition at line 14 of file class.ilLOTestRun.php.

Referenced by getTestId().

ilLOTestRun::$user_id = 0
protected

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

Referenced by getUserId().


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