function _updateObjectiveStatus($a_user_id, $objectives)
 {
     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') . " " . "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;
 }
 function _deleteUser($a_usr_id)
 {
     // Delete all user related data
     // delete lm_history
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     ilCourseLMHistory::_deleteUser($a_usr_id);
     include_once './Modules/Course/classes/class.ilCourseParticipants.php';
     ilCourseParticipants::_deleteUser($a_usr_id);
     // Course objectives
     include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
     ilCourseObjectiveResult::_deleteUser($a_usr_id);
 }
Exemplo n.º 3
0
 function resetObject()
 {
     global $ilUser;
     include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
     $usr_results = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId());
     $usr_results->delete();
     include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
     include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
     ilLOTestRun::deleteRuns($this->object->getId(), $GLOBALS['ilUser']->getId());
     include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
     $tmp_obj_res = new ilCourseObjectiveResult($ilUser->getId());
     $tmp_obj_res->reset($this->object->getId());
     $ilUser->deletePref('crs_objectives_force_details_' . $this->object->getId());
     ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
     $this->viewObject();
 }
Exemplo n.º 4
0
 /**
  * Sets the points, a learner has reached answering the question
  * Additionally objective results are updated
  *
  * @param integer $user_id The database ID of the learner
  * @param integer $test_id The database Id of the test containing the question
  * @param integer $points The points the user has reached answering the question
  * @return boolean true on success, otherwise false
  * @access public
  */
 function _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 {
     global $ilDB;
     if ($points <= $maxpoints) {
         if (is_null($pass)) {
             $pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
         }
         // retrieve the already given points
         $old_points = 0;
         $result = $ilDB->queryF("SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass));
         $manual = $manualscoring ? 1 : 0;
         $rowsnum = $result->numRows();
         if ($rowsnum) {
             $row = $ilDB->fetchAssoc($result);
             $old_points = $row["points"];
             if ($old_points != $points) {
                 $affectedRows = $ilDB->manipulateF("UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('float', 'integer', 'integer', 'integer', 'integer', 'integer'), array($points, $manual, time(), $active_id, $question_id, $pass));
             }
         } else {
             $next_id = $ilDB->nextId('tst_test_result');
             $affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'float', 'integer', 'integer', 'integer'), array($next_id, $active_id, $question_id, $points, $pass, $manual, time()));
         }
         if ($old_points != $points || !$rowsnum) {
             assQuestion::_updateTestPassResults($active_id, $pass, $obligationsEnabled);
             // finally update objective result
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
             ilCourseObjectiveResult::_updateObjectiveResult(ilObjTest::_getUserIdFromActiveId($active_id), $question_id, $points);
             include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
             if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
                 global $lng, $ilUser;
                 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
                 $username = ilObjTestAccess::_getParticipantData($active_id);
                 assQuestion::_logAction(sprintf($lng->txtlng("assessment", "log_answer_changed_points", ilObjAssessmentFolder::_getLogLanguage()), $username, $old_points, $points, $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")"), $active_id, $question_id);
             }
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
 function resetObject()
 {
     global $ilUser;
     include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
     $tmp_obj_res = new ilCourseObjectiveResult($ilUser->getId());
     $tmp_obj_res->reset($this->object->getId());
     $ilUser->deletePref('crs_objectives_force_details_' . $this->object->getId());
     ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
     $this->viewObject();
 }
 /**
  * read suggested objectives
  *
  * @access protected
  * @param
  * @return
  */
 protected function readSuggested($a_usr_id, $a_crs_id)
 {
     return ilCourseObjectiveResult::_getSuggested($a_usr_id, $a_crs_id, self::getStatus($a_usr_id, $a_crs_id));
 }