/** * 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; } }