From: Chris S. <san...@us...> - 2005-06-14 17:55:01
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8050 Modified Files: Tag: frontend_dev editquiz.php quiz.php Log Message: Index: quiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/quiz.php,v retrieving revision 1.22.2.1 retrieving revision 1.22.2.2 diff -C2 -d -r1.22.2.1 -r1.22.2.2 *** quiz.php 14 Jun 2005 17:16:52 -0000 1.22.2.1 --- quiz.php 14 Jun 2005 17:54:52 -0000 1.22.2.2 *************** *** 76,91 **** //////////////////////////////////////////////// ! // (2.1) Guest users cannot store information in the DB if ('continue_quiz' == $action and 0 == $user['id']) { $action = 'new_quiz_version'; } ! // (2.2) Sort out focus/unfocus behaviour. if ('focus' == $action) { $focus = TRUE; ! // This is a bit of a HACK! We need to get the number into $_POST, // And the javascript function takeaction('mark_question',no) inserts into quizID, so ..... - if (array_key_exists('quizID',$_POST) ){ $focus_on = $_POST['quizID']; --- 76,90 ---- //////////////////////////////////////////////// ! // (4.1) Guest users cannot store information in the DB if ('continue_quiz' == $action and 0 == $user['id']) { $action = 'new_quiz_version'; } ! // (4.2) Sort out focus/unfocus behaviour. if ('focus' == $action) { $focus = TRUE; ! // This is a bit of a HACK, since we need to get the number into $_POST, // And the javascript function takeaction('mark_question',no) inserts into quizID, so ..... if (array_key_exists('quizID',$_POST) ){ $focus_on = $_POST['quizID']; *************** *** 94,102 **** } } if ('unfocus' == $action) { $focus = FALSE; } ! // (2.3) construct the $quiz if ('continue_quiz' == $action or 'new_quiz_version' == $action) { // Clear any existing quiz and quizInst from the $_SESSION --- 93,102 ---- } } + if ('unfocus' == $action) { $focus = FALSE; } ! // (4.3) construct the $quiz if ('continue_quiz' == $action or 'new_quiz_version' == $action) { // Clear any existing quiz and quizInst from the $_SESSION *************** *** 124,128 **** } ! // (2.4) At this point we should have a $quiz and $quizInst to work on. // Find out if we have quiz options. $quiz_options = array(); --- 124,128 ---- } ! // (4.4) At this point we should have a $quiz and $quizInst to work on. // Find out if we have quiz options. $quiz_options = array(); *************** *** 131,135 **** } ! // (2.5) Reconstruct $quizInst from previous data if ('continue_quiz' == $action) { // Check for the necessary informtaion incoming. --- 131,135 ---- } ! // (4.5) Reconstruct $quizInst from previous data if ('continue_quiz' == $action) { // Check for the necessary informtaion incoming. *************** *** 142,145 **** --- 142,149 ---- $quiz['seed'] = $seed; + // Check if students have previously asked for solutions. + // If so, they can't do anything else with this version + // of the quiz, but look at the solutions again. + // ie, they can't try again after solutions. if ($userinfo['SolRequest']) { $action = 'solutions'; *************** *** 152,155 **** --- 156,161 ---- $quizInst[]=$qInst; + // Make the $RawAns array equal to the student's last answer, if + // they have tried the quiz before. if (array_key_exists('questionAttempts', $qInst)) { if (is_array($qInst['questionAttempts'])) { *************** *** 164,171 **** } ! // (2.6) Start a new quiz if ('new_quiz_version' == $action) { $focus = FALSE; ! $seed = time()+rand(0,30000); $quiz['seed'] = $seed; // Record the information in the DB --- 170,177 ---- } ! // (4.6) Start a new quiz if ('new_quiz_version' == $action) { $focus = FALSE; ! $seed = time()+rand(0,30000); $quiz['seed'] = $seed; // Record the information in the DB *************** *** 178,193 **** stack_question_validate($question,$errors["qu$key"]); ! $options = stack_options_set($question); if ( '' == $errors["qu$key"] ) { - // HACK: Need a better mechanism $quizInst[] = stack_question_inst($question,$seed,$options,$errors["qu$key"]); } else { $question = NULL; ! $question['questionStemInst'] = "<font color=\"red\">There were errors in the question.</font> ! <br />Please contact your system administrator about questionID $qID.<br />"; ! $question['questionAnsInst'] = 0; ! $question['errors'] = $errors["qu$key"]; ! $quizInst[] = $question; } } --- 184,198 ---- stack_question_validate($question,$errors["qu$key"]); ! $options = stack_options_set($question,$quiz_options); if ( '' == $errors["qu$key"] ) { $quizInst[] = stack_question_inst($question,$seed,$options,$errors["qu$key"]); } else { $question = NULL; ! $a = array($qID); ! $question['questionStemInst'] = get_string('Quiz_error_q','stack',$a); ! $question['questionAnsInst'] = 0; ! $question['errors'] = $errors["qu$key"]; ! $quizInst[] = $question; } } *************** *** 196,203 **** ! // (2.7) Get the information from the $_SESSION if ('new_quiz_version' != $action and 'continue_quiz' != $action and 'choose_quiz' != $action) { ! // (2.6.1) Get the quiz from the $_SESSION if (array_key_exists('quiz',$_SESSION)) { $quiz = $_SESSION['quiz']; --- 201,208 ---- ! // (4.7) Get the information about the quiz from the $_SESSION if ('new_quiz_version' != $action and 'continue_quiz' != $action and 'choose_quiz' != $action) { ! // (4.7.1) Get the quiz from the $_SESSION if (array_key_exists('quiz',$_SESSION)) { $quiz = $_SESSION['quiz']; *************** *** 211,215 **** } ! // (2.6.2) Get the quizInst from the $_SESSION if (array_key_exists('quizInst',$_SESSION)) { $quizInst=$_SESSION['quizInst']; --- 216,220 ---- } ! // (4.7.2) Get the quizInst from the $_SESSION if (array_key_exists('quizInst',$_SESSION)) { $quizInst=$_SESSION['quizInst']; *************** *** 218,236 **** } ! // (2.6.3) Ensure that for each question in the quiz, $RawAns exists. foreach ($quizInst as $key => $q) { $RawAns[] = ''; } ! // (2.6.4) Get the list of answers from $_POST if (array_key_exists('RawAns',$_POST) ){ foreach ($_POST['RawAns'] as $key => $q) { $RawAns[$key] = $q; ! } } } ! // (2.8) Mark just one question in the quiz. if ('mark_question' == $action) { // This is a bit of a HACK! We need to get the number into $_POST, --- 223,241 ---- } ! // (4.7.3) Ensure that for each question in the quiz, $RawAns exists. foreach ($quizInst as $key => $q) { $RawAns[] = ''; } ! // (4.7.4) Get the list of answers from $_POST if (array_key_exists('RawAns',$_POST) ){ foreach ($_POST['RawAns'] as $key => $q) { $RawAns[$key] = $q; ! } } } ! // (4.8) Mark just one question in the quiz. if ('mark_question' == $action) { // This is a bit of a HACK! We need to get the number into $_POST, *************** *** 243,247 **** } ! // (2.8) Process responses. This requires a focus/unfocus top-level split if ( 'new_quiz_version' != $action and 'continue_quiz' != $action --- 248,252 ---- } ! // (4.9) Process responses. This requires a focus/unfocus top-level split if ( 'new_quiz_version' != $action and 'continue_quiz' != $action *************** *** 251,255 **** if ($focus) { ! // (2.8.focus) Process one question in the quiz, and don't loose new answers. $key = $focus_on; --- 256,260 ---- if ($focus) { ! // (4.10.focus) Process one question in the quiz, and don't loose new answers. $key = $focus_on; Index: editquiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/editquiz.php,v retrieving revision 1.10.2.3 retrieving revision 1.10.2.4 diff -C2 -d -r1.10.2.3 -r1.10.2.4 *** editquiz.php 14 Jun 2005 15:50:05 -0000 1.10.2.3 --- editquiz.php 14 Jun 2005 17:54:52 -0000 1.10.2.4 *************** *** 164,168 **** if ('quiz_edit' == $action) { ! stack_quiz_edit_form($quiz,&$errors,$PostTo = ''); echo "<p>\n<form name='quizform' action='$PostTo' method='POST'> --- 164,168 ---- if ('quiz_edit' == $action) { ! stack_quiz_edit_form($quiz,$errors,$PostTo = ''); echo "<p>\n<form name='quizform' action='$PostTo' method='POST'> |