From: jamiesensei Date: Mon, 7 May 2007 04:55:55 +0000 (+0000) Subject: changes to pass category id from page to page in question bank editing. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7bc26c8f6df85c14f008265e8b85bba49135dba6;p=moodle.git changes to pass category id from page to page in question bank editing. --- diff --git a/question/editlib.php b/question/editlib.php index 7a27faec9c..c45cd4f23a 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -124,7 +124,7 @@ function question_category_form($course, $pageurl, $current, $recurse=1, $showhi $strshow = get_string("show", "quiz"); $streditcats = get_string("editcategories", "quiz"); - popup_form ("edit.php?".$pageurl->get_query_string()."&catchange=", $catmenu, "catmenu", $current, "", "", "", false, "self", "$strcategory"); + popup_form ("edit.php?".$pageurl->get_query_string()."&category=", $catmenu, "catmenu", $current, "", "", "", false, "self", "$strcategory"); echo '
'; echo "
"; @@ -413,7 +413,7 @@ function question_list($course, $pageurl, $categoryid, $cm = null, * move Moves a question to a different category * deleteselected Deletes the selected questions from the category * Other actions: - * catchange Chooses the category + * category Chooses the category * displayoptions Sets display options * * @author Martin Dougiamas and many others. This has recently been extensively @@ -567,6 +567,18 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){ $pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT); + + //pass 'cat' from page to page and when 'category' comes from a drop down menu + //then we also reset the qpage so we go to page 1 of + //a new cat. + $pagevars['cat'] = optional_param('cat', 0, PARAM_INT); + if ($category = optional_param('category', 0, PARAM_INT)){ + $pagevars['cat'] = $category; + $pagevars['qpage'] = 0; + } + if ($pagevars['cat']){ + $thispageurl->param('cat', $pagevars['cat']); + } if ($pagevars['qpage'] > -1) { $thispageurl->param('qpage', $pagevars['qpage']); } else { @@ -589,20 +601,10 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){ $pagevars['qsortorder'] = $sortorder; $thispageurl->param('qsortorder', $sortorder); } else { - $pagevars['qsortorder'] = 'qtype, name ASC'; + $pagevars['qsortorderdecoded'] = $sortoptions['typealpha']; + $pagevars['qsortorder'] = 'typealpha'; } - //pass cat from page to page and catchange comes a drop down menu - //on catchange then we also reset the qpage so we go to page 1 of - //a new cat. - $pagevars['cat'] = optional_param('cat', 0, PARAM_INT); - if ($catchange = optional_param('catchange', 0, PARAM_INT)){ - $pagevars['cat'] = $catchange; - $pagevars['qpage'] = 0; - } - if ($pagevars['cat']){ - $thispageurl->param('cat', $pagevars['cat']); - } if (empty($pagevars['cat']) or !count_records_select("question_categories", "id = '".$pagevars['cat']."' AND (course = '{$COURSE->id}' OR publish = '1')")) { $category = get_default_question_category($COURSE->id); @@ -632,6 +634,5 @@ function question_edit_setup($requirecmid = false, $requirecourseid = true){ } return array($thispageurl, $courseid, $cmid, $cm, $module, $pagevars); - } ?> diff --git a/question/export.php b/question/export.php index 32b1e22f2e..c792ddbf2e 100644 --- a/question/export.php +++ b/question/export.php @@ -14,7 +14,6 @@ list($thispageurl, $courseid, $cmid, $cm, $module, $pagevars) = question_edit_setup(); - $categoryid = optional_param('category',0, PARAM_INT); $cattofile = optional_param('cattofile',0, PARAM_BOOL); $exportfilename = optional_param('exportfilename','',PARAM_FILE ); @@ -40,15 +39,8 @@ error("Course does not exist!"); } - if ($categoryid) { // update category in session variable - $SESSION->questioncat = $categoryid; - } else { // try to get category from session - if (isset($SESSION->questioncat)) { - $categoryid = $SESSION->questioncat; - } - } - if (!$category = get_record("question_categories", "id", $categoryid)) { + if (!$category = get_record("question_categories", "id", $pagevars['cat'])) { $category = get_default_question_category($courseid); } @@ -66,9 +58,9 @@ make_upload_directory( "$course->id" ); // check category is valid - if (!empty($categoryid)) { + if (!empty($pagevars['cat'])) { $validcats = question_category_options( $course->id, true, false ); - if (!array_key_exists( $categoryid, $validcats)) { + if (!array_key_exists( $pagevars['cat'], $validcats)) { print_error( 'invalidcategory','quiz' ); } } @@ -125,15 +117,15 @@ $qformat->setCattofile( $cattofile ); if (! $qformat->exportpreprocess()) { // Do anything before that we need to - error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id))); + error( $txt->exporterror, $thispageurl->out()); } if (! $qformat->exportprocess()) { // Process the export data - error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id))); + error( $txt->exporterror, $thispageurl->out()); } if (! $qformat->exportpostprocess()) { // In case anything needs to be done after - error( $txt->exporterror, $thispageurl->out(false, array('category'=>$category->id))); + error( $txt->exporterror, $thispageurl->out()); } echo "
"; diff --git a/question/import.php b/question/import.php index 1d2115d54b..7e0b794e75 100644 --- a/question/import.php +++ b/question/import.php @@ -19,7 +19,6 @@ // get parameters $params = new stdClass; $params->choosefile = optional_param('choosefile','',PARAM_PATH); - $categoryid = optional_param('category', 0, PARAM_INT); $catfromfile = optional_param('catfromfile', 0, PARAM_BOOL ); $format = optional_param('format','',PARAM_FILE); $params->matchgrades = optional_param('matchgrades','',PARAM_ALPHA); @@ -56,21 +55,11 @@ $matchgrades['error'] = $txt->matchgradeserror; $matchgrades['nearest'] = $txt->matchgradesnearest; - if ($categoryid) { // update category in session variable - $SESSION->questioncat = $categoryid; - } else { // try to get category from session - if (isset($SESSION->questioncat)) { - $categoryid = $SESSION->questioncat; - } - } - if (!$category = get_record("question_categories", "id", $categoryid)) { + + if ($category = get_record("question_categories", "id", $pagevars['cat'])) { // if no valid category was given, use the default category - if ($courseid) { - $category = get_default_question_category($courseid); - } else { - print_error('nocategory','quiz'); - } + print_error('nocategory','quiz'); } if (!$courseid) { // need to get the course from the chosen category