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 |
Definition at line 42 of file class.ilCourseObjectiveResult.php.
ilCourseObjectiveResult::__deleteEntries | ( | $ | a_objective_ids | ) |
Definition at line 245 of file class.ilCourseObjectiveResult.php.
References $query.
Referenced by reset().
{ if(!count($a_objective_ids)) { return true; } $in = "IN ('"; $in .= implode("','",$a_objective_ids); $in .= "')"; $query = "DELETE FROM crs_objective_results ". "WHERE usr_id = '".$this->getUserId()."' ". "AND question_id ".$in; $this->db->query($query); }
ilCourseObjectiveResult::__isFullfilled | ( | $ | question_points, | |
$ | objective_data | |||
) |
Definition at line 404 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 / $max_points * 100) >= $objective_data['tst_limit']) ? true : false; }
ilCourseObjectiveResult::__updatePassed | ( | $ | a_user_id, | |
$ | objective_ids | |||
) |
Definition at line 424 of file class.ilCourseObjectiveResult.php.
References $query, $res, and $row.
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("','",$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 = '".$row->crs_id."' ". "AND user_id = '".$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)) { $query = "UPDATE crs_members SET passed = '1' ". "WHERE usr_id = '".$a_user_id."' ". "AND obj_id IN ('".implode("','",$passed)."') "; $ilDB->query($query); } }
ilCourseObjectiveResult::_deleteUser | ( | $ | user_id | ) |
Definition at line 261 of file class.ilCourseObjectiveResult.php.
References $query.
{ global $ilDB; $query = "DELETE FROM crs_objective_results ". "WHERE usr_id = '".$user_id."'"; $ilDB->query($query); $query = "DELETE FROM crs_objective_status ". "WHERE user_id = '".$user_id."'"; $ilDB->query($query); $query = "DELETE FROM crs_objective_status_pretest ". "WHERE user_id = '".$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 $query, $res, $row, and ilCourseObjective::_getObjectiveIds().
Referenced by getAccomplished().
{ global $ilDB; include_once '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("','",$objectives)."') ". "AND user_id = '".$a_user_id."'"; $res = $ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $accomplished[] = $row->objective_id; } return $accomplished ? $accomplished : array(); }
ilCourseObjectiveResult::_getSuggested | ( | $ | a_user_id, | |
$ | a_crs_id, | |||
$ | a_status = IL_OBJECTIVE_STATUS_FINAL | |||
) |
Definition at line 91 of file class.ilCourseObjectiveResult.php.
References $query, $res, $row, and ilCourseObjective::_getObjectiveIds().
Referenced by getSuggested().
{ global $ilDB; $objectives = ilCourseObjective::_getObjectiveIds($a_crs_id); $finished = array(); if($a_status == IL_OBJECTIVE_STATUS_FINAL or $a_status == IL_OBJECTIVE_STATUS_FINISHED) { // check finished $query = "SELECT objective_id FROM crs_objective_status ". "WHERE objective_id IN ('".implode("','",$objectives)."') ". "AND user_id = '".$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("','",$objectives)."') ". "AND user_id = '".$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(); }
ilCourseObjectiveResult::_readAssignedObjectives | ( | $ | a_all_objectives | ) |
Definition at line 319 of file class.ilCourseObjectiveResult.php.
References $query, $res, and $row.
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("','",$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; } return $objectives ? $objectives : array(); }
ilCourseObjectiveResult::_readAssignedObjectivesOfQuestion | ( | $ | a_question_id | ) |
Definition at line 294 of file class.ilCourseObjectiveResult.php.
References $query, $res, $row, and _readAssignedObjectives().
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 = '".$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(); }
ilCourseObjectiveResult::_updateObjectiveResult | ( | $ | a_user_id, | |
$ | a_active_id, | |||
$ | a_question_id | |||
) |
Definition at line 279 of file class.ilCourseObjectiveResult.php.
References _readAssignedObjectivesOfQuestion(), and _updateObjectiveStatus().
Referenced by assTextQuestion::_setReachedPoints(), and assQuestion::saveWorkingData().
{ // find all objectives this question is assigned to if(!$objectives = ilCourseObjectiveResult::_readAssignedObjectivesOfQuestion($a_question_id)) { // 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; } ilCourseObjectiveResult::_updateObjectiveStatus($a_user_id,$objectives); return true; }
ilCourseObjectiveResult::_updateObjectiveStatus | ( | $ | a_user_id, | |
$ | objectives | |||
) |
Definition at line 340 of file class.ilCourseObjectiveResult.php.
References $data, $query, $res, $row, __isFullfilled(), and __updatePassed().
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("','",$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 = '".$a_user_id."' ". "AND question_fi IN ('".implode("','",$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; }
ilCourseObjectiveResult::getAccomplished | ( | $ | a_crs_id | ) |
Definition at line 61 of file class.ilCourseObjectiveResult.php.
References _getAccomplished(), and getUserId().
Referenced by getStatus().
{ return ilCourseObjectiveResult::_getAccomplished($this->getUserId(),$a_crs_id); }
ilCourseObjectiveResult::getStatus | ( | $ | a_course_id | ) |
Definition at line 171 of file class.ilCourseObjectiveResult.php.
References $data, assQuestion::_areAnswered(), ilCourseObjective::_getObjectiveIds(), _readAssignedObjectives(), getAccomplished(), getSuggested(), and getUserId().
{ include_once 'assessment/classes/class.assQuestion.php'; include_once '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($accomplished) == count($objective_ids)) { return IL_OBJECTIVE_STATUS_FINISHED; } $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) { return IL_OBJECTIVE_STATUS_FINAL; } if($all_pretest_answered and !count($suggested)) { return IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST; } elseif($all_pretest_answered) { return IL_OBJECTIVE_STATUS_PRETEST; } return IL_OBJECTIVE_STATUS_NONE; }
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); }
ilCourseObjectiveResult::getUserId | ( | ) |
Definition at line 56 of file class.ilCourseObjectiveResult.php.
Referenced by getAccomplished(), getStatus(), getSuggested(), readStatus(), and reset().
{
return $this->user_id;
}
ilCourseObjectiveResult::hasAccomplishedObjective | ( | $ | a_objective_id | ) |
Definition at line 217 of file class.ilCourseObjectiveResult.php.
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 231 of file class.ilCourseObjectiveResult.php.
References ilCourseObjective::_getObjectiveIds(), _readAssignedObjectives(), _updateObjectiveStatus(), and getUserId().
{ include_once './course/classes/class.ilCourseObjective.php'; $objective_ids = ilCourseObjective::_getObjectiveIds($a_crs_id); $objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids); ilCourseObjectiveResult::_updateObjectiveStatus($this->getUserId(),$objectives); return true; }
ilCourseObjectiveResult::reset | ( | $ | a_course_id | ) |
Definition at line 133 of file class.ilCourseObjectiveResult.php.
References $query, __deleteEntries(), ilCourseObjective::_getObjectiveIds(), ilObjectFactory::getInstanceByRefId(), and getUserId().
{ include_once './course/classes/class.ilCourseObjective.php'; include_once './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("','",$objectives)."') ". "AND user_id = '".$this->getUserId()."'"; $this->db->query($query); $query = "DELETE FROM crs_objective_status_pretest ". "WHERE objective_id IN ('".implode("','",$objectives)."') ". "AND user_id = '".$this->getUserId()."'"; $this->db->query($query); } return true; }
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.