5define(
'IL_OBJECTIVE_STATUS_EMPTY', 
'empty');
 
    6define(
'IL_OBJECTIVE_STATUS_PRETEST', 
'pretest');
 
    7define(
'IL_OBJECTIVE_STATUS_FINAL', 
'final');
 
    8define(
'IL_OBJECTIVE_STATUS_NONE', 
'none');
 
    9define(
'IL_OBJECTIVE_STATUS_FINISHED', 
'finished');
 
   10define(
'IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST', 
'pretest_non_suggest');
 
   35        $this->user_id = $a_usr_id;
 
   50        include_once 
'Modules/Course/classes/class.ilCourseObjective.php';
 
   55        if (!is_array($objectives)) {
 
   58        $query = 
"SELECT objective_id FROM crs_objective_status " .
 
   59            "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
' ' .
 
   60            "AND user_id = " . 
$ilDB->quote($a_user_id, 
'integer') . 
" ";
 
   63            $accomplished[] = 
$row->objective_id;
 
   65        return $accomplished ? $accomplished : array();
 
   77        include_once 
'./Modules/Course/classes/class.ilCourseObjective.php';
 
   86            $query = 
"SELECT objective_id FROM crs_objective_status " .
 
   87                "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
" " .
 
   88                "AND user_id = " . 
$ilDB->quote($a_user_id, 
'integer') . 
" ";
 
   91                $finished[] = 
$row->objective_id;
 
   95            $query = 
"SELECT objective_id FROM crs_objective_status_p " .
 
   96                "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
' ' .
 
   97                "AND user_id = " . 
$ilDB->quote($a_user_id, 
'integer');
 
  100                $finished[] = 
$row->objective_id;
 
  103        foreach ($objectives as $objective_id) {
 
  104            if (!in_array($objective_id, $finished)) {
 
  105                $suggested[] = $objective_id;
 
  108        return $suggested ? $suggested : array();
 
  119        foreach (self::_getSuggested($a_usr_id, $a_crs_id) as $objective_id) {
 
  120            include_once 
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
 
  122            foreach ($obj->getFinalTestQuestions() as $qst) {
 
  123                $qsts[] = $qst[
'question_id'];
 
  126        return $qsts ? $qsts : array();
 
  135        include_once 
"Modules/Test/classes/class.ilTestLP.php";
 
  137        $test_lp->resetLPDataForUserIds(array($a_user_id));
 
  150        include_once 
'./Modules/Course/classes/class.ilCourseObjective.php';
 
  151        include_once 
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
 
  153        include_once 
'./Services/Object/classes/class.ilObjectFactory.php';
 
  156        include_once 
'./Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
 
  157        include_once 
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
 
  159        foreach (array_merge(
 
  164            $tst = 
$factory->getInstanceByRefId($assignment->getTestRefId(), 
false);
 
  168                require_once 
'Modules/Test/classes/class.ilTestParticipantData.php';
 
  170                $participantData->setUserIds(array($this->
getUserId()));
 
  171                $participantData->load($tst->getTestId());
 
  172                $tst->removeTestResults($participantData);
 
  177        $initial_tst = 
$factory->getInstanceByRefId($initial, 
false);
 
  183        $qualified_tst = 
$factory->getInstanceByRefId($qualified, 
false);
 
  184        if ($qualified_tst instanceof 
ilObjTest) {
 
  190        if (count($objectives)) {
 
  191            $query = 
"DELETE FROM crs_objective_status " .
 
  192                "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
' ' .
 
  193                "AND user_id = " . 
$ilDB->quote($this->
getUserId(), 
'integer') . 
" ";
 
  196            $query = 
"DELETE FROM crs_objective_status_p " .
 
  197                "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
' ' .
 
  201            $query = 
"DELETE FROM loc_user_results " .
 
  202                "WHERE " . 
$ilDB->in(
'objective_id', $objectives, 
false, 
'integer') . 
' ' .
 
  207        include_once 
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
 
  215        include_once 
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
 
  216        include_once 
'Modules/Course/classes/class.ilCourseObjective.php';
 
  224        if (!count($objective_ids)) {
 
  228        if (count($accomplished) == count($objective_ids)) {
 
  232        $all_pretest_answered = 
false;
 
  233        $all_final_answered = 
false;
 
  234        foreach ($objectives as 
$data) {
 
  236                if (
$data[
'tst_status']) {
 
  237                    $all_final_answered = 
true;
 
  239                    $all_pretest_answered = 
true;
 
  243        if ($all_final_answered) {
 
  246        if ($all_pretest_answered and
 
  247           !count($suggested)) {
 
  249        } elseif ($all_pretest_answered) {
 
  259        $query = 
"SELECT status FROM crs_objective_status " .
 
  260            "WHERE objective_id = " . 
$ilDB->quote($a_objective_id, 
'integer') . 
" " .
 
  261            "AND user_id = " . 
$ilDB->quote($this->
getUserId(), 
'integer') . 
"";
 
  272        include_once 
'./Modules/Course/classes/class.ilCourseObjective.php';
 
  291        #$ilLog(__METHOD__.': Call of deprecated method.'); 
  300        $query = 
"DELETE FROM crs_objective_status " .
 
  301            "WHERE user_id = " . 
$ilDB->quote(
$user_id, 
'integer') . 
" ";
 
  304        $query = 
"DELETE FROM crs_objective_status_p " .
 
  305            "WHERE user_id = " . 
$ilDB->quote(
$user_id, 
'integer') . 
" ";
 
  313        if (!$objectives = self::_readAssignedObjectivesOfQuestion($a_question_id)) {
 
  328        $query = 
"SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, " .
 
  329            "crs_objective_qst q2 " .
 
  330            "WHERE q1.question_id = " . 
$ilDB->quote($a_question_id, 
'integer') . 
" " .
 
  331            "AND q1.objective_id = q2.objective_id ";
 
  335            $objectives[
'all_objectives'][
$row->ob] = 
$row->ob;
 
  336            $objectives[
'all_questions'][
$row->qid] = 
$row->qid;
 
  338        if (!is_array($objectives)) {
 
  342        return $objectives ? $objectives : array();
 
  351        $query = 
"SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit " .
 
  352            "FROM crs_objective_tst t JOIN crs_objective_qst q " .
 
  353            "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) " .
 
  354            "WHERE " . 
$ilDB->in(
't.objective_id', $a_all_objectives, 
false, 
'integer');
 
  365            $objectives[
$row->obj . 
"_" . 
$row->tst_status][
'questions'][
$row->question_id] = 
$row->question_id;
 
  366            $objectives[
$row->obj . 
"_" . 
$row->tst_status][
'tst_status'] = 
$row->tst_status;
 
  367            $objectives[
$row->obj . 
"_" . 
$row->tst_status][
'tst_limit'] = 
$row->tst_limit;
 
  368            $objectives[
$row->obj . 
"_" . 
$row->tst_status][
'objective_id'] = 
$row->obj;
 
  370        return $objectives ? $objectives : array();
 
  377        if (!count($objectives[
'all_questions']) or
 
  378           !count($objectives[
'all_objectives'])) {
 
  382        $query = 
"SELECT question_id,points FROM qpl_questions " .
 
  383            "WHERE " . 
$ilDB->in(
'question_id', (array) $objectives[
'all_questions'], 
false, 
'integer');
 
  386            $objectives[
'all_question_points'][
$row[
'question_id']][
'max_points'] = 
$row[
'points'];
 
  389        $query = 
"SELECT question_fi, MAX(points) as reached FROM tst_test_result " .
 
  390            "JOIN tst_active ON (active_id = active_fi) " .
 
  391            "WHERE user_fi = " . 
$ilDB->quote($a_user_id, 
'integer') . 
" " .
 
  392            "AND " . 
$ilDB->in(
'question_fi', (array) $objectives[
'all_questions'], 
false, 
'integer') . 
" " .
 
  393            #
"AND question_fi IN (".implode(
",",
ilUtil::quoteArray($objectives[
'all_questions'])).
") ".
 
  394            "GROUP BY question_fi,user_fi";
 
  397            $objectives[
'all_question_points'][
$row->question_fi][
'reached_points'] = 
$row->reached;
 
  401        $fullfilled = array();
 
  403        foreach ($objectives[
'objectives'] as $kind => 
$data) {
 
  407                if (
$data[
'tst_status']) {
 
  408                    $fullfilled[] = array(
$data[
'objective_id'],
$ilUser->getId(),
$data[
'tst_status']);
 
  410                    $pretest[] = array(
$data[
'objective_id'],
$ilUser->getId());
 
  414        if (count($fullfilled)) {
 
  415            foreach ($fullfilled as $fullfilled_arr) {
 
  417                    'crs_objective_status',
 
  419                        'objective_id' => array(
'integer',$fullfilled_arr[0]),
 
  420                        'user_id' => array(
'integer',$fullfilled_arr[1])
 
  423                        'status' => array(
'integer',$fullfilled_arr[2])
 
  429        if (count($pretest)) {
 
  430            foreach ($pretest as $pretest_arr) {
 
  432                    'crs_objective_status_p',
 
  434                        'objective_id' => array(
'integer',$pretest_arr[0]),
 
  435                        'user_id' => array(
'integer',$pretest_arr[1])
 
  446        if (!is_array($objective_data[
'questions'])) {
 
  451        foreach ($objective_data[
'questions'] as $question_id) {
 
  452            $max_points += $question_points[$question_id][
'max_points'];
 
  453            $reached_points += $question_points[$question_id][
'reached_points'];
 
  459        return $reached_points >= $objective_data[
'tst_limit'] ? true : 
false;
 
  461        return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ? true : 
false;
 
  477        $query = 
"SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 " .
 
  478            "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and  " .
 
  479            $ilDB->in(
't1.objective_id', $objective_ids, 
false, 
'integer') . 
" " .
 
  480            "GROUP BY t1.crs_id";
 
  484            $query = 
"SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs " .
 
  485                "JOIN crs_objectives co ON cs.objective_id = co.objective_id " .
 
  486                "WHERE crs_id = " . 
$ilDB->quote(
$row->crs_id, 
'integer') . 
" " .
 
  487                "AND user_id = " . 
$ilDB->quote($a_user_id, 
'integer') . 
" ";
 
  491                if ($user_row->num_passed == 
$row->num) {
 
  492                    $passed[] = 
$row->crs_id;
 
  495            $crs_ids[
$row->crs_id] = 
$row->crs_id;
 
  497        if (count($passed)) {
 
  498            foreach ($passed as $crs_id) {
 
  499                include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
 
  501                $members->updatePassed($a_user_id, 
true);
 
  506        foreach ($crs_ids as $cid) {
 
  507            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
An exception for terminatinating execution or to throw for unit testing.
const IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST
const IL_OBJECTIVE_STATUS_EMPTY
const IL_OBJECTIVE_STATUS_FINISHED
const IL_OBJECTIVE_STATUS_NONE
const IL_OBJECTIVE_STATUS_PRETEST
const IL_OBJECTIVE_STATUS_FINAL
static _areAnswered($a_user_id, $a_question_ids)
Checks if an array of question ids is answered by an user or not.
class ilcourseobjectiveQuestion
static _readAssignedObjectives($a_all_objectives)
static _getSuggested($a_user_id, $a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
static _updateObjectiveResult($a_user_id, $a_active_id, $a_question_id)
__construct($a_usr_id)
Constructor.
static _readAssignedObjectivesOfQuestion($a_question_id)
static getSuggestedQuestions($a_usr_id, $a_crs_id)
get suggested questions ids
static _deleteUser($user_id)
static _updateObjectiveStatus($a_user_id, $objectives)
static _getAccomplished($a_user_id, $a_crs_id)
resetTestForUser(ilObjTest $a_test, $a_user_id)
hasAccomplishedObjective($a_objective_id)
static __isFullfilled($question_points, $objective_data)
static __updatePassed($a_user_id, $objective_ids)
can be protected?
getAccomplished($a_crs_id)
__deleteEntries($a_objective_ids)
getSuggested($a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
static _getObjectiveIds($course_id, $a_activated_only=false)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
const TYPE_TEST_QUALIFIED
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
removeTestActives($activeIds)
getActiveIdOfUser($user_id="", $anonymous_id="")
Gets the active id of a given user.
static getInstance($a_obj_id)
getId()
get object id @access public
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
foreach($_POST as $key=> $value) $res