2017 © Pedro Peláez
 

library quiz-in-session

A simple php package quiz core that allows the creation of questions, alternatives and choice of answers in a very easy way.

image

soufraz/quiz-in-session

A simple php package quiz core that allows the creation of questions, alternatives and choice of answers in a very easy way.

  • Sunday, April 16, 2017
  • by Soufraz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Composer quiz package to be used in session

A simple composer quiz package that allows the creation of questions, alternatives and choice of answers in a very easy way., (*1)

Install

composer require soufraz/quiz-in-session master

Usage

Creating quiz, (*2)

$data = [
    'title' => 'The first quiz of all'
];

$quiz = new Quiz();
$quiz->create($data);

Hey: All of the following examples we will assume that $quiz is already defined, (*3)

Adding questions to created quiz, (*4)

$data = [
    [
        'id' => 10,
        'title' => 'How many continents are there on earth?'
    ],
    [
        'id' => 20,
        'title' => 'When was php released?'
    ],
    [
        'id' => 30,
        'title' => 'Bill Gates really stolen a Steve Jobs idea?'
    ]
];

$quiz->addQuestions($data);

Adding alternatives to created questions, (*5)

// Mocking a question
$data = [
    'question_id' => 10,
    'alternatives' => [
        'five',
        'six',
        'seven',
    ]
];

$quiz->addAlternativesToQuestion($data['question_id'], $data);

LET'S PLAY!, (*6)

Getting quiz, (*7)

$your_quiz = $quiz->get();

Requesting next question and alternatives, (*8)

$question = $quiz->nextQuestion();

Hey: If $question returns false then quiz is over, (*9)

Saving answer, (*10)

$quiz->setAnswerToQuestion($question, 2);

Getting answers to save ind database or do wherever you want, (*11)

$answers = $this->getQuestions();

Used resources

Boilerplate composer package https://github.com/stilliard/composer-package-boilerplate, (*12)

ScallioXTX https://www.sitepoint.com/community/t/phpunit-testing-cookies-and-sessions/36557, (*13)

License

This project is open-sourced software licensed under the MIT license, (*14)

The Versions

16/04 2017

dev-master

9999999-dev

A simple php package quiz core that allows the creation of questions, alternatives and choice of answers in a very easy way.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Rafael Soufraz

16/04 2017

dev-develop

dev-develop

A simple php package quiz core that allows the creation of questions, alternatives and choice of answers in a very easy way.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Rafael Soufraz

16/04 2017

1.0.0

1.0.0.0

A simple php package quiz core that allows the creation of questions, alternatives and choice of answers in a very easy way.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Rafael Soufraz