From: Chris S. <san...@us...> - 2005-06-20 15:43:38
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/scripts Modified Files: moodlelib.php stackAuthor.php stackDatabase.php stackQuestion.php stackQuiz.php stackUser.php stackUtility.php stackWin.php stackXML.php Removed Files: en.php nl.php Log Message: Major changes to the font end. Attempt 1. Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** stackDatabase.php 10 Jun 2005 18:40:25 -0000 1.16 --- stackDatabase.php 20 Jun 2005 15:42:55 -0000 1.17 *************** *** 109,116 **** global $_PHP_SELF; if ('try' == $action) { ! $filter = 'demo'; } ! $query = 'SELECT questionID, questionName, questionDescription, questionKeywords, DATE_FORMAT(questionDateLastEdited,"%k:%i, %d/%m/%y"), questionGUID --- 109,127 ---- global $_PHP_SELF; + + // Sort out how we are going to filter questions. + if ('' === $filter) { + $filter['kw'] = ''; + $filter['name'] = ''; + } if ('try' == $action) { ! $filter['kw'] = 'demo'; ! $filter['name'] = ''; } ! ! $filter_name = $filter['name']; ! $filter_kw = $filter['kw']; ! ! // Build the query to the database. $query = 'SELECT questionID, questionName, questionDescription, questionKeywords, DATE_FORMAT(questionDateLastEdited,"%k:%i, %d/%m/%y"), questionGUID *************** *** 135,142 **** echo "<th><a href=\"javascript:SelectQs('edit_metadata');\">Filter</a></th>"; } else { ! echo "<th><a href=\"javascript:SelectQs('startover');\">Filter</a></th>"; } ! echo "<th></th><th></th> <th> <input type='text' name='bank_filter' value='$filter' /> ! </th></tr></thead><tbody>"; } for ($i = 0; $i < mysql_num_rows($result); $i++) { --- 146,154 ---- echo "<th><a href=\"javascript:SelectQs('edit_metadata');\">Filter</a></th>"; } else { ! echo "<th><a href=\"javascript:SelectQs('questionbank_screen');\">Filter</a></th>"; } ! echo "<th></th><th><input type='text' name='bank_filter[name]' value='$filter_name' /> ! </th> <th> <input type='text' name='bank_filter[kw]' value='$filter_kw' /> ! </th> </tr></thead><tbody>"; } for ($i = 0; $i < mysql_num_rows($result); $i++) { *************** *** 144,160 **** $qkeywords = stripslashes($row[3]); ! $dispQ = TRUE; ! if ('' != $filter) { ! $dispQ = strpos($qkeywords,$filter); } if (FALSE !== $dispQ) { - if ('' == $row[1]) { - $qname = ''; - } - else - { - $qname = stripslashes($row[1]); - } $guid = $row[5]; --- 156,169 ---- $qkeywords = stripslashes($row[3]); ! if ('' == $row[1]) { ! $qname = ''; ! } else { ! $qname = stripslashes($row[1]); } + + // Decide how to filter questions + $dispQ = stack_db_question_filter($qname,$qkeywords,$filter_name,$filter_kw); if (FALSE !== $dispQ) { $guid = $row[5]; *************** *** 167,174 **** echo('<td>' . $qkeywords . '</td>'); echo "\n<td nowrap='nowrap'><a href=\"javascript:SelectQ('$row[0]','edit_from_db');\">edit</a> ! <a href=\"javascript:SelectQ('$row[0]','try_from_db');\">try</a> <a href=\"javascript:SelectQ('$row[0]','export_xml_db');\">xml</a>"; if ('edit'==$action) { ! echo "\n<a href=\"javascript:SelectQ('$row[0]','delete_from_db');\"><font color=\"red\">del</font></a>"; } echo "\n</td>"; --- 176,183 ---- echo('<td>' . $qkeywords . '</td>'); echo "\n<td nowrap='nowrap'><a href=\"javascript:SelectQ('$row[0]','edit_from_db');\">edit</a> ! <a href=\"javascript:SelectQ('$row[0]','preview_from_db');\">try</a> <a href=\"javascript:SelectQ('$row[0]','export_xml_db');\">xml</a>"; if ('edit'==$action) { ! echo "\n<a href=\"javascript:SelectQ('$row[0]','delete');\"><font color=\"red\">del</font></a>"; } echo "\n</td>"; *************** *** 219,222 **** --- 228,239 ---- { // List all the questions in the database + // Sort out how we are going to filter questions. + if ('' === $filter) { + $filter['kw'] = ''; + $filter['name'] = ''; + } + $filter_name = $filter['name']; + $filter_kw = $filter['kw']; + $query = 'SELECT questionID, questionName, questionKeywords *************** *** 228,232 **** echo '<table><thead><tr>'; ! echo "<tr><th>Add</th><th>Question no.</th><th>Name</th> <th>Key words</th></tr>\n"; echo "\n</thead><tbody>\n"; --- 245,249 ---- echo '<table><thead><tr>'; ! echo "<tr><th>Add</th><th>Question no.</th><th>Name</th> <th>Keyword</th></tr>\n"; echo "\n</thead><tbody>\n"; *************** *** 234,242 **** $row = mysql_fetch_row($result); $qkw = stripslashes($row[2]); ! $dispQ = TRUE; ! if ('' != $filter) { ! $dispQ = strpos($qkw,$filter); ! } if (FALSE !== $dispQ) { --- 251,257 ---- $row = mysql_fetch_row($result); + $name = stripslashes($row[1]); $qkw = stripslashes($row[2]); ! $dispQ = stack_db_question_filter($name,$qkw,$filter_name,$filter_kw); if (FALSE !== $dispQ) { *************** *** 244,255 **** $qname = ''; ! if ('' != $row[1]) { ! $qname = stripslashes($row[1]); ! $qname = "<a href=\"javascript:EditPopup('$qID');\">{$qname}</a>"; } echo "<tr><td><input type=\"checkbox\" name=\"questionsToAdd[$qID][add]\" value=\"ticked\" /></td>\n"; ! echo "<td>$qID</td><td>$qname</td><td>$qkw</td> </tr>\n"; } // End preg_match to display each line. --- 259,269 ---- $qname = ''; ! if ('' != $name) { ! $name = "<a href=\"javascript:EditPopup('$qID');\">{$name}</a>"; } echo "<tr><td><input type=\"checkbox\" name=\"questionsToAdd[$qID][add]\" value=\"ticked\" /></td>\n"; ! echo "<td>$qID</td><td>$name</td><td>$qkw</td> </tr>\n"; } // End preg_match to display each line. *************** *** 265,268 **** --- 279,310 ---- } + + /** + * Decides whether to display a question based upon the name, keywords and filter. + * + * @param $name string Question name. + * @param $kw string Question keywords. + * @param $filter_name string Filter to be applied to the name. + * @param $filter_kw string Filter to be applied to the name. + * @return $dispQ boolean + */ + function stack_db_question_filter($name,$kw,$filter_name,$filter_kw) { + + $dispQ = TRUE; + + if ('' != $filter_kw) { + if ('' != $filter_name) { + $dispQ = max(strpos($kw,$filter_kw),strpos($name,$filter_name)); + } else { + $dispQ = strpos($kw,$filter_kw); + } + } else if ('' != $filter_name) { + $dispQ = strpos($name,$filter_name); + } + + return($dispQ); + } + + /** * Add or edit a question in the database. *************** *** 991,1003 **** * 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); *************** *** 1013,1023 **** * 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); } *************** *** 1025,1044 **** /** ! * 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); *************** *** 1059,1065 **** // 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); *************** *** 1083,1087 **** } ! if ('' == $quizID) { return $quiz_list; } else { --- 1125,1129 ---- } ! if ('' == $quizid) { return $quiz_list; } else { *************** *** 1092,1100 **** /** * 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) { *************** *** 1103,1115 **** $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; } *************** *** 1136,1143 **** $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 { *************** *** 1157,1166 **** $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; } *************** *** 1169,1179 **** * 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); } *************** *** 1182,1193 **** * 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); } *************** *** 1199,1214 **** * 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); *************** *** 1222,1233 **** * 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); } *************** *** 1236,1240 **** * 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. *************** *** 1243,1249 **** * @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); } *************** *** 1252,1263 **** * 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); } *************** *** 1266,1278 **** * 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.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** stackAuthor.php 13 Jun 2005 11:51:30 -0000 1.23 --- stackAuthor.php 20 Jun 2005 15:42:55 -0000 1.24 *************** *** 192,202 **** // Buttons to go somewhere next if ($stack_stand_alone) { ! echo "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { ! echo "<a href=\"javascript:EditQ('try')\">Try this question</a> \n"; ! echo "<a href=\"javascript:EditQ('export_xml')\">Export XML</a> \n"; if ('admin'==$user['username']) { ! echo "<a href=\"javascript:EditQ('store_in_db')\">Store question</a>\n ! <a href=\"javascript:EditQ('store_new_db')\">Store as a new question</a>\n"; } } --- 192,202 ---- // Buttons to go somewhere next if ($stack_stand_alone) { ! echo "<a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { ! echo "<a href=\"javascript:EditQ('preview')\">Try question</a> \n"; ! echo "<a href=\"javascript:EditQ('export_xml')\">Export as XML</a> \n"; if ('admin'==$user['username']) { ! echo "<a href=\"javascript:EditQ('save')\">Store question</a>\n ! <a href=\"javascript:EditQ('save_as')\">Store as a new question </a>\n"; } } *************** *** 271,277 **** // Potential responses ! echo "<br /><a href=\"javascript:EditQ('edit')\">Add</a>\n"; echo '<input type="input" name="questionPotResp[add]" value="0" size="3" />'; ! echo " potential responses<a href=\"javascript:HelpPopup('all','stackQuestionPotResp');\"><img align=\"middle\" border=\"0\" height=\"17\" width=\"17\" src=\"pics/help.gif\" /></a> (distractors etc).<br />"; if (array_key_exists('questionPotResp',$question)) { --- 271,277 ---- // Potential responses ! echo "<br /><a href=\"javascript:EditQ('edit')\">Edit</a> and add \n"; echo '<input type="input" name="questionPotResp[add]" value="0" size="3" />'; ! echo " potential responses<a href=\"javascript:HelpPopup('all','author_potresp');\"><img align=\"middle\" border=\"0\" height=\"17\" width=\"17\" src=\"pics/help.gif\" /></a> (distractors etc).<br />"; if (array_key_exists('questionPotResp',$question)) { *************** *** 320,328 **** echo "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { ! echo "<a href=\"javascript:EditQ('try')\">Try this question</a> \n"; ! echo "<a href=\"javascript:EditQ('export_xml')\">Export XML</a> \n"; if ('admin'==$user['username']) { ! echo "<a href=\"javascript:EditQ('store_in_db')\">Store question</a>\n ! <a href=\"javascript:EditQ('store_new_db')\">Store as a new question</a>\n"; } } --- 320,328 ---- echo "<p><a href=\"javascript:EditQ('edit')\">Edit question</a> \n"; if (''==$errors) { ! echo "<a href=\"javascript:EditQ('preveiw')\">Try question</a> \n"; ! echo "<a href=\"javascript:EditQ('export_xml')\">Export as XML</a> \n"; if ('admin'==$user['username']) { ! echo "<a href=\"javascript:EditQ('save')\">Store question</a>\n ! <a href=\"javascript:EditQ('save_as')\">Store as a new question</a>\n"; } } *************** *** 660,664 **** $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){ --- 660,664 ---- $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){ *************** *** 740,748 **** 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; } --- 740,748 ---- 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; } *************** *** 759,763 **** $quID = $qu['questionID']; if (array_key_exists('drop',$qu)) { ! $nodropped = stack_db_quiz_drop_question($quiz['quizID'],$quID); unset($quiz['questions'][$key]); } --- 759,763 ---- $quID = $qu['questionID']; if (array_key_exists('drop',$qu)) { ! $nodropped = stack_db_quiz_drop_question($quiz['quizid'],$quID); unset($quiz['questions'][$key]); } *************** *** 806,812 **** } if ($ordered) { ! stack_db_quiz_reorder_question($quizID,$qu['questionID'],$qu['order']); } else { ! stack_db_quiz_reorder_question($quizID,$qu['questionID']); } } --- 806,812 ---- } if ($ordered) { ! stack_db_quiz_reorder_question($quizid,$qu['questionID'],$qu['order']); } else { ! stack_db_quiz_reorder_question($quizid,$qu['questionID']); } } *************** *** 828,832 **** if (stack_db_confirm_question_exists($quID)) { ! stack_db_quiz_add_question($quizID,$quID); $quiz['questions'][] = array('questionID'=>$quID); } else { --- 828,832 ---- if (stack_db_confirm_question_exists($quID)) { ! stack_db_quiz_add_question($quizid,$quID); $quiz['questions'][] = array('questionID'=>$quID); } else { Index: stackXML.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackXML.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stackXML.php 1 Apr 2005 18:59:31 -0000 1.2 --- stackXML.php 20 Jun 2005 15:42:55 -0000 1.3 *************** *** 66,70 **** $xml .= $pad." <{$tag}_ord order=\"$key\">\n".stack_xml_create_question_frag($orderdata,$depth+6)."$pad </{$tag}_ord>\n"; } ! $xml .= $pad."</$tag>\n";; } else { // Just a regular open tag. --- 66,70 ---- $xml .= $pad." <{$tag}_ord order=\"$key\">\n".stack_xml_create_question_frag($orderdata,$depth+6)."$pad </{$tag}_ord>\n"; } ! $xml .= $pad."</$tag>\n"; } else { // Just a regular open tag. *************** *** 127,132 **** function stack_xml_write_quiz_file($quiz, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory ! ! $xml_file_name = 'stack_quiz.xml'; // create the file we will use for writing --- 127,133 ---- function stack_xml_write_quiz_file($quiz, $directory) { // takes a $stackQuestion array and writes it to an XML file in $directory ! ! ! $xml_file_name = 'stack_quiz_'.time().'.xml'; // create the file we will use for writing Index: stackQuiz.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuiz.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** stackQuiz.php 12 Jun 2005 09:48:37 -0000 1.1 --- stackQuiz.php 20 Jun 2005 15:42:55 -0000 1.2 *************** *** 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'; *************** *** 26,28 **** --- 26,71 ---- $stackQuiz['quizMode']['mysql'] = 'TINYTEXT'; + /* + * Displays the student quiz selection screen + * @param array $quize_store The list of quizzes + * @param $user + * @return void + */ + function stack_quiz_student_select($quiz_store, $user) { + global $stack_root; + + require_once("{$stack_root}/html/quizjava.html"); + echo "<h1>Please choose a quiz to try</h1>"; + global $stackQuiz; + if (is_array($quiz_store)) { + echo "<p>\n<form name='quizform' action='quiz.php' method='POST'> + <input type='hidden' name='quizid' value='-1'> + <input type='hidden' name='action' value='continue_quiz'>"; + echo "\n<table cellpadding='2'>\n"; + echo "\n<tr><th>{$stackQuiz['quizName']['descript']}</th><th>{$stackQuiz['quizDescription']['descript']}</th><th>Last mark (%)</th></tr>"; + foreach ($quiz_store as $qs => $quiz) { + $qname = $quiz['quizName']; + $qID = $quiz['quizid']; + $mark = '-'; + if (is_array($user)) { + if (array_key_exists('id',$user)) { + $userinfo = stack_db_quiz_quizattempt_getlast($qID,$user['id']); + if (is_array($userinfo)) { + if (NULL != $userinfo['mark']) { + $mark = round(100*$userinfo['mark']/$userinfo['maxmark'],2); + } + } + } + } + + echo "<tr><td><a href=\"javascript:takeaction('continue_quiz','$qID');\">{$qname}</a></td>\n"; + echo "<td>".$quiz['quizDescription']."</td><td align='center'>$mark</td></tr>\n"; + } + echo "\n</table>\n</form>\n</p>"; + } else { + echo "<p>You have no quizzes available to try.</p>"; + } + } + + ?> Index: stackQuestion.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackQuestion.php,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** stackQuestion.php 10 Jun 2005 20:53:16 -0000 1.19 --- stackQuestion.php 20 Jun 2005 15:42:55 -0000 1.20 *************** *** 331,335 **** } } else { ! $errors[$qfield] = get_string('QValidRequiredField','stack','');; $question[$qfield] = ''; } --- 331,335 ---- } } else { ! $errors[$qfield] = get_string('QValidRequiredField','stack',''); $question[$qfield] = ''; } *************** *** 443,447 **** foreach ($cas_keywords as $cas_kw) { if (in_array($locvar['key'],$stack_cas[$cas_kw])) { ! $errors[$keyvals_name_raw][$locvar['key']] = $locvar['key']." ".get_string('QValidMaximaName','stack','');; } } --- 443,447 ---- foreach ($cas_keywords as $cas_kw) { if (in_array($locvar['key'],$stack_cas[$cas_kw])) { ! $errors[$keyvals_name_raw][$locvar['key']] = $locvar['key']." ".get_string('QValidMaximaName','stack',''); } } *************** *** 595,601 **** global $stackQuestion,$stackQuestionPotResp; $errstr = ''; - if (is_array($errors)) { ! $errstr = "<b>The item is invalid, and the following field(s) contain errors.</b><br />\n\n"; $errstr .= "<table border='1' cellpadding='2'>"; foreach ($errors as $qfield => $err) { --- 595,600 ---- global $stackQuestion,$stackQuestionPotResp; $errstr = ''; if (is_array($errors)) { ! $errstr = '<b>'.get_string('QValidSummaryTable0','stack')."</b><br />\n\n"; $errstr .= "<table border='1' cellpadding='2'>"; foreach ($errors as $qfield => $err) { *************** *** 603,607 **** if ('questionPotResp' == $qfield) { foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td colspan='2'><b>Potential response '$varname' </b></td></tr>\n"; foreach ($varerr as $prf => $pre) { if (is_array($pre) ) { --- 602,606 ---- if ('questionPotResp' == $qfield) { foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td colspan='2'><b>".get_string('QValidSummaryTable3','stack',$varname)." </b></td></tr>\n"; foreach ($varerr as $prf => $pre) { if (is_array($pre) ) { *************** *** 620,627 **** } ! if ('questionVarsRaw' == $qfield) { ! $errstr .= "\n<tr><td colspan='2'>One or more of the <b>".$stackQuestion[$qfield]['descript']."</b> contained error(s), as follows.</td></tr>"; foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td>The variable '$varname': </td><td>".$varerr."</td></tr>\n"; } $errstr .= "<tr><td> </td><td> </td></tr>\n"; --- 619,627 ---- } ! if ('questionVarsRaw' == $qfield or 'questionAnsVarsRaw' == $qfield) { ! $a = get_string('stackQuestion_'.$qfield,'stack'); ! $errstr .= "\n<tr><td colspan='2'>".get_string('QValidSummaryTable1','stack',$a).'</td></tr>'; foreach($err as $varname => $varerr) { ! $errstr .= "\n<tr><td>".get_string('QValidSummaryTable2','stack',$varname)."</td><td>".$varerr."</td></tr>\n"; } $errstr .= "<tr><td> </td><td> </td></tr>\n"; *************** *** 629,633 **** } else { ! $errstr .= '<tr><td><b>'.$stackQuestion[$qfield]['descript'].":</b></td><td> ".$err."</td></tr>\n\n"; } --- 629,634 ---- } else { ! $fname = get_string('stackQuestion_'.$qfield,'stack'); ! $errstr .= '<tr><td><b>'.$fname.":</b></td><td> ".$err."</td></tr>\n\n"; } *************** *** 683,687 **** // 'Language'; $stackOptions['Language']['type'] = 'list'; ! $stackOptions['Language']['values'] = array('en','nl'); $stackOptions['Language']['default'] = 'en'; --- 684,688 ---- // 'Language'; $stackOptions['Language']['type'] = 'list'; ! $stackOptions['Language']['values'] = array('en','es','nl'); $stackOptions['Language']['default'] = 'en'; *************** *** 1014,1018 **** } - // Now put the implicit question variables back into the castext strings. --- 1015,1018 ---- *************** *** 1020,1029 **** $err_when_inst = "<br /><font color=\"red\">CAS ERROR when instantiated!</font> "; foreach($stackQuestion as $qfield => $val) { if ('castext' == $stackQuestion[$qfield]['type'] and array_key_exists($qfield,$question)) { $errct = ''; ! $questionInst["{$qfield}Inst"]= stack_castext_to_display($question["{$qfield}Inst"], $imp_locs_Inst, $options['Display'] , $errct); ! ! if (''!=$errct) { // We have some errors! $errors[$qfield]=$err_when_inst.$errct; } --- 1020,1030 ---- $err_when_inst = "<br /><font color=\"red\">CAS ERROR when instantiated!</font> "; + $displayed = $options['Display']; + foreach($stackQuestion as $qfield => $val) { if ('castext' == $stackQuestion[$qfield]['type'] and array_key_exists($qfield,$question)) { $errct = ''; ! $questionInst["{$qfield}Inst"] = stack_castext_to_display($question["{$qfield}Inst"], $imp_locs_Inst, $displayed , $errct); ! if ('' != $errct) { // We have some errors! $errors[$qfield]=$err_when_inst.$errct; } *************** *** 1740,1744 **** $RawAns = $this_attempt['RawAns']; - // (2) Pose the ``question" stack_question_inst_displayq($questionInst); --- 1741,1744 ---- *************** *** 1846,1850 **** echo $options['FeedBackGenericCorrect']; } else if (0==$this_attempt['RawMark']) { ! echo $options['FeedBackGenericIncorrect'];; } else { echo $options['FeedBackGenericPCorrect']; --- 1846,1850 ---- echo $options['FeedBackGenericCorrect']; } else if (0==$this_attempt['RawMark']) { ! echo $options['FeedBackGenericIncorrect']; } else { echo $options['FeedBackGenericPCorrect']; Index: stackUtility.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUtility.php,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** stackUtility.php 12 Jun 2005 16:10:01 -0000 1.22 --- stackUtility.php 20 Jun 2005 15:42:55 -0000 1.23 *************** *** 14,17 **** --- 14,19 ---- } require_once("{$stack_root}/scripts/stackQuiz.php"); + require_once("{$stack_root}/scripts/stackUser.php"); + require_once("{$stack_root}/frontend_general/frontend_util.php"); /** *************** *** 26,30 **** /** ! * Synonym for the PHP function htmlspecialchars * * @param string $str The input string. --- 28,32 ---- /** ! * Synonym for the PHP function htmlspecialchars. See the Moodle function s(.) * * @param string $str The input string. *************** *** 108,112 **** * @return array Field [0] contains the string between the two characters, Field [1] contains the start position of -1 if it does not exist and Field [2] contains the end position of -1 if there was no match. */ ! function GrabBetween($strin,$leftc,$rightc,$start) { // Starting at $start, (a number) // Find the first occurance of $leftc, match with an occurance of --- 110,114 ---- * @return array Field [0] contains the string between the two characters, Field [1] contains the start position of -1 if it does not exist and Field [2] contains the end position of -1 if there was no match. */ ! function stack_util_grabbetween($strin,$leftc,$rightc,$start) { // Starting at $start, (a number) // Find the first occurance of $leftc, match with an occurance of *************** *** 159,162 **** --- 161,166 ---- return $ret; } + + // ********************************************************** *************** *** 355,359 **** } ! // (3) Check for missing *'s // hack: This needs some careful thought. // We can't simply check for adjcent letters. For example sin(x) is ok, xsin(x) is not! --- 359,414 ---- } ! // (3) We should only allow certain strings in student's answers. ! // These are kept in $stack_cas['studentAllow'], and are generated on the fly from ! // the CAS docs. ! ! if ($stack_cas['strict']) { ! // Match more then one occurance ! $pat = "|[\?_A-Za-z0-9]+|"; ! preg_match_all($pat,$strout,$out,PREG_PATTERN_ORDER); ! ! ! // Filter out some of these matches. ! $strin_keywords=''; ! foreach($out[0] as $key) { ! // Do we have only numbers, or only 2 characters? ! // These strings are fine. ! preg_match("|[0-9]+|",$key,$justnum); ! ! if (empty($justnum) and strlen($key)>2) { ! $strin_keywords[] = $key; ! } ! } ! ! // Students are only allowed certain strings. ! if ('t' != $seclevel) { ! // Make sure each one is really an allowed keyword ! if (is_array($strin_keywords)) { ! foreach ($strin_keywords as $strinkey) { ! ! if (!in_array(strtoupper($strinkey),$stack_cas['studentAllow'])) { ! // We are in trouble! ! $a = array('key' => stack_s($strinkey)); ! $ret.='<br />'.get_string('UnknownFun','stack',$a); ! } ! } ! } ! } else { // End of keyword checks for students ! // Make sure a teacher has not entered an unsupported function. ! if (is_array($strin_keywords)) { ! foreach ($strin_keywords as $strinkey) { ! ! if (in_array(strtoupper($strinkey),$stack_cas['teacherNotAllow'])) { ! // We are in trouble! ! $a = array('key' => stack_s($strinkey)); ! $ret.='<br />'.get_string('NotSupported','stack',$a); ! } ! } ! } ! ! } ! } ! ! // (4) Check for missing *'s // hack: This needs some careful thought. // We can't simply check for adjcent letters. For example sin(x) is ok, xsin(x) is not! *************** *** 411,464 **** } - // (5) We should only allow certain strings in student's answers. - // These are kept in $stack_cas['studentAllow'], and are generated on the fly from - // the CAS docs. - - if ($stack_cas['strict']) { - // Match more then one occurance - $pat = "|[\?_A-Za-z0-9]+|"; - preg_match_all($pat,$strout,$out,PREG_PATTERN_ORDER); - - - // Filter out some of these matches. - $strin_keywords=''; - foreach($out[0] as $key) { - // Do we have only numbers, or only 2 characters? - // These strings are fine. - preg_match("|[0-9]+|",$key,$justnum); - - if (empty($justnum) and strlen($key)>2) { - $strin_keywords[] = $key; - } - } - - // Students are only allowed certain strings. - if ('t' != $seclevel) { - // Make sure each one is really an allowed keyword - if (is_array($strin_keywords)) { - foreach ($strin_keywords as $strinkey) { - - if (!in_array(strtoupper($strinkey),$stack_cas['studentAllow'])) { - // We are in trouble! - $a = array('key' => stack_s($strinkey)); - $ret.='<br />'.get_string('UnknownFun','stack',$a); - } - } - } - } else { // End of keyword checks for students - // Make sure a teacher has not entered an unsupported function. - if (is_array($strin_keywords)) { - foreach ($strin_keywords as $strinkey) { - - if (in_array(strtoupper($strinkey),$stack_cas['teacherNotAllow'])) { - // We are in trouble! - $a = array('key' => stack_s($strinkey)); - $ret.='<br />'.get_string('NotSupported','stack',$a); - } - } - } - - } - } // Knock off first "<br />", (6 chars) --- 466,469 ---- *************** *** 925,931 **** echo "</font></em></p>"; - if ($stack_stand_alone) { // Then print a footer - echo "\n</body></html>"; - } } --- 930,933 ---- --- en.php DELETED --- Index: stackUser.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackUser.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** stackUser.php 8 Jun 2005 08:31:18 -0000 1.8 --- stackUser.php 20 Jun 2005 15:42:55 -0000 1.9 *************** *** 210,212 **** --- 210,214 ---- + + ?> Index: moodlelib.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/moodlelib.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** moodlelib.php 8 Jun 2005 08:41:29 -0000 1.2 --- moodlelib.php 20 Jun 2005 15:42:54 -0000 1.3 *************** *** 97,101 **** //In Moodle we should have a /lang/en/ dir etc. ! //$location = $stack_root.'/lang/'; // Get the current language --- 97,101 ---- //In Moodle we should have a /lang/en/ dir etc. ! $location = $stack_root.'/lang/'; // Get the current language *************** *** 107,112 **** } ! //$langfile = $location.$lang.'/'.$module.'.php'; ! $langfile = $stack_root.'/scripts/'.$lang.'.php'; if (file_exists($langfile)) { if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { --- 107,111 ---- } ! $langfile = $location.$lang.'/'.$module.'.php'; if (file_exists($langfile)) { if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { --- nl.php DELETED --- Index: stackWin.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackWin.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** stackWin.php 12 Jun 2005 16:10:01 -0000 1.2 --- stackWin.php 20 Jun 2005 15:42:55 -0000 1.3 *************** *** 88,118 **** fwrite($pipes[0], $strin); fwrite($pipes[0], $stack_cas['closeCommand']."\n\n"); $ret = ''; // read output from stdout ! // $start_time = stack_microtime_float(); ! $continue = TRUE; while (!feof($pipes[1])) { $out = fgets($pipes[1], 1024); $ret .= $out; //echo $out; $now = stack_microtime_float(); ! if (($now-$start_time) > 0.3) { ! if ($continue) { ! $continue = FALSE; ! } ! // CTRL+C should be ASCII 3. ! //fwrite($pipes[0], chr(3)); ! fwrite($pipes[0], chr(27)."[13~"); ! fflush($pipes[0]); ! } } fclose($pipes[0]); - - //$end_time = stack_microtime_float(); - //$time_taken = $end_time - $start_time; - //echo "<br />Time taken: ".$time_taken; - fclose($pipes[1]); } else { --- 88,117 ---- fwrite($pipes[0], $strin); fwrite($pipes[0], $stack_cas['closeCommand']."\n\n"); + fflush($pipes[0]); $ret = ''; // read output from stdout ! $start_time = stack_microtime_float(); while (!feof($pipes[1])) { $out = fgets($pipes[1], 1024); + if ('' == $out) { + // PAUSE + usleep(1000); + } $ret .= $out; //echo $out; $now = stack_microtime_float(); ! // if (($now-$start_time) > 0.3) { ! // // CTRL+C should be ASCII 3. ! // //fwrite($pipes[0], chr(3)); ! // fwrite($pipes[0], chr(27)."[13~"); ! // fflush($pipes[0]); ! // } } fclose($pipes[0]); fclose($pipes[1]); + //$time_taken = $now-$start_time; + //echo "Start: $start_time<br >End: $now<br >Taken = $time_taken"; + } else { |