473,395 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Javascript Quiz Code

Hello:

I found a script for a simple multiple choice quiz that I would like to
tailor to a quiz that I want to post on a website. The quiz I want to use
can be found at :

http://mtl.math.uiuc.edu/users/C2Schult/quiz2.html

Here is my problem. I want to be able to use answers with more than one
word or number which requires spaces. When I tried doing that, it did not
recognize the question as being answered. For example, it would not
recognize an answer of Bob Smith unless I put Bob_Smith which I don't want
to do. The answers in the example are all either 1 word or 1 number answers
so I cannot tell from that how to do this. Can someone tell me what I need
to do to be able to use multiple word answers without having to use an
underscore? Thanks for your help.

David
Jul 20 '05 #1
4 9194
"C. David Rossen" <cd******@cdrmarketing.com> wrote in message
news:O6********************@comcast.com...
Hello:

I found a script for a simple multiple choice quiz that I would like to
tailor to a quiz that I want to post on a website. The quiz I want to use
can be found at :

http://mtl.math.uiuc.edu/users/C2Schult/quiz2.html

Here is my problem. I want to be able to use answers with more than one
word or number which requires spaces. When I tried doing that, it did not
recognize the question as being answered. For example, it would not
recognize an answer of Bob Smith unless I put Bob_Smith which I don't want
to do. The answers in the example are all either 1 word or 1 number answers so I cannot tell from that how to do this. Can someone tell me what I need to do to be able to use multiple word answers without having to use an
underscore? Thanks for your help.

David


I don't see the problem.

The answers are merely hardcoded in the JavaScript :

var aKey = new Array(3);
aKey[0]="distributive";
aKey[1]="1/3";
aKey[2]="24/99";

Just include a space in your answer; for example,

aKey[0]="distributive property";

Note, you may have to be concerned with case sensitivity if you allow
free-form answers.
Jul 20 '05 #2
OK..when I change all instances of "distributive" to "distributive
property", it does not recognize the answer as a correct answer. Here are
the places where I changed it:

aKey[0]="distributive property";

<input type="radio" name="q1" value="distributive property"
onClick=studentAns(1,"distributive property") >distributive property<br>

That choice is a correct answer, but along with the other two correct
answers, it is only giving me a 67% score instead of a 100% score so it is
not recognizing "distributive property" as a correct answer.

Any ideas? Thanks.
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:vD********************@rwcrnsc52.ops.asp.att. net...
"C. David Rossen" <cd******@cdrmarketing.com> wrote in message
news:O6********************@comcast.com...
Hello:

I found a script for a simple multiple choice quiz that I would like to
tailor to a quiz that I want to post on a website. The quiz I want to use can be found at :

http://mtl.math.uiuc.edu/users/C2Schult/quiz2.html

Here is my problem. I want to be able to use answers with more than one
word or number which requires spaces. When I tried doing that, it did not recognize the question as being answered. For example, it would not
recognize an answer of Bob Smith unless I put Bob_Smith which I don't want to do. The answers in the example are all either 1 word or 1 number

answers
so I cannot tell from that how to do this. Can someone tell me what I

need
to do to be able to use multiple word answers without having to use an
underscore? Thanks for your help.

David


I don't see the problem.

The answers are merely hardcoded in the JavaScript :

var aKey = new Array(3);
aKey[0]="distributive";
aKey[1]="1/3";
aKey[2]="24/99";

Just include a space in your answer; for example,

aKey[0]="distributive property";

Note, you may have to be concerned with case sensitivity if you allow
free-form answers.

Jul 20 '05 #3
"C. David Rossen" <cd******@cdrmarketing.com> writes:
<input type="radio" name="q1" value="distributive property"
onClick=studentAns(1,"distributive property") >distributive property<br>


This is incorrect HTML. You MUST quote attribute values that contain
spaces for it to work. Otherwise, the value ends right after
"distributive", giving syntactically incorrect Javascript as well.

According to the HTML definition, you MUST quote attribute values that
contain anything but letters, digits, and a few select types of
punctuation. Browsers are more forgiving than the requirement, but still
fails at spaces, greater-than signs, etc.

