dmorg Posted February 13, 2007 Share Posted February 13, 2007 Hi, I have written a student assignment with a login page, an instructions page, 6 question pages and a summary of marks page: http://yamnuska.ca/student/smtl/assigns/A1/login.php (any alpha names and numeric id get you in) Student logs in, answers questions, checks his score... But if student checks his score before attempting all questions, the unvisited questions are uninitialised and the student cannot get results from unvisited question (particularly, how many marks are available for that question) I would like to (from first visit to instructions page) visit all question pages briefly to initialize the array containing user submissions, correct answers, some flags, etc. All the questions are in sequentially ordered pages: SMTLAssign01Q1.php, SMTLAssign01Q2.php, ... Anyone have an elegant solution for this? It would be nice to have it all handled in a function called from the instructions page. This is what I've been playing with: if(!$_SESSION['initArray']){ for($question = 1; $question <= QUESTION_COUNT; $question++){ $target = ASSIGNMENT_PHP_FILE."Q".$question.".php"; header("Location: $target"); } } How do I wait for a return from the first question page before sending out the second, third, ... headers? Or is there a better way altogether? Thanks, Dave Link to comment https://forums.phpfreaks.com/topic/38246-initializing-a-series-of-pages/ Share on other sites More sharing options...
phat_hip_prog Posted February 13, 2007 Share Posted February 13, 2007 On the first page, once you've started a session, declare and initialise all required session variables: $_SESSION[q1] = -1; Then re-assign them as necessary $_SESSION[q1] = 1; Link to comment https://forums.phpfreaks.com/topic/38246-initializing-a-series-of-pages/#findComment-183230 Share on other sites More sharing options...
dmorg Posted February 13, 2007 Author Share Posted February 13, 2007 Thanks for your reply. I want to keep the design flexible. When I create a new question, or add a part to a question, I only want to edit one file - the one with the current question - and possibly a constants file with the question count defined. So, after login, I would like to visit all the question pages (however many there are) and do the initialization. I'd like to keep the program as scalable as possible. Dave Link to comment https://forums.phpfreaks.com/topic/38246-initializing-a-series-of-pages/#findComment-183235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.