Added question type that is used if a question of unknown type is encountered.

Also removed some of the unnecessary calls to name()
This commit is contained in:
gustav_delius
2006-03-24 21:21:59 +00:00
parent 5c2447494d
commit 4eda4eecbd
11 changed files with 258 additions and 13 deletions
+6 -7
View File
@@ -126,10 +126,7 @@ class default_questiontype {
* it is not a standard question object.
*/
function save_question_options($question) {
/// This default implementation must be overridden:
$result->error = "Unsupported question type ($question->qtype)!";
return $result;
return null;
}
/**
@@ -330,9 +327,11 @@ class default_questiontype {
function get_correct_responses(&$question, &$state) {
/* The default implementation returns the response for the first answer
that gives full marks. */
foreach ($question->options->answers as $answer) {
if (((int) $answer->fraction) === 1) {
return array('' => $answer->answer);
if ($question->options->answers) {
foreach ($question->options->answers as $answer) {
if (((int) $answer->fraction) === 1) {
return array('' => $answer->answer);
}
}
}
return null;