From: Chris S. <san...@us...> - 2005-08-29 18:41:12
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9530 Modified Files: analysis.php chat.php chat_mathml.php documentation.php editquiz.php import.php index.php question_bank.php quiz.php stackConfig.php.dist stackLib.php user.php Log Message: Index: import.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/import.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** import.php 29 Aug 2005 15:35:22 -0000 1.4 --- import.php 29 Aug 2005 18:41:03 -0000 1.5 *************** *** 33,36 **** --- 33,37 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); require_once("{$stack_root}/html/trypopupform.html"); Index: quiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/quiz.php,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** quiz.php 29 Aug 2005 15:35:22 -0000 1.30 --- quiz.php 29 Aug 2005 18:41:03 -0000 1.31 *************** *** 14,17 **** --- 14,18 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); $default_action = 'choose_quiz'; Index: index.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/index.php,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** index.php 29 Aug 2005 15:35:22 -0000 1.26 --- index.php 29 Aug 2005 18:41:03 -0000 1.27 *************** *** 16,26 **** * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... ! ! * ! * This file contains the front end logic for the main frontend pages ! * TO DO: Some of the code in this file needs to be factored out into separate ! * algorithms- ideally we should have a function for each action on entry and ! * for display. ! * - Added logic to view installation instructions if stackConfig.php not dectected * @package Stack */ --- 16,20 ---- * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... ! * * @package Stack */ *************** *** 32,39 **** session_start(); - /////////////////////////////////////////////////////////////// - // (1) Process Input - this sets $action, $user and $username - /////////////////////////////////////////////////////////////// - if (file_exists('stackConfig.php')) { require_once('stackConfig.php'); --- 26,29 ---- *************** *** 44,69 **** die(); } $default_action = 'loginscreen'; - include_once($stack_root.'/frontend_general/front_end_display.php'); include($stack_root.'/frontend_general/process_input.php'); ! //Initialisation include_once("{$stack_root}/scripts/stackXML.php"); ! //1. Check that XML schemas are up to date ! if (!stack_xml_check_schema_version(schemaBaseDir)) ! { ! $action = 'update_schema'; } ! //2. Check whether database needs updating - need to be logged in to get credentials include_once("{$stack_root}/scripts/stackDatabase.php"); ! if (!stack_db_database_update() && stack_is_logged_in($user) and !stack_user_is_guest($user)) ! { ! $action = 'update_db'; } /////////////////////////////////////////////////////////////// ! // (2) Take any actions required /////////////////////////////////////////////////////////////// --- 34,67 ---- die(); } + require_once('stackLib.php'); + + /////////////////////////////////////////////////////////////// + // (1) Process Input - this sets $action, $user and $username + /////////////////////////////////////////////////////////////// + + require_once($stack_root.'/scripts/stackFrontend.php'); $default_action = 'loginscreen'; include($stack_root.'/frontend_general/process_input.php'); ! /////////////////////////////////////////////////////////////// ! // (2) Check if updates are needed ! /////////////////////////////////////////////////////////////// ! ! ! // 2.1 Check that XML schemas are up to date include_once("{$stack_root}/scripts/stackXML.php"); ! if (!stack_xml_check_schema_version(schemaBaseDir)) { ! $action = 'update_schema'; } ! // 2.2 Check whether database needs updating - need to be logged in to get credentials include_once("{$stack_root}/scripts/stackDatabase.php"); ! if (!stack_db_database_update() && stack_is_logged_in($user) and !stack_user_is_guest($user)) { ! $action = 'update_db'; } /////////////////////////////////////////////////////////////// ! // (3) Take any actions required /////////////////////////////////////////////////////////////// *************** *** 107,116 **** switch ($action) { case 'loginscreen': ! stack_display_main_login($username, $errun, $errps); ! break; ! case 'registration_screen': ! include_once($stack_root."/scripts/stackUser.php"); ! stack_display_main_register($username, $user, $errors, $err); ! break; case 'update_info': if (stack_is_logged_in($user) and !stack_user_is_guest($user)) { --- 105,128 ---- switch ($action) { case 'loginscreen': ! echo '<h1>Login</h1><form action="index.php" method="post" name="login" id="login"><table><tr><td align="right">Username:</td>'; ! echo "<td><input type=\"text\" name=\"username\" size=\"15\" value=\"{$username}\" alt=\"Username\" /></td><td>".$errun.'</td>'; ! echo '</tr><tr><td>Password:</td>'; ! echo '<td><input type="password" name="password" size="15" value="" alt="Password" /></td><td>'.$errps.'</td>'; ! echo '</tr><tr><td> ! <input type="hidden" name="action" value="login" /> ! <input type="submit" value="Login" /> ! </td></tr> ! </table></form>'; ! ! echo 'You may login with the username "guest" and an empty password.'; ! ! echo '<form action="index.php" method="post" name="guestlogin"> ! Register with this STACK sever: ! <input type="hidden" name="username" value="guest" /> ! <input type="hidden" name="password" value="guest" /> ! <input type="hidden" name="action" value="registration_screen" /> ! <input type="submit" value="Register" /> ! </form>'; ! break; case 'update_info': if (stack_is_logged_in($user) and !stack_user_is_guest($user)) { *************** *** 121,126 **** } break; ! case 'error': ! echo "There was an error with the login or registration"; break; case 'choose_quiz': --- 133,146 ---- } break; ! case 'registration_screen': ! include_once($stack_root."/scripts/stackUser.php"); ! ! echo "<h1>Register as a new user</h1><form action=\"index.php\" method=\"post\" name=\"register\" id=\"register\">"; ! echo '<p>To register as a STACK user, please provide the following information.<p>'; ! echo '<table><tr><td>Username </td><td><input type="text" name="user[username]" size="25" value="'.stack_s($username).'" alt="User name" /></td><td>'.$err.'</td></tr>'; ! // TO DO: Need to fix typo in this form - institution ! stack_user_edit_form($user,$errors); ! echo '</table><input type="hidden" name="action" value="register" /><input type="submit" value="Register" /></form>'; ! break; case 'choose_quiz': *************** *** 132,136 **** break; case 'update_db': ! include("{$stack_root}/scripts/install/stackUpdateDatabase.php"); break; } --- 152,156 ---- break; case 'update_db': ! include("{$stack_root}/scripts/install/stackUpdateDatabase.php"); break; } Index: chat_mathml.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/chat_mathml.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** chat_mathml.php 29 Aug 2005 15:35:22 -0000 1.8 --- chat_mathml.php 29 Aug 2005 18:41:03 -0000 1.9 *************** *** 14,18 **** session_start(); require_once('stackConfig.php'); ! // Deal with slahes in input --- 14,18 ---- session_start(); require_once('stackConfig.php'); ! require_once('stackLib.php'); // Deal with slahes in input Index: stackLib.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/stackLib.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** stackLib.php 29 Aug 2005 15:35:22 -0000 1.1 --- stackLib.php 29 Aug 2005 18:41:03 -0000 1.2 *************** *** 13,16 **** --- 13,21 ---- $stack_ver['cvsmodule'] = 'stack-1-0'; + if (file_exists('stackConfig.php')) { + include('stackConfig.php'); + } + + // The forbidden commands are generated dynamically, and stored here if (file_exists($stack_logfiles.'CASkeywords.php')) { *************** *** 28,33 **** require_once("{$stack_root}/scripts/stackUser.php"); - require_once("{$stack_root}/frontend_general/frontend_util.php"); - require_once("{$stack_root}/scripts/stackCAS.php"); if ('unix' == $stack_os) { --- 33,36 ---- Index: documentation.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/documentation.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** documentation.php 29 Aug 2005 15:35:22 -0000 1.7 --- documentation.php 29 Aug 2005 18:41:03 -0000 1.8 *************** *** 34,37 **** --- 34,39 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + $default_action = ''; include($stack_root.'/frontend_general/process_input.php'); Index: stackConfig.php.dist =================================================================== RCS file: /cvsroot/stack/stack-1-0/stackConfig.php.dist,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stackConfig.php.dist 29 Aug 2005 16:33:54 -0000 1.2 --- stackConfig.php.dist 29 Aug 2005 18:41:03 -0000 1.3 *************** *** 134,142 **** $stack_web_services_provide = FALSE; - /*************************************************************/ - /* Load the libraries */ - /*************************************************************/ - - require_once('stackLib.php'); - ?> --- 134,136 ---- Index: user.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/user.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** user.php 29 Aug 2005 15:35:22 -0000 1.5 --- user.php 29 Aug 2005 18:41:03 -0000 1.6 *************** *** 25,30 **** session_start(); require_once('stackConfig.php'); $default_action = 'none'; - include_once($stack_root.'/frontend_general/front_end_display.php'); include($stack_root.'/frontend_general/process_input.php'); --- 25,31 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + $default_action = 'none'; include($stack_root.'/frontend_general/process_input.php'); Index: analysis.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/analysis.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** analysis.php 29 Aug 2005 15:35:22 -0000 1.18 --- analysis.php 29 Aug 2005 18:41:03 -0000 1.19 *************** *** 30,39 **** */ session_start(); - - /** - * Include local settings. - * - */ require_once('stackConfig.php'); require_once("{$stack_root}/html/trypopupform.html"); --- 30,36 ---- */ session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + require_once("{$stack_root}/html/trypopupform.html"); Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** question_bank.php 29 Aug 2005 15:35:22 -0000 1.11 --- question_bank.php 29 Aug 2005 18:41:03 -0000 1.12 *************** *** 32,44 **** session_start(); require_once('stackConfig.php'); $default_action = 'questionbank_screen'; include($stack_root.'/frontend_general/process_input.php'); include('html/trypopupform.html'); include('html/helpform.php'); include('html/javascripthead.html'); include('html/inputtool.html'); ! include_once($stack_root.'/frontend_general/question_bank_util.php'); ! include_once($stack_root.'/frontend_general/qb_display.php'); $question = ''; --- 32,47 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + require_once($stack_root.'/scripts/stackFrontend.php'); $default_action = 'questionbank_screen'; include($stack_root.'/frontend_general/process_input.php'); + include('html/trypopupform.html'); include('html/helpform.php'); include('html/javascripthead.html'); include('html/inputtool.html'); ! //include_once($stack_root.'/frontend_general/question_bank_util.php'); ! //include_once($stack_root.'/frontend_general/qb_display.php'); $question = ''; *************** *** 121,125 **** // Get the question, question options and question instance if required if ($get_question) { ! $question = stack_get_question($source); if (!$new_question) { stack_question_validate($question,$errors); --- 124,128 ---- // Get the question, question options and question instance if required if ($get_question) { ! $question = stack_question_get($source); if (!$new_question) { stack_question_validate($question,$errors); *************** *** 131,135 **** // Work out the correct value for any filter to be applied to the question // bank. This is not needed by all actions, but it is harmless to set it. ! $question_bank_filter = stack_get_questionbank_filter(); if ('export_xml' == $action) { --- 134,138 ---- // Work out the correct value for any filter to be applied to the question // bank. This is not needed by all actions, but it is harmless to set it. ! $question_bank_filter = stack_questionbank_filter_get(); if ('export_xml' == $action) { *************** *** 282,286 **** switch ($action) { case 'questionbank_screen': ! stack_display_qb_main($admin, $question_bank_filter); break; case 'edit': --- 285,298 ---- switch ($action) { case 'questionbank_screen': ! include("{$stack_root}/html/qselectform.php"); ! ! if ($admin) { ! stack_db_listquestions('edit',$question_bank_filter); ! } else { ! stack_db_listquestions('try',$question_bank_filter); ! } ! ! echo "<p><a href=\"javascript:SelectQs('export_xml_list');\">Export selected as XML</a> "; ! echo "<p><a href=\"javascript:SelectQs('edit_metadata');\">Edit metadata</a> "; break; case 'edit': *************** *** 288,292 **** print_string('qp_notadmin','stack'); } ! stack_display_qb_edit($question, $errors); break; } --- 300,311 ---- print_string('qp_notadmin','stack'); } ! include_once("{$stack_root}/scripts/stackAuthor.php"); ! include("{$stack_root}/html/qselectform.php"); ! stack_question_edit_form($question,$errors); ! ! echo "<p><a href=\"javascript:HelpPopup('all','author_questionfields');\">Help with question fields.</a>\n ! <a href=\"javascript:HelpPopup('all','author_options');\">Help with options.</a>\n ! <a href=\"javascript:HelpPopup('all','author_answertest');\">Help with answer tests.</a>\n ! <a href=\"javascript:HelpPopup('all','author_potresp');\">Help with potential responses.</a></p>"; break; } Index: chat.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/chat.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** chat.php 29 Aug 2005 15:35:22 -0000 1.11 --- chat.php 29 Aug 2005 18:41:03 -0000 1.12 *************** *** 14,17 **** --- 14,19 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + $default_action = ''; include($stack_root.'/frontend_general/process_input.php'); *************** *** 20,24 **** $options['Display']='LaTeX'; ! include('html/pagehead.php'); ?> --- 22,26 ---- $options['Display']='LaTeX'; ! include('html/pagehead.php'); ?> Index: editquiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/editquiz.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** editquiz.php 29 Aug 2005 15:35:22 -0000 1.16 --- editquiz.php 29 Aug 2005 18:41:03 -0000 1.17 *************** *** 34,44 **** session_start(); require_once('stackConfig.php'); require_once("{$stack_root}/html/trypopupform.html"); - require_once("{$stack_root}/frontend_general/editquiz_display.php"); require_once("{$stack_root}/html/helpform.php"); require_once("{$stack_root}/html/quizjava.html"); - require_once("{$stack_root}/scripts/stackAuthor.php"); /////////////////////////////////////////////////////////////// --- 34,48 ---- session_start(); require_once('stackConfig.php'); + require_once('stackLib.php'); + + require_once("{$stack_root}/scripts/stackAuthor.php"); + require_once("{$stack_root}/scripts/stackFrontend.php"); require_once("{$stack_root}/html/trypopupform.html"); require_once("{$stack_root}/html/helpform.php"); require_once("{$stack_root}/html/quizjava.html"); + //require_once("{$stack_root}/frontend_general/editquiz_display.php"); + //include_once('frontend_general/edit_quiz_util.php'); /////////////////////////////////////////////////////////////// *************** *** 48,52 **** include('frontend_general/process_input.php'); - include_once('frontend_general/edit_quiz_util.php'); $PostTo = 'editquiz.php'; $filter = ''; --- 52,55 ---- *************** *** 65,69 **** // Work out the correct value for any filter to be applied to the question // bank. This is not needed by all actions, but it is harmless to set it. ! $question_bank_filter = stack_get_questionbank_filter(); //////////////////////////////////////////////// --- 68,72 ---- // Work out the correct value for any filter to be applied to the question // bank. This is not needed by all actions, but it is harmless to set it. ! $question_bank_filter = stack_questionbank_filter_get(); //////////////////////////////////////////////// *************** *** 101,106 **** if ('quiz_edit' == $action or 'quiz_edit_addqs' == $action) { ! $quiz_source = 'post'; ! $quiz = stack_get_quiz('post', $quizid); if ('' == $quiz) { $quizid_source = 'post'; --- 104,108 ---- if ('quiz_edit' == $action or 'quiz_edit_addqs' == $action) { ! $quiz = nsf($_POST, 'quiz'); if ('' == $quiz) { $quizid_source = 'post'; *************** *** 108,115 **** } ! $quizid = stack_get_quizid($quizid_source, $quiz); if (('quiz_edit' == $action or 'quiz_edit_addqs' == $action) and '' == $quiz) { ! $quiz = stack_get_quiz('database', $quizid); } --- 110,126 ---- } ! // Establish the $quizid ! $quizid = ''; ! if ('quiz' == $quizid_source) { ! $quizid = nsf($quiz,'quizid'); ! } else if ('database' == $quizid_source) { ! $quizid = stack_db_quiz_update(array()); ! } else if ('post' == $quizid_source) { ! $quizid = nsf($_POST, 'quizid'); ! } ! if (('quiz_edit' == $action or 'quiz_edit_addqs' == $action) and '' == $quiz) { ! $quiz = stack_db_quiz_get($quizid); } *************** *** 165,169 **** include_once("{$stack_root}/scripts/stackXML.php"); ! $quiz = stack_get_quiz('database', $quizid); stack_xml_remove_quiz_meta_defaults($quiz); //Pass quiz by reference and remove all default metadata $name = stack_xml_write_quiz_new($quiz,"{$stack_root}/tmp/"); --- 176,180 ---- include_once("{$stack_root}/scripts/stackXML.php"); ! $quiz = stack_db_quiz_get($quizid); stack_xml_remove_quiz_meta_defaults($quiz); //Pass quiz by reference and remove all default metadata $name = stack_xml_write_quiz_new($quiz,"{$stack_root}/tmp/"); *************** *** 174,179 **** //////////////////////////////////////////////// - stack_display_editquiz_error($errors); switch ($action) { case 'quiz_xml': --- 185,202 ---- //////////////////////////////////////////////// + // (3.1) Display any errors. + if (is_array($errors)) { + echo "<font color=\"red\">Errors exist!</font><br/>"; + if (array_key_exists('quiz',$errors)) { + foreach($errors['quiz'] as $key => $val) { + echo "The field $key, gave the following error."; + echo $val; + } + } + + } + + // (3.2) Now take some action switch ($action) { case 'quiz_xml': *************** *** 183,187 **** case 'quiz_choose': $quiz_store = stack_db_quiz_get(); ! stack_display_editquiz_select($quiz_store, $PostTo); break; case 'import': --- 206,210 ---- case 'quiz_choose': $quiz_store = stack_db_quiz_get(); ! stack_quiz_selectform($quiz_store, $PostTo); break; case 'import': *************** *** 189,193 **** } case 'quiz_report': ! $quizid = stack_get_quizid('post', $quiz); stack_quiz_report($quizid); break; --- 212,216 ---- } case 'quiz_report': ! $quizid = nsf($_POST, 'quizid'); stack_quiz_report($quizid); break; |