Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-13-2006, 09:13 PM   PM User | #1
baldtrainer
New to the CF scene

 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
baldtrainer is an unknown quantity at this point
Creating a Script that Calculates Test Scores

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!!
baldtrainer is offline   Reply With Quote
Old 11-13-2006, 11:12 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
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

Code:
<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 Code:
<?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
ess is offline   Reply With Quote
Old 11-13-2006, 11:13 PM   PM User | #3
rubenbuhr
Regular Coder

 
Join Date: Oct 2006
Posts: 107
Thanks: 3
Thanked 5 Times in 5 Posts
rubenbuhr is an unknown quantity at this point
How's this?
PHP Code:
<!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','thirteen','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> 
rubenbuhr is offline   Reply With Quote
Old 11-14-2006, 03:03 PM   PM User | #4
baldtrainer
New to the CF scene

 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
baldtrainer is an unknown quantity at this point
Just wanted to say thanks. I'm going to try your suggestions. I really appreciate it!!
baldtrainer is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:09 PM.


Advertisement
Log in to turn off these ads.