changes to pass category id from page to page in question bank editing.

This commit is contained in:
jamiesensei
2007-05-07 04:55:55 +00:00
parent eeea21878d
commit 7bc26c8f6d
3 changed files with 25 additions and 43 deletions
+16 -15
View File
@@ -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()."&amp;catchange=", $catmenu, "catmenu", $current, "", "", "", false, "self", "<strong>$strcategory</strong>");
popup_form ("edit.php?".$pageurl->get_query_string()."&amp;category=", $catmenu, "catmenu", $current, "", "", "", false, "self", "<strong>$strcategory</strong>");
echo '<form method="post" action="edit.php" id="displayoptions">';
echo "<fieldset class='invisiblefieldset'>";
@@ -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);
}
?>
+6 -14
View File
@@ -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 "<hr />";
+3 -14
View File
@@ -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