PDA

View Full Version : Script calculations not being performed


Cornerpocket
11-23-2002, 12:47 AM
I stumbled across a good source for an interactive script for a website I am building. It offered a JS called "Quizzer" which tests users on any subject and provides instant feedback. Part of the script calculates a test score based on answers selected.I appparently missed something because it doesn't do the calculation.

I believe this is the part where the calculation takes place:

// 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="nr/rbl.gif";
}
function dimIt(){
if (ack[Math.floor(flg/5)]!=flg){
document.images[flg+ad].src="nr/rbd.gif";
}
}
function dumpIt(){
if (ack[Math.floor(flg/5)]==flg){
document.images[ack[Math.floor(flg/5)]+ad].src="nr/rbd.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="nr/rbd.gif";
}
document.images[flg+ad].src="nr/rbl.gif";
ack[Math.floor(flg/5)]=flg;
}
}
function ckSco(){
document.images[ad+(nr*5)].src="nr/cwf2.gif";
setTimeout('document.images[ad+(nr*5)].src="nr/cwf0.gif"',1000);

for (var i=0;i<nr;i++){
u=cor.charAt(i);
v=ls.indexOf(u)+(i*5);
document.images[ad+v].src="nr/gbl.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="nr/yts.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="nr/cwf1.gif";
}
function dimbut(){
document.images[ad+(nr*5)].src="nr/cwf0.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("rbd.gif")>-1){
ad=i;
i=20;
}
}
}
// End Hiding -->
</SCRIPT>

Does anyone see anything I missed when I copied the script?