[ Index | Introduction | Security | The Program | Notes | RakuConf ]
We start with a question. If the user gives the correct answer, the program forwards them to the next question. If the user gives an incorrect answer, they are stuck at the same question - until a correct answer has been given.
The system does not track the users in any way. All it has is a list of questions (and answers), each with an unique and (hopefully) unguessable ID. Except the very first one, as you have to disclose it to get the ball (or quiz) rolling.
I have chosen to place the questions in a CSV file, to separate them from the program. In addition to columns for question and answer, we have a pre-question column. It can be used to give instructions/background, before the question itself, and on the very last page to give the congratulatory message.
The CSV file, with line breaks added for readability here:
File: sample-quiz.csv
sample-quiz;<h1>Welcome to a Sample Quiz</h1><p>It has been created to \
Showcase the Quiz system…</p>;What is the greatest programming language \
ever created on this planet?;Raku
8u9rstpjkqw21ang;;The next-best programming language ever created on this \
planet?;Perl
173xyrundoczpjbi;Congratulations!<br>You got it. Contact your parent(s)/\
spouse/parole officer/lawyer/etc. for your reward;;
Note the non-random ID of the first question. That is intentional, as you have to give that away to the users (or rather, the URL, but we'll get to that in the next section).
Note that the program ignores empty lines, so you can have them in the file if you want to. (The result is a non-compliant CSV file, but the Quiz system does not mind.)
Note that html formatting is allowed in the pre-question and question columns. This allows for quite a lot of flexibility, but be careful to write legal html only.
Note that anything goes in
thefields, except semicolons (;
) - as they are used as a field
separator.
Note that the system treats lowercase and uppercase letters as the same, so all of «raku», «Raku» and «RAKU» will match the correct answer «Raku» in the first question.
Start the application server:
$ ./app
Then point your web browser to the first question (with the ID sample-quiz):
http://localhost:8080/q/sample-quiz
Voilla:
Note that the Question Numbers (in this case «1») are calculated automatically by the program, as it reads them from the CSV file.
Try basic:
That was wrong, as shown by the big red header message:
Try again, this time with Raku:
YES! That was correct, as shown by the nice green header message:
You are now at the next (second) question. Try Perl:
You got that one correct as well, and have reached the end:
The reward does not look that promising, but have a go at it if you want to...
[ Index | Introduction | Security | The Program | Notes | RakuConf ]