18/04/2002, 02:51
|
| | Fecha de Ingreso: noviembre-2001
Mensajes: 117
Antigüedad: 23 años, 2 meses Puntos: 0 | |
Re: Quiz ... mejorado! <HTML><HEAD>
<TITLE>JavaScript Quiz</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from JavaScript-Impaired Browsers
ctr=0;
/* Put the title of your test here, just
as you want it to appear on screen. */
ttl="JavaScript Quiz... using JavaScript!";
/* Now, what is a perfect score? Although
it will usually be 100, you can alter
it if you wish. However, it may not
exceed 999 and must be a whole number. */
psco=100;
/* Deduction for each wrong answer. May
be the perfect score divided by the
number of questions. But if you "weight"
wrong answers, as we have done in this
little demo script, it may be higher,
but must be a whole number. */
wrans=25;
/* Deduction for each "no answer". Usually
this will be the simple arithmetical
perfect score divided by number of
questions. (A whole number) However,
again, you are in charge. */
noans=20;
/* Change "nr" below to be equal to the
number of questions you have on this
test. (Our demo has 5 questions) */
nr=5;
/* Simply replace the "questions" below with
the ones you wish to use for this test. If
you wish more than 5 questions, simply add
ques[5], ques[6], etc. But be sure that the
"nr" just above is changed to reflect the
actual number of questions you have
prepared. NOTE: do not use any double
quote signs in your questions. If you
need them, use the HTML &quot; instead.
Or, single quote signs may be safely used. */
ques=new Array();
ques[0]="Who invented JavaScript?";
ques[1]="What software do you need to create JavaScript?";
ques[2]="How hard is it to program JavaScript?";
ques[3]="What can I do if I hate programming?";
ques[4]="What is the best workshop ever?";
// add as many questions as you wish here
/* Now the tedious part. You must put the
letter equivalent for each correct answer
(a, b, c, d, or e) in order in a row for
your particular test. As you can see
below, I've done so for the demo test. */
cor="aebce";
/* When entering your own answers, do not
use any double quote signs in your
answers. Instead, use the HTML &quot;
so the JS will not get confused. */
ans=new Array();
ans[0]="NetScape";
ans[1]="Sun";
ans[2]="Bill Gates";
ans[3]="Isaac Newton";
ans[4]="Steve Jobs";
ans[5]="Mr Coffee";
ans[6]="Visual Basic";
ans[7]="Shockwave";
ans[8]="C++";
ans[9]="A text editor";
ans[10]="It's easier than HTML";
ans[11]="It's easier than Java";
ans[12]="You need a Computer Science degree";
ans[13]="An infant can do it";
ans[14]="It's impossible for humans";
ans[15]="Stay off the web";
ans[16]="Buy every book I can find";
ans[17]="Cut and Paste someone else's JavaScript";
ans[18]="Hire a geek";
ans[19]="Learn to love it";
ans[20]="This one";
ans[21]="The one with JavaScript and Shockwave";
ans[22]="http://www.mcli.dist.maricopa.edu/show/conn98/";
ans[23]="Interactive Elements for Your Web Site";
ans[24]="Is this a trick question?";
// Continue adding answers here
// The rest of the code should not be edited!
ns="0123456789"
ls="abcde";
astr="";
ack=new Array();
for (var i=0;i<nr;i++){
ack[I]=(nr*5)+1;
}
function lightIt(){
document.images[flg+ad].src="images/close_o.gif";
}
function dimIt(){
if (ack[Math.floor(flg/5)]!=flg){
document.images[flg+ad].src="images/close_up.gif";
}
}
function dumpIt(){
if (ack[Math.floor(flg/5)]==flg){
document.images[ack[Math.floor(flg/5)]+ad].src="images/close_up.gif";
ack[Math.floor(flg/5)]=(nr*5)+1;
}
else{
if (ack[Math.floor(flg/5)]!=flg&&ack[Math.floor(flg/5)]!=(nr*5)+1){
document.images[ack[Math.floor(flg/5)]+ad].src="images/close_up.gif";
}
document.images[flg+ad].src="images/close_o.gif";
ack[Math.floor(flg/5)]=flg;
}
}
function ckSco(){
document.images[ad+(nr*5)].src="images/enviar.gif";
setTimeout('document.images[ad+(nr*5)].src="images/enviar.gif"',1000);
for (var i=0;i<nr;i++){
u=cor.charAt(i);
v=ls.indexOf(u)+(i*5);
document.images[ad+v].src="images/bull_fl.gif";
}
sco=psco;
for (var i=0;i<nr;i++){
if (ack[i]==(nr*5)+1){
sco-=noans;
}
else{
u=cor.charAt(i);
v=ls.indexOf(u)+(i*5);
sco=(v==ack[i]?sco:sco-wrans);
}
}
sco=(sco<0?0:sco); // prevent minus score
scos=""+sco;
while (scos.length<3){
scos="0"+scos;
}
document.images[ad+(nr*5)+1].src="images/go_find.gif";
ctr=ad+(nr*5)+2;
for (var i=0;i<3;i++){
nj=ns.indexOf(scos.charAt(i));
document.images[ctr].src="nr/"+nj+".gif";
ctr++;
}
}
function litbut(){
document.images[ad+(nr*5)].src="images/enviar.gif";
}
function dimbut(){
document.images[ad+(nr*5)].src="images/enviar.gif";
}
ctr=0;
function srand() {
today=new Date();
rand=today.getTime();
picker=""+rand
picker=picker.charAt((picker.length - 4));
rec=eval(picker);
}
/* This little routine is simply used to count the
number of images you may place on your web page
prior to the radio buttons. Just makes the routine
independent of how you lay your page out. */
function getImgAdd(){
for (var i=0;i<20;i++){
if (document.images[i].src.indexOf("close_up.gif")>-1){
ad=i;
i=20;
}
}
}
// End Hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<P>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from JavaScript-Impaired Browsers
document.write('<TABLE BORDER=0 CELLPADDING=2'
+' CELLSPACING=0 WIDTH=486><TR><TD COLSPAN=2 '
+'ALIGN=CENTER><FONT SIZE=1 FACE="verdana,a'
+'rial,geneva" COLOR=black><B>'+ttl+'</B></FON'
+'T></TD></TR><TR>');
for (var i=0;i<nr;i++){
document.write('<TD COLSPAN=2 VALIGN=TOP><HR'
+' NOSHADE><FONT SIZE=1 FACE="verdana,aria'
+'l,geneva">'+ques+'</FONT></TD></TR>')
for (var j=0;j<5;j++){
document.write('<TR><TD><A HREF="mctest.htm'
+'" onMouseOver="flg='+((i*5)+j)+';lightIt('
+');return true" onMouseOut="flg='+((i*5)+j)
+';dimIt();return true;" onClick="flg='
+((i*5)+j)+';dumpIt();return false;"><IMG S'
+'RC="images/close_up.gif" WIDTH=11 HEIGHT=11 BORDER'
+'=0></TD><TD ALIGN=LEFT><FONT SIZE=1 FACE='
+'"verdana,arial,geneva">'+ans[(i*5)+j]
+'</FONT></TD></TR>');
}
}
document.write('<TR><TD COLSPAN=3 ALIGN=CE'
+'NTER><A HREF="mctest.htm" onClick="ckSco'
+'();return false;" onMouseOver="litbut();'
+'return true;" onMouseOut="dimbut();retur'
+'n true;"><IMG SRC="images/enviar.gif"'
+' WIDTH=67 HEIGHT=12 BORDER=0 NAME="but">'
+'<P><IMG SRC="images/r_arrow.gif" WIDTH=120 HEIGHT'
+'=10 BORDER=0><IMG SRC="images/r_arrow.gif" WIDTH='
+'7 HEIGHT=10 BORDER=0><IMG SRC="images/r_arrow.gif'
+'" WIDTH=7 HEIGHT=10 BORDER=0><IMG SRC="ima'
+'ges/r_arrow.gif" WIDTH=7 HEIGHT=10 BORDER=0></T'
+'D></TR></TABLE>');
getImgAdd();
// End Hiding -->
</SCRIPT>
<!-- You may put any other instructions or
next lesson assignments here. -->
</BODY>
</HTML> |