ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.assAnswerErrorText.php
Go to the documentation of this file.
1 <?php
2 
19 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
20 
30 {
31  protected string $text_wrong;
32  protected string $text_correct;
33  protected float $points;
34  protected ?int $position;
35  protected int $length;
36 
43  public function __construct(
44  string $text_wrong = "",
45  string $text_correct = "",
46  float $points = 0.0,
47  ?int $position = null
48  ) {
49  $this->text_wrong = $text_wrong;
50  $this->text_correct = $text_correct;
51  $this->points = $points;
52  $this->position = $position;
53 
54  $word_array = preg_split("/\s+/", $text_wrong);
55 
56  if ($word_array) {
57  $this->length = count($word_array);
58  }
59  }
60 
61  public function getTextWrong(): string
62  {
63  return $this->text_wrong;
64  }
65 
66  public function getTextCorrect(): string
67  {
68  return $this->text_correct;
69  }
70 
71  public function getPoints(): string
72  {
73  return $this->points;
74  }
75 
76  public function withPoints(float $points): self
77  {
78  $clone = clone $this;
79  $clone->points = $points;
80  return $clone;
81  }
82 
83  public function getPosition(): ?int
84  {
85  return $this->position;
86  }
87 
88  public function withPosition(int $position): self
89  {
90  $clone = clone $this;
91  $clone->position = $position;
92  return $clone;
93  }
94 
95  public function getLength(): int
96  {
97  return $this->length;
98  }
99 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $text_wrong="", string $text_correct="", float $points=0.0, ?int $position=null)
assAnswerErrorText constructor