Merged from 1.5.

This commit is contained in:
mindforge
2005-09-14 11:17:24 +00:00
parent ea30fc5c0b
commit f8180ec8d8
3 changed files with 35 additions and 11 deletions
+6 -1
View File
@@ -1,4 +1,4 @@
<?PHP // $Id$
<?php // $Id$
// quiz.php - created with Moodle 1.5 ALPHA (2005050600)
@@ -388,6 +388,11 @@ $string['shuffleanswers'] = 'Shuffle answers';
$string['shufflequestions'] = 'Shuffle questions';
$string['significantfigures'] = ' with $a ';
$string['significantfiguresformat'] = 'significant figures';
$string['sortalpha'] = 'Sort alphabetically';
$string['sortage'] = 'Sort by age';
$string['sortsubmit'] = 'Sort quetsions';
$string['startagain'] = 'Start again';
$string['startagain'] = 'Start again';
$string['startagain'] = 'Start again';
$string['startedon'] = 'Started on';
$string['subneterror'] = 'Sorry, this quiz has been locked so that it is only accessible from certain locations. Currently your computer is not one of those allowed to use this quiz.';
+17 -6
View File
@@ -38,10 +38,14 @@
require_login();
$courseid = optional_param('courseid');
$quizid = optional_param('quizid');
$page = optional_param('page', -1);
$perpage = optional_param('perpage', 20);
$courseid = optional_param('courseid');
$quizid = optional_param('quizid');
$page = optional_param('page', -1);
$perpage = optional_param('perpage', 20);
$sortorder = optional_param('sortorder', 'qtype, name ASC');
if (preg_match("/[';]/", $sortorder)) {
error("Incorrect use of the parameter 'sortorder'");
}
$strquizzes = get_string('modulenameplural', 'quiz');
$strquiz = get_string('modulename', 'quiz');
@@ -79,6 +83,13 @@
add_to_log($courseid, 'quiz', 'editquestions', "index.php?id=$courseid");
} else if (!empty($sortorder)) {
// no quiz or course was specified so we need to use the stored modform
if (isset($SESSION->modform)) {
$modform = $SESSION->modform;
} else {
exit;
}
} else {
// we might get here after editing a question in
// a popup window. So close window automatically.
@@ -95,7 +106,7 @@ if (self.name == 'editquestion') {
</noscript>
<?php
// no quiz or course was specified so we need to use the stored modform
if (isset($SESSION->modform)) {
if (isset($SESSION->modform)) {
$modform = $SESSION->modform;
} else {
exit;
@@ -472,7 +483,7 @@ if (self.name == 'editquestion') {
// continues with list of questions
print_simple_box_start("center", "100%");
quiz_print_cat_question_list($course, $modform->category,
isset($modform->instance) ? $modform->instance : 0, $SESSION->quiz_recurse, $page, $perpage, $SESSION->quiz_showhidden);
isset($modform->instance) ? $modform->instance : 0, $SESSION->quiz_recurse, $page, $perpage, $SESSION->quiz_showhidden, $sortorder);
print_simple_box_end();
if (!isset($modform->instance)) {
print_continue("index.php?id=$modform->course");
+12 -4
View File
@@ -439,7 +439,7 @@ function quiz_print_category_form($course, $current, $recurse=1, $showhidden=fal
* @param boolean $showhidden True if also hidden questions should be displayed
*/
function quiz_print_cat_question_list($course, $categoryid, $quizid,
$recurse=1, $page, $perpage, $showhidden=false) {
$recurse=1, $page, $perpage, $showhidden=false, $sortorder='qtype, name ASC') {
global $QUIZ_QUESTION_TYPE, $USER;
$strcategory = get_string("category", "quiz");
@@ -463,6 +463,10 @@ function quiz_print_cat_question_list($course, $categoryid, $quizid,
$strcreatemultiple = get_string("createmultiple", "quiz");
$strpreview = get_string("preview","quiz");
$strsortalpha = get_string("sortalpha", "quiz");
$strsortage = get_string("sortage", "quiz");
$strsortsubmit = get_string("sortsubmit", "quiz");
if (!$categoryid) {
echo "<p align=\"center\"><b>";
print_string("selectcategoryabove", "quiz");
@@ -526,10 +530,10 @@ function quiz_print_cat_question_list($course, $categoryid, $quizid,
return;
}
if (!$questions = get_records_select('quiz_questions', "category IN ($categorylist) AND parent = '0' $showhidden", 'qtype, name ASC', '*', $page*$perpage, $perpage)) {
if (!$questions = get_records_select('quiz_questions', "category IN ($categorylist) AND parent = '0' $showhidden", $sortorder, '*', $page*$perpage, $perpage)) {
// There are no questions on the requested page.
$page = 0;
if (!$questions = get_records_select('quiz_questions', "category IN ($categorylist) AND parent = '0' $showhidden", 'qtype, name ASC', '*', 0, $perpage)) {
if (!$questions = get_records_select('quiz_questions', "category IN ($categorylist) AND parent = '0' $showhidden", $sortorder, '*', 0, $perpage)) {
// There are no questions at all
echo "<p align=\"center\">";
print_string("noquestions", "quiz");
@@ -549,7 +553,11 @@ function quiz_print_cat_question_list($course, $categoryid, $quizid,
echo '<table id="categoryquestions" cellspacing="0"><tr>';
$actionwidth = $canedit ? 95 : 70;
echo "<th width=\"$actionwidth\" nowrap=\"nowrap\" class=\"header\">$straction</th>";
echo "<th width=\"100%\" align=\"left\" nowrap=\"nowrap\" class=\"header\">$strquestionname</th>
$sortoptions = array('qtype, name ASC' => $strsortalpha,
'id ASC' => $strsortage);
$orderselect = choose_from_menu ($sortoptions, 'sortorder', $sortorder, false, 'this.form.submit();', '0', true);
$orderselect .= '<noscript><input type="submit" value="$strsortsubmit" /></noscript>';
echo "<th width=\"100%\" align=\"left\" nowrap=\"nowrap\" class=\"header\">$strquestionname $orderselect</th>
<th nowrap=\"nowrap\" class=\"header\">$strtype</th>";
echo "</tr>\n";
foreach ($questions as $question) {