From: Chris S. <san...@us...> - 2005-06-18 21:01:19
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8957 Modified Files: Tag: frontend_dev index.php qb_preview.php question_bank.php Log Message: Index: qb_preview.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/Attic/qb_preview.php,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** qb_preview.php 18 Jun 2005 09:54:12 -0000 1.1.2.6 --- qb_preview.php 18 Jun 2005 21:01:02 -0000 1.1.2.7 *************** *** 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); - } ?> --- 1,3 ---- Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.3.2.22 retrieving revision 1.3.2.23 diff -C2 -d -r1.3.2.22 -r1.3.2.23 *** question_bank.php 18 Jun 2005 09:54:12 -0000 1.3.2.22 --- question_bank.php 18 Jun 2005 21:01:02 -0000 1.3.2.23 *************** *** 65,69 **** // export_xml_db Export single question as xml from the database. // export_xml_list Export the list of selected questions as a single XML file ! // import Deal with an uploaded file. // edit_metadata Edit all the meta data fields in the question bank. // questionbank_screen Begin again. --- 65,70 ---- // export_xml_db Export single question as xml from the database. // export_xml_list Export the list of selected questions as a single XML file ! // import Present a form to add file name to upload. ! // uploaded_xml Deal with an uploaded file. // edit_metadata Edit all the meta data fields in the question bank. // questionbank_screen Begin again. *************** *** 94,98 **** } ! if ('export_xml_db' == $action) { $action = 'export_xml'; } --- 95,99 ---- } ! if ('export_xml_db' == $action) { $action = 'export_xml'; } *************** *** 126,133 **** // Work out the correct value for any filter to be applied to the question ! // bank $question_bank_filter = stack_get_questionbank_filter(); - $upload_successful = FALSE; if ('uploaded_xml' == $action) { --- 127,133 ---- // 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(); $upload_successful = FALSE; if ('uploaded_xml' == $action) { *************** *** 149,181 **** } } - - // Export a whole list of questions. - $multiple_questions = FALSE; ! if ('export_xml_list'==$action) { ! $multiple_questions = TRUE; ! $action = 'export_xml'; } ! ! if ('export_xml'==$action) { ! if ($multiple_questions) { ! $questions_to_export = stack_get_selected_questions(); ! } else { ! stack_question_validate($question,$errors); ! } ! include_once("{$stack_root}/scripts/stackXML.php"); ! ! if ($multiple_questions) { $name = stack_xml_write_quiz_file($questions_to_export, "{$stack_root}/tmp/"); ! } else { ! $name = stack_xml_write_question_file($question, "{$stack_root}/tmp/"); ! } } if ('edit_metadata' == $action ) { ! if (!$admin) { ! stack_display_qb_error_not_admin(); ! } else { // If needed update the database if (array_key_exists('edit_metadata',$_POST)) { --- 149,173 ---- } } ! if ('export_xml' == $action) { ! include_once("{$stack_root}/scripts/stackXML.php"); ! stack_question_validate($question,$errors); ! $name = stack_xml_write_question_file($question, "{$stack_root}/tmp/"); ! $questions_to_export = TRUE; } ! ! if ('export_xml_list' == $action) { include_once("{$stack_root}/scripts/stackXML.php"); ! $questions_to_export = stack_get_selected_questions(); ! $name = ''; ! if (NULL !== $questions_to_export) { $name = stack_xml_write_quiz_file($questions_to_export, "{$stack_root}/tmp/"); ! } ! $action = 'export_xml'; } + if ('edit_metadata' == $action ) { ! if ($admin) { // If needed update the database if (array_key_exists('edit_metadata',$_POST)) { *************** *** 223,228 **** stack_display_qb_show_imported($quiz); } else { ! stack_display_qb_error_upload_failure(); } break; case 'import': --- 215,221 ---- stack_display_qb_show_imported($quiz); } else { ! echo '<p>Could not extract a question or quiz from your uploaded file. Please edit your file carefully and try again.</p>'; } + $action = 'questionbank_screen'; break; case 'import': *************** *** 231,246 **** case 'export_xml': if (NULL == $questions_to_export) { ! stack_display_error_no_questions_selected(); ! $action = 'questionbank_screen'; } ! stack_display_qb_export($name); break; case 'edit_metadata': stack_display_qb_edit_metadata($question_bank_filter); break; } ! // Deal with actions connected with previewing questions ! include('qb_preview.php'); switch ($action) { --- 224,310 ---- case 'export_xml': if (NULL == $questions_to_export) { ! echo "<p>Could not get any ticked questions! Please try again.</p>"; ! } else { ! echo "<p>Please download the file <a href='{$stack_web_url}tmp/{$name}'>$name</a>.</p>"; } ! $action = 'questionbank_screen'; break; case 'edit_metadata': + if (!$admin) { + print_string('qp_notadmin','stack'); + } stack_display_qb_edit_metadata($question_bank_filter); break; } ! ! // 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) { ! echo '<p>Could not instantiate the question, because of errors.<br />Try to edit the question instead.</p>'; ! $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); ! } ! switch ($action) { *************** *** 249,252 **** --- 313,319 ---- break; case 'edit': + if (!$admin) { + print_string('qp_notadmin','stack'); + } stack_display_qb_edit($question, $errors); break; Index: index.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/index.php,v retrieving revision 1.17.2.12 retrieving revision 1.17.2.13 diff -C2 -d -r1.17.2.12 -r1.17.2.13 *** index.php 18 Jun 2005 09:54:12 -0000 1.17.2.12 --- index.php 18 Jun 2005 21:01:02 -0000 1.17.2.13 *************** *** 44,47 **** --- 44,48 ---- session_unregister('user'); unset($_SESSION['user']); + $_GET['expand'] = 0; } *************** *** 59,68 **** if ('logout' == $action) { ! stack_display_main_logout(); $action = 'loginscreen'; } if ('welcome' == $action) { ! stack_display_main_welcome($user); $action = 'choose_quiz'; } --- 60,69 ---- if ('logout' == $action) { ! echo '<h1>Thank you</h1><p>Thank you for using STACK.'; $action = 'loginscreen'; } if ('welcome' == $action) { ! echo "<h1>Welcome</h1> <p>Welcome to STACK, {$user['firstname']} {$user['lastname']}.</p>"; $action = 'choose_quiz'; } *************** *** 81,93 **** 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; } --- 82,95 ---- stack_display_main_update_userinfo($user, $err, $errors); } else { ! echo '<h1>Update user information</h1>'; ! echo '<p>Please logout and login as a personal user first to update your information.</p>'; } break; case 'error': ! echo "There was an error with the login or registration"; break; case 'choose_quiz': $quiz_store = stack_db_quiz_get(); ! stack_quiz_student_select($quiz_store, $user); break; } |