MDL-12410 - a way to select which questions to export, includes debug messages

This commit is contained in:
jamiesensei
2007-12-11 03:54:21 +00:00
parent 0abcfef0c9
commit be350cb127
+24 -4
View File
@@ -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
@@ -303,7 +320,6 @@ class qformat_default {
}
return true;
}
/**
* Count all non-category questions in the questions array.
*
@@ -608,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;
@@ -662,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