19declare(strict_types=1);
61 private readonly TestResultRepository $test_result_repository
63 $this->evaluation_factory = new \ilTestEvaluationFactory($this->db, $this->test);
88 $participants = $this->evaluation_factory->getCorrectionsEvaluationData()->getParticipants();
90 foreach ($participants as $active_id => $userdata) {
105 ->getCompleteEvaluationData()
106 ->getParticipant($active_id);
109 $user_data->getPass($pass),
110 $user_data->getUserID(),
114 $this->test_result_repository->updateTestResultCache($active_id);
119 foreach ($userdata->
getPasses() as $pass => $passdata) {
124 $this->test_result_repository->updateTestResultCache($active_id);
133 $reached_points_changed = false;
136 $reached_points_changed = $reached_points_changed || $this->recalculateQuestionScore(
$user_id, $active_id, $pass, $question_data);
142 private function recalculateQuestionScore(
148 if ($this->preserve_manual_scores && $questiondata[
'manual'] === 1) {
152 $q_id = $questiondata[
'id'];
153 $this->question_cache[$q_id] ??= $this->test->createQuestionGUI(
'', $q_id)->getObject();
155 $question = $this->question_cache[$q_id];
157 $old_points = $question->getReachedPoints($active_id, $pass);
158 $reached = $question->adjustReachedPointsByScoringOptions(
159 $question->calculateReachedPoints($active_id, $pass),
163 return $this->updateReachedPoints(
169 $question->getMaximumPoints(),
189 $has_changed = $old_points !== $points;
190 if ($has_changed && $points <= $max_points) {
206 $logger = $this->test->getTestLogger();
207 if ($logger->isLoggingEnabled()) {
208 $logger->logScoringInteraction(
210 $this->test->getRefId(),
212 $this->scorer->getId(),
227 bool $reached_points_changed
230 $data = $this->test->getQuestionCountAndPointsForPassOfParticipant($active_id, $pass);
236 if ($reached_points_changed) {
237 $result = $this->db->queryF(
238 'SELECT SUM(points) reachedpoints FROM tst_test_result WHERE active_fi = %s AND pass = %s',
255 public function calculateBestSolutionForTest(): string
258 foreach ($this->test->getAllQuestions() as $question) {
260 $question_gui = $this->test->createQuestionGUI(
"", $question[
'question_id']);
261 $solution .=
'<h1>' . $question_gui->getObject()->getTitleForHTMLOutput() .
'</h1>';
262 $solution .= $question_gui->getSolutionOutput(0,
null,
true,
true,
false,
false,
true,
false);
270 $query =
"DELETE FROM tst_test_result WHERE question_fi = %s";
271 $this->db->manipulateF($query, [
'integer'], [$question_id]);
280 foreach ($active_ids as $active_id) {
281 $passSelector = new \ilTestPassesSelector($this->db, $this->test);
282 $passSelector->setActiveId($active_id);
284 foreach ($passSelector->getExistingPasses() as $pass) {
285 $this->test_result_repository->updateTestAttemptResult(
294 $this->test_result_repository->updateTestResultCache($active_id);
301 SELECT COUNT(*) num_manual_scorings
302 FROM tst_test_result tres
303 INNER JOIN tst_active tact
304 ON tact.active_id = tres.active_fi
305 WHERE tact.test_fi = %s
309 $types = [
'integer'];
310 $values = [$this->test->getTestId()];
312 if ($this->getQuestionId()) {
314 AND tres.question_fi = %s
317 $types[] =
'integer';
318 $values[] = $this->getQuestionId();
321 $res = $this->db->queryF($query, $types, $values);
323 while ($row = $this->db->fetchAssoc(
$res)) {
324 return (
int) $row[
'num_manual_scorings'];
ilTestEvaluationFactory $evaluation_factory
updateReachedPoints(int $user_id, int $active_id, int $question_id, float $old_points, float $points, float $max_points, int $pass)
This is an optimized version of \assQuestion::_setReachedPoints that only executes updates in the dat...
setPreserveManualScores(bool $preserve_manual_scores)
recalculatePasses(\ilTestEvaluationUserData $userdata, int $active_id)
updatePassAndTestResults(array $active_ids)
setQuestionId(int $question_id)
removeAllQuestionResults($question_id)
__construct(private \ilObjTest $test, private \ilObjUser $scorer, private \ilDBInterface $db, private readonly TestResultRepository $test_result_repository)
updatePassResultsTable(int $active_id, int $pass, bool $reached_points_changed)
bool $preserve_manual_scores
recalculatePass(\ilTestEvaluationPassData $passdata, int $user_id, int $active_id, int $pass)
recalculateSolution(int $active_id, int $pass)
getPreserveManualScores()
static _updateObjectiveResult(int $a_user_id, int $a_active_id, int $a_question_id)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
TestScoringInteractionTypes
if(!file_exists('../ilias.ini.php'))