A simple multiple-choice quiz based on plain PHP, SCSS and jQuery, including questions about Open Access in German.
Starting with a short introduction, the participant is presented with a number of multiple-choice questions. Both the order of questions and answer options are randomized for each run. After an answer has been picked, the correct one is shown along with optional additional information. When all questions have been answered, a score based on the number of correct answers and the overall time required is calculated. Results are logged to a plain text file.
A web server running PHP 5.3.6 or above.
At first, you need to have node.js with npm version 3 or above installed.
If you just want to install the quiz, run
npm install --production
to install the dependencies,gulp
to compile,
then copy the contents of the newly created dist/
directory to your server. Set the access rights for dist/data/
: the process running PHP has to have write access, while everyone else should have neither read nor write access.
For development, run
npm install
to install the dependencies including dev,gulp watch
to compile and wait for changes.
See gulpfile.js
for more tasks.
Questions are stored in a JSON file at app/data/questions.json
, which consists of an array of objects. HTML is allowed for all text content.
id
: A unique identifier, e.g."question1"
.question
: The question, e.g."What is this all about?"
.options
: An array of exactly 4 possible answers, e.g.["Everything", "Nothing", "Any of it", "All of it"]
.answer
: Zero-based index of the correct option, e.g.0
.info
(optional): Additional text that will be shown after a question has been answered.
For each question answered, results are logged to logs/answers.txt
with one line per question.
shtbehlmnh3ct3itju0b7vjkl4 ?3!1P1=1T4.6
The first value is the session ID, the second value reads as ?{Question ID}!{Correct answer}P{Picked answer}={Correct (1) or wrong (0)}T{Seconds required}
.
The results for each participant are logged to logs/scores.txt
with one line per completion.
1461246275 ?2!1P3T1.3|?4!1P0T2.4|?3!1P1T1.5|?1!0P0T1.6|?5!0P0T7.8 2915
The first value is the Unix timestamp at completion, the second value is the order of questions and each given answer in the format ?{Question ID}!{Correct answer}P{Picked answer}={Correct (1) or wrong (0)}T{Seconds required}
(same as above) with questions delimited by |
, the third value is the score.