- Use
1
| <input type="radio" id="option1"/><label for="option1">caption</label> |
for your radiobuttons and checkboxes, so users can click on the text to select the option.
- Don't use <p>s for anything else than paragraphs. Use <div> instead (or <span> if if does not represent a block)
Great tip, much better.
- Don't give forms the same name
I'm doing that to identify the elements so that I can use javascript to find them and give them unique id tags. I'm trying to avoid the human error that will occur if I try and give every question the correct question number. I think it's logical to use javascript (or maybe I'll switch to using php on the server to do this) to allocate question numbers and other repetitive things. Instead of using the 'name' attribute, I'll use 'title' which is what jQuery seems to use for labelling similar elements for the purpose of finding them later.
The next hard thing...
Sounds like the right solution.
Cool. I'm going to use the php expat parser for this (
http://www.w3schools.com/php/php_xml_parser_expat.asp).
Final advice:
make this whole thing work completely without javascript. Let it be crude and clumsy, but provide all the building blocks with only html and some php controler script. Then use unobstrusive javascript technics (preferable with jQuery) to streamline the experience, like inlining the answer-pages via javascript. Remember KISS - if you find that you'll rewrite stuff in javascript, that already works without it, you are doing wrong. If you break the HTML/PHP version while adding javascript, you are doing it wrong. If you have to switch between the html and the javascript version, well, you are doing it wrong

Goal should be, that you only enhance a working version of your html-only app by adding a single <script type="text/javascript" src="make-it-even-better.js"></script>
See
http://coding.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/But if the students don't have javascript then they won't be able to submit their marks at all since it requires the AJAX mechanism. Also, apparently only 2% or less of people have javascript disabled.
But I think you're right that my javascript is a mess. I'm thinking of migrating all of my javascript client code to php on the server. Then I can do all of the inserting of id tags, question numbers etc on the server rather than on the client using javascript. This would make it a lot easier to do the answer-insertion after the students get the answer wrong since the php script would already have the question data numbered properly.
Looks nice! Once I get my tests functioning properly I'll have some questions for you about CSS and prettiness.
It's even better to prevent issues beforehand. Try JSLint. I f-ing love it. It's what made JavaScript acceptable to me. (A good editor like Komodo Edit/IDE also helps a lot.)
I'll take a look but now that I've got Netbeans working well with php, javascript, css and html I'm pretty happy.
Thanks so much for all of your tips Cylab and Onyx. Unlike the orderly java ecosystem, the web/scripting world is a mess. I would have wasted weeks going down wrong tracks without your help.