questions MDL-20276 Fixed minor issue with URL handling within the paging bar for the question bank

This commit is contained in:
samhemelryk 2009-09-16 02:43:58 +00:00
parent 587132ef27
commit b0f4e4e442
4 changed files with 56 additions and 14 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -1300,13 +1300,7 @@ class question_bank_view {
} else {
$showall = '<a href="edit.php?'.$pageurl->get_query_string(array('qperpage'=>DEFAULT_QUESTIONS_PER_PAGE)).'">'.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).'</a>';
}
if ($paging) {
$paging = substr($paging, 0, strrpos($paging, '</div>'));
$paging .= "<br />$showall</div>";
} else {
$paging = "<div class='paging'>$showall</div>";
}
echo $paging;
echo "<div class='paging'>$showall</div>";
}
echo '</div>';

View File

@ -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);
}