From: Juliette W. <jv...@us...> - 2005-06-17 10:55:02
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15612/scripts Modified Files: Tag: frontend_dev stackAuthor.php stackDatabase.php stackQuiz.php Log Message: Fixed one of the problems. Changed quizID to quizid everywhere because I thought this might be the problem, need to decide on how to name things consistently. Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** stackQuiz.php 12 Jun 2005 09:48:37 -0000 1.1 --- stackQuiz.php 17 Jun 2005 10:54:52 -0000 1.1.2.1 *************** *** 8,13 **** */ ! $stackQuiz['quizID']['descript'] = 'Quiz ID number'; ! $stackQuiz['quizID']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; $stackQuiz['quizName']['descript'] = 'Quiz name'; --- 8,13 ---- */ ! $stackQuiz['quizid']['descript'] = 'Quiz ID number'; ! $stackQuiz['quizid']['mysql'] = 'INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY'; $stackQuiz['quizName']['descript'] = 'Quiz name'; Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.16.2.5 retrieving revision 1.16.2.6 diff -C2 -d -r1.16.2.5 -r1.16.2.6 *** stackDatabase.php 16 Jun 2005 14:30:17 -0000 1.16.2.5 --- stackDatabase.php 17 Jun 2005 10:54:52 -0000 1.16.2.6 *************** *** 1033,1045 **** * Confirms a quiz still exists in the database. * ! * @param int $quizID The quizID of the quuiz. * @return boolean */ ! function stack_db_confirm_quiz_exists($quizID) { $exists = FALSE; ! if ('' != $quizID ) { ! $query = 'SELECT quizName FROM stackQuiz WHERE quizID='.$quizID; $result= stack_db_query($query); --- 1033,1045 ---- * Confirms a quiz still exists in the database. * ! * @param int $quizid The quizid of the quuiz. * @return boolean */ ! function stack_db_confirm_quiz_exists($quizid) { $exists = FALSE; ! if ('' != $quizid ) { ! $query = 'SELECT quizName FROM stackQuiz WHERE quizid='.$quizid; $result= stack_db_query($query); *************** *** 1055,1065 **** * Deletes a quiz from the database. * ! * @param int $quizID The quizID of the quuiz. * @return void */ ! function stack_db_quiz_delete($quizID) { ! if ('' != $quizID ) { ! $query = "DELETE FROM stackQuiz WHERE quizID = '$quizID'"; $result= stack_db_query($query); } --- 1055,1065 ---- * Deletes a quiz from the database. * ! * @param int $quizid The quizid of the quuiz. * @return void */ ! function stack_db_quiz_delete($quizid) { ! if ('' != $quizid ) { ! $query = "DELETE FROM stackQuiz WHERE quizid = '$quizid'"; $result= stack_db_query($query); } *************** *** 1067,1086 **** /** ! * Get details of the quiz from the database. If no $quizID is supplied, then all quizzes * are listed instead. * ! * @param int $quizID The quizID number of the quiz needed. * @param boolean $allqs If set to TRUE, then all questions are returned, including hidden ones! * @return array $quiz_list Full information about the quizzes. */ ! function stack_db_quiz_get($quizID='',$allqs=TRUE) { global $stackQuiz; $quiz_list = NULL; $quiz_fields = array_keys($stackQuiz); ! if ('' == $quizID) { $query = "SELECT * FROM stackQuiz"; } else { ! $query = "SELECT * FROM stackQuiz WHERE quizID = '$quizID'"; } $result = stack_db_query($query); --- 1067,1086 ---- /** ! * Get details of the quiz from the database. If no $quizid is supplied, then all quizzes * are listed instead. * ! * @param int $quizid The quizid number of the quiz needed. * @param boolean $allqs If set to TRUE, then all questions are returned, including hidden ones! * @return array $quiz_list Full information about the quizzes. */ ! function stack_db_quiz_get($quizid='',$allqs=TRUE) { global $stackQuiz; $quiz_list = NULL; $quiz_fields = array_keys($stackQuiz); ! if ('' == $quizid) { $query = "SELECT * FROM stackQuiz"; } else { ! $query = "SELECT * FROM stackQuiz WHERE quizid = '$quizid'"; } $result = stack_db_query($query); *************** *** 1101,1107 **** // Obtain all questions in the quizzes. if ($allqs) { ! $query = "SELECT questionID, qord FROM quiz_question WHERE quizID = {$quiz['quizID']} ORDER BY qord"; } else { ! $query = "SELECT questionID, qord FROM quiz_question WHERE quizID = {$quiz['quizID']} AND qord >= 0 ORDER BY qord"; } $questions_result = stack_db_query($query); --- 1101,1107 ---- // Obtain all questions in the quizzes. if ($allqs) { ! $query = "SELECT questionID, qord FROM quiz_question WHERE quizid = {$quiz['quizid']} ORDER BY qord"; } else { ! $query = "SELECT questionID, qord FROM quiz_question WHERE quizid = {$quiz['quizid']} AND qord >= 0 ORDER BY qord"; } $questions_result = stack_db_query($query); *************** *** 1125,1129 **** } ! if ('' == $quizID) { return $quiz_list; } else { --- 1125,1129 ---- } ! if ('' == $quizid) { return $quiz_list; } else { *************** *** 1134,1142 **** /** * Update details of the quiz in the database. ! * If the quizID is blank, or the $quizID is not in the database a new * quiz is created. * * @param array $quiz The quiz. ! * @return int $quizID The quizID of the quiz in question. */ function stack_db_quiz_update($quiz) { --- 1134,1142 ---- /** * Update details of the quiz in the database. ! * If the quizid is blank, or the $quizid is not in the database a new * quiz is created. * * @param array $quiz The quiz. ! * @return int $quizid The quizid of the quiz in question. */ function stack_db_quiz_update($quiz) { *************** *** 1145,1157 **** $quiz_fields = array_keys($stackQuiz); ! $quizID = ''; ! if (array_key_exists('quizID',$quiz)) { ! $quizID = trim($quiz['quizID']); } $new_quiz = FALSE; ! if ('' == $quizID) { $new_quiz = TRUE; ! } else if(!stack_db_confirm_quiz_exists($quizID)) { $new_quiz = TRUE; } --- 1145,1157 ---- $quiz_fields = array_keys($stackQuiz); ! $quizid = ''; ! if (array_key_exists('quizid',$quiz)) { ! $quizid = trim($quiz['quizid']); } $new_quiz = FALSE; ! if ('' == $quizid) { $new_quiz = TRUE; ! } else if(!stack_db_confirm_quiz_exists($quizid)) { $new_quiz = TRUE; } *************** *** 1178,1185 **** $result = stack_db_query($query); ! // GET the last quizID $result= stack_db_query('SELECT LAST_INSERT_ID() FROM stackQuiz'); $row = mysql_fetch_row($result); ! $quizID = $row[0]; } else { --- 1178,1185 ---- $result = stack_db_query($query); ! // GET the last quizid $result= stack_db_query('SELECT LAST_INSERT_ID() FROM stackQuiz'); $row = mysql_fetch_row($result); ! $quizid = $row[0]; } else { *************** *** 1199,1208 **** $qu = substr($qu,1,strlen($qu)-1); ! $query = "UPDATE stackQuiz SET $qu WHERE quizID = '$quizID'"; $result = stack_db_query($query); } ! return $quizID; } --- 1199,1208 ---- $qu = substr($qu,1,strlen($qu)-1); ! $query = "UPDATE stackQuiz SET $qu WHERE quizid = '$quizid'"; $result = stack_db_query($query); } ! return $quizid; } *************** *** 1211,1221 **** * Add a questionID to a quiz * ! * @param int $quizID The quizID number of the quiz needed. * @param int $questionID The questionID of the question! * @return void */ ! function stack_db_quiz_add_question($quizID,$questionID) { ! $query = "INSERT INTO quiz_question (quizID, questionID) VALUES ('$quizID','$questionID')"; $result = stack_db_query($query); } --- 1211,1221 ---- * Add a questionID to a quiz * ! * @param int $quizid The quizid number of the quiz needed. * @param int $questionID The questionID of the question! * @return void */ ! function stack_db_quiz_add_question($quizid,$questionID) { ! $query = "INSERT INTO quiz_question (quizid, questionID) VALUES ('$quizid','$questionID')"; $result = stack_db_query($query); } *************** *** 1224,1235 **** * Drop a questionID from a quiz * ! * @param int $quizID The quizID number of the quiz needed. * @param int $questionID The questionID of the question! * @return int $result The number of table rows dropped. */ ! function stack_db_quiz_drop_question($quizID,$questionID) { ! if ('' != $quizID and '' != $questionID) { ! $query = "DELETE FROM quiz_question WHERE quizID = '$quizID' and questionID= '$questionID'"; $result = stack_db_query($query); } --- 1224,1235 ---- * Drop a questionID from a quiz * ! * @param int $quizid The quizid number of the quiz needed. * @param int $questionID The questionID of the question! * @return int $result The number of table rows dropped. */ ! function stack_db_quiz_drop_question($quizid,$questionID) { ! if ('' != $quizid and '' != $questionID) { ! $query = "DELETE FROM quiz_question WHERE quizid = '$quizid' and questionID= '$questionID'"; $result = stack_db_query($query); } *************** *** 1241,1256 **** * Reorder a questionID within a quiz * ! * @param int $quizID The quizID number of the quiz needed. * @param int $questionID The questionID of the question! * @param int $order * @return int $result The number of table rows dropped. */ ! function stack_db_quiz_reorder_question($quizID,$questionID,$order='NULL') { ! if ('' != $quizID and '' != $questionID) { if ('NULL' === $order) { ! $query = "UPDATE quiz_question SET qord=NULL WHERE quizID='$quizID' AND questionID='$questionID'"; } else { ! $query = "UPDATE quiz_question SET qord='$order' WHERE quizID='$quizID' AND questionID='$questionID'"; } $result = stack_db_query($query); --- 1241,1256 ---- * Reorder a questionID within a quiz * ! * @param int $quizid The quizid number of the quiz needed. * @param int $questionID The questionID of the question! * @param int $order * @return int $result The number of table rows dropped. */ ! function stack_db_quiz_reorder_question($quizid,$questionID,$order='NULL') { ! if ('' != $quizid and '' != $questionID) { if ('NULL' === $order) { ! $query = "UPDATE quiz_question SET qord=NULL WHERE quizid='$quizid' AND questionID='$questionID'"; } else { ! $query = "UPDATE quiz_question SET qord='$order' WHERE quizid='$quizid' AND questionID='$questionID'"; } $result = stack_db_query($query); *************** *** 1264,1275 **** * are listed instead. * ! * @param int $quizID The $quizID number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. * @return void */ ! function stack_db_quiz_quizattempt_store($quizID,$userID,$seed) { ! $query = "INSERT INTO quizAttempts (quizID, userID, Seed ) VALUES ('$quizID','$userID','$seed')"; $result = stack_db_query($query); } --- 1264,1275 ---- * are listed instead. * ! * @param int $quizid The $quizid number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. * @return void */ ! function stack_db_quiz_quizattempt_store($quizid,$userID,$seed) { ! $query = "INSERT INTO quizAttempts (quizid, userID, Seed ) VALUES ('$quizid','$userID','$seed')"; $result = stack_db_query($query); } *************** *** 1278,1282 **** * Record details of the mark for the last attempt. * ! * @param int $quizID The $quizID number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. --- 1278,1282 ---- * Record details of the mark for the last attempt. * ! * @param int $quizid The $quizid number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. *************** *** 1285,1291 **** * @return void */ ! function stack_db_quiz_quizattempt_updatemark($quizID,$userID,$seed,$maxmark,$mark) { ! $query = "UPDATE quizAttempts SET MaxMark='$maxmark', Mark='$mark' WHERE quizID='$quizID' AND userID='$userID' AND Seed='$seed';"; $result = stack_db_query($query); } --- 1285,1291 ---- * @return void */ ! function stack_db_quiz_quizattempt_updatemark($quizid,$userID,$seed,$maxmark,$mark) { ! $query = "UPDATE quizAttempts SET MaxMark='$maxmark', Mark='$mark' WHERE quizid='$quizid' AND userID='$userID' AND Seed='$seed';"; $result = stack_db_query($query); } *************** *** 1294,1305 **** * Record the fact the student has seen the solutions. * ! * @param int $quizID The $quizID number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. * @return void */ ! function stack_db_quiz_quizattempt_seensol($quizID,$userID,$seed) { ! $query = "UPDATE quizAttempts SET SolRequest = '1' WHERE quizID='$quizID' AND userID='$userID' AND Seed='$seed';"; $result = stack_db_query($query); } --- 1294,1305 ---- * Record the fact the student has seen the solutions. * ! * @param int $quizid The $quizid number. * @param int $userID The $userID number. * @param int $seed The $seed used to generate the questions. * @return void */ ! function stack_db_quiz_quizattempt_seensol($quizid,$userID,$seed) { ! $query = "UPDATE quizAttempts SET SolRequest = '1' WHERE quizid='$quizid' AND userID='$userID' AND Seed='$seed';"; $result = stack_db_query($query); } *************** *** 1308,1320 **** * Return the last attempt at a quiz. An array containing the seed and mark are returned. * ! * @param int $quizID The $quizID number. * @param int $userID The $userID number. * @return array $userinfo */ ! function stack_db_quiz_quizattempt_getlast($quizID,$userID) { $userinfo = NULL; ! $query = "SELECT Seed, Mark, MaxMark, SolRequest FROM quizAttempts WHERE quizID = '$quizID' and userID = '$userID'"; $result = stack_db_query($query); --- 1308,1320 ---- * Return the last attempt at a quiz. An array containing the seed and mark are returned. * ! * @param int $quizid The $quizid number. * @param int $userID The $userID number. * @return array $userinfo */ ! function stack_db_quiz_quizattempt_getlast($quizid,$userID) { $userinfo = NULL; ! $query = "SELECT Seed, Mark, MaxMark, SolRequest FROM quizAttempts WHERE quizid = '$quizid' and userID = '$userID'"; $result = stack_db_query($query); Index: stackAuthor.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackAuthor.php,v retrieving revision 1.22.2.3 retrieving revision 1.22.2.4 diff -C2 -d -r1.22.2.3 -r1.22.2.4 *** stackAuthor.php 16 Jun 2005 14:30:17 -0000 1.22.2.3 --- stackAuthor.php 17 Jun 2005 10:54:52 -0000 1.22.2.4 *************** *** 659,663 **** $err = ''; echo "<tr><td><b>{$fields['descript']}</b></td>\n"; ! if ('quizID' == $key) { echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; } else if ('quizOptions' == $key){ --- 659,663 ---- $err = ''; echo "<tr><td><b>{$fields['descript']}</b></td>\n"; ! if ('quizid' == $key) { echo "<td><input type=\"hidden\" name=\"quiz[$key]\" value=\"{$quiz[$key]}\" alt=\"$key\" />{$quiz[$key]}</td><td>".$err.'</td></tr>'; } else if ('quizOptions' == $key){ *************** *** 739,747 **** function stack_quiz_edit(&$quiz,&$errors) { ! // (0) Establish the quizID ! if (array_key_exists('quizID',$quiz)) { ! $quizID = $quiz['quizID']; } else { ! $errors['quiz']['quizID'] = '<br />Could not find a quizID!'; return NULL; } --- 739,747 ---- function stack_quiz_edit(&$quiz,&$errors) { ! // (0) Establish the quizid ! if (array_key_exists('quizid',$quiz)) { ! $quizid = $quiz['quizid']; } else { ! $errors['quiz']['quizid'] = '<br />Could not find a quizid!'; return NULL; } *************** *** 758,762 **** $quID = $qu['questionID']; if (array_key_exists('drop',$qu)) { ! $nodropped = stack_db_quiz_drop_question($quiz['quizID'],$quID); unset($quiz['questions'][$key]); } --- 758,762 ---- $quID = $qu['questionID']; if (array_key_exists('drop',$qu)) { ! $nodropped = stack_db_quiz_drop_question($quiz['quizid'],$quID); unset($quiz['questions'][$key]); } *************** *** 805,811 **** } if ($ordered) { ! stack_db_quiz_reorder_question($quizID,$qu['questionID'],$qu['order']); } else { ! stack_db_quiz_reorder_question($quizID,$qu['questionID']); } } --- 805,811 ---- } if ($ordered) { ! stack_db_quiz_reorder_question($quizid,$qu['questionID'],$qu['order']); } else { ! stack_db_quiz_reorder_question($quizid,$qu['questionID']); } } *************** *** 827,831 **** if (stack_db_confirm_question_exists($quID)) { ! stack_db_quiz_add_question($quizID,$quID); $quiz['questions'][] = array('questionID'=>$quID); } else { --- 827,831 ---- if (stack_db_confirm_question_exists($quID)) { ! stack_db_quiz_add_question($quizid,$quID); $quiz['questions'][] = array('questionID'=>$quID); } else { |