แบบทดสอบ

<html><head><title>แบบทดสอบความรู้ออนไลน์</title>
<script language="JavaScript">
<!--

var numQues = 2;
var numChoi = 4;

var answers = new Array(2);
answers[0] = "By bus";
answers[1] = "In Songkhla";

function getScore(form) {
  var score = 0;
  var currElt;
  var currSelection;

  for (i=0; i<numQues; i++) {
    currElt = i*numChoi;
    for (j=0; j<numChoi; j++) {
      currSelection = form.elements[currElt + j];
      if (currSelection.checked) {
        if (currSelection.value == answers[i]) {
          score++;
          break;
        }
      }
    }
  }

  score = Math.round(score/numQues*100);
  form.percentage.value = score + "%";

  var correctAnswers = "";
  for (i=1; i<=numQues; i++) {
    correctAnswers += i + ". " + answers[i-1] + "\r\n";
  }
  form.solutions.value = correctAnswers;

}

// -->
</script>แบบทดสอบโดยครูทองครูไทยหัวใจพอเพียง
</head>

<body>

<form name="quiz">
1. How do you go to school?<br>
<input type="radio" name="q1" value="By bus">By bus<br>
<input type="radio" name="q1" value="In the morning">In the morning<br>
<input type="radio" name="q1" value="At school">At school<br>
<input type="radio" name="q1" value="I like my school">I like my school<br>
<p>

2. Whee do you live?<br>
<input type="radio" name="q2" value="Yes , I do.">Yes , I do.<br>
<input type="radio" name="q2" value="My parents">My parents<br>
<input type="radio" name="q2" value="In Songkhla">In Songkhla<br>
<input type="radio" name="q2" value="With my parents">With my parents<br>
<p>

<input type="button" value="ดูผลคะแนน" onClick="getScore(this.form)">
<input type="reset" value="ยกเลิก"><p>
ผลคะแนน = <input type=text size=15 name="percentage"><br>
เฉลยคำตอบ:<br>
<textarea name="solutions" wrap="virtual" rows="4" cols="80"></textarea>
</form>

</body></html>
แบบทดสอบความรู้ออนไลน์ แบบทดสอบโดยครูทองครูไทยหัวใจพอเพียง
1. How do you go to school?
By bus
In the morning
At school
I like my school

2. Whee do you live?
Yes , I do.
My parents
In Songkhla
With my parents

ผลคะแนน =
เฉลยคำตอบ:

ไม่มีความคิดเห็น:

แสดงความคิดเห็น