Question
PHP -- can someone help please! The assignment is below, along with my code. I'm new to multidimensional arrays and am in need of someone
PHP -- can someone help please!
The assignment is below, along with my code. I'm new to multidimensional arrays and am in need of someone to look over my code. Please update or just let me know what I'm doing wrong. THANKS!
Directions
-------------------
1.Home page
Welcome the user to the site with simple instructions of what they are supposed to do.
2. Lesson page
Inform the user about a topic of your choice. This can be a hobby of yours or related
to a new technique in web design/development.
3. Quiz page
Quiz the user on their knowledge of the content in your lesson page with at least five multiple-choice questions.
Technical Requirements:
1. Multi-file PHP template
Within your includes folder, you must have at least a header.html.php,
footer.html.php, and functions.php. Your pages will then include/require these pieces.
Be sure to use an external style sheet and put any images in a folder called images.
Your design will also be graded based on creativity and appeal.
2. The quiz
This part of the assignment will use arrays, loops and functions. Use one multidimensional
associative array to store the questions, choices and answers for this
quiz. Use a nested foreach loop to display the questions and choices. Create and use
a simple function to calculate the percentage based on the number correct out of the
total number of questions.
3. Validation and sticky forms
The form should be validated to ensure the user and answered all five questions
before calculating the score. After the user submits the page, it should always keep
the choices the user chose.
CODE
Index
html> charset="UTF-8"> http-equiv="X-UA-Compatible" content="IE=edge"> name="viewport" content="width=device-width, initial-scale=1">Wisconsin State Symbols href="css/bootstrap.css" rel="stylesheet" type="text/css"> href="css/custom.css" rel="stylesheet" type="text/css"> rel="icon" type="/images/favicon.png"> class="text-center">class="cover-container d-flex h-100 p-3 mx-auto flex-column">class="masthead mb-auto"> class="inner">class="masthead-brand">Home
role="main" class="inner cover"> class="cover-heading">Welcome!
class="lead">Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.
class="lead"> href="lesson.php" class="btn btn-lg btn-secondary">Learn more
Quiz page
html> charset="UTF-8"> http-equiv="X-UA-Compatible" content="IE=edge"> name="viewport" content="width=device-width, initial-scale=1">Wisconsin State Symbols href="css/bootstrap.css" rel="stylesheet" type="text/css"> href="css/custom.css" rel="stylesheet" type="text/css"> rel="icon" href="/images/favicon.png"> class="text-center">class="cover-container d-flex h-100 p-3 mx-auto flex-column">class="masthead mb-auto"> class="inner">class="masthead-brand">Quiz
role="main" class="inner cover"> $stateSymbols[] = array ( $stateSymbols[] = array( 'question' => 'What is the state bird for Wisconsin?', 'related' => ('Cardinal', 'Sparrow', 'Robin', 'Eagle', 'Barn Owl'), 'answer' => 'Robin', ); $stateSymbols[] = [ 'question' => 'What is the state rock for Wisconsin?', 'related' => ('Alabaster', 'Galena', 'Limestone', 'Shale', 'Red Granite'), 'answer' => 'Red Granite', ]; $stateSymbols[] = [ 'question' => 'What is Wisconsin\'s grain?', 'related' => ('Rice', 'Wheat', 'Corn', 'Oats', 'Rye'), 'answer' => 'Corn', ]; $stateSymbols[] = [ 'question' => 'What is Wisconsin\'s state insect?', 'related' => ('Honey Bee', 'Moth', 'Mosquito', 'Botfly', 'Katydid'), 'answer' => 'Honey Bee', ]; $stateSymbols[] = [ 'question' => 'What is Wisconsin\'s beverage?', 'related' => ('Water', 'Beer', 'Orange Juice', 'Milk', 'Cranberry Juice'), 'answer' => 'Milk', ]; ); $max=5; $question=$_POST["question"] ; if ($_POST["Randon"]==0){ if($randomizequestions =="yes"){ $randval = mt_rand(1,$max); }else{ $randval=1; } $randval2 = $randval; }else{ $randval=$_POST["Randon"]; $randval2=$_POST["Randon"] + $question; if ($randval2>$max){ $randval2=$randval2-$max; } } $ok=$_POST["ok"] ; if ($question==0){ $question=0; $ok=0; $percentageRight=0; }else{ $percentageRight = Round(100*$ok / $question); } ?> "mastfoot mt-auto">class="cover-heading">- Quiz Time -
class="lead">Bacon ipsum dolor amet strip steak pork ground round, short loin tri-tip doner kielbasa. Cupim pastrami sausage short ribs jowl swine, beef pancetta pork belly ribeye kielbasa. Pork meatloaf ground round chuck.
"$title"; ?>
BORDER=0 CELLSPACING=5 WIDTH=500> ($question<$max){ ?>
ALIGN=RIGHT>
}else{ ?> ALIGN=Center> The Quiz has finished
Percentage of right answers: $percentageRight ; ?> % "$address; ?>">Home Page } ?>class="inner">Footer Here!
Function
------------------
function Goahead (number){ if (document.percentaje.response.value==0){ if (number==print $a[$randval2][6] ; ?>){ document.percentaje.response.value=1 document.percentaje.question.value++ document.percentaje.ok.value++ }else{ document.percentaje.response.value=1 document.percentaje.question.value++ } } if (number==$a[$randval2][6] ; ?>){ document.question.response.value="Correct" }else{ document.question.response.value="Incorrect" } } ?>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started