Jump to content

AdmiralQ

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by AdmiralQ

  1. So, I just don't know where to post this question. I've written a quiz program where 50 English vocab words are pulled from a dB and displayed on one page with the order scrambled. My students then type the Spanish translation for each. When they submit the form the next page grades their work. They have to get a 90 or better for the grade to be automatically recorded, so I want them to click the back button and go back and make corrections. The problem is when they use a Chrome browser and click the back button the program re-sorts the order of questions. It leaves the order of their answers the same. So what they answered for number 1 is still in the field for number 1, but the questions (the English vocab word) is different. Chrome does this consistently so I thought this was a Chrome issue only. Then one of my students said the same thing happened to her when using Safari. So here is my question, how can I stop Chrome (or any other browser) from re-running my server-side PHP scripts (re-sorting the vocab array) when clicking the back button? Here is the code for students taking the quiz: <form method="post" action="portal.php?load=vquiz_grade" style="margin-left: 50px; line-height: 30px;"> <table> <? $count = 1; $query = "SELECT * FROM inno_memorize WHERE uname = 'admiralq' AND subject = '$subject' AND title = '$title' ORDER BY subject, title"; $result= mysql_query($query) or die("Could not perform query: ".mysql_error()); while ($row = mysql_fetch_array($result)){ $ans[$count]['def'] = $row['definition']; $ans[$count]['word'] = $row['vocab_word']; $count++; } $max = $count-1; shuffle($ans); $count = 0; while ($count < $max){ // Search for () and eliminate along with contents $loc1 = strpos($ans[$count]['word'], "("); $loc2 = strpos($ans[$count]['word'], ")"); if ($loc1 != "" AND $loc2 != ""){ // string length $length = strlen($ans[$count]['word']); // from loc2 to end $lcount = $length - $loc2; // Dump location points and all text inbetween $ans[$count]['word'] = substr($ans[$count]['word'], 0, ($loc1-1)).substr($ans[$count]['word'], ($loc2+1)); } print "<tr><td>".($count+1).". <textarea id=\"kelp".$count."\" cols=25 rows=1 name=\"answer".$count."\" style=\"resize: none;\" autocomplete=\"off\"></textarea>&nbsp;</td>"; print "<td>".$ans[$count]['def']."</td>"; print "<td><input type=\"hidden\" name=\"correct".$count."\" value=\"".$ans[$count]['word']."\"></td>"; ?> <td> <span style="margin: 0px 0px 20px 50px;"> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&aacute;');">&aacute;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&eacute;');">&eacute;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&iacute;');">&iacute;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&oacute;');">&oacute;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&uacute;');">&uacute;</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&ntilde;');">&ntilde;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&iquest;');">&iquest;</button> <button type="button" onclick="insertAtCursor('kelp<?print $count?>', '&iexcl;');">&iexcl;</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span> </td> </tr> <? //print "<br>"; $count++; } ?> </table> <input type="hidden" name="max" value="<?print $max?>"> <input type="hidden" name="title" value="<?print $title?>"> <input type="hidden" name="subject" value="<?print $subject?>"> <input type="hidden" name="vlist" value="<?print $vlist?>"> <input type="hidden" name="lname" value="<?print $secure_lname?>"> <input type="hidden" name="fname" value="<?print $secure_fname?>"> <input type="hidden" name="secure_uname" value="<?print $secure_uname?>"> <input type="hidden" name="key_code" value="<?print $key_code?>"> <input type="hidden" name="vocab_quiz" value="1"> <input type="hidden" name="id" value="<?print $id?>"> <input type="submit"> </form> And here is the code showing them what they missed. <? $count = 0; $wcount = 0; $rcount = 0; // Total grade while ($count < $max){ if (trim(strtolower(${'answer'.$count})) == trim(strtolower(${'correct'.$count}))){$rcount++;} else {$wcount++;} $count++; } print "You missed ".$wcount." words.<br>"; $grade = $rcount / ($rcount+$wcount)*100; print "Your grade: ".round($grade)."<br>"; $count = 0; $wrong = 0; print "<table>"; print "<tr><td height=\"10\"></td></tr>"; while ($count < $max){ $tcolor = "0a0a0a"; // Grade response and set color if (trim(strtolower(${'answer'.$count})) == trim(strtolower(${'correct'.$count}))){$tcolor = "ff7777";} else {$tcolor = "000000"; $wrong = 1;} if ($wrong == 1){ print "<tr>"; print "<td>".($count+1).".&nbsp;</td>"; print "<td><span style=\"color: #".$tcolor.";\">".${'answer'.$count}."</span></td>"; print "<td><span style=\"color: #ff5555;\"> - ".${'correct'.$count}."</span></td>"; print "</tr>"; $wrong = 0; } $count++; } print "</table>"; if ($grade >= 90){ $query = "SELECT * FROM inno_vocab_assignments WHERE key_code = '$key_code' AND uname = '$secure_uname' AND teacher = '$teacher'"; $result= mysql_query($query) or die("Could not perform query: ".mysql_error()); if (mysql_num_rows($result) == 0){ // Prevent student from changing vocab list so as to do an easier list $query = "SELECT * FROM inno_grading_period WHERE uname = '{$_SESSION['student']['teacher']}' AND voc_title = '$title' AND subject = '$subject'"; $result= mysql_query($query) or die("Could not perform query: ".mysql_error()); if (mysql_num_rows($result) > 0){ // Insert grade $query = "INSERT INTO inno_vocab_assignments (uname, course_title, list_title, type, stamp, grade, key_code, course_id, teacher, lname, fname) VALUES ('$secure_uname', '$subject', '$title', 'typing', '".date("U")."', '$grade', '$key_code', '$course_id', '$teacher', '$lname', '$fname')"; $result= mysql_query($query) or die("Could not perform query: ".mysql_error()); print "<br><b>RESULT: Congratulations! Your quiz was recorded.</b><br><br><br><br>"; } else{ print "<span style=\"color: #ff5555; font-weight: bold;\">This vocab list was not assigned! The teacher has been notified of this attempt!<br>The assignment has NOT been recorded!</span>"; } } else {print "<br><b>THIS HAS ALREADY BEEN RECORDED!<br>You cannot submit the same assignment more than once.</b>";} } else{ print "<br><b>RESULT: Your score was below a 90 and so was not recorded. Click back to make corrections.</b><br><br><br><br><br>"; } ?> Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.