List of Topics

SfC Home > Training > eLearning >

 

Graded Test Using JavaScript

by Ron Kurtus (revised 9 January 1998)

Do you want to give your students or trainees an online test that automatically calculates the grade? Using JavaScript provides an easy way to do that.

Questions you may have on this subject are:

(You can jump to to specific answer or simply read the text in order.)

This lesson will answer those questions.



Sample test

Note: Your browser must be able to interpret JavaScript. To check this, click the Get Score button at the end of the test to make sure it works with your browser.

Instructions: Take test by clicking the correct round button for each question. Use the mouse and scroll bar to move to the next question. Do not use the down key, as it may change your answers.


1. What does "WBT" stand for?

a. World Boxing Association.

b. Web-Based Training.

c. Why Bother Testing?

 


2. What is JavaScript?

a. A programming language used with HTML.

b. The same as Java code.

c. The script used in the country Java.

 


3. Why use multiple choice tests in WBT?

a. It is different than regular tests.

b. It causes students to be confused.

c. It is easier to program and control.

 



JavaScript code

The following code was used in programming the test. (You can also examine the HTML source material).

Script language

This material can be placed either under <head> or directly under <body> within your HTML. The bracketed numbers after elements relate to the correct answer. The 9 answers for the three questions in this test are listed as 0, 1, 2...7, 8.

<script language="JavaScript">
function tester() {
var a = 0
var b = 0
var c = 0
if(document.forms[0].elements[1].checked==true) {
a = 1
}
if(document.forms[0].elements[3].checked==true) {
b = 1
}
if(document.forms[0].elements[8].checked==true) {
c = 1
}
total = a + b + c
grade = 33*total
if (total==3){
alert("Your grade is 100% correct. Great Job!")
}
if (total < 3){
alert("Your grade is "+ grade +"% correct.")
}
}
</script>

Form material

The JavaScript code for the actual test is always within <body> of the HTML.

<dl>
<form method="get" onsubmit="tester()">
<h4>1. What does &quot;WBT&quot; stand for?</h4>
<p><input type="radio" checked name="R1" value="V1">a. World Boxing Association.</p>
<p><input type="radio" name="R1" value="V2">b. Web-Based Training. </p>
<p><input type="radio" name="R1" value="V3">c. Why Bother Testing?</p>
<p>&nbsp;</p>
<hr>
<h4>2. What is JavaScript?</h4>
<p><input type="radio" name="R2" value="V4">a. A programming language used with HTML.</p>
<p><input type="radio" name="R2" value="V5">b. The same as Java code.</p>
<p><input type="radio" name="R2" value="V6">c. The script used in the country Java.</p>
<p>&nbsp;</p>
<hr>
<h4>3. Why use multiple choice tests in WBT?</h4>
<p><input type="radio" name="R3" value="V7">a. To be different than regular tests.</p>
<p><input type="radio" name="R3" value="V8">b. To cause confusion among the students. </p>
<p><input type="radio" name="R3" value="V9">c. It is easier to program and control. </p>
<p>&nbsp;</p>
<hr>
<div align="center"><center><p><input type="submit" value="Get Score"></p>
</center></div>
</form>
</dl>

Problem areas

There are a few problems with using JavaScript.

Not included in the code is a form for the student to input his or her name, as well as a way to send the test result and name via e-mail to the instructor. That code will be included at a later date.

Also, this type of test is not perfect.

Summary

Using JavaScript in this way is a simple method to give an online test to students and to have the grade automatically calculated. But there are some problems and refinements to be made.


Keep things simple -- but not too simple


Resources and references

Ron Kurtus' Credentials

Websites

eLearning Resources

Books

Top-rated books on eLearning


Questions and comments

Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. I will try to get back to you as soon as possible.


Share

Click on a button to bookmark or share this page through Twitter, Facebook, email, or other services:

 

Students and researchers

The Web address of this page is:
www.school-for-champions.com/elearning/
jsgradedtest.htm

Please include it as a link on your website or as a reference in your report, document, or thesis.

Copyright © Restrictions


Where are you now?

School for Champions

eLearning topics

Graded Test Using JavaScript




eLearning topics

Improving Business

Developing eLearning Material

Developing WBT

Also see



Let's make the world a better place

Be the best that you can be.

Use your knowledge and skills to help others succeed.

Don't be wasteful; protect our environment.

You CAN influence the world.





Live Your Life as a Champion:

Take care of your health

Seek knowledge and gain skills

Do excellent work

Be valuable to others

Have utmost character

Be a Champion!



The School for Champions helps you become the type of person who can be called a Champion.