From: jamiesensei Date: Tue, 11 Dec 2007 03:24:35 +0000 (+0000) Subject: MDL-12410 - a way to select which questions to export, includes debug messages X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2c44a3d39351201daca30f1ed803fc95046d6e72;p=moodle.git MDL-12410 - a way to select which questions to export, includes debug messages --- diff --git a/question/format.php b/question/format.php index c863dfa54e..d3d0de2fb7 100644 --- a/question/format.php +++ b/question/format.php @@ -12,6 +12,7 @@ class qformat_default { var $displayerrors = true; var $category = NULL; + var $questions = array(); var $course = NULL; var $filename = ''; var $matchgrades = 'error'; @@ -43,9 +44,25 @@ class qformat_default { * @param object category the category object */ function setCategory( $category ) { + if (count($this->questions)){ + debugging('You shouldn\'t call setCategory after setQuestions'); + } $this->category = $category; } + /** + * Set the specific questions to export. Should not include questions with + * parents (sub questions of cloze question type). + * Only used for question export. + * @param array of question objects + */ + function setQuestions( $questions ) { + if ($this->category !== null){ + debugging('You shouldn\'t call setQuestions after setCategory'); + } + $this->questions = $questions; + } + /** * set the course class variable * @param course object Moodle course variable @@ -607,7 +624,11 @@ class qformat_default { // get the questions (from database) in this category // only get q's with no parents (no cloze subquestions specifically) - $questions = get_questions_category( $this->category, true ); + if ($this->category){ + $questions = get_questions_category( $this->category, true ); + } else { + $questions = $this->questions; + } notify( get_string('exportingquestions','quiz') ); $count = 0; @@ -661,11 +682,11 @@ class qformat_default { // continue path for following error checks $course = $this->course; - $continuepath = "$CFG->wwwroot/question/export.php?courseid=$course->id"; + $continuepath = "$CFG->wwwroot/question/export.php?courseid=$course->id"; // did we actually process anything if ($count==0) { - print_error( 'noquestions','quiz',$continuepath ); + print_error( 'noquestions','quiz',$continuepath ); } // final pre-process on exported data