From: Chris S. <san...@us...> - 2005-06-14 17:17:09
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19691 Modified Files: Tag: frontend_dev quiz.php Log Message: Index: quiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/quiz.php,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -C2 -d -r1.22 -r1.22.2.1 *** quiz.php 10 Jun 2005 20:23:56 -0000 1.22 --- quiz.php 14 Jun 2005 17:16:52 -0000 1.22.2.1 *************** *** 11,14 **** --- 11,35 ---- include('stackstd.php'); + $default_action = 'choose_quiz'; + include($stack_root.'/frontend_general/process_input.php'); + + + ///////////////////////////////////////////////////////////// + // (1) For a quiz, the admin user should behave like a guest. + // We don't want lots of admin user quizzes to be stored. + // The user is not stored in the session, so it lasts only + // for this script. + ///////////////////////////////////////////////////////////// + + if ($user['id'] <= 0 or !$user['loggedin']) { + include_once($stack_root."/scripts/stackUser.php"); + $user = stack_user_guest(); + } + + + ////////////////////////////////////////////////////////// + // (2) Assign default values to quiz specific variables. + ////////////////////////////////////////////////////////// + $errors = ''; $options = ''; *************** *** 20,83 **** $focus = FALSE; $focus_on = NULL; - - //////////////////////////////////////////////////// - // Process incoming data, and check for any errors. - /////////////////////////////////////////////////// - ! if (get_magic_quotes_gpc()) { ! /** ! * Automatically removes slashes deeply from arrays. ! * ! * @param $value incoming array. ! * @return $value the array with slashed removed. ! */ ! function stripslashes_deep($value) ! { ! $value = is_array($value) ? ! array_map('stripslashes_deep', $value) : ! stripslashes($value); ! ! return $value; ! } ! ! $_POST = array_map('stripslashes_deep', $_POST); ! $_GET = array_map('stripslashes_deep', $_GET); ! $_COOKIE = array_map('stripslashes_deep', $_COOKIE); } ! ! //////////////////////////////////////////////// ! // (1) Establish the user. ! //////////////////////////////////////////////// ! ! if (array_key_exists('user',$_SESSION)) { ! $user = $_SESSION['user']; ! } else { ! // Make sure the user is logged in as a Guest. ! include_once($stack_root."/scripts/stackUser.php"); ! $user = stack_user_guest(); ! } ! ! ! $implied_guest = FALSE; ! if (is_array($user)) { ! if (array_key_exists('id',$user)) { ! if ($user['id'] <= 0 or !$user['loggedin']) { ! $implied_guest = TRUE; ! } ! } else { ! $implied_guest = TRUE; ! } ! } else { ! $implied_guest = TRUE; } - if ( $implied_guest) { - include_once($stack_root."/scripts/stackUser.php"); - $user = stack_user_guest(); - } - //////////////////////////////////////////////// ! // (2) Decide what we are trying to do. //////////////////////////////////////////////// --- 41,54 ---- $focus = FALSE; $focus_on = NULL; ! if (array_key_exists('focus',$_SESSION)) { ! $focus = $_SESSION['focus']; } ! if (array_key_exists('focus_on',$_SESSION)) { ! $focus_on = $_SESSION['focus_on']; } //////////////////////////////////////////////// ! // (3) Decide what we are trying to do. //////////////////////////////////////////////// *************** *** 85,101 **** // action = unfocus See all questions at once. // action = continue_quiz Continue a quiz, from $user information // action = new_quiz_version Start a new quiz version ! // actopn = validate Validate the response to *every question* // action = mark Mark the response to *every question* // action = mark_question Mark the response only to question in the field questiono // action = solutions Mark the response to *every question* then show the solutions // This prevents further attempts ! ! if (array_key_exists('action',$_POST)) { ! $action = $_POST['action']; ! } else { ! $action = 'choose_quiz'; ! } ! if (array_key_exists('quiz',$_SESSION)) { $quiz = $_SESSION['quiz']; --- 56,69 ---- // action = unfocus See all questions at once. // action = continue_quiz Continue a quiz, from $user information + // (default_action) // action = new_quiz_version Start a new quiz version ! // actoin = validate Validate the response to *every question* // action = mark Mark the response to *every question* // action = mark_question Mark the response only to question in the field questiono // action = solutions Mark the response to *every question* then show the solutions // This prevents further attempts ! ! // If there is a quiz stored in the $_SESSION, we should use this. ! // Otherwise we need to generate one. if (array_key_exists('quiz',$_SESSION)) { $quiz = $_SESSION['quiz']; *************** *** 104,117 **** } - - if (array_key_exists('focus',$_SESSION)) { - $focus = $_SESSION['focus']; - } - if (array_key_exists('focus_on',$_SESSION)) { - $focus_on = $_SESSION['focus_on']; - } - //////////////////////////////////////////////// ! // (2) Take some action //////////////////////////////////////////////// --- 72,77 ---- } //////////////////////////////////////////////// ! // (4) Take some action //////////////////////////////////////////////// |