From: Chris S. <san...@us...> - 2005-10-26 17:49:02
|
Update of /cvsroot/stack/stack-1-0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17401 Modified Files: index.php quiz.php Log Message: Index: quiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/quiz.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** quiz.php 11 Oct 2005 17:35:38 -0000 1.43 --- quiz.php 26 Oct 2005 17:48:50 -0000 1.44 *************** *** 97,100 **** --- 97,101 ---- // (4.1) Guest users cannot store information in the DB if ('continue_quiz' == $action and 0 == $user['id']) { + //HACK $action = 'new_quiz_version'; } *************** *** 191,205 **** ///////////////////////////////////////////////////////////// - if ($user['id'] <= 0 or !$user['loggedin']) { - include_once($stack_root."/scripts/stackUser.php"); - $user = stack_user_guest(); - } - // This is used by the remote calling functions. if ('review' == $action) { $student_user = $_POST['userid']; $user = stack_db_user_get_ID($student_user); } ! // (4.5) Reconstruct $quizInst from previous data if ('continue_quiz' == $action or 'review' == $action) { --- 192,206 ---- ///////////////////////////////////////////////////////////// // This is used by the remote calling functions. if ('review' == $action) { + if($user['id'] <= 0 and $user['loggedin']) { $student_user = $_POST['userid']; $user = stack_db_user_get_ID($student_user); + $user['loggedin'] = TRUE; + } else { + $action = 'new_quiz_version'; + } } ! // (4.5) Reconstruct $quizInst from previous data if ('continue_quiz' == $action or 'review' == $action) { *************** *** 207,210 **** --- 208,212 ---- $userinfo = stack_db_quiz_quizattempt_getlast($subjectID,$quizid,$user['id']); + $quiz['seed'] = '#'; if (is_array($userinfo)) { // We have attempted the quiz before with *************** *** 246,280 **** // (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 ! if ( '0' != $user['id']) { ! stack_db_quiz_quizattempt_store($subjectID,$quiz['quizid'],$user['id'],$seed); } ! foreach ($quiz_questions as $key => $qID) { ! $question = stack_db_getquestion($qID); ! stack_question_validate($question,$errors["qu$key"]); ! $options = stack_options_set($question,$quiz_options,$subject_options); ! if ( '' == $errors["qu$key"] ) { ! // We add an offset to the quiz $seed here to make sure each question in the quiz ! // is created with a different seed. A question may appear more than once, ! // if it is instantiated with the same seed we are in trouble. ! $quizInst[] = stack_question_inst($question,$seed+$key,$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; } ! } ! } // (4.7) Get the information about the quiz from the $_SESSION --- 248,308 ---- // (4.6) Start a new quiz if ('new_quiz_version' == $action) { ! $focus = FALSE; ! $new_seed = TRUE; ! $seed = time()+rand(0,30000); ! // Guest users should see their seed, and can return to their version of the quiz using this. ! if (0 == $user['id']) { ! // a seed must be only numbers three to five digits long. ! $seed = rand(0,99999); ! if ($seed<1000) { $seed .+ (1000*rand(1,9)+1000*rand(1,9)); } ! ! if (array_key_exists('seed',$_POST)) { ! if ( '' != $_POST['seed']) { ! $seed = $_POST['seed']; ! $new_seed = FALSE; ! if (!stack_question_validate_seed($seed)) { ! $action = 'quiz_error'; ! $error['quiz'] = get_string('quiz_version_no_err','stack',''); ! } ! } ! } } ! $quiz['seed'] = $seed; ! if ( 'quiz_error' != $action) { ! // Record the information in the DB ! if ( 0 <= $user['id'] and $new_seed) { ! stack_db_quiz_quizattempt_store($subjectID,$quiz['quizid'],$user['id'],$seed); ! } ! foreach ($quiz_questions as $key => $qID) { ! $question = stack_db_getquestion($qID); ! stack_question_validate($question,$errors["qu$key"]); ! ! $options = stack_options_set($question,$quiz_options,$subject_options); ! ! if ( '' == $errors["qu$key"] ) { ! // We add an offset to the quiz $seed here to make sure each question in the quiz ! // is created with a different seed. A question may appear more than once, ! // if it is instantiated with the same seed we are in trouble. ! $quizInst[] = stack_question_inst($question,$seed+$key,$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; ! } } ! } } + if ($user['id'] <= 0 or !$user['loggedin']) { + include_once($stack_root."/scripts/stackUser.php"); + $user = stack_user_guest(); + } + // (4.7) Get the information about the quiz from the $_SESSION *************** *** 568,572 **** echo "\n<a name='top'></a>\n"; echo '<table>'; ! echo '<tr><td><b>'.get_string('stackQuiz_quizName','stack','').'</b></td><td>'.$quiz['quizName'].'</td></tr>'; echo '<tr><td><b>'.get_string('stackOptions_QuizMode','stack','').'</b></td><td>'.$quizmode.'</td></tr>'; echo '<tr><td><b>'.get_string('quiz_page_created','stack','').'</b></td><td>'.$dtnow.'</td></tr>'; --- 596,604 ---- echo "\n<a name='top'></a>\n"; echo '<table>'; ! echo '<tr><td><b>'.get_string('stackQuiz_quizName','stack','').'</b></td><td>'.$quiz['quizName']; ! if ( 0 == $user['id'] ) { ! echo ' ('.get_string('quiz_version_no','stack','').' '.$quiz['seed'].')'; ! } ! echo '</td></tr>'; echo '<tr><td><b>'.get_string('stackOptions_QuizMode','stack','').'</b></td><td>'.$quizmode.'</td></tr>'; echo '<tr><td><b>'.get_string('quiz_page_created','stack','').'</b></td><td>'.$dtnow.'</td></tr>'; *************** *** 633,669 **** if (FALSE==$focus or ($focus and $key==$focus_on)) { ! echo "<center><table bgcolor='#CCCCCC' width='100%' cellpadding='2'><tr> <td align='left'><a name=\"q$qn\"><b>".get_string('Question','stack','')." $qn</b></a></td><td align='right'>"; if ($focus) { ! echo "<a href='#top'>".get_string('Top','stack','')."</a>  "; foreach ($quizInst as $qk => $dum) { $qnn = $qk+1; echo "<a href=\"javascript:takeaction('focus',$qk);\">$qnn</a> "; } ! echo "<a href='#bottom'>".get_string('Bottom','stack','')."</a>  "; } else { //unfocus if ('solutions' != $action and 'review' != $action) { ! echo "<a href=\"javascript:takeaction('focus',$key);\">".get_string('Focus','stack','')."</a> "; } ! echo "<a href='#top'>".get_string('Top','stack','')."</a>  "; foreach ($quizInst as $qk => $dum) { $qnn = $qk+1; echo "<a href='#q$qnn'>$qnn</a> "; } ! echo "<a href='#bottom'>".get_string('Bottom','stack','')."</a>  "; } if ('solutions' != $action and 'review' != $action) { ! echo" <a href=\"javascript:takeaction('validate',0);\">".get_string('Validate','stack','')."</a>  <a href=\"javascript:takeaction('mark_question',$key);\">".get_string('MarkThisQ','stack','')."</a>  "; } ! echo "<a href=\"javascript:HelpPopup('student','');\">".get_string('Help','stack','')."</a></td> ! </tr></table></center>"; // (1) Pose the question --- 665,700 ---- if (FALSE==$focus or ($focus and $key==$focus_on)) { ! echo "\n\n<center><table bgcolor='#CCCCCC' width='100%' cellpadding='2'><tr> <td align='left'><a name=\"q$qn\"><b>".get_string('Question','stack','')." $qn</b></a></td><td align='right'>"; if ($focus) { ! echo "\n\n<a href='#top'>".get_string('Top','stack','')."</a>  "; foreach ($quizInst as $qk => $dum) { $qnn = $qk+1; echo "<a href=\"javascript:takeaction('focus',$qk);\">$qnn</a> "; } ! echo "\n<a href='#bottom'>".get_string('Bottom','stack','')."</a>  "; } else { //unfocus if ('solutions' != $action and 'review' != $action) { ! echo "\n<a href=\"javascript:takeaction('focus',$key);\">".get_string('Focus','stack','')."</a> "; } ! echo "\n<a href='#top'>".get_string('Top','stack','')."</a>  "; foreach ($quizInst as $qk => $dum) { $qnn = $qk+1; echo "<a href='#q$qnn'>$qnn</a> "; } ! echo "\n<a href='#bottom'>".get_string('Bottom','stack','')."</a>  "; } if ('solutions' != $action and 'review' != $action) { ! echo"\n<a href=\"javascript:takeaction('validate',0);\">".get_string('Validate','stack','')."</a>  <a href=\"javascript:takeaction('mark_question',$key);\">".get_string('MarkThisQ','stack','')."</a>  "; } ! echo "\n<a href=\"javascript:HelpPopup('student','');\">".get_string('Help','stack','')."</a></td></tr>\n\n</table>\n</center>"; // (1) Pose the question *************** *** 693,700 **** // Show a review table. if ('review' == $action) { ! echo "<p><table bgcolor='#CCCCCC' width='100%' cellpadding='2'><tr><td>"; stack_question_inst_show_attempts($qInst,$errors); ! echo "</td></tr><tr><td><b>".get_string('QTestQuestionNote','stack','')."</b> ".nsf($qInst,'questionNoteInst'); ! echo "</td></tr></table></p>"; stack_question_inst_show_sol($qInst,$errors); } --- 724,731 ---- // Show a review table. if ('review' == $action) { ! echo "\n<p>\n<table bgcolor='#CCCCCC' width='100%' cellpadding='2'>\n <tr><td>"; stack_question_inst_show_attempts($qInst,$errors); ! echo "</td></tr>\n <tr><td><b>".get_string('QTestQuestionNote','stack','')."</b> ".nsf($qInst,'questionNoteInst'); ! echo "</td></tr>\n</table></p>\n"; stack_question_inst_show_sol($qInst,$errors); } Index: index.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/index.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** index.php 25 Oct 2005 16:38:44 -0000 1.32 --- index.php 26 Oct 2005 17:48:50 -0000 1.33 *************** *** 120,123 **** --- 120,124 ---- case 'loginscreen': echo '<h1>'.get_string('FE_index_loginscreen_title','stack','').'</h1>'; + echo get_string('FE_index_loginscreen_guestok','stack',''); echo '<form action="index.php" method="post" name="login" id="login"><table><tr>'; echo '<td align="right">'.get_string('USR_Username','stack','').'</td>'; *************** *** 131,135 **** </table></form>'; - echo get_string('FE_index_loginscreen_guestok','stack',''); echo '<form action="index.php" method="post" name="guestlogin">'; --- 132,135 ---- |