Skip to content

Commit 485cee7

Browse files
committed
#157 Updating question
1 parent c35120b commit 485cee7

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

api/src/Markdown/Model/Question.php

+41-10
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66

77
class Question implements ModelInterface
88
{
9+
/** @var DOMNode[] * */
10+
private array $correctAnswer = [];
11+
/** @var DOMNode[] * */
12+
private array $content = [];
13+
/** @var DOMNode[] * */
14+
private array $possibleAnswers = [];
15+
916
/**
1017
* @param int $id
1118
* @param int $quizID
1219
* @param string $filePath
1320
* @param string $title
14-
* @param DOMNode[] $content
15-
* @param DOMNode[] $possibleAnswers
16-
* @param DOMNode[] $correctAnswer
1721
*/
1822
public function __construct(
1923
private readonly int $id,
2024
private readonly int $quizID,
2125
private readonly string $filePath,
22-
private readonly string $title,
23-
private readonly array $content,
24-
private readonly array $possibleAnswers,
25-
private readonly array $correctAnswer,
26+
private readonly string $title
2627
) {
2728
}
2829

@@ -42,24 +43,54 @@ public function getFilePath(): string
4243
return $this->filePath;
4344
}
4445

45-
/** @return DOMNode[] **/
46+
/** @return DOMNode[] * */
4647
public function getContent(): array
4748
{
4849
return $this->content;
4950
}
5051

51-
/** @return DOMNode[] **/
52+
/**
53+
* @param DOMNode[] $content
54+
* @return Question
55+
*/
56+
public function setContent(array $content): Question
57+
{
58+
$this->content = $content;
59+
return $this;
60+
}
61+
62+
/** @return DOMNode[] * */
5263
public function getPossibleAnswers(): array
5364
{
5465
return $this->possibleAnswers;
5566
}
5667

57-
/** @return DOMNode[] **/
68+
/**
69+
* @param DOMNode[] $possibleAnswers
70+
* @return Question
71+
*/
72+
public function setPossibleAnswers(array $possibleAnswers): Question
73+
{
74+
$this->possibleAnswers = $possibleAnswers;
75+
return $this;
76+
}
77+
78+
/** @return DOMNode[] * */
5879
public function getCorrectAnswer(): array
5980
{
6081
return $this->correctAnswer;
6182
}
6283

84+
/**
85+
* @param DOMNode[] $correctAnswer
86+
* @return Question
87+
*/
88+
public function setCorrectAnswer(array $correctAnswer): Question
89+
{
90+
$this->correctAnswer = $correctAnswer;
91+
return $this;
92+
}
93+
6394
/**
6495
* @return string
6596
*/

api/src/Markdown/QuestionGenerator.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ public function process(array $filePaths): array
7373
continue;
7474
}
7575

76-
$content = [];
77-
$possibleAnswers = [];
78-
$correctAnswers = [];
79-
$question = new Question($questionID, $quizID, $filePath, $title, $content, $possibleAnswers, $correctAnswers);
76+
$question = new Question($questionID, $quizID, $filePath, $title);
8077

8178
$dataSets[] = $question;
8279
}

0 commit comments

Comments
 (0)