ILIAS  Release_4_0_x_branch Revision 61816
 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)
 _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

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

Member Function Documentation

ilCourseObjectiveResult::__deleteEntries (   $a_objective_ids)

Definition at line 276 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 441 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 464 of file class.ilCourseObjectiveResult.php.

References $ilDB, $query, $res, $row, ilCourseParticipants\_getInstanceByObjId(), 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);
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;
}
}
}
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:

static ilCourseObjectiveResult::_deleteUser (   $user_id)
static

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

References $ilDB, $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 65 of file class.ilCourseObjectiveResult.php.

References $ilDB, $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 92 of file class.ilCourseObjectiveResult.php.

References $ilDB, $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 339 of file class.ilCourseObjectiveResult.php.

References $ilDB, $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 314 of file class.ilCourseObjectiveResult.php.

References $ilDB, $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 300 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 369 of file class.ilCourseObjectiveResult.php.

References $data, $ilDB, $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
/*
$types = $ilDB->addTypesToArray(array(), 'integer', count($objectives['all_questions']));
$placeholders = $ilDB->addTypesToArray(array(), '%s', count($objectives['all_questions']));
$res = $ilDB->queryF("SELECT question_id,points FROM qpl_questions WHERE question_id IN(". implode(",", $placeholders) .")",
$types,
$objectives['all_questions']
);
*/
$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))
{
$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_p 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 195 of file class.ilCourseObjectiveResult.php.

References $data, assQuestion\_areAnswered(), ilCourseObjective\_getObjectiveIds(), _readAssignedObjectives(), elseif(), 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:

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 141 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 56 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 246 of file class.ilCourseObjectiveResult.php.

References $ilDB, $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 48 of file class.ilCourseObjectiveResult.php.

References $ilDB.

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

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

References $ilDB, $query, $res, ilCourseObjective\_getObjectiveIds(), 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);
}
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: