Foros del Web » Programando para Internet » Javascript »

Quiz ... mejorado!

Estas en el tema de Quiz ... mejorado! en el foro de Javascript en Foros del Web. Quisiera pedir vuestra ayuda ... Soy docente de la Universidad de Sevilla (España) y estoy preparando material para los estudiantes. Nuestros recursos son escasos. Encontré ...
  #1 (permalink)  
Antiguo 18/04/2002, 02:51
 
Fecha de Ingreso: noviembre-2001
Mensajes: 117
Antigüedad: 22 años, 5 meses
Puntos: 0
Quiz ... mejorado!

Quisiera pedir vuestra ayuda ...

Soy docente de la Universidad de Sevilla (España) y estoy preparando material para los estudiantes. Nuestros recursos son escasos.

Encontré el siguiente examen tipo tests en la Red pero mi perfil no me permite modificarlo para incluir una serie de aspectos que considero necesarios.

Que el test:

A) Ofrezca un cuadro de puntuación acertada y puntuación errónea (en porcentaje). O bien un diagrama de barras; algo curioso.
B) Clicando sobre un botón, pueda comprobar las respuestas acertadas y falsas sobre el mismo test. Esa función ya la incorpora el test que muestro, pero quisiera que la secuencia fuese la que os indico: primero el punto A y luego, si decido clicar y no intentarlo de nuevo, el punto B.
C) Elimine la función que incorpora el test de hacer click sobre un botón final que muestre sin hacer el test las respuestas acertadas.

Ruego vuestra ayuda.

Recibid un cordial saludo,

majesus

nota: adjunto el código en el siguiente mensaje.

<a href="http://www.canalpublicidad.com"><img border="0" src="http://www.canalpublicidad.com/images/banner_crystal_g.gif" width="468" height="60"></a>
  #2 (permalink)  
Antiguo 18/04/2002, 02:51
 
Fecha de Ingreso: noviembre-2001
Mensajes: 117
Antigüedad: 22 años, 5 meses
Puntos: 0
Re: Quiz ... mejorado!

&lt;HTML&gt;&lt;HEAD&gt;
&lt;TITLE&gt;JavaScript Quiz&lt;/TITLE&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
&lt;!-- Hide from JavaScript-Impaired Browsers
ctr=0;
/* Put the title of your test here, just
as you want it to appear on screen. */
ttl=&quot;JavaScript Quiz... using JavaScript!&quot;;

/* 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 &quot;weight&quot;
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 &quot;no answer&quot;. 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 &quot;nr&quot; below to be equal to the
number of questions you have on this
test. (Our demo has 5 questions) */
nr=5;

/* Simply replace the &quot;questions&quot; 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
&quot;nr&quot; 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 &amp;quot; instead.
Or, single quote signs may be safely used. */
ques=new Array();
ques[0]=&quot;Who invented JavaScript?&quot;;
ques[1]=&quot;What software do you need to create JavaScript?&quot;;
ques[2]=&quot;How hard is it to program JavaScript?&quot;;
ques[3]=&quot;What can I do if I hate programming?&quot;;
ques[4]=&quot;What is the best workshop ever?&quot;;
// 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=&quot;aebce&quot;;

/* When entering your own answers, do not
use any double quote signs in your
answers. Instead, use the HTML &amp;quot;
so the JS will not get confused. */

ans=new Array();
ans[0]=&quot;NetScape&quot;;
ans[1]=&quot;Sun&quot;;
ans[2]=&quot;Bill Gates&quot;;
ans[3]=&quot;Isaac Newton&quot;;
ans[4]=&quot;Steve Jobs&quot;;

ans[5]=&quot;Mr Coffee&quot;;
ans[6]=&quot;Visual Basic&quot;;
ans[7]=&quot;Shockwave&quot;;
ans[8]=&quot;C++&quot;;
ans[9]=&quot;A text editor&quot;;

ans[10]=&quot;It's easier than HTML&quot;;
ans[11]=&quot;It's easier than Java&quot;;
ans[12]=&quot;You need a Computer Science degree&quot;;
ans[13]=&quot;An infant can do it&quot;;
ans[14]=&quot;It's impossible for humans&quot;;

ans[15]=&quot;Stay off the web&quot;;
ans[16]=&quot;Buy every book I can find&quot;;
ans[17]=&quot;Cut and Paste someone else's JavaScript&quot;;
ans[18]=&quot;Hire a geek&quot;;
ans[19]=&quot;Learn to love it&quot;;

ans[20]=&quot;This one&quot;;
ans[21]=&quot;The one with JavaScript and Shockwave&quot;;
ans[22]=&quot;http://www.mcli.dist.maricopa.edu/show/conn98/&quot;;
ans[23]=&quot;Interactive Elements for Your Web Site&quot;;
ans[24]=&quot;Is this a trick question?&quot;;
// Continue adding answers here



// The rest of the code should not be edited!
ns=&quot;0123456789&quot;
ls=&quot;abcde&quot;;
astr=&quot;&quot;;
ack=new Array();
for (var i=0;i&lt;nr;i++){
ack[I]=(nr*5)+1;
}

function lightIt(){
document.images[flg+ad].src=&quot;images/close_o.gif&quot;;
}
function dimIt(){
if (ack[Math.floor(flg/5)]!=flg){
document.images[flg+ad].src=&quot;images/close_up.gif&quot;;
}
}
function dumpIt(){
if (ack[Math.floor(flg/5)]==flg){
document.images[ack[Math.floor(flg/5)]+ad].src=&quot;images/close_up.gif&quot;;
ack[Math.floor(flg/5)]=(nr*5)+1;
}
else{
if (ack[Math.floor(flg/5)]!=flg&amp;&amp;ack[Math.floor(flg/5)]!=(nr*5)+1){
document.images[ack[Math.floor(flg/5)]+ad].src=&quot;images/close_up.gif&quot;;
}
document.images[flg+ad].src=&quot;images/close_o.gif&quot;;
ack[Math.floor(flg/5)]=flg;
}
}
function ckSco(){
document.images[ad+(nr*5)].src=&quot;images/enviar.gif&quot;;
setTimeout('document.images[ad+(nr*5)].src=&quot;images/enviar.gif&quot;',1000);

for (var i=0;i&lt;nr;i++){
u=cor.charAt(i);
v=ls.indexOf(u)+(i*5);
document.images[ad+v].src=&quot;images/bull_fl.gif&quot;;
}
sco=psco;
for (var i=0;i&lt;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&lt;0?0:sco); // prevent minus score
scos=&quot;&quot;+sco;
while (scos.length&lt;3){
scos=&quot;0&quot;+scos;
}
document.images[ad+(nr*5)+1].src=&quot;images/go_find.gif&quot;;
ctr=ad+(nr*5)+2;
for (var i=0;i&lt;3;i++){
nj=ns.indexOf(scos.charAt(i));
document.images[ctr].src=&quot;nr/&quot;+nj+&quot;.gif&quot;;
ctr++;
}
}
function litbut(){
document.images[ad+(nr*5)].src=&quot;images/enviar.gif&quot;;
}
function dimbut(){
document.images[ad+(nr*5)].src=&quot;images/enviar.gif&quot;;
}
ctr=0;

function srand() {
today=new Date();
rand=today.getTime();
picker=&quot;&quot;+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&lt;20;i++){
if (document.images[i].src.indexOf(&quot;close_up.gif&quot;)&gt;-1){
ad=i;
i=20;
}
}
}
// End Hiding --&gt;
&lt;/SCRIPT&gt;
&lt;/HEAD&gt;
&lt;BODY BGCOLOR=&quot;#FFFFFF&quot;&gt;
&lt;P&gt;
&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;
&lt;!-- Hide from JavaScript-Impaired Browsers
document.write('&lt;TABLE BORDER=0 CELLPADDING=2'
+' CELLSPACING=0 WIDTH=486&gt;&lt;TR&gt;&lt;TD COLSPAN=2 '
+'ALIGN=CENTER&gt;&lt;FONT SIZE=1 FACE=&quot;verdana,a'
+'rial,geneva&quot; COLOR=black&gt;&lt;B&gt;'+ttl+'&lt;/B&gt;&lt;/FON'
+'T&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;');
for (var i=0;i&lt;nr;i++){
document.write('&lt;TD COLSPAN=2 VALIGN=TOP&gt;&lt;HR'
+' NOSHADE&gt;&lt;FONT SIZE=1 FACE=&quot;verdana,aria'
+'l,geneva&quot;&gt;'+ques+'&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;')
for (var j=0;j&lt;5;j++){
document.write('&lt;TR&gt;&lt;TD&gt;&lt;A HREF=&quot;mctest.htm'
+'&quot; onMouseOver=&quot;flg='+((i*5)+j)+';lightIt('
+');return true&quot; onMouseOut=&quot;flg='+((i*5)+j)
+';dimIt();return true;&quot; onClick=&quot;flg='
+((i*5)+j)+';dumpIt();return false;&quot;&gt;&lt;IMG S'
+'RC=&quot;images/close_up.gif&quot; WIDTH=11 HEIGHT=11 BORDER'
+'=0&gt;&lt;/TD&gt;&lt;TD ALIGN=LEFT&gt;&lt;FONT SIZE=1 FACE='
+'&quot;verdana,arial,geneva&quot;&gt;'+ans[(i*5)+j]
+'&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;');
}
}
document.write('&lt;TR&gt;&lt;TD COLSPAN=3 ALIGN=CE'
+'NTER&gt;&lt;A HREF=&quot;mctest.htm&quot; onClick=&quot;ckSco'
+'();return false;&quot; onMouseOver=&quot;litbut();'
+'return true;&quot; onMouseOut=&quot;dimbut();retur'
+'n true;&quot;&gt;&lt;IMG SRC=&quot;images/enviar.gif&quot;'
+' WIDTH=67 HEIGHT=12 BORDER=0 NAME=&quot;but&quot;&gt;'
+'&lt;P&gt;&lt;IMG SRC=&quot;images/r_arrow.gif&quot; WIDTH=120 HEIGHT'
+'=10 BORDER=0&gt;&lt;IMG SRC=&quot;images/r_arrow.gif&quot; WIDTH='
+'7 HEIGHT=10 BORDER=0&gt;&lt;IMG SRC=&quot;images/r_arrow.gif'
+'&quot; WIDTH=7 HEIGHT=10 BORDER=0&gt;&lt;IMG SRC=&quot;ima'
+'ges/r_arrow.gif&quot; WIDTH=7 HEIGHT=10 BORDER=0&gt;&lt;/T'
+'D&gt;&lt;/TR&gt;&lt;/TABLE&gt;');
getImgAdd();
// End Hiding --&gt;
&lt;/SCRIPT&gt;

&lt;!-- You may put any other instructions or
next lesson assignments here. --&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:54.