mitochondria
Ventrilo
Follow via Facebook Follow via Twitter Follow via YouTube Follow via RSS Steam Group

Author Topic: For Ratio  (Read 581 times)

Utopi

  • Admin
  • Posts: 971
  • Reputation: +9/-1
    • LD50
For Ratio
« on: Feb 20, 2014, 10:41 AM »
php quiz

Code: [Select]
<?php

$questionarray 
= array(
"What is Rebel Wilsons Character Name?" => array
(
20 => "Fat Amy",
=> "Rebelicious",
=> "Fat Samy",
=> "Pitch Slapper",

),
"What are Nodes?" => array
(
=> "An STD",
20 => "Vocal cords rubbing together at an above average rate w/o proper lubrication",
=> "A point at which lines or pathways intersect",
=> "A high note"
),
"What song did Beca audition with?" => array
(
20 => "Cups",
=> "Call me Maybe",
=> "Titanium",
=> "No Diggity"
),
"What happened at last years finals?" => array
(
=> "They Won",
=> "Chloe had surgery on her vocal chords",
=> "Bumper sabotaged the Barden Belles",
20 => "Aubrey threw up on stage"
)
);



// $questionarray is the key and $options is the value (an array)
foreach ($questionarray as $questions => $options) {

echo 
'<p>';
echo 
$questions;
echo 
'<br>';

// $options is the key and $points is the value
foreach ($options as $answer => $points) {
echo 
'<input type="radio" name="questions" value="20" id="questions" />';
echo 
$answer;
echo 
'<br>';
}

echo 
'</p>';
}

echo 
'<p align="center"><input type="submit" name="submit" value="Submit" /></p>';

« Last Edit: Feb 20, 2014, 10:42 AM by Ratio »




"There is a fine line between success and failure. In order to succeed, one must learn how to be rid of that line."

Ratio

  • Admin
  • Posts: 1418
  • Reputation: +10/-0
Re: For Ratio
« Reply #1 on: Feb 20, 2014, 10:59 AM »
Something like this is probably what you want:

Code: [Select]
<?php

$quiz 
= array();
$quiz[]['question'] = "What is Rebel Wilsons Character Name?";
$key key(end($questions));
$quiz[$key]['answers'] = array (
'Fat Amy',
'Rebelicious',
'Fat Samy',
'Pitch Slapper',
);
$quiz[$key]['correct_answer'] = 'Fat Amy';

$i 0;

foreach (
$quiz as $item) {
$i++;
$question $item['question'];
$answers $item['answers'];
$correct_answer $item['correct_answer'];

echo '<p>' $question '<br />';

foreach($answers as $answer) {
$value = ($answer == $correct_answer) ? '20' '0';
echo '<input type="radio" name="question'.$i.'" value="' $value '" id="question'.$i.'" />';
echo $answer;
echo '<br />';
}

echo '</p>';
}
« Last Edit: Feb 20, 2014, 11:02 AM by Ratio »
Happiness is when you play a game so well that people call you a hacker.

There are two types of people in the world, those who can extrapolate from incomplete information.

Utopi

  • Admin
  • Posts: 971
  • Reputation: +9/-1
    • LD50
Re: For Ratio
« Reply #2 on: Feb 20, 2014, 11:09 AM »
Code: [Select]
<?php 

$Questions 
= array(
    
=> array(
        
'Question' => 'CSS stands for',
        
'Answers' => array(
            
'A' => 'Computer Styled Sections',
            
'B' => 'Cascading Style Sheets',
            
'C' => 'Crazy Solid Shapes'
        
),
        
'CorrectAnswer' => 'A'
    
),
    
=> array(
        
'Question' => 'Second question',
        
'Answers' => array(
            
'A' => 'First answer of Second question',
            
'B' => 'Second answer Second question',
            
'C' => 'Third answer Second question'
        
),
        
'CorrectAnswer' => 'C'
    
)
);

if (isset(
$_POST['answers'])){
    
$Answers $_POST['answers']; // Get submitted answers.

    // Now this is fun, automated question checking! ;)

    
foreach ($Questions as $QuestionNo => $Value){
        
// Echo the question
        
echo $Value['Question'].'<br />';

        if (
$Answers[$QuestionNo] != $Value['CorrectAnswer']){
            echo 
'<span style="color: red;">'.$Value['Answers'][$Answers[$QuestionNo]].'</span>'// Replace style with a class
        
} else {
            echo 
'<span style="color: green;">'.$Value['Answers'][$Answers[$QuestionNo]].'</span>'// Replace style with a class
        
}
        echo 
'<br /><hr>';
    }
} else {
?>

    <form action="grade.php" method="post" id="quiz">
    <?php foreach ($Questions as $QuestionNo => $Value){ ?>
    <li>
        <h3><?php echo $Value['Question']; ?></h3>
        <?php 
            
foreach ($Value['Answers'] as $Letter => $Answer){ 
            
$Label 'question-'.$QuestionNo.'-answers-'.$Letter;
        
?>

        <div>
            <input type="radio" name="answers[<?php echo $QuestionNo?>]" id="<?php echo $Label?>" value="<?php echo $Letter?>" />
            <label for="<?php echo $Label?>"><?php echo $Letter?>) <?php echo $Answer?> </label>
        </div>
        <?php ?>
    </li>
    <?php ?>
    <input type="submit" value="Submit Quiz" />
    </form>
<?php 
}
?>




"There is a fine line between success and failure. In order to succeed, one must learn how to be rid of that line."

Nature Boy

  • Alumni
  • Posts: 25
  • Reputation: +1/-0
  • Woooo
Re: For Ratio
« Reply #3 on: Feb 20, 2014, 10:12 PM »
You ever go here back in the day Ratio? Saw this on facebook and it took me back to my NE Ohio days. I remember spending alot of time in the summer between this place and Geauga Lake.


Ratio

  • Admin
  • Posts: 1418
  • Reputation: +10/-0
Re: For Ratio
« Reply #4 on: Feb 20, 2014, 10:47 PM »
Nope. Just Geauga Lake and Cedar Point.
Happiness is when you play a game so well that people call you a hacker.

There are two types of people in the world, those who can extrapolate from incomplete information.

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
838 Views
Last post Jan 25, 2013, 06:18 PM
by Conrad
Fo' Ratio

Started by Acorns Humor

4 Replies
565 Views
Last post Feb 09, 2014, 10:49 PM
by Bastian

* Live Streams

Data retrieved in 0.19 seconds.

* Recent Posts

Canderous Ordo Trash Talk by Cates
[Apr 26, 2017, 04:49 PM]


New Voice Communicator...? by Cates
[Apr 26, 2017, 04:49 PM]


Star Citizen by Cates
[Nov 19, 2016, 05:21 AM]


Free Games by Crabbok
[Jul 29, 2016, 11:47 PM]


XCOM 2: LD50 at War! by Yuri
[Jul 14, 2016, 05:17 PM]


Overwatch by Crabbok
[Apr 30, 2016, 04:17 PM]


Disney buys Star Wars by Dargos
[Apr 14, 2016, 04:57 AM]


Free Division Clothing "Gear" Sets by Cates
[Mar 06, 2016, 08:23 PM]


Internet on the Island by Fixate
[Mar 03, 2016, 07:14 AM]


Division pvp by Surrena
[Mar 01, 2016, 01:55 PM]

* Gallery

A C O R N S

Views: 1357
By: Acorns