<style type="text/css">
TH {text-align: left;}
H1 {text-align: left;}
H1, H2, H3, H4, H5, H6, p, th, td, li, ul, ol, body {font-family: Arial, Helvetica, Verdana, sans-serif;}
H1, H2, H3, H4, H5, H6 {font-weight: lighter;}
H1 {font-size: 30pt; color: blue; letter-spacing: normal; clip: rect(   ); font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: lighter;}
H2 {font-size: 24pt; color: red;}
H3 {font-size: 18pt;}
H4 {font-size: 16pt; color: #660000;}
H5 {font-size: 14pt; color: #660000;}
H6 {font-size: 12pt; font-weight: 500;}
P  {font-size: 10pt; color: #333333;}
TH, TD, li, ul, ol, body {font-size: 10pt;}
pre {font-size: 8pt;}
address {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; font-style: italic;}
dt {font-family: Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold;}
dd {font-family: Arial, Helvetica, sans-serif; font-size: 10pt;}
A {text-decoration: underline; color: blue;}
A:Hover {text-decoration: underline; color: red;}
input {font-family: Arial, Helvetica, sans-serif; height:18; font-size:8pt;}
select {font-family: Arial, Helvetica, sans-serif; font-size:8pt;}
textarea {font-family: Arial, Helvetica, sans-serif; font-size:8pt;}
TD:banner1 {}
.topicTitle {font-family: Palatino, Times, Times New Roman, serif; font-size:18pt; color:#ff9933; font-style: normal; font-weight: bold;}
.popshadow{position:relative; left:-4; top:-4; filter:shadow(silver,direction=135)}
</style>

<script type="text/javascript" src="quizGrader_bare.js"></script>

<script type="text/javascript">
<!--
function x_gradeQuiz(frm){
  var sz=frm.elements.length;   // assumes last element is button
  //frm.chksum.value=sz;          //debug - isWorking test
  var ans="";
  var anz=0;
  var pts=0;
  var score=0;                  //number of points for any question (usually same as pts if right)
  var isCorrect=0;
  var p=0, i=0, j=0;
  var ar;
  var alt="";
  var bld="";                   //alert-box response
  var totalPoints=0;
  var totalEarned=0;
  var tpercent=0;
  var elemValue="", lcValue="";
  var badCT=0, goodCT=0;
  var curName="", newName="";
  var eType="";
  varchkct=0;
  
  for ( var i=0; i<sz; i++ )
  {
    eType=frm.elements[i].type.toLowerCase();

    
    switch(eType)
    {
    case "text":
    {
      alt=frm.elements[i].alt.toLowerCase();
      ar=alt.split("|");
      anz=ar.length;
      pts=parseInt(ar[0]);
      totalPoints += pts;
      ans="|";
      for(j=1; j<anz; j++)
      {
        ans += ar[j] + "|"
      }
      elemValue=frm.elements[i].value;   //answer as input
      lcValue=elemValue.toLowerCase();   //answer as input
      p=ans.indexOf("|" + lcValue + "|");
      isCorrect=0;
      if(p>=0)
      {
       isCorrect=1;
       goodCT++;
       totalEarned += pts;
       bld += pts + "pts = " + elemValue + " (ok)\n";
      }
      else
      {
       badCT++;
       bld += " (0 pts), " + lcValue + " (wrong)\n";       
      }
      score=isCorrect * pts;
      //frm.elements[i].value=pts + ", " + ans;   //for debugging
    }
    break;
    
    case "radio":
    {
      alt=frm.elements[i].alt;
      ar=alt.split("|");
      anz=ar.length;
      pts=parseInt(ar[0]);
      ans=parseInt(ar[1]);
      newName=frm.elements[i].name
      if(newName==""){newName=frm.elements[i].id}
      if(curName != newName)
      {
        curName=newName;
        totalPoints += pts;
        isCorrect=0;
      }

      if(curName == newName)
      {
        if(frm.elements[i].checked)
        {
          lcValue=frm.elements[i].value.toLowerCase();   //answer as input
          if(ans>0)
          {
            isCorrect=1;
            goodCT++;
            totalEarned += pts;
            bld += pts + "pts = " + lcValue + " (ok)\n";
            //frm.pageQuiz5.value=ans;
          }
          else
          {
            badCT++;
            bld += " (0 pts), " + lcValue + " (wrong)\n";
            //frm.pageQuiz4.value=ans;
          }
         score=isCorrect * pts;
        } // if checked
        
      } // if name
    }
    break;
    
    case "checkbox":
    {
      alt=frm.elements[i].alt;
      ar=alt.split("|");
      anz=ar.length;
      pts=parseInt(ar[0]);
      ans=parseInt(ar[1]);
      newName=frm.elements[i].name
      if(newName==""){newName=frm.elements[i].id}
      if(curName != newName)
      {
        curName=newName;
        //totalPoints += pts;
        isCorrect=0;
        varchkct=1;
      }

      if(curName == newName)
      {
        
        if(frm.elements[i].checked)
        {
          lcValue=frm.elements[i].value.toLowerCase();   //answer as input
          if(ans>0)
          {
            isCorrect=1;
            goodCT++;
            totalPoints += pts;    //total possible accumulated for right answers only
            totalEarned += pts;    //total earned is collected from right answers
            bld += pts + "pts = " + lcValue + " (ok)\n";
            //frm.pageQuiz5.value=ans;
          }
          else
          {
            badCT++;
            totalEarned -= pts;   //any wrong answer checked subtracts from the total earned
            bld += " (-" + pts + " pts), " + lcValue + " (wrong)\n";
            //frm.pageQuiz4.value=ans;
          }
         score=isCorrect * pts;
        } // if checked
        
      } // if name
    }
    break;

    default:
    {
    }
    
    }

  }
  tpercent = parseInt((totalEarned / totalPoints)*100);
  if(tpercent>=90){msg="Very Good. Feel free to go to another section."}
  if(tpercent>=70 && tpercent<80){msg="Take another look and then retake the quizz. You should feel more in charge of this material."}
  if(tpercent>=80 && tpercent<90){msg="You can do yet a little better. \nTake another look and then retake the quizz."}
  if(tpercent<70){msg="Definitely go back over this section. Look for the items you missed."}
  
  //bld = "Total Correct: " + goodCT + "\nTotal Wrong: " + badCT + "\nTotal Points: " + totalPoints + "\nTotal Earned:" + totalEarned + "\nPercent: " + tpercent + "\n\n" + bld;
  bld += "\n\nTotal Correct: " + goodCT + "\nTotal Wrong: " + badCT + "\nTotal Points: " + totalPoints + "\nTotal Earned:" + totalEarned + "\nPercent: " + tpercent + "\n\n" + msg;
  alert(bld);
}
// -->
</script>
