﻿/************************************************************************************\
*                                                                                   *
*  You've come to this place because you are a savvy Web user or a curious person.  *
*  Fyi, this script was developed inhouse specially for www.conniq.com              *
*  quiz solution. Although using very basic JavaSript programming knowledge,        *
*  I incorporate some cool features, like adding correct or wrong sign,             *
*  inner html insert, and multiple types of questions.                              *
*                                                                                   *
\************************************************************************************/

var tries = 0
function checkitbq() {
     
       var i
       var j
       var sel = new Array()
       var x=0
       var ans = new Array()
       var stat = new Array()
       var cor = ['OPP','PAN','SDAP','BPP','DUN','HID','A2DP','FTP','VDP','HFP','FAX','SAP','AVRCP','CTP','ICP','SPP','SYNC','HSP','BIP','CIP']
      
       for (i=0;i<20;i++) {

           sel[i] = eval("document.bq.S"+i)
           ans[i] = sel[i].value
           
           
           if (ans[i]=='') {
              alert("You haven't answered Question "+(i+1)+".")
              stat[i] = '#000000'
              return
           }
           else if (ans[i]==cor[i]) { 
              stat[i] = '#009900' 
              x++
           }
           else 
              stat[i] = '#FF0000'
                     
       }

     for (i=0;i<20;i++) {
      
         var sign = sel[i].getElementsByTagName('option') 
         for (j=0;j<sign.length;j++) {
             if (sign[j].selected == false) 
                 sign[j].style.color = '#000000'
             else 
                 sign[j].style.color = stat[i]
         }

     }       
   
     tries++     
     var score = Math.round((x/20)*100)

     alert("You answered "+x+" questions "+"correctly. Your score is "+score+"%."+" You've tried "+tries+" times.")  
     
     if (score==100)
         bqdiv.innerHTML = "Congratulations! Excellent score."
     else if (score>=80)
         bqdiv.innerHTML = "Very Good!"
     else if (score>=60)
         bqdiv.innerHTML = "Good!"
     else
         bqdiv.innerHTML = "Sorry, you need to learn more."

}


