﻿var tries=0
function checkitosiq(id) { 

 var i
 var j
 var x = 0
 var cor1 = 'ISO'
 var cor3 = 'F'
 var cor4 = 'APP'
 var cor5 = 'PHY'
 var Quest
 var imgtrue = 'images/true.gif'
 var imgwrong = 'images/wrong.gif'
 var sig = new Array()
 var score
 
/* ==========================Question 1========================================================*/        
     Quest = eval("document.osiq.Q1")   
     for (i=0; i<Quest.length; i++) {
	 if (Quest[i].checked)
	    var ans1 = Quest[i].value
	 }
	 
     /* Q1 correct or wrong */
	 if (ans1 == cor1) {
	      sig[0] = imgtrue
	      x++
	 }
	 else
	      sig[0] = imgwrong
	 
     /* Q1 validation */
     if (ans1 == null) {
	     alert ("You haven't answered Question 1")
	     return
     }
     
/*==============================Question 2=======================================================*/
var cor2 = ['APP','PRE','SES','TRA','NET','DAT','PHY']
var c=0
var el = document.getElementById(id)
var ans2 = new Array()
var listq = el.getElementsByTagName("li")
	for (i=0; i<listq.length; i++) {
	    var lista = listq[i]
        ans2.push(ToolMan.junkdrawer()._identifier(lista))
	    if (ans2[i] == cor2[i])
	       c++ 
	}
	if (c==7){
	       sig[1] = imgtrue
	       x++
	}
    else 
           sig[1] = imgwrong

/* ==========================Question 3============================================================*/   
     Quest = eval("document.osiq.Q3")     
     for (i=0; i<Quest.length; i++) {
	 if (Quest[i].checked)
	    var ans3 = Quest[i].value
	 }
	 
     /* Q3 correct or wrong */
	 if (ans3 == cor3) {
	      sig[2] = imgtrue
	      x++
	 }
	 else
	      sig[2] = imgwrong
	 
     /* Q3 validation */
     if (ans3 == null) {
	     alert ("You haven't answered Question 3")
	     return
     }
/* ==========================Question 4=============================================================*/   
     Quest = eval("document.osiq.Q4")     
     for (i=0; i<Quest.length; i++) {
	 if (Quest[i].checked)
	    var ans4 = Quest[i].value
	 }
	 
     /* Q4 correct or wrong */
	 if (ans4 == cor4) {
	      sig[3] = imgtrue
	      x++
	 }
	 else
	      sig[3] = imgwrong
	 
     /* Q4 validation */
     if (ans4 == null) {
	     alert ("You haven't answered Question 4")
	     return
     }
 
/* ==========================Question 5=============================================================*/   
     Quest = eval("document.osiq.Q5")     
     for (i=0; i<Quest.length; i++) {
	 if (Quest[i].checked)
	    var ans5 = Quest[i].value
	 }
	 
     /* Q5 correct or wrong */
	 if (ans5 == cor5) {
	      sig[4] = imgtrue
	      x++
	 }
	 else
	      sig[4] = imgwrong
	 
     /* Q5 validation */
     if (ans5 == null) {
	     alert ("You haven't answered Question 5")
	     return
     }
/*====================================================================================================*/
/* put the correct or wrong sign */
	 
	 for (i=0;i<5;i++) {
	     eval("document.myImage"+i).src = sig[i]
	 }
/*=====================================================================================================*/	 
score = (x/5)*100
tries++   
     
alert("You answered "+x+" correctly."+" Your score is "+score+"%. "+"You've tried "+tries+" times.")
/*===================================================================================================*/
 if (score==100)
         osiqdiv.innerHTML = "Congratulations! Excellent score."
     else if (score==80)
         osiqdiv.innerHTML = "Very Good!, you scored "+x+" out of 5."
     else if (score==60)
         osiqdiv.innerHTML = "Good!, you scored "+x+" out of 5."
     else
         osiqdiv.innerHTML = "Sorry, you need to learn more."
/*=====================================================================================================*/        

}
