init() public static method

Returns a new set of randomized questions
public static init ( integer $number, array $categories, $path ) : Certificationy\Certification\Set
$number integer
$categories array
return Certificationy\Certification\Set
Ejemplo n.º 1
0
 /**
  * Tests loader
  */
 public function testInitialization()
 {
     $set = Loader::init(5, array(), $this->configFile);
     $this->assertInstanceOf('Certificationy\\Certification\\Set', $set, 'Should return an instance of set');
     $this->assertCount(5, $set->getQuestions(), 'Should return 5 questions');
     $this->assertNull($set->getAnswers());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('list')) {
         $output->writeln(Loader::getCategories($this->path()));
         return;
     }
     $categories = $input->getArgument('categories');
     $number = $input->getOption('number');
     $set = Loader::init($number, $categories, $this->path());
     if ($set->getQuestions()) {
         $output->writeln(sprintf('Starting a new set of <info>%s</info> questions (available questions: <info>%s</info>)', count($set->getQuestions()), Loader::count(array(), $this->path())));
         $this->askQuestions($set, $input, $output);
         $this->displayResults($set, $output);
     } else {
         $output->writeln('<error>✗</error> No questions can be found.');
     }
 }