From: Juliette W. <jv...@us...> - 2005-06-17 16:25:38
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31005 Modified Files: Tag: frontend_dev documentation.php editquiz.php index.php qb_preview.php question_bank.php Log Message: Added docs/comments. Index: documentation.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/documentation.php,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** documentation.php 16 Jun 2005 11:44:44 -0000 1.2.2.4 --- documentation.php 17 Jun 2005 16:25:26 -0000 1.2.2.5 *************** *** 16,21 **** * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... * ! * @package Stack */ --- 16,24 ---- * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... + * @author Juliette White jv...@jv... * ! * This file contains the front end logic for the documentation ! * @package frontend ! * @subpackage Stack */ Index: qb_preview.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/Attic/qb_preview.php,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** qb_preview.php 17 Jun 2005 13:16:41 -0000 1.1.2.4 --- qb_preview.php 17 Jun 2005 16:25:27 -0000 1.1.2.5 *************** *** 1,69 **** ! <?php ! if ('new_version' == $action) { ! ! foreach ($stackQuestion as $qfield => $val) ! { ! if (array_key_exists($qfield,$questionInst)) ! { ! $question[$qfield] = $questionInst[$qfield]; ! } ! } ! unset($questionInst); ! ! $action = 'preview'; ! } ! // Have the questions been marked? ! if ('mark' == $action or 'validate' == $action) { ! if (array_key_exists('RawAns',$_POST) ){ ! $RawAns=$_POST['RawAns']; ! } ! else { ! $error['RawAns'] = '<font color="red">You have not entered an answer!</font>'; } ! } ! - if ('preview'==$action) { - - stack_question_validate($question,$errors); ! if ('' == $errors) { ! if ($database) { ! $action='validate'; ! } else { ! $action = 'mark'; ! } ! ! $seed = stack_get_seed(); ! // TO DO: There was a bug originally in the code that is still here ! // where the Display field of $options does not get set. As a result ! // the preview code does not work ! ! $questionInst = stack_question_inst($question,$seed,$options,$errors); ! // For the purposes of this test, fill in the correct answer ! if ($database) { ! if (array_key_exists('RawAns',$_POST)) { ! $RawAns=$_POST['RawAns']; ! } ! } else { ! $RawAns = $questionInst['questionAnsInst']['value']; ! } ! } ! if (''!=$errors) { ! stack_display_qb_error_validation_failure(); ! $action='edit'; } } ! // Now deal with a student's answer if ('mark'==$action or 'validate'==$action) { - - $this_attempt = stack_question_inst_mark($questionInst,$options,$RawAns,$errors); $this_attempt['Action']=$action; --- 1,86 ---- ! <?php ! /** ! * ! * Welcome to STACK. A system for teaching and assessment using a ! * computer algebra kernel. ! * <br> ! * This file is licensed under the GPL License. ! * <br> ! * A copy of the license is in your STACK distribution called ! * license.txt. If you are missing this file you can obtain ! * it from: ! * http://www.stack.bham.ac.uk/license.txt ! * <br> ! * Copyright (c) 2005, Christopher James Sangwin ! * ! * @author Chris Sangwin C.J...@bh... ! * @author Laura Naismith L.N...@bh... ! * @author Juliette White jv...@jv... ! * ! * This file contains a script called by question_bank.php ! * TO DO: This code should really be factored out into functions and the logic ! * returned to question_bank.php ! * TO DO: There appears to be no difference between the behaviour of 'mark' and ! * 'validate' as an action - is there are reason why there are separate actions? ! * @package frontend ! * @subpackage Stack ! */ ! // Preview a new version of the quiz. ! if ('new_version' == $action) { ! foreach ($stackQuestion as $qfield => $val) { ! if (array_key_exists($qfield,$questionInst)) { ! $question[$qfield] = $questionInst[$qfield]; ! } ! } ! unset($questionInst); ! $action = 'preview'; ! } ! if ('mark' == $action or 'validate' == $action) { ! if (array_key_exists('RawAns',$_POST) ){ ! $RawAns=$_POST['RawAns']; ! } else { ! $error['RawAns'] = '<font color="red">You have not entered an answer!</font>'; } ! } ! if ('preview'==$action) { ! stack_question_validate($question,$errors); ! if ('' == $errors) { ! if ($database) { ! $action='validate'; ! } else { ! $action = 'mark'; ! } ! ! $seed = stack_get_seed(); ! // TO DO: There was a bug originally in the code that is still here ! // where the Display field of $options does not get set. As a result ! // the preview code does not work ! $questionInst = stack_question_inst($question,$seed,$options,$errors); ! // For the purposes of this test, fill in the correct answer ! ! if ($database) { ! if (array_key_exists('RawAns',$_POST)) { ! $RawAns=$_POST['RawAns']; ! } ! } else { ! $RawAns = $questionInst['questionAnsInst']['value']; ! } ! } ! if (''!=$errors) { ! stack_display_qb_error_validation_failure(); ! $action='edit'; } } ! // Now deal with the answer if ('mark'==$action or 'validate'==$action) { $this_attempt = stack_question_inst_mark($questionInst,$options,$RawAns,$errors); $this_attempt['Action']=$action; Index: editquiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/editquiz.php,v retrieving revision 1.10.2.9 retrieving revision 1.10.2.10 diff -C2 -d -r1.10.2.9 -r1.10.2.10 *** editquiz.php 17 Jun 2005 13:16:41 -0000 1.10.2.9 --- editquiz.php 17 Jun 2005 16:25:26 -0000 1.10.2.10 *************** *** 2,8 **** /** * ! * This file contains the logic of interactions with the site as ! * an editor of quizzes. * * @package frontend * @subpackage Stack --- 2,26 ---- /** * ! * Welcome to STACK. A system for teaching and assessment using a ! * computer algebra kernel. ! * <br> ! * This file is licensed under the GPL License. ! * <br> ! * A copy of the license is in your STACK distribution called ! * license.txt. If you are missing this file you can obtain ! * it from: ! * http://www.stack.bham.ac.uk/license.txt ! * <br> ! * Copyright (c) 2005, Christopher James Sangwin * + * @author Chris Sangwin C.J...@bh... + * @author Laura Naismith L.N...@bh... + * @author Juliette White jv...@jv... + * + * + * This file contains the front end logic for the quiz editting + * 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. * @package frontend * @subpackage Stack *************** *** 40,62 **** } ! //////////////////////////////////////////////// ! // (2) Decide what we are trying to do. ! //////////////////////////////////////////////// ! ! // action = quiz_edit Edit a quiz ! // action = quiz_choose Choose a quiz ! // action = quiz_new Create a new quiz ! // action = quiz_delete Delete a quiz ! // action = quiz_edit_addqs Add questions to the quiz. ! // action = filter Re-display the list of questions, filtered. ! // show_array($_POST); ! ! //////////////////////////////////////////////// ! // Set $quizid and $quiz if necessary ! //////////////////////////////////////////////// $quiz = ''; $quizid_source = ''; --- 58,78 ---- } ! //////////////////////////////////////////////// ! // (2) Take any actions required on entry to the page ! //////////////////////////////////////////////// ! // TO DO: Much of this code would be better replaced by a switch statement ! // with the functions factored out + // Possible values of $action are + // quiz_edit Edit a quiz + // quiz_choose Choose a quiz + // quiz_new Create a new quiz + // quiz_delete Delete a quiz + // quiz_edit_addqs Add questions to the quiz. + // filter Re-display the list of questions, filtered. + // Get the quiz and quiz id $quiz = ''; $quizid_source = ''; *************** *** 83,86 **** --- 99,103 ---- } + // Get the question bank filter if ('filter' == $action) { $filter_source = 'post'; *************** *** 118,124 **** } ! //////////////////////////////////////////////// ! // (4) Generate web page ! //////////////////////////////////////////////// stack_display_editquiz_error($errors); --- 135,141 ---- } ! //////////////////////////////////////////////// ! // (3) Generate web page ! //////////////////////////////////////////////// stack_display_editquiz_error($errors); Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.3.2.20 retrieving revision 1.3.2.21 diff -C2 -d -r1.3.2.20 -r1.3.2.21 *** question_bank.php 17 Jun 2005 13:16:41 -0000 1.3.2.20 --- question_bank.php 17 Jun 2005 16:25:27 -0000 1.3.2.21 *************** *** 16,24 **** * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... * ! * ! * This file contains the logic of interactions with the site as ! * an editor of questions and the question bank. ! * * @package frontend * @subpackage Stack --- 16,25 ---- * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... + * @author Juliette White jv...@jv... * ! * This file contains the front end logic for the question bank ! * 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. * @package frontend * @subpackage Stack *************** *** 150,154 **** } ! // (2.4) Export a whole list of questions. $multiple_questions = FALSE; --- 151,155 ---- } ! // Export a whole list of questions. $multiple_questions = FALSE; *************** *** 260,265 **** ! if ('questionbank_screen'==$action or 'edit_metadata' == $action) ! { session_unregister('question'); session_unregister('questionInst'); --- 261,265 ---- ! if ('questionbank_screen'==$action or 'edit_metadata' == $action) { session_unregister('question'); session_unregister('questionInst'); Index: index.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/index.php,v retrieving revision 1.17.2.10 retrieving revision 1.17.2.11 diff -C2 -d -r1.17.2.10 -r1.17.2.11 *** index.php 17 Jun 2005 13:16:41 -0000 1.17.2.10 --- index.php 17 Jun 2005 16:25:26 -0000 1.17.2.11 *************** *** 16,20 **** * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... ! * * @package Stack */ --- 16,25 ---- * @author Chris Sangwin C.J...@bh... * @author Laura Naismith L.N...@bh... ! * @author Juliette White jv...@jv... ! * ! * 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. * @package Stack */ *************** *** 52,56 **** ////////////////////////////////////////////////////////////// - include('html/pagehead.php'); --- 57,60 ---- *************** *** 65,93 **** } ! if ('loginscreen' == $action) { ! stack_display_main_login($username, $errun, $errps); ! } ! ! if ('registration_screen' == $action) { ! include_once($stack_root."/scripts/stackUser.php"); ! stack_display_main_register($username, $user, $errors, $err); ! } ! ! if ('update_info' == $action) { ! if (stack_is_logged_in($user) and !stack_user_is_guest($user)) { ! $err = stack_get_err2($errors); ! stack_display_main_update_userinfo($user, $err, $errors); ! } else { ! stack_display_main_error_update_userinfo(); ! } ! } ! ! if ('error' == $action) { ! stack_display_main_error_login($error); ! } ! ! if ('choose_quiz' == $action) { ! $quiz_store = stack_db_quiz_get(); ! stack_display_main_select_quiz($quiz_store, $user); } --- 69,95 ---- } ! 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)) { ! $err = stack_get_err2($errors); ! stack_display_main_update_userinfo($user, $err, $errors); ! } else { ! stack_display_main_error_update_userinfo(); ! } ! break; ! case 'error': ! stack_display_main_error_login($error); ! break; ! case 'choose_quiz': ! $quiz_store = stack_db_quiz_get(); ! stack_display_main_select_quiz($quiz_store, $user); ! break; } |