ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
QuestionResult.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Results\Data;
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 int $requested_hints,
41  private readonly ?string $content_for_recapitulation,
42  private readonly ?string $autosaved_answer,
43  private readonly int $position,
44  ) {
45  }
46 
47  public function getId(): int
48  {
49  return $this->id;
50  }
51  public function getType(): string
52  {
53  return $this->type;
54  }
55  public function getTitle(): string
56  {
57  return $this->title;
58  }
59  public function getUserAnswer(): string
60  {
61  return $this->usr_solution;
62  }
63  public function getBestSolution(): string
64  {
65  return $this->best_solution;
66  }
67  public function getQuestionScore(): float
68  {
69  return $this->question_score;
70  }
71  public function getUserScore(): float
72  {
73  return $this->usr_score;
74  }
75  public function getUserScorePercent(): float
76  {
77  if ($this->getQuestionScore() === 0.0) {
78  return 100;
79  }
80 
81  return 100 / $this->getQuestionScore() * $this->getUserScore();
82  }
83  public function getCorrect(): int
84  {
85  if ($this->getUserScore() === 0.0) {
86  return self::CORRECT_NONE;
87  }
88  if ($this->getUserScore() === $this->getQuestionScore()) {
89  return self::CORRECT_FULL;
90  }
91  return self::CORRECT_PARTIAL;
92  }
93  public function getFeedback(): string
94  {
95  return $this->feedback;
96  }
97  public function isWorkedThrough(): bool
98  {
99  return $this->workedthrough;
100  }
101  public function isAnswered(): bool
102  {
103  return $this->answered;
104  }
105  public function getContentForRecapitulation(): ?string
106  {
107  return $this->content_for_recapitulation;
108  }
109  public function getNumberOfRequestedHints(): int
110  {
111  return $this->requested_hints;
112  }
113  public function getAutosavedAnswer(): ?string
114  {
115  return $this->autosaved_answer;
116  }
117  public function getPosition(): int
118  {
119  return $this->position;
120  }
121 
122 }
__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 int $requested_hints, private readonly ?string $content_for_recapitulation, private readonly ?string $autosaved_answer, private readonly int $position,)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24