From: Chris S. <san...@us...> - 2005-06-18 09:54:25
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27637 Modified Files: Tag: frontend_dev index.php qb_preview.php question_bank.php quiz.php Log Message: Index: qb_preview.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/Attic/qb_preview.php,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** qb_preview.php 17 Jun 2005 16:25:27 -0000 1.1.2.5 --- qb_preview.php 18 Jun 2005 09:54:12 -0000 1.1.2.6 *************** *** 1,93 **** ! <?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; ! stack_question_add_attempt($questionInst,$this_attempt,$errors); ! $_SESSION['questionInst'] = $questionInst; ! $_SESSION['question'] = $questionInst; ! stack_display_qb_preview($questionInst); ! stack_question_inst_try_test($questionInst,$this_attempt,$options,$errors); ! } ! ?> --- 1,96 ---- ! <?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(); ! $options = stack_options_set($question); ! $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; ! ! stack_question_add_attempt($questionInst,$this_attempt,$errors); ! $_SESSION['questionInst'] = $questionInst; ! $_SESSION['question'] = $questionInst; ! // CJS We should display the question as the student should see it. Hence not ! //stack_display_qb_preview($questionInst); ! // But instead ! ! stack_question_inst_try_test($questionInst,$this_attempt,$options,$errors); ! } ! ?> Index: quiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/quiz.php,v retrieving revision 1.22.2.5 retrieving revision 1.22.2.6 diff -C2 -d -r1.22.2.5 -r1.22.2.6 *** quiz.php 17 Jun 2005 10:54:51 -0000 1.22.2.5 --- quiz.php 18 Jun 2005 09:54:12 -0000 1.22.2.6 *************** *** 564,568 **** // (1) Pose the question ! echo '<p>'.$qInst['questionStemInst'].'</p>'; if (array_key_exists('errors',$qInst)) { --- 564,568 ---- // (1) Pose the question ! stack_question_inst_displayq($qInst); if (array_key_exists('errors',$qInst)) { Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.3.2.21 retrieving revision 1.3.2.22 diff -C2 -d -r1.3.2.21 -r1.3.2.22 *** question_bank.php 17 Jun 2005 16:25:27 -0000 1.3.2.21 --- question_bank.php 18 Jun 2005 09:54:12 -0000 1.3.2.22 *************** *** 78,82 **** if ('edit_new' == $action) { $new_question = TRUE; ! $action = 'edit'; } --- 78,82 ---- if ('edit_new' == $action) { $new_question = TRUE; ! $action = 'edit'; } *************** *** 99,113 **** $get_question = FALSE; - if ('edit' == $action or 'mark' == $action or 'validate' == $action ! or 'save' == $action ! or 'save_as' == $action ! or 'preview' == $action or 'new_version' == $action or 'export_xml' == $action) { $get_question = TRUE; ! $source = 'default'; if ($database) { $source = 'database'; --- 99,114 ---- $get_question = FALSE; if ('edit' == $action or 'mark' == $action or 'validate' == $action ! or 'save' == $action ! or 'save_as' == $action ! or 'preview' == $action or 'new_version' == $action or 'export_xml' == $action) { + $get_question = TRUE; ! $source = 'default'; ! if ($database) { $source = 'database'; *************** *** 120,126 **** if ($get_question) { $question = stack_get_question($source); ! ! $options = stack_options_set($question); ! $questionInst = stack_get_questionInst(); } --- 121,125 ---- if ($get_question) { $question = stack_get_question($source); ! $options = stack_options_set($question); $questionInst = stack_get_questionInst(); } *************** *** 260,265 **** ////////////////////////////////////////////////////////////// ! ! if ('questionbank_screen'==$action or 'edit_metadata' == $action) { session_unregister('question'); session_unregister('questionInst'); --- 259,263 ---- ////////////////////////////////////////////////////////////// ! 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.11 retrieving revision 1.17.2.12 diff -C2 -d -r1.17.2.11 -r1.17.2.12 *** index.php 17 Jun 2005 16:25:26 -0000 1.17.2.11 --- index.php 18 Jun 2005 09:54:12 -0000 1.17.2.12 *************** *** 32,38 **** include('stackstd.php'); $default_action = 'loginscreen'; - include($stack_root.'/frontend_general/process_input.php'); include_once($stack_root.'/frontend_general/front_end_display.php'); ! include_once($stack_root.'/frontend_general/frontend_util.php'); /////////////////////////////////////////////////////////////// --- 32,37 ---- include('stackstd.php'); $default_action = 'loginscreen'; include_once($stack_root.'/frontend_general/front_end_display.php'); ! include($stack_root.'/frontend_general/process_input.php'); /////////////////////////////////////////////////////////////// *************** *** 48,52 **** include('frontend_general/loginregister.php'); ! $err = stack_get_err($errors); $errun = stack_get_errun($err); $errps = stack_get_errps($err); --- 47,51 ---- include('frontend_general/loginregister.php'); ! $err = nsf($errors,'user'); $errun = stack_get_errun($err); $errps = stack_get_errps($err); |