ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLOUserResults Class Reference
+ Collaboration diagram for ilLOUserResults:

Public Member Functions

 __construct ($a_course_obj_id, $a_user_id)
 Constructor.
 delete ()
 Delete for user and course type $ilDB.
 saveObjectiveResult ($a_objective_id, $a_type, $a_status, $a_result_percentage, $a_limit_percentage, $a_tries, $a_is_final)
 Save objective result.
 getCompletedObjectiveIdsByType ($a_type)
 All completed objectives by type.
 getSuggestedObjectiveIds ()
 Get all objectives where the user failed the initial test.
 getCompletedObjectiveIds ()
 Get all objectives where the user completed the qualified test.
 getFailedObjectiveIds ($a_is_final=true)
 Get all objectives where the user failed the qualified test.
 getCourseResultsForUserPresentation ()
 Get all results for course and user.

Static Public Member Functions

static lookupResult ($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
 Lookup user result.
static resetFinalByObjective ($a_objective_id)
static deleteResultsForUser ($a_user_id)
 Delete all result entries for user.
static deleteResultsForCourse ($a_course_id)
 Delete all result entries for course.
static deleteResultsFromLP ($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified)
 Delete all (qualified) result entries for course members.
static getObjectiveStatusForLP ($a_user_id, array $a_objective_ids)
static getSummarizedObjectiveStatusForLP (array $a_objective_ids, $a_user_id=null)
static hasResults ($a_container_id, $a_user_id)

Data Fields

const TYPE_INITIAL = 1
const TYPE_QUALIFIED = 2
const STATUS_COMPLETED = 1
const STATUS_FAILED = 2

Protected Member Functions

 findObjectiveIds ($a_type=null, $a_status=null, $a_is_final=null)
 Find objective ids by type and/or status.

Static Protected Member Functions

static isValidType ($a_type)
 Is given type valid?
static isValidStatus ($a_status)
 Is given status valid?

Protected Attributes

 $course_obj_id
 $user_id

Detailed Description

Definition at line 11 of file class.ilLOUserResults.php.

Constructor & Destructor Documentation

ilLOUserResults::__construct (   $a_course_obj_id,
  $a_user_id 
)

Constructor.

Parameters
int$a_course_obj_id
int$a_user_id
Returns
ilLOUserResults

Definition at line 29 of file class.ilLOUserResults.php.

{
$this->course_obj_id = (int)$a_course_obj_id;
$this->user_id = (int)$a_user_id;
}

Member Function Documentation

ilLOUserResults::delete ( )

Delete for user and course type $ilDB.

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

References $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

{
global $ilDB;
$query = 'DELETE FROM loc_user_results '.
'WHERE course_id = '.$ilDB->quote($this->course_obj_id).' '.
'AND user_id = '.$ilDB->quote($this->user_id);
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilLOUserResults::deleteResultsForCourse (   $a_course_id)
static

Delete all result entries for course.

Parameters
int$a_course_id
Returns
bool

Definition at line 124 of file class.ilLOUserResults.php.

References $ilDB.

{
global $ilDB;
if(!(int)$a_course_id)
{
return false;
}
$ilDB->manipulate("DELETE FROM loc_user_results".
" WHERE course_id = ".$ilDB->quote($a_course_id, "integer"));
return true;
}
static ilLOUserResults::deleteResultsForUser (   $a_user_id)
static

Delete all result entries for user.

Parameters
int$a_user_id
Returns
bool

Definition at line 103 of file class.ilLOUserResults.php.

References $ilDB.

Referenced by ilObjCourse\_deleteUser().

{
global $ilDB;
if(!(int)$a_user_id)
{
return false;
}
$ilDB->manipulate("DELETE FROM loc_user_results".
" WHERE user_id = ".$ilDB->quote($a_user_id, "integer"));
return true;
}

+ Here is the caller graph for this function:

static ilLOUserResults::deleteResultsFromLP (   $a_course_id,
array  $a_user_ids,
  $a_remove_initial,
  $a_remove_qualified 
)
static

Delete all (qualified) result entries for course members.

Parameters
int$a_course_id
array$a_user_ids
bool$a_remove_initial
bool$a_remove_qualified
Returns
bool

Definition at line 161 of file class.ilLOUserResults.php.

References $ilDB.

Referenced by ilTestLP\resetCustomLPDataForUserIds().

{
global $ilDB;
if(!(int)$a_course_id || !sizeof($a_user_ids))
{
return false;
}
$sql = "DELETE FROM loc_user_results".
" WHERE course_id = ".$ilDB->quote($a_course_id, "integer").
" AND ".$ilDB->in("user_id", $a_user_ids, "", "integer");
if(!(bool)$a_remove_initial || !(bool)$a_remove_qualified)
{
if((bool)$a_remove_initial)
{
$sql .= " AND type = ".$ilDB->quote(self::TYPE_INITIAL, "integer");
}
else
{
$sql .= " AND type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer");
}
}
$ilDB->manipulate($sql);
return true;
}

+ Here is the caller graph for this function:

ilLOUserResults::findObjectiveIds (   $a_type = null,
  $a_status = null,
  $a_is_final = null 
)
protected

Find objective ids by type and/or status.

Parameters
int$a_type
int$a_status
bool$a_is_final
Returns
array

Definition at line 239 of file class.ilLOUserResults.php.

References $ilDB, $res, $row, isValidStatus(), and isValidType().

Referenced by getCompletedObjectiveIds(), getCompletedObjectiveIdsByType(), getFailedObjectiveIds(), and getSuggestedObjectiveIds().

{
global $ilDB;
$res = array();
$sql = "SELECT objective_id".
" FROM loc_user_results".
" WHERE course_id = ".$ilDB->quote($this->course_obj_id, "integer").
" AND user_id = ".$ilDB->quote($this->user_id, "integer");
if($this->isValidType($a_type))
{
$sql .= " AND type = ".$ilDB->quote($a_type, "integer");
}
if($this->isValidStatus($a_status))
{
$sql .= " AND status = ".$ilDB->quote($a_status, "integer");
}
if($a_is_final !== null)
{
$sql .= " AND is_final = ".$ilDB->quote($a_is_final, "integer");
}
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row["objective_id"];
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOUserResults::getCompletedObjectiveIds ( )

Get all objectives where the user completed the qualified test.

Returns
array objective-ids

Definition at line 297 of file class.ilLOUserResults.php.

References findObjectiveIds().

{
return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED);
}

+ Here is the call graph for this function:

ilLOUserResults::getCompletedObjectiveIdsByType (   $a_type)

All completed objectives by type.

Parameters
type$a_type
Returns
type

Definition at line 277 of file class.ilLOUserResults.php.

References findObjectiveIds().

{
return $this->findObjectiveIds($a_type, self::STATUS_COMPLETED);
}

+ Here is the call graph for this function:

ilLOUserResults::getCourseResultsForUserPresentation ( )

Get all results for course and user.

Returns
array

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

References $ilDB, $res, and $row.

{
global $ilDB;
$res = array();
$set = $ilDB->query("SELECT *".
" FROM loc_user_results".
" WHERE course_id = ".$ilDB->quote($this->course_obj_id, "integer").
" AND user_id = ".$ilDB->quote($this->user_id, "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$objective_id = $row["objective_id"];
$type = $row["type"];
unset($row["objective_id"]);
unset($row["type"]);
$res[$objective_id][$type] = $row;
}
return $res;
}
ilLOUserResults::getFailedObjectiveIds (   $a_is_final = true)

Get all objectives where the user failed the qualified test.

Parameters
bool$a_is_final
Returns
array objective-ids

Definition at line 308 of file class.ilLOUserResults.php.

References findObjectiveIds().

{
return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_FAILED, $a_is_final);
}

+ Here is the call graph for this function:

static ilLOUserResults::getObjectiveStatusForLP (   $a_user_id,
array  $a_objective_ids 
)
static

Definition at line 340 of file class.ilLOUserResults.php.

References $ilDB, $res, $row, ilLPStatus\LP_STATUS_COMPLETED_NUM, and ilLPStatus\LP_STATUS_FAILED_NUM.

Referenced by ilTrQuery\getObjectivesStatusForUser().

{
global $ilDB;
// this method returns LP status codes!
include_once "Services/Tracking/classes/class.ilLPStatus.php";
$res = array();
$sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
" FROM loc_user_results lor".
" JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
" WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer").
" AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer").
" AND lor.user_id = ".$ilDB->quote($a_user_id, "integer").
" AND cobj.active = ".$ilDB->quote(1, "integer");
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
switch($row["status"])
{
case self::STATUS_FAILED:
break;
case self::STATUS_COMPLETED:
break;
default:
/*
$status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
break;
*/
continue;
}
$res[$row["objective_id"]] = $status;
}
return $res;
}