For good coding practice, you SHOULD quote all attribute values. It saves
yourself from having to remember the exceptions, and it is more stable
in the cases where you make changes, like here.

So:
<label for="q1Id">
<input type="radio" name="q1" id="q1Id" value="distributive property"
onClick='studentAns(1,"distributive property")'>distributive property
</label></br>

(use the label tag for the text associated with the radiobutton. Then you
can click the text as well.)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4


C. David Rossen a écrit:
OK..when I change all instances of "distributive" to "distributive
property", it does not recognize the answer as a correct answer. Here are
the places where I changed it:

aKey[0]="distributive property";

<input type="radio" name="q1" value="distributive property"
onClick=studentAns(1,"distributive property") >distributive property<br>

That choice is a correct answer, but along with the other two correct
answers, it is only giving me a 67% score instead of a 100% score so it is
not recognizing "distributive property" as a correct answer.

Any ideas? Thanks.
use method replace ex : string.replace(" ","#") in comparaison and
inverse for display

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:vD********************@rwcrnsc52.ops.asp.att. net...
"C. David Rossen" <cd******@cdrmarketing.com> wrote in message
news:O6********************@comcast.com...
Hello:

I found a script for a simple multiple choice quiz that I would like to
tailor to a quiz that I want to post on a website. The quiz I want to

use
can be found at :

http://mtl.math.uiuc.edu/users/C2Schult/quiz2.html

Here is my problem. I want to be able to use answers with more than one
word or number which requires spaces. When I tried doing that, it did

not
recognize the question as being answered. For example, it would not
recognize an answer of Bob Smith unless I put Bob_Smith which I don't

want
to do. The answers in the example are all either 1 word or 1 number


answers
so I cannot tell from that how to do this. Can someone tell me what I


need
to do to be able to use multiple word answers without having to use an
underscore? Thanks for your help.

David


I don't see the problem.

The answers are merely hardcoded in the JavaScript :

var aKey = new Array(3);
aKey[0]="distributive";
aKey[1]="1/3";
aKey[2]="24/99";

Just include a space in your answer; for example,

aKey[0]="distributive property";

Note, you may have to be concerned with case sensitivity if you allow
free-form answers.



Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sketcher | last post by:
Hi, I am trying to create a quiz, Code is as follows: <html> <head> <title>Quiz</title> </head> <BODY> <Center><TABLE cellSpacing=3 cellPadding=0 border=0>
17
by: rgoya | last post by:
Peace be with you! About a year ago, I created a JavaScript which turns any web site into an online anti-war protest: http://www.geocities.com/rgoya/javascript/PROTEST.HTM I have recently...
6
by: Vandana Rola | last post by:
Hello Everyone, I posted this question earlier under creating Multiple choice quiz. Is it possible to ignore something using javascript. What I am trying to do is creating a multiple answer...
11
by: admin | last post by:
Hi all, First time poster here... I'm a webmaster and I'd like to add a simple script to my website which will allow users to fill in a brief multiple choice questionaire, and then provide a...
2
by: Cox News | last post by:
Greetings. Any help with this would be greatly appreciated! I use Articulate Quizmaker to develop online quizes. When published, the outputed JS on the HTML page looks like this: ...
2
by: kenny | last post by:
I'm making a quiz to be posted on the internet. but I'm facing difficulties in finding a simple timer for the quiz (unlimited timing) which will keep on running regardless to the change of the page...
2
by: Surya Vellanki | last post by:
Hi all, I have been struggling with this problem from a few days. I hope I will get some help here. I am developing an online quiz portal with ASP.NET 2.0 and I am using Atlas framework for...
5
by: Steve | last post by:
I need to make an HTML page that has multiple choice quiz questions that pull from an XML doc. I have been looking at various online examples of how to do this, mainly this one:...
8
by: danjoplin | last post by:
I've only recently started javascript and I'm a java programmer so I'm sure I've done something obvious that I can't see. Basically this goes with an html document which has a number of questions on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.