19 declare(strict_types=1);
66 $this->
lng = $DIC->language();
67 $this->initiator_name = $DIC->user()->getFullname() .
" (" . $DIC->user()->getLogin() .
")";
68 $this->initiator_id = $DIC->user()->getId();
97 $this->participants = $factory->getCorrectionsEvaluationData()->getParticipants();
99 foreach ($this->participants as $active_id => $userdata) {
100 if (is_object($userdata) && is_array($userdata->getPasses())) {
103 $this->test->getId(),
104 $userdata->getUserID()
116 ->getCompleteEvaluationData(
false)
117 ->getParticipant($active_id)
121 $this->test->updateTestResultCache($active_id);
127 foreach ($passes as $pass => $passdata) {
128 if (is_object($passdata)) {
133 $this->test->updateTestResultCache($active_id);
142 foreach ($questions as $question_data) {
151 if (!isset($this->question_cache[$q_id])) {
152 $this->question_cache[$q_id] = $this->test->createQuestionGUI(
"", $q_id)->object;
154 $question = $this->question_cache[$q_id];
156 $old_points = $question->getReachedPoints($active_id, $pass);
157 $reached = $question->adjustReachedPointsByScoringOptions(
158 $question->calculateReachedPoints($active_id, $pass),
163 if ($this->preserve_manual_scores && $questiondata[
'manual'] ==
'1') {
172 $question->getMaximumPoints(),
184 public function updateReachedPoints(
int $active_id,
int $question_id,
float $old_points,
float $points,
float $max_points,
int $pass): void
187 $has_changed = $old_points !== $points;
188 if ($has_changed && $points <= $max_points) {
192 'points' => [
'float', $points],
193 'tstamp' => [
'integer', time()],
196 'active_fi' => [
'integer', $active_id],
197 'question_fi' => [
'integer', $question_id],
198 'pass' => [
'integer', $pass]
206 'maxpoints' => [
'float',
$data[
'points']],
207 'tstamp' => [
'integer', time()],
211 $result = $this->db->queryF(
212 'SELECT SUM(points) reachedpoints FROM tst_test_result WHERE active_fi = %s AND pass = %s',
213 [
'integer',
'integer'],
216 $values[
'points'] = [
'float', $result->fetchAssoc()[
'reachedpoints'] ?? 0.0];
222 [
'active_fi' => [
'integer', $active_id],
'pass' => [
'integer', $pass]]
231 $this->participants[$active_id]->getName() :
235 $this->initiator_name
239 $this->test->getId(),
249 public function calculateBestSolutionForTest():
string 252 foreach ($this->test->getAllQuestions() as $question) {
254 $question_gui = $this->test->createQuestionGUI(
"", $question[
'question_id']);
255 $solution .=
'<h1>' . $question_gui->object->getTitleForHTMLOutput() .
'</h1>';
256 $solution .= $question_gui->getSolutionOutput(0, null,
true,
true,
false,
false,
true,
false);
264 $this->recalculated_passes = [];
274 if (! array_key_exists($active_id, $this->recalculated_passes)
275 || !is_array($this->recalculated_passes[$active_id])
277 $this->recalculated_passes[$active_id] = [];
280 $this->recalculated_passes[$active_id][] = $pass;
285 $query =
"DELETE FROM tst_test_result WHERE question_fi = %s";
286 $this->db->manipulateF($query, array(
'integer'), array($question_id));
295 foreach ($active_ids as $active_id) {
297 $passSelector->setActiveId($active_id);
299 foreach ($passSelector->getExistingPasses() as $pass) {
300 $this->test->updateTestPassResults($active_id, $pass, $this->test->areObligationsEnabled());
303 $this->test->updateTestResultCache($active_id);
310 SELECT COUNT(*) num_manual_scorings 311 FROM tst_test_result tres 313 INNER JOIN tst_active tact 314 ON tact.active_id = tres.active_fi 315 AND tact.test_fi = %s 317 WHERE tres.manual = 1 320 $types = array(
'integer');
321 $values = array($this->test->getTestId());
325 AND tres.question_fi = %s 328 $types[] =
'integer';
332 $res = $this->db->queryF($query, $types, $values);
334 while ($row = $this->db->fetchAssoc(
$res)) {
335 return (
int) $row[
'num_manual_scorings'];
removeAllQuestionResults($question_id)
static _addLog( $user_id, $object_id, $logtext, $question_id=0, $original_id=0, $test_only=false, $test_ref_id=0)
Add an assessment log entry.
updateReachedPoints(int $active_id, int $question_id, float $old_points, float $points, float $max_points, int $pass)
This is an optimized version of ::_setReachedPoints that only executes updates in the database if nec...
setQuestionId(int $question_id)
array $recalculated_passes
getRecalculatedPassesByActives()
setPreserveManualScores(bool $preserve_manual_scores)
recalculatePasses(ilTestEvaluationUserData $userdata, int $active_id)
static _getUserIdFromActiveId(int $active_id)
static _enabledAssessmentLogging()
static _getQuestionCountAndPointsForPassOfParticipant($active_id, $pass)
recalculateQuestionScore(int $q_id, int $active_id, int $pass, array $questiondata)
updatePassAndTestResults(array $active_ids)
resetRecalculatedPassesByActives()
recalculateSolution(int $active_id, int $pass)
addRecalculatedPassByActive(int $active_id, int $pass)
bool $preserve_manual_scores
recalculatePass(ilTestEvaluationPassData $passdata, int $active_id, int $pass)
static _updateObjectiveResult(int $a_user_id, int $a_active_id, int $a_question_id)
__construct(private ilObjTest $test, private ilDBInterface $db)
getPreserveManualScores()
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)