ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseObjectiveResult Class Reference

class ilcourseobjective More...

+ Collaboration diagram for ilCourseObjectiveResult:

Public Member Functions

 ilCourseObjectiveResult ($a_usr_id)
 getUserId ()
 getAccomplished ($a_crs_id)
 _getAccomplished ($a_user_id, $a_crs_id)
 getSuggested ($a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
 _getSuggested ($a_user_id, $a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
 reset ($a_course_id)
 getStatus ($a_course_id)
 hasAccomplishedObjective ($a_objective_id)
 readStatus ($a_crs_id)
 __deleteEntries ($a_objective_ids)
 _updateObjectiveResult ($a_user_id, $a_active_id, $a_question_id)
 _readAssignedObjectivesOfQuestion ($a_question_id)
 _readAssignedObjectives ($a_all_objectives)
 _updateObjectiveStatus ($a_user_id, $objectives)
 __isFullfilled ($question_points, $objective_data)
 __updatePassed ($a_user_id, $objective_ids)

Static Public Member Functions

static getSuggestedQuestions ($a_usr_id, $a_crs_id)
 get suggested questions ids
static _deleteUser ($user_id)

Data Fields

 $db = null
 $user_id = null

Detailed Description

class ilcourseobjective

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 19 of file class.ilCourseObjectiveResult.php.

Member Function Documentation

ilCourseObjectiveResult::__deleteEntries (   $a_objective_ids)

Definition at line 256 of file class.ilCourseObjectiveResult.php.

References $ilLog.

{
global $ilLog;
$ilLog->logStack();
#$ilLog(__METHOD__.': Call of deprecated method.');
return true;
}
ilCourseObjectiveResult::__isFullfilled (   $question_points,
  $objective_data 
)

Definition at line 432 of file class.ilCourseObjectiveResult.php.

Referenced by _updateObjectiveStatus().

{
if(!is_array($objective_data['questions']))
{
return false;
}
$max_points = 0;
$reached_points = 0;
foreach($objective_data['questions'] as $question_id)
{
$max_points += $question_points[$question_id]['max_points'];
$reached_points += $question_points[$question_id]['reached_points'];
}
if(!$max_points)
{
return false;
}
return $reached_points >= $objective_data['tst_limit'] ? true : false;
return (($reached_points / $max_points * 100) >= $objective_data['tst_limit']) ? true : false;
}

+ Here is the caller graph for this function:

ilCourseObjectiveResult::__updatePassed (   $a_user_id,
  $objective_ids 
)

Definition at line 455 of file class.ilCourseObjectiveResult.php.

References $query, $res, $row, ilCourseParticipants\_getInstanceByObjId(), ilLPStatusWrapper\_updateStatus(), and DB_FETCHMODE_OBJECT.

Referenced by _updateObjectiveStatus().

{
global $ilDB;
$passed = array();
$query = "SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 ".
"JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and ".
$ilDB->in('t1.objective_id',$objective_ids,false,'integer')." ".
"GROUP BY t1.crs_id";
$res = $ilDB->query($query);
$crs_ids = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$query = "SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs ".
"JOIN crs_objectives co ON cs.objective_id = co.objective_id ".
"WHERE crs_id = ".$ilDB->quote($row->crs_id ,'integer')." ".
"AND user_id = ".$ilDB->quote($a_user_id ,'integer')." ";
$user_res = $ilDB->query($query);
while($user_row = $user_res->fetchRow(DB_FETCHMODE_OBJECT))
{
if($user_row->num_passed == $row->num)
{
$passed[] = $row->crs_id;
}
}
$crs_ids[$row->crs_id] = $row->crs_id;
}
if(count($passed))
{
foreach($passed as $crs_id)
{
include_once('Modules/Course/classes/class.ilCourseParticipants.php');
$members->updatePassed($a_user_id,true);
}
}
// update tracking status
foreach ($crs_ids as $cid)
{
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseObjectiveResult::_deleteUser (   $user_id)
static

Definition at line 266 of file class.ilCourseObjectiveResult.php.

References $query, $res, and $user_id.

{
global $ilDB;
$query = "DELETE FROM crs_objective_status ".
"WHERE user_id = ".$ilDB->quote($user_id ,'integer')." ";
$res = $ilDB->manipulate($query);
$query = "DELETE FROM crs_objective_status_p ".
"WHERE user_id = ".$ilDB->quote($user_id ,'integer')." ";
$res = $ilDB->manipulate($query);
return true;
}
ilCourseObjectiveResult::_getAccomplished (   $a_user_id,
  $a_crs_id 
)

Definition at line 42 of file class.ilCourseObjectiveResult.php.

References $query, $res, $row, ilCourseObjective\_getObjectiveIds(), and DB_FETCHMODE_OBJECT.

Referenced by getAccomplished().

{
global $ilDB;
include_once 'Modules/Course/classes/class.ilCourseObjective.php';
$objectives = ilCourseObjective::_getObjectiveIds($a_crs_id);
if(!is_array($objectives))
{
return array();
}
$query = "SELECT objective_id FROM crs_objective_status ".
"WHERE ".$ilDB->in('objective_id',$objectives,false,'integer').' '.
"AND user_id = ".$ilDB->quote($a_user_id ,'integer')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$accomplished[] = $row->objective_id;
}
return $accomplished ? $accomplished : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_getSuggested (   $a_user_id,
  $a_crs_id,
  $a_status = IL_OBJECTIVE_STATUS_FINAL 
)

Definition at line 69 of file class.ilCourseObjectiveResult.php.

References $query, $res, $row, ilCourseObjective\_getObjectiveIds(), DB_FETCHMODE_OBJECT, IL_OBJECTIVE_STATUS_FINAL, and IL_OBJECTIVE_STATUS_FINISHED.

Referenced by getSuggested(), and ilCourseObjectiveResultCache\readSuggested().

{
global $ilDB;
include_once './Modules/Course/classes/class.ilCourseObjective.php';
$objectives = ilCourseObjective::_getObjectiveIds($a_crs_id);
$finished = array();
if($a_status == IL_OBJECTIVE_STATUS_FINAL or
{
// check finished
$query = "SELECT objective_id FROM crs_objective_status ".
"WHERE ".$ilDB->in('objective_id',$objectives,false,'integer')." ".
"AND user_id = ".$ilDB->quote($a_user_id ,'integer')." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$finished[] = $row->objective_id;
}
}
else
{
// Pretest
$query = "SELECT objective_id FROM crs_objective_status_p ".
"WHERE ".$ilDB->in('objective_id',$objectives,false,'integer').' '.
"AND user_id = ".$ilDB->quote($a_user_id ,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$finished[] = $row->objective_id;
}
}
foreach($objectives as $objective_id)
{
if(!in_array($objective_id,$finished))
{
$suggested[] = $objective_id;
}
}
return $suggested ? $suggested : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_readAssignedObjectives (   $a_all_objectives)

Definition at line 319 of file class.ilCourseObjectiveResult.php.

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

Referenced by _readAssignedObjectivesOfQuestion(), getStatus(), and readStatus().

{
global $ilDB;
// Read necessary points
$query = "SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit ".
"FROM crs_objective_tst t JOIN crs_objective_qst q ".
"ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
"WHERE ".$ilDB->in('t.objective_id',$a_all_objectives,false,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
/*
$objectives[$row->obj."_".$row->ref]['questions'][$row->question_id] = $row->question_id;
$objectives[$row->obj."_".$row->ref]['tst_status'] = $row->tst_status;
$objectives[$row->obj."_".$row->ref]['tst_limit'] = $row->tst_limit;
$objectives[$row->obj."_".$row->ref]['objective_id'] = $row->obj;
*/
$objectives[$row->obj."_".$row->tst_status]['questions'][$row->question_id] = $row->question_id;
$objectives[$row->obj."_".$row->tst_status]['tst_status'] = $row->tst_status;
$objectives[$row->obj."_".$row->tst_status]['tst_limit'] = $row->tst_limit;
$objectives[$row->obj."_".$row->tst_status]['objective_id'] = $row->obj;
}
return $objectives ? $objectives : array();
}

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_readAssignedObjectivesOfQuestion (   $a_question_id)

Definition at line 294 of file class.ilCourseObjectiveResult.php.

References $query, $res, $row, _readAssignedObjectives(), and DB_FETCHMODE_OBJECT.

Referenced by _updateObjectiveResult().

{
global $ilDB;
// get all objtives and questions this current question is assigned to
$query = "SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, ".
"crs_objective_qst q2 ".
"WHERE q1.question_id = ".$ilDB->quote($a_question_id ,'integer')." ".
"AND q1.objective_id = q2.objective_id ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$objectives['all_objectives'][$row->ob] = $row->ob;
$objectives['all_questions'][$row->qid] = $row->qid;
}
if(!is_array($objectives))
{
return false;
}
$objectives['objectives'] = ilCourseObjectiveResult::_readAssignedObjectives($objectives['all_objectives']);
return $objectives ? $objectives : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_updateObjectiveResult (   $a_user_id,
  $a_active_id,
  $a_question_id 
)

Definition at line 280 of file class.ilCourseObjectiveResult.php.

References _readAssignedObjectivesOfQuestion(), and _updateObjectiveStatus().

Referenced by assQuestion\_setReachedPoints(), and assQuestion\calculateResultsFromSolution().

{
// find all objectives this question is assigned to
{
// no objectives found. TODO user has passed a test. After that questions of that test are assigned to an objective.
// => User has not passed
return true;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_updateObjectiveStatus (   $a_user_id,
  $objectives 
)

Definition at line 349 of file class.ilCourseObjectiveResult.php.

References $data, $ilUser, $query, $res, $row, __isFullfilled(), __updatePassed(), and DB_FETCHMODE_OBJECT.

Referenced by _updateObjectiveResult(), and readStatus().

{
global $ilDB,$ilUser;
if(!count($objectives['all_questions']) or
!count($objectives['all_objectives']))
{
return false;
}
// Read reachable points
$query = "SELECT question_id,points FROM qpl_questions ".
"WHERE ".$ilDB->in('question_id',(array) $objectives['all_questions'],false,'integer');
$res = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($res))
{
$objectives['all_question_points'][$row['question_id']]['max_points'] = $row['points'];
}
// Read reached points
$query = "SELECT question_fi, MAX(points) as reached FROM tst_test_result ".
"JOIN tst_active ON (active_id = active_fi) ".
"WHERE user_fi = ".$ilDB->quote($a_user_id,'integer')." ".
"AND ".$ilDB->in('question_fi',(array) $objectives['all_questions'],false,'integer')." ".
#"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
"GROUP BY question_fi,user_fi";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$objectives['all_question_points'][$row->question_fi]['reached_points'] = $row->reached;
}
// Check accomplished
$fullfilled = array();
$pretest = array();
foreach($objectives['objectives'] as $kind => $data)
{
// objective does not allow to change status
if(ilCourseObjectiveResult::__isFullfilled($objectives['all_question_points'],$data))
{
// Status 0 means pretest fullfilled, status 1 means final test fullfilled
if($data['tst_status'])
{
$fullfilled[] = array($data['objective_id'],$ilUser->getId(),$data['tst_status']);
}
else
{
$pretest[] = array($data['objective_id'],$ilUser->getId());
}
}
}
if(count($fullfilled))
{
foreach($fullfilled as $fullfilled_arr)
{
$ilDB->replace(
'crs_objective_status',
array(
'objective_id' => array('integer',$fullfilled_arr[0]),
'user_id' => array('integer',$fullfilled_arr[1])
),
array(
'status' => array('integer',$fullfilled_arr[2])
)
);
}
ilCourseObjectiveResult::__updatePassed($a_user_id,$objectives['all_objectives']);
}
if(count($pretest))
{
foreach($pretest as $pretest_arr)
{
$ilDB->replace(
'crs_objective_status_p',
array(
'objective_id' => array('integer',$pretest_arr[0]),
'user_id' => array('integer',$pretest_arr[1])
),
array()
);
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::getAccomplished (   $a_crs_id)

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

References _getAccomplished(), and getUserId().

Referenced by getStatus().

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::getStatus (   $a_course_id)

Definition at line 175 of file class.ilCourseObjectiveResult.php.

References $data, assQuestion\_areAnswered(), ilCourseObjective\_getObjectiveIds(), _readAssignedObjectives(), getAccomplished(), getSuggested(), getUserId(), IL_OBJECTIVE_STATUS_EMPTY, IL_OBJECTIVE_STATUS_FINAL, IL_OBJECTIVE_STATUS_FINISHED, IL_OBJECTIVE_STATUS_NONE, IL_OBJECTIVE_STATUS_PRETEST, and IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST.

{
include_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
include_once 'Modules/Course/classes/class.ilCourseObjective.php';
$objective_ids = ilCourseObjective::_getObjectiveIds($a_course_id);
$objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids);
$accomplished = $this->getAccomplished($a_course_id);
$suggested = $this->getSuggested($a_course_id);
if(!count($objective_ids))
{
}
if(count($accomplished) == count($objective_ids))
{
}
$all_pretest_answered = false;
$all_final_answered = false;
foreach($objectives as $data)
{
if(assQuestion::_areAnswered($this->getUserId(),$data['questions']))
{
if($data['tst_status'])
{
$all_final_answered = true;
}
else
{
$all_pretest_answered = true;
}
}
}
if($all_final_answered)
{
}
if($all_pretest_answered and
!count($suggested))
{
}
elseif($all_pretest_answered)
{
}
}

+ Here is the call graph for this function:

ilCourseObjectiveResult::getSuggested (   $a_crs_id,
  $a_status = IL_OBJECTIVE_STATUS_FINAL 
)

Definition at line 64 of file class.ilCourseObjectiveResult.php.

References _getSuggested(), and getUserId().

Referenced by getStatus().

{
return ilCourseObjectiveResult::_getSuggested($this->getUserId(),$a_crs_id,$a_status);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseObjectiveResult::getSuggestedQuestions (   $a_usr_id,
  $a_crs_id 
)
static

get suggested questions ids

Parameters
object$a_usr_id
object$a_crs_id
Returns

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

{
foreach(self::_getSuggested($a_usr_id,$a_crs_id) as $objective_id)
{
include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
$obj = new ilCourseObjectiveQuestion($objective_id);
foreach($obj->getFinalTestQuestions() as $qst)
{
$qsts[] = $qst['question_id'];
}
}
return $qsts ? $qsts : array();
}
ilCourseObjectiveResult::getUserId ( )

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

References $user_id.

Referenced by getAccomplished(), getStatus(), getSuggested(), hasAccomplishedObjective(), readStatus(), and reset().

{
}

+ Here is the caller graph for this function:

ilCourseObjectiveResult::hasAccomplishedObjective (   $a_objective_id)

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

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getUserId().

{
global $ilDB;
$query = "SELECT status FROM crs_objective_status ".
"WHERE objective_id = ".$ilDB->quote($a_objective_id ,'integer')." ".
"AND user_id = ".$ilDB->quote($this->getUserId() ,'integer')."";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilCourseObjectiveResult::ilCourseObjectiveResult (   $a_usr_id)

Definition at line 25 of file class.ilCourseObjectiveResult.php.

{
global $ilDB;
$this->db =& $ilDB;
$this->user_id = $a_usr_id;
}
ilCourseObjectiveResult::readStatus (   $a_crs_id)

Definition at line 242 of file class.ilCourseObjectiveResult.php.

References ilCourseObjective\_getObjectiveIds(), _readAssignedObjectives(), _updateObjectiveStatus(), and getUserId().

{
include_once './Modules/Course/classes/class.ilCourseObjective.php';
$objective_ids = ilCourseObjective::_getObjectiveIds($a_crs_id);
$objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids);
return true;
}

+ Here is the call graph for this function:

ilCourseObjectiveResult::reset (   $a_course_id)

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

References $query, $res, ilCourseObjective\_getObjectiveIds(), ilLPStatusWrapper\_updateStatus(), ilObjectFactory\getInstanceByRefId(), and getUserId().

Referenced by ilObjCourseGUI\cciResetObject(), ilCourseObjectivePresentationGUI\reset(), and ilObjCourseGUI\resetObject().

{
global $ilDB;
include_once './Modules/Course/classes/class.ilCourseObjective.php';
include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
foreach($objectives = ilCourseObjective::_getObjectiveIds($a_course_id) as $objective_id)
{
$tmp_obj_question =& new ilCourseObjectiveQuestion($objective_id);
foreach($tmp_obj_question->getTests() as $test_data)
{
#$this->__deleteEntries($tmp_obj_question->getQuestionsByTest($test_data['ref_id']));
if($tmp_test =& ilObjectFactory::getInstanceByRefId($test_data['ref_id']))
{
$tmp_test->removeTestResultsForUser($this->getUserId());
unset($tmp_test);
}
}
}
if(count($objectives))
{
$query = "DELETE FROM crs_objective_status ".
"WHERE ".$ilDB->in('objective_id',$objectives,false,'integer').' '.
"AND user_id = ".$ilDB->quote($this->getUserId() ,'integer')." ";
$res = $ilDB->manipulate($query);
$query = "DELETE FROM crs_objective_status_p ".
"WHERE ".$ilDB->in('objective_id',$objectives,false,'integer').' '.
"AND user_id = ".$ilDB->quote($this->getUserId())."";
$res = $ilDB->manipulate($query);
}
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCourseObjectiveResult::$db = null

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

ilCourseObjectiveResult::$user_id = null

Definition at line 22 of file class.ilCourseObjectiveResult.php.

Referenced by _deleteUser(), and getUserId().


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