...

View Full Version : Creating a Script that Calculates Test Scores



baldtrainer
11-13-2006, 09:13 PM
I'm an eLearning developer and use Dreamweaver to create most of my courses. I'm able to do most of the things needed for these courses; however, my company just asked me to step out of the box and I'm not sure how to go about doing this.

I need to create a page that allows auditors to listen to customer service calls and 'score' them based on a 1 - 5 grading scale. There are 18 questions that need to be answered based on the grading scale. Once the scoring is completed, the program needs to calculate the score (based on the 18 questions) and forward the final score to their boss.

I'm assuming a javascript can do this; however, I have no idea how to create it. Any help is greatly appreciated!!

ess
11-13-2006, 11:12 PM
Of course you can use JavaScript to do this for you. Though, I would suggest that you use a server side technology so that you can record this information in a database and as such...get the overall score.

Here is an example....first html


<form action="collect_scores.php" method="POST">

<p><input type="radio" name="question1" value="1">1<br>
<input type="radio" name="question1" value="2">2<br>
<input type="radio" name="question1" value="3">3<br>
<input type="radio" name="question1" value="4">4<br>
<input type="radio" name="question1" value="5">5<br>
<input type="radio" name="question1" value="6">6</p>

<p><input type="radio" name="question2" value="1">1<br>
<input type="radio" name="question2" value="2">2<br>
<input type="radio" name="question2" value="3">3<br>
<input type="radio" name="question2" value="4">4<br>
<input type="radio" name="question2" value="5">5<br>
<input type="radio" name="question2" value="6">6</p>

<input type="submit" value="Submit"/>
</form>

second the php


<?php
$question1 = $_POST['question1'];
$question2 = $_POST['question2'];

$total = $question1 + $question2;

echo "Total Score: " . $total;
?>

By the way...you can also use Ajax..to this as well...with PHP, or other scripting language.

Good luck.
ess

rubenbuhr
11-13-2006, 11:13 PM
How's this?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><TITLE>Average Score </TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="txt/javascript">
<STYLE type=text/CSS>

</STYLE>
<SCRIPT type="text/javascript">
var Q= new Array('one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirte en','fourteen','fifeteen','sixteen','seventeen','eighteen');
function avg(){
k=document.forms[0].elements.length;
for(i=0,j=0;i<k;i++){j+=document.forms[0].elements[i].value*1}

j=j/k
alert(j)
}
</SCRIPT>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
I need to create a page that allows auditors to listen to customer service calls and 'score' them based on a 1 - 5 grading scale. There are 18 questions that need to be answered based on the grading scale. Once the scoring is completed, the program needs to calculate the score (based on the 18 questions) and forward the final score to their boss.
<form>
<TABLE BORDER="1">
<TBODY>
<SCRIPT type="text/javascript">
var s='';
for(i=0;i<Q.length;i++){k='';s+='<tr><td><B>Question</B> '+Q[i]+'</td><td><SELECT><OPTGROUP label="Score">';
for(j=1;j<=5;j++){k+='<OPTION value="'+j+'">'+j+''}
s+=k+'</select>'}
document.write(s)
</SCRIPT>
</TR>
</TBODY>
</TABLE>
</form>
<button onclick="avg()">Average</button>

</BODY></HTML>

baldtrainer
11-14-2006, 03:03 PM
Just wanted to say thanks. I'm going to try your suggestions. I really appreciate it!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum