Skip to content

Commit

Permalink
#157 Updating question
Browse files Browse the repository at this point in the history
  • Loading branch information
pfwd committed Nov 6, 2022
1 parent c35120b commit 485cee7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
51 changes: 41 additions & 10 deletions api/src/Markdown/Model/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@

class Question implements ModelInterface
{
/** @var DOMNode[] * */
private array $correctAnswer = [];
/** @var DOMNode[] * */
private array $content = [];
/** @var DOMNode[] * */
private array $possibleAnswers = [];

/**
* @param int $id
* @param int $quizID
* @param string $filePath
* @param string $title
* @param DOMNode[] $content
* @param DOMNode[] $possibleAnswers
* @param DOMNode[] $correctAnswer
*/
public function __construct(
private readonly int $id,
private readonly int $quizID,
private readonly string $filePath,
private readonly string $title,
private readonly array $content,
private readonly array $possibleAnswers,
private readonly array $correctAnswer,
private readonly string $title
) {
}

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

/** @return DOMNode[] **/
/** @return DOMNode[] * */
public function getContent(): array
{
return $this->content;
}

/** @return DOMNode[] **/
/**
* @param DOMNode[] $content
* @return Question
*/
public function setContent(array $content): Question
{
$this->content = $content;
return $this;
}

/** @return DOMNode[] * */
public function getPossibleAnswers(): array
{
return $this->possibleAnswers;
}

/** @return DOMNode[] **/
/**
* @param DOMNode[] $possibleAnswers
* @return Question
*/
public function setPossibleAnswers(array $possibleAnswers): Question
{
$this->possibleAnswers = $possibleAnswers;
return $this;
}

/** @return DOMNode[] * */
public function getCorrectAnswer(): array
{
return $this->correctAnswer;
}

/**
* @param DOMNode[] $correctAnswer
* @return Question
*/
public function setCorrectAnswer(array $correctAnswer): Question
{
$this->correctAnswer = $correctAnswer;
return $this;
}

/**
* @return string
*/
Expand Down
5 changes: 1 addition & 4 deletions api/src/Markdown/QuestionGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ public function process(array $filePaths): array
continue;
}

$content = [];
$possibleAnswers = [];
$correctAnswers = [];
$question = new Question($questionID, $quizID, $filePath, $title, $content, $possibleAnswers, $correctAnswers);
$question = new Question($questionID, $quizID, $filePath, $title);

$dataSets[] = $question;
}
Expand Down

0 comments on commit 485cee7

Please sign in to comment.