ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseObjectiveResult Class Reference
+ 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)
 _deleteUser ($user_id)
 _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)

Data Fields

 $db = null
 $user_id = null

Detailed Description

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

Member Function Documentation

ilCourseObjectiveResult::__deleteEntries (   $a_objective_ids)

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

References $in, getUserId(), and ilUtil\quoteArray().

Referenced by reset().

{
global $ilDB;
if(!count($a_objective_ids))
{
return true;
}
$in = "IN (";
$in .= implode(",",ilUtil::quoteArray($a_objective_ids));
$in .= ")";
$query = "DELETE FROM crs_objective_results ".
"WHERE usr_id = ".$ilDB->quote($this->getUserId())." ".
"AND question_id ".$in;
$this->db->query($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::__isFullfilled (   $question_points,
  $objective_data 
)

Definition at line 424 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 447 of file class.ilCourseObjectiveResult.php.

References $res, ilCourseParticipants\_getInstanceByObjId(), DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

Referenced by _updateObjectiveStatus().

{
global $ilDB;
$passed = array();
$query = "SELECT COUNT(t1.crs_id) AS num,t1.crs_id FROM crs_objectives as t1 ".
"JOIN crs_objectives as t2 WHERE t1.crs_id = t2.crs_id and t1.objective_id ".
"IN (".implode(",",ilUtil::quoteArray($objective_ids)).") ".
"GROUP BY t1.crs_id";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$query = "SELECT COUNT(cs.objective_id) AS num_passed FROM crs_objective_status AS cs ".
"JOIN crs_objectives AS co ON cs.objective_id = co.objective_id ".
"WHERE crs_id = ".$ilDB->quote($row->crs_id)." ".
"AND user_id = ".$ilDB->quote($a_user_id)." ";
$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;
}
}
}
if(count($passed))
{
foreach($passed as $crs_id)
{
include_once('Modules/Course/classes/class.ilCourseParticipants.php');
$members->updatePassed($a_user_id,true);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_deleteUser (   $user_id)

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

References $user_id.

{
global $ilDB;
$query = "DELETE FROM crs_objective_results ".
"WHERE usr_id = ".$ilDB->quote($user_id)." ";
$ilDB->query($query);
$query = "DELETE FROM crs_objective_status ".
"WHERE user_id = ".$ilDB->quote($user_id)." ";
$ilDB->query($query);
$query = "DELETE FROM crs_objective_status_pretest ".
"WHERE user_id = ".$ilDB->quote($user_id)." ";
$ilDB->query($query);
return true;
}
ilCourseObjectiveResult::_getAccomplished (   $a_user_id,
  $a_crs_id 
)

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

References $res, ilCourseObjective\_getObjectiveIds(), DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

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 objective_id IN (".implode(",",ilUtil::quoteArray($objectives))." ) ".
"AND user_id = ".$ilDB->quote($a_user_id)." ";
$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 92 of file class.ilCourseObjectiveResult.php.

References $res, ilCourseObjective\_getObjectiveIds(), DB_FETCHMODE_OBJECT, IL_OBJECTIVE_STATUS_FINAL, IL_OBJECTIVE_STATUS_FINISHED, and ilUtil\quoteArray().

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

{
global $ilDB;
$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 objective_id IN (".implode(",",ilUtil::quoteArray($objectives)).") ".
"AND user_id = ".$ilDB->quote($a_user_id)." ";
$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_pretest ".
"WHERE objective_id IN (".implode(",",ilUtil::quoteArray($objectives)).") ".
"AND user_id = ".$ilDB->quote($a_user_id)."";
$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 330 of file class.ilCourseObjectiveResult.php.

References $res, DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

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

{
global $ilDB;
// Read necessary points
$query = "SELECT t.objective_id as obj,t.ref_id as ref, question_id,tst_status,tst_limit ".
"FROM crs_objective_tst as t JOIN crs_objective_qst as q ".
"ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
"WHERE t.objective_id IN (".implode(",",ilUtil::quoteArray($a_all_objectives)).")";
$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 call graph for this function:

+ Here is the caller graph for this function:

ilCourseObjectiveResult::_readAssignedObjectivesOfQuestion (   $a_question_id)

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

References $res, _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 as qid,q2.objective_id as ob FROM crs_objective_qst as q1, ".
"crs_objective_qst as q2 ".
"WHERE q1.question_id = ".$ilDB->quote($a_question_id)." ".
"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 291 of file class.ilCourseObjectiveResult.php.

References _readAssignedObjectivesOfQuestion(), and _updateObjectiveStatus().

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

{
// 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 360 of file class.ilCourseObjectiveResult.php.

References $data, $res, __isFullfilled(), __updatePassed(), DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

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 question_id IN(".implode(",",ilUtil::quoteArray($objectives['all_questions'])).")";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$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)." ".
"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))
{
$ilDB->executeMultiple($ilDB->prepare("REPLACE INTO crs_objective_status VALUES(?,?,?)"),
$fullfilled);
ilCourseObjectiveResult::__updatePassed($a_user_id,$objectives['all_objectives']);
}
if(count($pretest))
{
$ilDB->executeMultiple($ilDB->prepare("REPLACE INTO crs_objective_status_pretest VALUES(?,?)"),
$pretest);
}
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 61 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 174 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 87 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:

ilCourseObjectiveResult::getUserId ( )

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

References $user_id.

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

{
}

+ Here is the caller graph for this function:

ilCourseObjectiveResult::hasAccomplishedObjective (   $a_objective_id)

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

References $res, DB_FETCHMODE_OBJECT, and getUserId().

{
global $ilDB;
$query = "SELECT status FROM crs_objective_status ".
"WHERE objective_id = ".$ilDB->quote($a_objective_id)." ".
"AND user_id = ".$ilDB->quote($this->getUserId())."";
$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 48 of file class.ilCourseObjectiveResult.php.

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

Definition at line 241 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 134 of file class.ilCourseObjectiveResult.php.

References __deleteEntries(), ilCourseObjective\_getObjectiveIds(), ilObjectFactory\getInstanceByRefId(), getUserId(), and ilUtil\quoteArray().

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 objective_id IN (".implode(",",ilUtil::quoteArray($objectives)).") ".
"AND user_id = ".$ilDB->quote($this->getUserId())." ";
$this->db->query($query);
$query = "DELETE FROM crs_objective_status_pretest ".
"WHERE objective_id IN (".implode(",",ilUtil::quoteArray($objectives)).") ".
"AND user_id = ".$ilDB->quote($this->getUserId())."";
$this->db->query($query);
}
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 44 of file class.ilCourseObjectiveResult.php.

ilCourseObjectiveResult::$user_id = null

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

Referenced by _deleteUser(), and getUserId().


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