Jump to content

Search the Community

Showing results for tags 'php quiz'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hello guys! I need some help here. So this is the situation: I have a page where I teach other students. i want to create a quiz/exam for them. So there is a question and there is a box for answer. And I want that this form correct itself. So he/she click on the submit button and then there will be the results and if an answer is incorrect then there will be an explanation why is that incorrect and why is the good anser is correct. So I hope you guys understand and you can help me. Thank you!
  2. Hey Everyone, I'm trying to make a quiz in PHP for a class. THis is what I have so far. I just can't get the answers to show up. Any help will be wonderful! <?php $quiz_questions = array(); $quiz_questions['q1'] = array( 'question' => 'What is Rebel Wilsons Character Name?', 'choices' => array( 'a' => 'Fat Amy', 'b' => 'Rebelicious', 'c' => 'Fat Samy', 'd' => 'Pitch Slapper'), 'answer' => 'a'); $quiz_questions['q2'] = array( 'question' => 'What are Nodes?', 'choices' => array( 'a' => 'An STD', 'b' => 'Vocal cords rubbing together at an above average rate w/o proper lubrication', 'c' => 'A point at which lines or pathways intersect', 'd' => 'A high note'), 'answer' => 'b'); $quiz_questions['q3'] = array( 'question' => 'What song did Beca audition with?', 'choices' => array( 'a' => 'Cups', 'b' => 'Call me Maybe', 'c' => 'Titanium', 'd' => 'No Diggity'), 'answer' => 'a'); $quiz_questions['q4'] = array( 'question' => 'Where does Beca work?', 'choices' => array( 'a' => 'Jamba Juice', 'b' => 'Vocal coach at the university', 'c' => 'University radio station', 'd' => 'McDonalds'), 'answer' => 'c'); $quiz_questions['q5'] = array( 'question' => 'What happened at last years finals?', 'choices' => array( 'a' => 'They Won', 'b' => 'Chloe had surgery on her vocal chords', 'c' => 'Bumper sabotaged the Barden Belles', 'd' => 'Aubrey threw up on stage'), 'answer' => 'd'); if($user_answers[$qid] ==' '){ //user did not answer the question }elseif($user_answers[$qid] == $question['answer']){ //answer is correct $total_answered++; $total_correct++; }else{ //answer is wrong $total_answered++; } foreach($quiz_questions as $qid => $question){ //output the question text echo '<p>'.$question['question']. '<p>'; } foreach($question['choices'] as $cid => $choice){ $lid = $qid.'_'.$cid; //default message $msg = ' '; $checked = ($user_answers[$qid]== $cid) ? ' checked ' : ' '; //if all questions have been answered, display correct and wrong answers if($total_answered > 0 and $total_answered == $total_questions){ if ($checked){ if($user_answers[$qid]== $question['answer']){ $msg = echo '<p>CORRECT!</p>'; }else{ $msg = echo '<p>INCORRECT</p>'; } } } echo ' <input type="radio" name=" ' . $qid . ' " value= " ' .$cid. ' " id= " ' .$lid. ' " ' . $checked . '/> <label for =" '. $lid . ' ">' . $choice . '</label>'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.