Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Online Quiz

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Online Quiz

Postby shaidujjaman » Fri Apr 26, 2013 8:27 am

Hello there,

I am new to php. I am trying to make a online quiz using php. Is it possible???? If yes can anyone help me with coding.

Quiz Question Categories:
1. Multiple Choice.
2. Fill in the Blanks.
3. True/False.
4. Tag questions.
5. Case Studies (Essay Type).
6. Short questions.


Please help.
shaidujjaman
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Apr 26, 2013 8:21 am

Re: Online Quiz

Postby shaidujjaman » Tue Apr 30, 2013 8:10 am

Come guys..................can't anyone help me with my problem????
shaidujjaman
New php-forum User
New php-forum User
 
Posts: 4
Joined: Fri Apr 26, 2013 8:21 am

Re: Online Quiz

Postby Strider64 » Tue Apr 30, 2013 1:31 pm

Yes, it's possible to make a trivia/quiz game using php; however, it would be best to use JQuery(JavaScript) and maybe a little AJAX along with php.

Here's something I was goofing around in php a couple of months ago, I was trying to see if I could convert a game that I did in flash/php and make it strictly php. This is only one page:

Code: Select all
<?php require_once("includes/common.php"); ?>
<?php require("includes/DatabaseConnectionClass.php"); ?>
<?php require("includes/ReadTriviaDataClass.php"); ?>
<?php
          
   $trivia_menu = array();
   $display_trivia_menu = array();
   
   $next = new ReadTriviaData;
   $trivia = new ReadTriviaData;
   $trivia_menu = $trivia->get_trivia_data();
   
   // Check to see if user has click on the menu   
   if (isset($_GET['answer']) && isset($_GET['show']) && isset($_GET['page']))
   {
       $show = $_GET['show'];
       $x = $_GET['page'];  // Get the current page / question
       $answer = $_GET['answer']; // Get user's response to the question
      
       $message = $trivia->game_controls($trivia_menu, $x, $answer);
       $show = 0;
   }
   else
   {
      $x = 0;
      $show = 1;
      $message = 'Please select your answer: ';
   }               
      
   if (isset($_GET['next']))
   {
       $show = 1;
       $x = $_GET['next'] + 1;   
   }
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Pepster's Trivia Game Beta 1.0</title>
<link href="css/user_style.css" rel="stylesheet" type="text/css" >
</head>

<body>
   <section>
     <!--/Displays the Question & Possible Answers-->
       <?php $trivia->trivia_menu($trivia_menu, $x, $show); ?>
       
       <div id = "next-style">       
          <h5><?php echo $message ?></h5>
          <p><?php echo $next->next_question($x); ?></p>   
       </div>
       
       <footer>
       </footer>
       
     </section>
</body>
</html>

A couple of things about it, first like I said I was just testing to see if is possible to do it solely php and just did this on my local server. If was going to put it on the internet I would sanitize my variables first and lastly I wouldn't don't it all in php for while php is good for pulling information from the server. JavaScript (even Flash) is better for the client side of things.
User avatar
Strider64
New php-forum User
New php-forum User
 
Posts: 56
Joined: Sat Mar 23, 2013 8:24 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.