From b0f4e4e442017718ec22b6db117b6977fbc8cf21 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Wed, 16 Sep 2009 02:43:58 +0000 Subject: [PATCH] questions MDL-20276 Fixed minor issue with URL handling within the paging bar for the question bank --- lib/weblib.php | 8 +------- question/edit.php | 21 +++++++++++++++++++++ question/editlib.php | 8 +------- question/question.php | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 850262b1850..2d0d0d13739 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -557,20 +557,14 @@ function prepare_url($url, $stripformparams=false) { // Handle relative URLs if (substr($output, 0, 4) != 'http' && substr($output, 0, 1) != '/') { if (preg_match('/(.*)\/([A-Za-z0-9-_]*\.php)$/', $PAGE->url->out(true), $matches)) { - return $matches[1] . "/$output"; } else if ($output == '') { return $PAGE->url->out(false, array(), false) . '#'; } else { - throw new coding_exception('Your page uses bizarre relative URLs which Moodle cannot handle. Please use absolute URLs.'); + throw new coding_exception('Unrecognied URL scheme. Please check the formatting of the URL passed to this function. Absolute URLs are the preferred scheme.'); } } - // Add wwwroot only if the URL does not already start with http:// or https:// - if (!preg_match('|https?://|', $output) ) { - $output = $CFG->wwwroot . $output; - } - return $output; } diff --git a/question/edit.php b/question/edit.php index 4d87285f86a..8711cb103ae 100644 --- a/question/edit.php +++ b/question/edit.php @@ -33,6 +33,27 @@ require_once("../config.php"); require_once("editlib.php"); + $url = new moodle_url($CFG->wwwroot.'/question/edit.php'); + if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) { + $url->param('lastchanged', $lastchanged); + } + if (($category = optional_param('category', 0, PARAM_TEXT)) !== 0) { + $url->param('category', $category); + } + if (($qpage = optional_param('qpage', 0, PARAM_INT)) !== 0) { + $url->param('qpage', $qpage); + } + if (($cat = optional_param('cat', 0, PARAM_TEXT)) !== 0) { + $url->param('cat', $cat); + } + if (($courseid = optional_param('courseid', 0, PARAM_INT)) !== 0) { + $url->param('courseid', $courseid); + } + if (($returnurl = optional_param('returnurl', 0, PARAM_INT)) !== 0) { + $url->param('returnurl', $returnurl); + } + $PAGE->set_url($url); + list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = question_edit_setup('questions'); $questionbank = new question_bank_view($contexts, $thispageurl, $COURSE, $cm); $questionbank->process_actions(); diff --git a/question/editlib.php b/question/editlib.php index 64b766175e3..d03f8175d2f 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -1300,13 +1300,7 @@ class question_bank_view { } else { $showall = ''.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).''; } - if ($paging) { - $paging = substr($paging, 0, strrpos($paging, '')); - $paging .= "
$showall"; - } else { - $paging = "
$showall
"; - } - echo $paging; + echo "
$showall
"; } echo ''; diff --git a/question/question.php b/question/question.php index 7e574e335ad..af9b63f7927 100644 --- a/question/question.php +++ b/question/question.php @@ -26,6 +26,39 @@ $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL); $appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA); $inpopup = optional_param('inpopup', 0, PARAM_BOOL); +$url = new moodle_url($CFG->wwwroot.'/question/question.php'); +if ($id !== 0) { + $url->param('id', $id); +} +if ($qtype !== '') { + $url->param('qtype', $qtype); +} +if ($categoryid !== 0) { + $url->param('category', $categoryid); +} +if ($cmid !== 0) { + $url->param('cmid', $cmid); +} +if ($courseid !== 0) { + $url->param('courseid', $courseid); +} +if ($wizardnow !== '') { + $url->param('wizardnow', $wizardnow); +} +if ($movecontext !== 0) { + $url->param('movecontext', $movecontext); +} +if ($returnurl !== 0) { + $url->param('returnurl', $returnurl); +} +if ($appendqnumstring !== '') { + $url->param('appendqnumstring', $appendqnumstring); +} +if ($inpopup !== 0) { + $url->param('inpopup', $inpopup); +} +$PAGE->set_url($url); + if ($movecontext && !$id){ print_error('questiondoesnotexist', 'question', $returnurl); }