From: Juliette W. <jv...@us...> - 2005-06-15 13:34:57
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7216 Modified Files: Tag: frontend_dev question_bank.php question_bank_util.php Log Message: More work on question bank code. Made minor change to question editting form. Index: question_bank_util.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/Attic/question_bank_util.php,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** question_bank_util.php 14 Jun 2005 16:33:56 -0000 1.1.2.1 --- question_bank_util.php 15 Jun 2005 13:34:36 -0000 1.1.2.2 *************** *** 25,38 **** */ ! function stack_question_in_session() { ! if (array_key_exists('question',$_SESSION)) { ! return TRUE; ! } else { ! return FALSE; ! } ! } function stack_get_question_from_session() { ! $question = 'unknown'; // Get any $question from the current $_SESSION if (array_key_exists('question',$_SESSION)) { --- 25,32 ---- */ ! function stack_get_question_from_session() { ! $question = NULL; // Get any $question from the current $_SESSION if (array_key_exists('question',$_SESSION)) { *************** *** 50,55 **** } ! function stack_get_questionInst_from_session() { ! $questionInst = 'unknown'; // Get any $questionInst from the current $_SESSION if (array_key_exists('questionInst',$_SESSION)) { --- 44,49 ---- } ! function stack_get_questionInst() { ! $questionInst = NULL; // Get any $questionInst from the current $_SESSION if (array_key_exists('questionInst',$_SESSION)) { *************** *** 64,75 **** function stack_get_question_from_post() { ! // Get any $_POSTED data // This should over write any $_SESSION data, as it may have been entered in a form. ! foreach( $stackQuestion as $qfield => $attribs) { ! if ( array_key_exists($qfield,$_POST) ) { if ('questionOptions' == $qfield) { --- 58,69 ---- function stack_get_question_from_post() { ! $question = NULL; // Get any $_POSTED data // This should over write any $_SESSION data, as it may have been entered in a form. ! foreach($stackQuestion as $qfield => $attribs) { ! if (array_key_exists($qfield,$_POST) ) { if ('questionOptions' == $qfield) { *************** *** 89,108 **** } ! // $source should be 'from database', 'new', 'session' or 'post' function stack_get_question($source) { ! if ('from_database' == $source) { $questionID = $_POST['questionID']; $question=stack_db_getquestion($questionID); } else if ('new' == $source) { ! $question['questionID']='0'; $question['questionAnsKey']='ans1'; - } else if ('session' == $source) { - $question = stack_get_question_from_session(); - } else if ('post' == $source) { - $stack_get_question_from_post(); - } else { - echo "Invalid arg to stack_get_question"; - // Error! How are we handling these? } } --- 83,103 ---- } ! // $source should be 'from database', 'new' or 'default' function stack_get_question($source) { ! $question = NULL; ! ! // $_POSTED data should over write any $_SESSION data, as it may have been ! // entered in a form. ! if ('default' == $source) { ! $question = stack_get_question_from_session(); ! $question = stack_get_question_from_post(); ! } else if ('database' == $source) { $questionID = $_POST['questionID']; $question=stack_db_getquestion($questionID); } else if ('new' == $source) { ! $question['questionID']='0'; $question['questionAnsKey']='ans1'; } + return $question; } Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.3.2.4 retrieving revision 1.3.2.5 diff -C2 -d -r1.3.2.4 -r1.3.2.5 *** question_bank.php 14 Jun 2005 16:33:56 -0000 1.3.2.4 --- question_bank.php 15 Jun 2005 13:34:36 -0000 1.3.2.5 *************** *** 75,89 **** or 'new_version' == $action or 'export_xml' == $action) { $get_question = TRUE; ! } ! ! $get_question_from_database = FALSE; ! ! if ('edit_from_db'==$action or 'try_from_db'==$action or 'export_xml_db'==$action) { ! $get_question_from_database = TRUE; ! } ! $get_new_question = FALSE; ! ! if ('start_new' == $action) { ! $get_new_question = TRUE; } --- 75,85 ---- or 'new_version' == $action or 'export_xml' == $action) { $get_question = TRUE; ! $source = 'default'; ! } else if ('edit_from_db'==$action or 'try_from_db'==$action or 'export_xml_db'==$action) { ! $source = 'database'; ! $get_question = TRUE; ! } else if ('start_new' == $action) { ! $get_question = TRUE; ! $source = 'new'; } *************** *** 91,117 **** // There should be a question in the $POST or $SESSION if ($get_question) { ! ! // $_POSTED data should over write any $_SESSION data, as it may have been ! // entered in a form. ! $question = stack_get_question_from_session(); ! $questionInst = stack_get_questionInst_from_session(); ! $question = stack_get_question_from_post(); ! } ! ! // End (2.1) ! ! // (2.2) Get a question from the database. ! if ($get_question_from_database) { ! $questionID = $_POST['questionID']; ! $question=stack_db_getquestion($questionID); } - // End (2.2) - // (2.3) Provide a minimal blank question - if ($get_new_question) { - $question['questionID']='0'; - $question['questionAnsKey']='ans1'; - } - // End (2.3) // (2.4) Uploaded file. --- 87,94 ---- // There should be a question in the $POST or $SESSION if ($get_question) { ! $question = stack_get_question($source); ! $questionInst = stack_get_questionInst(); } // (2.4) Uploaded file. |