From: Juliette W. <jv...@us...> - 2005-06-17 13:16:51
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23417 Modified Files: Tag: frontend_dev editquiz.php index.php qb_preview.php question_bank.php Log Message: Couple of fixes and made function names more consistent Index: qb_preview.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/Attic/qb_preview.php,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** qb_preview.php 16 Jun 2005 14:30:17 -0000 1.1.2.3 --- qb_preview.php 17 Jun 2005 13:16:41 -0000 1.1.2.4 *************** *** 15,23 **** - // These branches need the question to be validated - if ('edit' == $action or 'preview'==$action or 'export_xml'==$action) { - stack_question_validate($question,$errors); - } - // Have the questions been marked? if ('mark' == $action or 'validate' == $action) { --- 15,18 ---- *************** *** 31,116 **** ! ! if ('preview'==$action && $database) { ! if (''==$errors) { ! $action='validate'; ! if (array_key_exists('seed',$_POST)) { ! $seed=$_POST['seed']; ! } else { ! // HACK: this should involve the concept of a user! ! $seed = time(); ! } $questionInst = stack_question_inst($question,$seed,$options,$errors); - // For the purposes of this test, fill in the correct answer - // Which must exist! - // $RawAns = $questionInst['questionAnsInst']['value']; ! if (array_key_exists('RawAns',$_POST)) { ! $RawAns=$_POST['RawAns']; ! } ! if (''!=$errors) { ! $action='edit'; } - - } - else { - echo "Could not instantiate the question, because of errors. - <br />Try to edit the question instead."; - $action='edit'; - } - } - - // If we have just taken a question from the edit from, we need to instantiate it. - if ('preview'==$action) { - if (''==$errors) { - $action='mark'; - $seed = time(); // HACK: this should involve the concept of a user! - $questionInst = stack_question_inst($question,$seed,$options,$errors); - // For the purposes of this test, fill in the correct answer - // Which must exist! - $RawAns = $questionInst['questionAnsInst']['value']; } if (''!=$errors) { $action='edit'; - echo '<p>Could not instantiate the question, because of errors. - <br />Try to edit the question instead.</p>'; - //show_array($errors); } - } ! // 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; stack_question_add_attempt($questionInst,$this_attempt,$errors); ! ! } ! ! //(4.3) Try the questions ! if ('mark' == $action or 'validate' == $action) { ! ! $_SESSION['questionInst'] = $questionInst; ! $_SESSION['question'] = $questionInst; ! ! echo "<center><table bgcolor='#CCCCCC' width='100%' cellpadding='2'> ! <td align='left'> ! ! <b>Question: ".sf($questionInst,'questionName')."</b> (".sf($questionInst,'questionID'); ! echo ")</td><td align='right'>"; ! echo "<a href=\"javascript:HelpPopup('student','');\">Help</a></td></tr></table></center>"; ! ! ! //show_array($questionInst); ! stack_question_inst_try_test($questionInst,$this_attempt,$options,$errors); ! ! //stack_question_inst_try($questionInst,$this_attempt,$options,$errors); ! //stack_question_inst_show_sol($questionInst,$errors); ! } ?> --- 26,76 ---- ! 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; 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); } ?> Index: editquiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/editquiz.php,v retrieving revision 1.10.2.8 retrieving revision 1.10.2.9 diff -C2 -d -r1.10.2.8 -r1.10.2.9 *** editquiz.php 17 Jun 2005 10:54:51 -0000 1.10.2.8 --- editquiz.php 17 Jun 2005 13:16:41 -0000 1.10.2.9 *************** *** 35,39 **** if (!stack_user_is_admin($user) or !stack_is_logged_in($user)) { ! stack_quiz_edit_not_admin($user); include('html/pagefoot.php'); die(); --- 35,39 ---- if (!stack_user_is_admin($user) or !stack_is_logged_in($user)) { ! stack_display_editquiz_error_not_admin($user); include('html/pagefoot.php'); die(); *************** *** 122,137 **** //////////////////////////////////////////////// ! stack_quiz_edit_errors($errors); switch ($action) { case 'quiz_choose': $quiz_store = stack_db_quiz_get(); ! stack_select_quiz_screen($quiz_store, $PostTo); break; case 'quiz_edit': ! stack_quiz_edit_screen($quiz,$errors,$PostTo); break; case 'quiz_edit_addqs': ! stack_add_questions_screen($PostTo, $quizid, $question_bank_filter); break; } --- 122,137 ---- //////////////////////////////////////////////// ! stack_display_editquiz_error($errors); switch ($action) { case 'quiz_choose': $quiz_store = stack_db_quiz_get(); ! stack_display_editquiz_select($quiz_store, $PostTo); break; case 'quiz_edit': ! stack_display_editquiz_edit($quiz,$errors,$PostTo); break; case 'quiz_edit_addqs': ! stack_display_editquiz_add_questions($PostTo, $quizid, $question_bank_filter); break; } Index: question_bank.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/question_bank.php,v retrieving revision 1.3.2.19 retrieving revision 1.3.2.20 diff -C2 -d -r1.3.2.19 -r1.3.2.20 *** question_bank.php 16 Jun 2005 16:50:49 -0000 1.3.2.19 --- question_bank.php 17 Jun 2005 13:16:41 -0000 1.3.2.20 *************** *** 119,123 **** --- 119,125 ---- if ($get_question) { $question = stack_get_question($source); + $options = stack_options_set($question); + $questionInst = stack_get_questionInst(); } *************** *** 174,178 **** if ('edit_metadata' == $action ) { if (!$admin) { ! stack_print_not_admin(); } else { // If needed update the database --- 176,180 ---- if ('edit_metadata' == $action ) { if (!$admin) { ! stack_display_qb_error_not_admin(); } else { // If needed update the database *************** *** 203,207 **** break; case 'edit': ! stack_question_validate($question,$errors); break; } --- 205,211 ---- break; case 'edit': ! if (!$new_question) { ! stack_question_validate($question,$errors); ! } break; } *************** *** 217,237 **** case 'uploaded_xml': if ($upload_successful) { ! stack_show_uploaded_questions_screen($quiz); } else { ! stack_upload_error_screen(); } break; case 'import': ! stack_import_questions_screen($errors); break; case 'export_xml': if (NULL == $questions_to_export) { ! stack_print_questionbank_no_questions_screen(); $action = 'questionbank_screen'; } ! stack_print_download_export_screen($name); break; case 'edit_metadata': ! stack_print_edit_metadata_screen($question_bank_filter); break; } --- 221,241 ---- case 'uploaded_xml': if ($upload_successful) { ! stack_display_qb_show_imported($quiz); } else { ! stack_display_qb_error_upload_failure(); } break; case 'import': ! stack_display_qb_import($errors); break; 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; } *************** *** 242,249 **** switch ($action) { case 'questionbank_screen': ! stack_print_question_bank_screen($admin, $question_bank_filter); break; case 'edit': ! stack_print_edit_screen($question, $errors); break; } --- 246,253 ---- switch ($action) { case 'questionbank_screen': ! stack_display_qb_main($admin, $question_bank_filter); break; case 'edit': ! 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.9 retrieving revision 1.17.2.10 diff -C2 -d -r1.17.2.9 -r1.17.2.10 *** index.php 17 Jun 2005 10:54:51 -0000 1.17.2.9 --- index.php 17 Jun 2005 13:16:41 -0000 1.17.2.10 *************** *** 56,93 **** if ('logout' == $action) { ! stack_logout_screen(); $action = 'loginscreen'; } if ('welcome' == $action) { ! stack_welcome_screen($user); $action = 'choose_quiz'; } if ('loginscreen' == $action) { ! stack_login_screen($username, $errun, $errps); } if ('registration_screen' == $action) { include_once($stack_root."/scripts/stackUser.php"); ! stack_registration_screen($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_update_info_screen($user, $err, $errors); } else { ! stack_update_info_error_screen(); } } if ('error' == $action) { ! stack_login_error_screen($error); } if ('choose_quiz' == $action) { $quiz_store = stack_db_quiz_get(); ! stack_select_quiz_screen($quiz_store, $user); } --- 56,93 ---- if ('logout' == $action) { ! stack_display_main_logout(); $action = 'loginscreen'; } if ('welcome' == $action) { ! stack_display_main_welcome($user); $action = 'choose_quiz'; } 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); } |