/    Sign up×
Community /Pin to ProfileBookmark

how to tackle a multi group quiz (logical approach)

Firstly thanks to all who help me get my code updated, very happy with it.

My current quiz has no correct answers scaled from 1-5 and each radio button has a individual point.
it totals and on result prints text value saying how well you did.

If questions were split in to groups eg Red questions Blue etc, what would be a logical approach to tackling it. So that 5 questions of each group are intermingled (20total) and on submit each groups score is printed out and and appropiate text response, eg well done.

Your blue scotre was: 40% well done
your Red score was 70% extremely knowledgeable

etc

Im sure that i have the tool already from the previous quiz so it just the best way about doing it.

I have thought if seperate forms four questions in each 5 times =20 questions?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoOct 12.2006 — Simply assign classes to the seperate groups, and then check the className when you calculate the score.
Copy linkTweet thisAlerts:
@konithomimoOct 12.2006 — For example:
<html>
<head>
<script type="text/javascript">
var answers= new Array(1,3,0,4,2);

var blue=0
var red=0;

var numblues = 2;
var numreds = 3;

function scoreIt()
{
for(i=0;i<5;i++)
{
myquestion = eval("document.myform.q"+i);
for(j=0;j<myquestion.length;j++)
{
if(myquestion[j].checked)
{
if (j==answers[i])
{
if(myquestion[j].className=='blue')
blue++;
else
red++;
}
}
}
}
alert("Reds: "+ (((red/numreds).toFixed(2))*100) + "%");
alert("Blues: "+ (((blue/numblues).toFixed(2))*100) + "%");

}

</script>
</head>
<body>
<form name="myform">
<input type="radio" name="q0" class="red">0
<input type="radio" name="q0" class="red">1
<input type="radio" name="q0" class="red">2
<input type="radio" name="q0" class="red">3
<input type="radio" name="q0" class="red">4
<br>
<br>
<input type="radio" name="q1" class="red">0
<input type="radio" name="q1" class="red">1
<input type="radio" name="q1" class="red">2
<input type="radio" name="q1" class="red">3
<input type="radio" name="q1" class="red">4
<br>
<br>
<input type="radio" name="q2" class="blue">0
<input type="radio" name="q2" class="blue">1
<input type="radio" name="q2" class="blue">2
<input type="radio" name="q2" class="blue">3
<input type="radio" name="q2" class="blue">4
<br>
<br>
<input type="radio" name="q3" class="red">0
<input type="radio" name="q3" class="red">1
<input type="radio" name="q3" class="red">2
<input type="radio" name="q3" class="red">3
<input type="radio" name="q3" class="red">4
<br>
<br>
<input type="radio" name="q4" class="blue">0
<input type="radio" name="q4" class="blue">1
<input type="radio" name="q4" class="blue">2
<input type="radio" name="q4" class="blue">3
<input type="radio" name="q4" class="blue">4
<br>
<br>
<input type="button" onclick="scoreIt()">
</form>
</body>
</html>
Copy linkTweet thisAlerts:
@JMRKEROct 13.2006 — Suggestion:

I would put:
[code=php]
var blue=0
var red=0;
var numblues = 2;
var numreds = 3;
function scoreIt() {
[/code]

like this:
[code=php]
function scoreIt() {
var blue=0
var red=0;
var numblues = 2;
var numreds = 3;
[/code]

to assure the score is reset to zero at the start of the function

rather than summarized with multiple 'scoreIt()' requests.
Copy linkTweet thisAlerts:
@konithomimoOct 13.2006 — Suggestion:

I would put:
[code=php]
var blue=0
var red=0;
var numblues = 2;
var numreds = 3;
function scoreIt() {
[/code]

like this:
[code=php]
function scoreIt() {
var blue=0;
var red=0;
var numblues = 2;
var numreds = 3;
[/code]

to assure the score is reset to zero at the start of the function

rather than summarized with multiple 'scoreIt()' requests.[/QUOTE]

Good point. It should be written like that, or like this (since only the variables blue and red need to be reset to 0):
var numblues = 2;
var numreds = 3;
function scoreIt() {
var blue=0
var red=0;
×

Success!

Help @wilburforce spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...