ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Questions\Temp\Attempt Class Reference
+ Collaboration diagram for ILIAS\Questions\Temp\Attempt:

Public Member Functions

 __construct (private readonly Uuid $attempt_id, private array $solved_questions)
 
 getAttemptId ()
 
 isQuestionSolved (Uuid $question_id)
 
 getSolvedQuestionsForStorage ()
 
 withAdditionalSolvedQuestion (Uuid $question_id)
 
 withQuestionRemovedFromSolved (Uuid $question_id)
 

Detailed Description

Definition at line 25 of file Attempt.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Questions\Temp\Attempt::__construct ( private readonly Uuid  $attempt_id,
private array  $solved_questions 
)

Definition at line 27 of file Attempt.php.

30 {
31 }

Member Function Documentation

◆ getAttemptId()

ILIAS\Questions\Temp\Attempt::getAttemptId ( )

Definition at line 33 of file Attempt.php.

33 : Uuid
34 {
35 return $this->attempt_id;
36 }

◆ getSolvedQuestionsForStorage()

ILIAS\Questions\Temp\Attempt::getSolvedQuestionsForStorage ( )

Definition at line 44 of file Attempt.php.

44 : string
45 {
46 return implode(',', $this->solved_questions);
47 }

◆ isQuestionSolved()

ILIAS\Questions\Temp\Attempt::isQuestionSolved ( Uuid  $question_id)

Definition at line 38 of file Attempt.php.

40 : bool {
41 return in_array($question_id->toString(), $this->solved_questions);
42 }

◆ withAdditionalSolvedQuestion()

ILIAS\Questions\Temp\Attempt::withAdditionalSolvedQuestion ( Uuid  $question_id)

Definition at line 49 of file Attempt.php.

51 : self {
52 if ($this->isQuestionSolved($question_id)) {
53 return $this;
54 }
55
56 $clone = clone $this;
57 $clone->solved_questions[] = $question_id->toString();
58 return $clone;
59 }
isQuestionSolved(Uuid $question_id)
Definition: Attempt.php:38

◆ withQuestionRemovedFromSolved()

ILIAS\Questions\Temp\Attempt::withQuestionRemovedFromSolved ( Uuid  $question_id)

Definition at line 61 of file Attempt.php.

63 : self {
64 if (!$this->isQuestionSolved($question_id)) {
65 return $this;
66 }
67
68 $clone = clone $this;
69 unset(
70 $clone->solved_questions[array_search($question_id->toString(), $clone->solved_questions)]
71 );
72 return $clone;
73 }

The documentation for this class was generated from the following file: