You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
884 B
34 lines
884 B
<?php
|
|
|
|
namespace Model;
|
|
|
|
use BusinessClass\Question;
|
|
use BusinessClass\TextQuestion;
|
|
|
|
class FactoryQuestion extends Factory
|
|
{
|
|
public function create(array $results): array
|
|
{
|
|
$questions = [];
|
|
for($i = 0; $i < count($results[0]); $i++)
|
|
{
|
|
if(strcmp($results[0][$i]['type'], "BusinessClass\TextQuestion") == 0)
|
|
{
|
|
$questions[] = new TextQuestion($results[0][$i]['content'], $results[0][$i]['id']);
|
|
}
|
|
else
|
|
{
|
|
$possiblesResponses = $results[1][$i];
|
|
$content = $results[0][$i]['content'];
|
|
|
|
$categories = $results[2][$i];
|
|
|
|
$id = $results[0][$i]['id'];
|
|
|
|
$questions[] = new $results[0][$i]['type']($possiblesResponses, $content, $categories, $id);
|
|
}
|
|
}
|
|
return $questions;
|
|
}
|
|
}
|