The program is a self-grading multiple-choice testing environment. The teacher can enter an arbitrary number of questions, with four possible answers to each question. Only one of the answers may be correct. The program randomizes the questions and answers, so a student will never get the same test twice (and can't cheat using a scoring key).
This example is a simple spelling test. Three of the answers are wrong ('W') and one is right ('R'):
==========
$VAR1 = [
[
'a',
'W',
'interupt'
],
[
'b',
'R',
'interrupt'
],
[
'c',
'W',
'innterupt'
],
[
'd',
'W',
'intterupt'
]
];
==========
Since the answers have been randomized, the program has to match the entered answer letter ('a..d') to the 'W' or 'R' that is the second element of one of the elements of the $qablock. Only then can the actual answer be recorded for later scoring (since the answer 'b' has no lasting significance).
The reason that I removed the square brackets from the
grep is because the element of $qablock that the
grep is assigning should already be an anonymous array reference. But then I still had to use the brackets for the assignment in the
foreach, so I tried it with brackets as well. Basically, I've been flailing in the hope of getting lucky....
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.