So I'm trying to make an online quiz where the user can 'take the quiz' or go to 'module' where the user can edit the quiz. I've tried for days to search through the net for this particular one but I can't find any solutions.
For the quiz I made a comma delimited text file and tried to use that file to make a multidimensional array.
So far I only have the following:
<h2>ONLINE QUIZ</h2>
<ul>
<li><a href='question.php'>Take quiz</a></li>
<li><a href='module.php'>Admin Module</a></li>
</ul>
<?php
$file = fopen ("data.txt","r");
$i=0;
while (feof($file)==false)
{
$line = fgets($file);
$array[$i]=$line;
$i=$i + 1;
}
fclose($file);
session_start();
$_SESSION["questions_array"]=$array;
?>
My question is, how do I turn the text file from something that looks like this:
HTML is...,Main markup language for web pages,Cross-site Security,Cleverly Structured Scripting,eXtremely Safe and Secure,
PHP...,General-purpose server-side scripting language,Cross-site Security,Processing Hypertext Products,Process HTML Prettily
To output something like this:
Question #1
HTML is...
[radio button] a.) Main markup language for web pages
[radio button] b.) Cross-site Security
etc, etc
ll----I will type out the exact plan for this quiz----ll
Main page: module and quiz link.
For the quiz
Question page: Questions only show up one by one.
ex.) What is a dog?
a.) a human
b.) a pet
c.) a job
d.) a car
(Submit button)
Answer page: Once submit is hit, the page goes here, where the user can see whether they answered right or wrong.
ex.) INCORRECT
Your answer: a.) a human
Correct answer: b.) a pet
(continue link)
Note that when 'continue' is hit, the page redirects back to the 'question page' but this time outputs the next question. When no more questions are available, the page automatically redirects to the 'results page'.
Results page: Table of results
For the module
Main: A table of the available questions plus their choice answers
ex.)
Question l choice a l choice b l
[] What? cat toy
[] How? rat pop
etc.
Each row can be selected through a radio button. (so we know which question to edit)
Select option: Drop down list whether to 'add', 'edit' or 'delete' a question. Each choice directs to a different page where you can perform the action. Also, if 'delete' is chosen, a confirmation page should show up. (i.e are you sure you want to delete this file?)
I think that's detailed enough, I'm so sorry for the trouble;;
but please if you don't have the time to help me throughout the whole thing, please help me figure out how to use the text file as a multi-dim array (aka the first thing I asked). I've been dying to know how to do it but I just can't get it to work so I'd really appreciate that!
Thank you!