CONTRIB-490 Added support for scripted generation of questions. Calculated type not yet supported (datasets too complicated ;)

This commit is contained in:
nicolasconnault
2008-06-12 09:15:16 +00:00
parent ea2fdf56ce
commit b9bd6da4f8
9 changed files with 212 additions and 16 deletions
+24
View File
@@ -1582,5 +1582,29 @@ class default_questiontype {
// There is nothing to decode
return $state->answer;
}
/**
* Abstract function implemented by each question type. It runs all the code
* required to set up and save a question of any type for testing purposes.
* Alternate DB table prefix may be used to facilitate data deletion.
*/
function generate_test($name, $courseid=null) {
$form = new stdClass();
$form->name = $name;
$form->questiontextformat = 1;
$form->questiontext = 'test question, generated by script';
$form->defaultgrade = 1;
$form->penalty = 0.1;
$form->generalfeedback = "Well done";
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$newcategory = question_make_default_categories(array($context));
$form->category = $newcategory->id . ',1';
$question = new stdClass();
$question->courseid = $courseid;
$question->qtype = $this->qtype;
return array($form, $question);
}
}
?>