+ Here is the caller graph for this function:

ilLOUserResults::getSuggestedObjectiveIds ( )

Get all objectives where the user failed the initial test.

Returns
array objective-ids

Definition at line 287 of file class.ilLOUserResults.php.

References findObjectiveIds().

{
return $this->findObjectiveIds(self::TYPE_INITIAL, self::STATUS_FAILED);
}

+ Here is the call graph for this function:

static ilLOUserResults::getSummarizedObjectiveStatusForLP ( array  $a_objective_ids,
  $a_user_id = null 
)
static

Definition at line 383 of file class.ilLOUserResults.php.

References $ilDB, $res, $row, $user_id, ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.

Referenced by ilLPStatusObjectives\_getStatusInfo(), and ilLPStatusObjectives\determineStatus().

{
global $ilDB;
// this method returns LP status codes!
include_once "Services/Tracking/classes/class.ilLPStatus.php";
$res = $tmp_completed = array();
$sql = "SELECT lor.objective_id, lor.user_id, lor.status, lor.is_final".
" FROM loc_user_results lor".
" JOIN crs_objectives cobj ON (cobj.objective_id = lor.objective_id)".
" WHERE ".$ilDB->in("lor.objective_id", $a_objective_ids, "", "integer").
" AND lor.type = ".$ilDB->quote(self::TYPE_QUALIFIED, "integer").
" AND cobj.active = ".$ilDB->quote(1, "integer");
if($a_user_id)
{
$sql .= " AND lor.user_id = ".$ilDB->quote($a_user_id, "integer");
}
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
$user_id = (int)$row["user_id"];
$status = (int)$row["status"];
// user did do something
switch($status)
{
case self::STATUS_COMPLETED:
$tmp_completed[$user_id]++;
break;
case self::STATUS_FAILED:
if((bool)$row["is_final"])
{
// object is failed when at least 1 objective is failed without any tries left
}
break;
}
}
$all_nr = sizeof($a_objective_ids);
foreach($tmp_completed as $user_id => $counter)
{
// if used as precondition object should be completed ASAP, status can be lost on subsequent tries
if($counter == $all_nr)
{
}
}
if($a_user_id)
{
// might return null!
return $res[$a_user_id];
}
else
{
return $res;
}
}

