2017 © Pedro Peláez
 

library multiplechoiceexams

A set of PHP Clases to manage multiple choice exams

image

mdagostino/multiplechoiceexams

A set of PHP Clases to manage multiple choice exams

  • Wednesday, January 20, 2016
  • by mdagostino
  • Repository
  • 4 Watchers
  • 4 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

MultipleChoiceExams

Build Status Coverage Status, (*1)

MultipleChoiceExams is a set of PHP clases to manage Multiple Choice Exams. This clases are able to adapt to different CMS, as Drupal, so the CMS only have the responsability of managing the content of the database., (*2)

Example

This is how the code works:, (*3)

<?php
require 'vendor/autoload.php';

use mdagostino\MultipleChoiceExams\Exam\Exam;
use mdagostino\MultipleChoiceExams\Controller\ExamWithTimeController;
use mdagostino\MultipleChoiceExams\Question\Question;
use mdagostino\MultipleChoiceExams\Timer\ExamTimer;
use mdagostino\MultipleChoiceExams\Question\QuestionInfo;
use mdagostino\MultipleChoiceExams\Question\QuestionEvaluatorSimple;
use mdagostino\MultipleChoiceExams\ApprovalCriteria\BasicApprovalCriteria;

// First create a list of Questions
// Each question can use a different evaluator method, for this example,
// all the questions use the simplest evaluation method: "A question is
// considered correct if the user chose only all the right questions".
$question_evaluator = new QuestionEvaluatorSimple();


$question = new Question($question_evaluator, new QuestionInfo());
$question
  ->setTitle('Django language')
  ->setDescription('In which language is written the Django framework');
  ->setChoices(['python' => 'Python', 'php' => 'PHP', 'go' => 'Go', 'java' => 'Java'])
  ->setRightChoices(['python'])
$questions[] = $question;



$question = new Question($question_evaluator, new QuestionInfo());
$question
  ->setTitle('Languages that runs on browsers')
  ->setDescription('Witch programming language can run on web browsers?');
  ->setChoices(['cobol' => 'Cobol', 'javascript' => 'Javascript', 'asm' => 'Assembler'])
  ->setRightChoices(['javascript'])
$questions[] = $question;


$question = new Question($question_evaluator, new QuestionInfo());
$question
  ->setTitle('Planets')
  ->setDescription('Wich planets of the Solar System are considered "giant planets"?');
  ->setChoices([
    'Me' => 'Mercury',
    'Ve' => 'Venus',
    'Ea' => 'Earth',
    'Ma' => 'Mars',
    'Ju' => 'Jupiter',
    'Sa' => 'Saturn',
    'Ur' => 'Uranus',
    'Ne' => 'Neptune'
    ])
  ->setRightChoices(['Ju', 'Sa', 'Ur', 'Ne'])
$questions[] = $question;


// This Exam is approved with 75%, each right question sums 1 point,
// each wrong question rest 0.3 points
$approval_criteria = new BasicApprovalCriteria;
$approval_criteria
  ->setScoreToApprove(75)
  ->setRightQuestionsSum(1)
  ->setWrongQuestionsRest(0.3);

$exam = new Exam();
$exam->setQuestions($questions);

$controller = new ExamWithTimeController($exam, $approval_criteria);

$exam_timer = new ExamTimer();
$exam_timer->setDuration(60); // 60 minutes
$controller->setTimer($exam_timer);
$controller->startExam();

$controller->answerCurrentQuestion(['go']); // Wrong answer
$controller->moveToNextQuestion();
$controller->answerCurrentQuestion(['javascript']); // Right answer
$controller->tagCurrentQuestion('review later');
$controller->moveToNextQuestion();
$controller->answerCurrentQuestion(['Ju', 'Sa']); // Wrong answer (incomplete)
$controller->tagCurrentQuestion('review later');
$controller->tagCurrentQuestion('difficult question');
$controller->untagCurrentQuestion('review later');
$controller->moveToNextQuestion();

$controller->finalizeExam();

echo 'Exam: ' . ($controller->getApprovalCriteria()->isApproved($exam->getQuestions()) ? 'Approved' : ' Not Approved')  . PHP_EOL;
echo 'Exam score: ' . sprintf('%.2f%%', $controller->getApprovalCriteria()->getScore()) . PHP_EOL;
echo 'Questions tagged to review later: ' . count($controller->getQuestionsTagged('review later'))  . PHP_EOL;
echo 'Questions tagged as difficult questions: ' . count($controller->getQuestionsTagged('difficult question'))  . PHP_EOL;

The Versions

20/01 2016

dev-master

9999999-dev

A set of PHP Clases to manage multiple choice exams

  Sources   Download

MIT

The Development Requires

exam multiple choice

15/01 2016

dev-refactor

dev-refactor

A set of PHP Clases to manage multiple choice exams

  Sources   Download

MIT

The Development Requires

exam multiple choice