Jump to content

Data Control on a Test


jrodd32

Recommended Posts

I have a scrambled test that I need to display one at a time.  However it is displaying all at once.  How would I control this?

Thanks

By the way, I am using sessions

[code]
<?php
$qnum=0;
for($count=0;$count<100;$count++) #count of number of questions
{
if($qnum>99) #keeps the question number in the proper range of 0-99
  $qnum=$qnum-99;
else
  $qnum=$qnum;
if(in_array($qnum,$used )) #checks to see if current question number is already in the array of used numbers
{
  $qnum=$qnum+1;
  $question=$tQ[$qnum];
  $used[$count]=$qnum;
}
else
{
  $question=$tQ[$qnum];
  $used[$count]=$qnum;
}
echo("Count: $count <br>" . "Random Number: $skip <br>" . "Question Number: $qnum <br>" . "$question <br>");
$qnum=$qnum+$skip;
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35258-data-control-on-a-test/
Share on other sites

Well my ultimate goal is to have the questions show up one at a time and the user select their answer and hit submit to save the answer and continue to the next question.  Is that possible without making a hundred different pages? Do I need to redo my logic completely?
Have the page get the number out of the session. If there is no number, start with 1.
So show one. Store the number 1 in the session.
When they click the continure button, show the page again. 1 is in the session, so go on to 2. Continue until done.
I am not completely sure I understand what you are saying. 

Are you saying to save the current question number as a variable then print that question? 

If so what would be the code to do something like that? Namely how would I control that on continue the next question would appear?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.