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
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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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