+ Here is the caller graph for this function:

static ilLOUserResults::hasResults (   $a_container_id,
  $a_user_id 
)
static

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

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

Referenced by ilContainerObjectiveGUI\getMainContent().

{
global $ilDB;
$query = 'SELECT objective_id FROM loc_user_results '.
'WHERE course_id = '.$ilDB->quote($a_container_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:

static ilLOUserResults::isValidStatus (   $a_status)
staticprotected

Is given status valid?

Parameters
int$a_status
Returns
bool

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

Referenced by findObjectiveIds().

{
return in_array((int)$a_status, array(self::STATUS_COMPLETED, self::STATUS_FAILED));
}

+ Here is the caller graph for this function:

static ilLOUserResults::isValidType (   $a_type)
staticprotected

Is given type valid?

Parameters
int$a_type
Returns
bool

Definition at line 81 of file class.ilLOUserResults.php.

Referenced by findObjectiveIds().

{
return in_array((int)$a_type, array(self::TYPE_INITIAL, self::TYPE_QUALIFIED));
}

+ Here is the caller graph for this function:

static ilLOUserResults::lookupResult (   $a_course_obj_id,
  $a_user_id,
  $a_objective_id,
  $a_tst_type 
)
static

Lookup user result.

Definition at line 38 of file class.ilLOUserResults.php.

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

Referenced by ilContainerObjectiveGUI\addItemDetails(), ilLOTestQuestionAdapter\initUserResult(), and ilLOTestQuestionAdapter\updateQuestionResult().

{
global $ilDB;
$query = 'SELECT * FROM loc_user_results '.
'WHERE user_id = '.$ilDB->quote($a_user_id,'integer').' '.
'AND course_id = '.$ilDB->quote($a_course_obj_id,'integer').' '.
'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
'AND type = '.$ilDB->quote($a_tst_type,'integer');
$res = $ilDB->query($query);
$ur = array(
'status' => self::STATUS_FAILED,
'result_perc' => 0,
'limit_perc' => 0,
'tries' => 0,
'is_final' => 0
);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$ur['status'] = $row->status;
$ur['result_perc'] = $row->result_perc;
$ur['limit_perc'] = $row->limit_perc;
$ur['tries'] = $row->tries;
$ur['is_final'] = $row->is_final;
}
return $ur;
}

+ Here is the caller graph for this function:

static ilLOUserResults::resetFinalByObjective (   $a_objective_id)
static

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

References $GLOBALS, and $query.

{
$query = 'UPDATE loc_user_results '.
'SET is_final = '.$GLOBALS['ilDB']->quote(0,'integer').' '.
'WHERE objective_id = '.$GLOBALS['ilDB']->quote($a_objective_id,'integer');
$GLOBALS['ilDB']->manipulate($query);
}
ilLOUserResults::saveObjectiveResult (   $a_objective_id,
  $a_type,
  $a_status,
  $a_result_percentage,
  $a_limit_percentage,
  $a_tries,
  $a_is_final 
)

Save objective result.

Parameters
int$a_objective_id
int$a_type
int$a_status
int$a_result_percentage
int$a_limit_percentage
int$a_tries
bool$a_is_final
Returns
bool

Definition at line 203 of file class.ilLOUserResults.php.

References $ilDB.

{
global $ilDB;
if(!self::isValidType($a_type) ||
!self::isValidStatus($a_status))
{
return false;
}
$ilDB->replace("loc_user_results",
array(
"course_id" => array("integer", $this->course_obj_id),
"user_id" => array("integer", $this->user_id),
"objective_id" => array("integer", $a_objective_id),
"type" => array("integer", $a_type)
),
array(
"status" => array("integer", $a_status),
"result_perc" => array("integer", $a_result_percentage),
"limit_perc" => array("integer", $a_limit_percentage),
"tries" => array("integer", $a_tries),
"is_final" => array("integer", $a_is_final),
"tstamp" => array("integer", time()),
)
);
return true;
}

Field Documentation

ilLOUserResults::$course_obj_id
protected

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

ilLOUserResults::$user_id
protected

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

Referenced by getSummarizedObjectiveStatusForLP().

const ilLOUserResults::STATUS_FAILED = 2

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