ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
QuestionResult.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 public const CORRECT_FULL = 1;
26 public const CORRECT_PARTIAL = 2;
27 public const CORRECT_NONE = 3;
28
29 public function __construct(
30 private readonly int $id,
31 private readonly string $type,
32 private readonly string $title,
33 private readonly float $question_score,
34 private readonly float $usr_score,
35 private readonly string $usr_solution,
36 private readonly string $best_solution,
37 private readonly string $feedback,
38 private readonly bool $workedthrough,
39 private readonly bool $answered,
40 private readonly ?string $content_for_recapitulation,
41 private readonly int $position
42 ) {
43 }
44
45 public function getId(): int
46 {
47 return $this->id;
48 }
49 public function getType(): string
50 {
51 return $this->type;
52 }
53 public function getTitle(): string
54 {
55 return $this->title;
56 }
57 public function getUserAnswer(): string
58 {
59 return $this->usr_solution;
60 }
61 public function getBestSolution(): string
62 {
63 return $this->best_solution;
64 }
65 public function getQuestionScore(): float
66 {
67 return $this->question_score;
68 }
69 public function getUserScore(): float
70 {
71 return $this->usr_score;
72 }
73 public function getUserScorePercent(): float
74 {
75 if ($this->getQuestionScore() === 0.0) {
76 return 100;
77 }
78
79 return 100 / $this->getQuestionScore() * $this->getUserScore();
80 }
81 public function getCorrect(): int
82 {
83 if ($this->getUserScore() === 0.0) {
84 return self::CORRECT_NONE;
85 }
86 if ($this->getUserScore() === $this->getQuestionScore()) {
87 return self::CORRECT_FULL;
88 }
90 }
91 public function getFeedback(): string
92 {
93 return $this->feedback;
94 }
95 public function isWorkedThrough(): bool
96 {
97 return $this->workedthrough;
98 }
99 public function isAnswered(): bool
100 {
101 return $this->answered;
102 }
103 public function getContentForRecapitulation(): ?string
104 {
105 return $this->content_for_recapitulation;
106 }
107 public function getPosition(): int
108 {
109 return $this->position;
110 }
111}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private readonly int $id, private readonly string $type, private readonly string $title, private readonly float $question_score, private readonly float $usr_score, private readonly string $usr_solution, private readonly string $best_solution, private readonly string $feedback, private readonly bool $workedthrough, private readonly bool $answered, private readonly ?string $content_for_recapitulation, private readonly int $position)