ThaRubby
Jun 11th, 2005, 08:21 PM
Ok this code is working decent but needs to be improved. I tried to make it so the user cant know what his score means until he tells me it, hence the multiplying, but ill make that better later. The problem is when a user hits one answer that he knows is correct it will give him a score like 105, when he knows another one and grades it it gives him a 110. So now he sees a pattern counts the questions and wala. Can someone make it so it only grades it once? Sorry this is my first time using PHP.
<html><body>
<form method="post" action"quiz.php">
1.) <b>In order for a workstation to connect to irc.unrealircd.com, which of the following must be true?</b><br><br>
<input type="radio" value="a" name="answer1">a.) The domain irc.unrealircd.com must be set in the configuration file<br>
<input type="radio" value="b" name="answer1">b.) A Domain Name Server will resolve the domain and allow the client to connect<br>
<input type="radio" value="c" name="answer1">c.) A client will send a RARP request for the IP address<br>
<input type="radio" value="d" name="answer1">d.) A DHCP server will respond to the request<br><br>
2.) <b>Which of the following is a protocol that tests full connectivity between a client and a server (Hint: Runs over all 7 layers of the OSI model)</b><br><br>
<input type="radio" value="a" name="answer2">a.) Ping<br>
<input type="radio" value="b" name="answer2">b.) SQL<br>
<input type="radio" value="c" name="answer2">c.) Telnet<br>
<input type="radio" value="d" name="answer2">d.) DHCP<br><br>
3.) <b>Which of the following devices uses IP addresses to determine best path to a destination?</b><br><br>
<input type="radio" value="a" name="answer3">a.) A Hub<br>
<input type="radio" value="b" name="answer3">b.) A Switch<br>
<input type="radio" value="c" name="answer3">c.) ISDN<br>
<input type="radio" value="d" name="answer3">d.) A Router<br><br>
4.) <b>When setting up the IRCd, which command must be entered?</b><br><br>
<input type="radio" value="a" name="answer4">a.) ./Config<br>
<input type="radio" value="b" name="answer4">b.) ./Compile<br>
<input type="radio" value="c" name="answer4">c.) ./Make<br>
<input type="radio" value="d" name="answer4">d.) ./Install<br><br>
5.) <b>Which of the following IRCd commands will authorize a client as a network administrator?</b><br><br>
<input type="radio" value="a" name="answer5">a.) /admin<br>
<input type="radio" value="b" name="answer5">b.) /oper<br>
<input type="radio" value="c" name="answer5">c.) /oline<br>
<input type="radio" value="d" name="answer5">d.) /netadmin<br><br>
6.) <b>Which of the following commands will enable the IRCd to reload the configuration without losing host connectivity?</b><br><br>
<input type="radio" value="a" name="answer6">a.) /reload<br>
<input type="radio" value="b" name="answer6">b.) /reloadconfig<br>
<input type="radio" value="c" name="answer6">c.) /rehash<br>
<input type="radio" value="d" name="answer6">d.) /restart<br><br>
7.) <b>Which linux command will enable you to learn if the IRCd is listening on a designated port?</b><br><br>
<input type="radio" value="a" name="answer7">a.) nmap<br>
<input type="radio" value="b" name="answer7">b.) ps x<br>
<input type="radio" value="c" name="answer7">c.) ls<br>
<input type="radio" value="d" name="answer7">d.) port -a<br><br>
8.) <b>Which command in linux will specify the process id of the IRCd?</b><br><br>
<input type="radio" value="a" name="answer8">a.) ls<br>
<input type="radio" value="b" name="answer8">b.) grep<br>
<input type="radio" value="c" name="answer8">c.) chmod<br>
<input type="radio" value="d" name="answer8">d.) ps x<br><br>
9.) <b>Which linux command will change the permission of a file to read and write for both the owner and everyone else?</b><br><br>
<input type="radio" value="a" name="answer9">a.) chmod 777<br>
<input type="radio" value="b" name="answer9">b.) chmod 544<br>
<input type="radio" value="c" name="answer9">c.) chmod 666<br>
<input type="radio" value="d" name="answer9">d.) chmod 744<br><br>
10.) <b>Which commands enable a user to list the contents of a directory and remove files respectively?</b><br><br>
<input type="radio" value="a" name="answer10">a.) grep, lsmod<br>
<input type="radio" value="b" name="answer10">b.) ls, rm<br>
<input type="radio" value="c" name="answer10">c.) ps x, pico<br>
<input type="radio" value="d" name="answer10">d.) nano,kwrite<br><br>
11.) <b>Which of the following is a popular console based linux text editor?</b><br><br>
<input type="radio" value="a" name="answer11">a.) kwrite<br>
<input type="radio" value="b" name="answer11">b.) kate<br>
<input type="radio" value="c" name="answer11">c.) pico<br>
<input type="radio" value="d" name="answer11">d.) gedit<br><br>
12.) <b>Which of the following IRC Clients is not linux based and can be used to connect to an IRC server?</b><br><br>
<input type="radio" value="a" name="answer12">a.) xchat<br>
<input type="radio" value="b" name="answer12">b.) mirc<br>
<input type="radio" value="c" name="answer12">c.) irssi<br>
<input type="radio" value="d" name="answer12">d.) BitchX<br><br>
<input type="submit" value="Submit" name="submit"><br>
</form>
</body></html>
<?php
$y = 0;
$answer=$_POST["answer1"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer2"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer3"];
if ($answer == "d")
{
$y++;
}
$answer=$_POST["answer4"];
if ($answer == "a")
{
$y++;
}
$answer=$_POST["answer5"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer6"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer7"];
if ($answer == "a")
{$y = 0;
$y++;
}
$answer=$_POST["answer8"];
if ($answer == "d")
{
$y++;
}
$answer=$_POST["answer9"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer10"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer11"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer12"];
if ($answer == "b")
{
$y++;
}
$y = $y + 20;
$y = $y * 5;
if ($y == "100")
{
$y = "";
}
echo $y;
?>
<!--
Answers.
130 = 12/12
125 = 11/12
120 = 10/12
115 = 9/12
110 = 8/12
100 = 7/12
95 = 6/12
90 = 5/12
85 = 4/12
80 = 3/12
75 = 2/12
70 = 1/12
65 = 0/12
-->
And I have all that in quiz.php in the order its in.
<html><body>
<form method="post" action"quiz.php">
1.) <b>In order for a workstation to connect to irc.unrealircd.com, which of the following must be true?</b><br><br>
<input type="radio" value="a" name="answer1">a.) The domain irc.unrealircd.com must be set in the configuration file<br>
<input type="radio" value="b" name="answer1">b.) A Domain Name Server will resolve the domain and allow the client to connect<br>
<input type="radio" value="c" name="answer1">c.) A client will send a RARP request for the IP address<br>
<input type="radio" value="d" name="answer1">d.) A DHCP server will respond to the request<br><br>
2.) <b>Which of the following is a protocol that tests full connectivity between a client and a server (Hint: Runs over all 7 layers of the OSI model)</b><br><br>
<input type="radio" value="a" name="answer2">a.) Ping<br>
<input type="radio" value="b" name="answer2">b.) SQL<br>
<input type="radio" value="c" name="answer2">c.) Telnet<br>
<input type="radio" value="d" name="answer2">d.) DHCP<br><br>
3.) <b>Which of the following devices uses IP addresses to determine best path to a destination?</b><br><br>
<input type="radio" value="a" name="answer3">a.) A Hub<br>
<input type="radio" value="b" name="answer3">b.) A Switch<br>
<input type="radio" value="c" name="answer3">c.) ISDN<br>
<input type="radio" value="d" name="answer3">d.) A Router<br><br>
4.) <b>When setting up the IRCd, which command must be entered?</b><br><br>
<input type="radio" value="a" name="answer4">a.) ./Config<br>
<input type="radio" value="b" name="answer4">b.) ./Compile<br>
<input type="radio" value="c" name="answer4">c.) ./Make<br>
<input type="radio" value="d" name="answer4">d.) ./Install<br><br>
5.) <b>Which of the following IRCd commands will authorize a client as a network administrator?</b><br><br>
<input type="radio" value="a" name="answer5">a.) /admin<br>
<input type="radio" value="b" name="answer5">b.) /oper<br>
<input type="radio" value="c" name="answer5">c.) /oline<br>
<input type="radio" value="d" name="answer5">d.) /netadmin<br><br>
6.) <b>Which of the following commands will enable the IRCd to reload the configuration without losing host connectivity?</b><br><br>
<input type="radio" value="a" name="answer6">a.) /reload<br>
<input type="radio" value="b" name="answer6">b.) /reloadconfig<br>
<input type="radio" value="c" name="answer6">c.) /rehash<br>
<input type="radio" value="d" name="answer6">d.) /restart<br><br>
7.) <b>Which linux command will enable you to learn if the IRCd is listening on a designated port?</b><br><br>
<input type="radio" value="a" name="answer7">a.) nmap<br>
<input type="radio" value="b" name="answer7">b.) ps x<br>
<input type="radio" value="c" name="answer7">c.) ls<br>
<input type="radio" value="d" name="answer7">d.) port -a<br><br>
8.) <b>Which command in linux will specify the process id of the IRCd?</b><br><br>
<input type="radio" value="a" name="answer8">a.) ls<br>
<input type="radio" value="b" name="answer8">b.) grep<br>
<input type="radio" value="c" name="answer8">c.) chmod<br>
<input type="radio" value="d" name="answer8">d.) ps x<br><br>
9.) <b>Which linux command will change the permission of a file to read and write for both the owner and everyone else?</b><br><br>
<input type="radio" value="a" name="answer9">a.) chmod 777<br>
<input type="radio" value="b" name="answer9">b.) chmod 544<br>
<input type="radio" value="c" name="answer9">c.) chmod 666<br>
<input type="radio" value="d" name="answer9">d.) chmod 744<br><br>
10.) <b>Which commands enable a user to list the contents of a directory and remove files respectively?</b><br><br>
<input type="radio" value="a" name="answer10">a.) grep, lsmod<br>
<input type="radio" value="b" name="answer10">b.) ls, rm<br>
<input type="radio" value="c" name="answer10">c.) ps x, pico<br>
<input type="radio" value="d" name="answer10">d.) nano,kwrite<br><br>
11.) <b>Which of the following is a popular console based linux text editor?</b><br><br>
<input type="radio" value="a" name="answer11">a.) kwrite<br>
<input type="radio" value="b" name="answer11">b.) kate<br>
<input type="radio" value="c" name="answer11">c.) pico<br>
<input type="radio" value="d" name="answer11">d.) gedit<br><br>
12.) <b>Which of the following IRC Clients is not linux based and can be used to connect to an IRC server?</b><br><br>
<input type="radio" value="a" name="answer12">a.) xchat<br>
<input type="radio" value="b" name="answer12">b.) mirc<br>
<input type="radio" value="c" name="answer12">c.) irssi<br>
<input type="radio" value="d" name="answer12">d.) BitchX<br><br>
<input type="submit" value="Submit" name="submit"><br>
</form>
</body></html>
<?php
$y = 0;
$answer=$_POST["answer1"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer2"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer3"];
if ($answer == "d")
{
$y++;
}
$answer=$_POST["answer4"];
if ($answer == "a")
{
$y++;
}
$answer=$_POST["answer5"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer6"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer7"];
if ($answer == "a")
{$y = 0;
$y++;
}
$answer=$_POST["answer8"];
if ($answer == "d")
{
$y++;
}
$answer=$_POST["answer9"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer10"];
if ($answer == "b")
{
$y++;
}
$answer=$_POST["answer11"];
if ($answer == "c")
{
$y++;
}
$answer=$_POST["answer12"];
if ($answer == "b")
{
$y++;
}
$y = $y + 20;
$y = $y * 5;
if ($y == "100")
{
$y = "";
}
echo $y;
?>
<!--
Answers.
130 = 12/12
125 = 11/12
120 = 10/12
115 = 9/12
110 = 8/12
100 = 7/12
95 = 6/12
90 = 5/12
85 = 4/12
80 = 3/12
75 = 2/12
70 = 1/12
65 = 0/12
-->
And I have all that in quiz.php in the order its in.