MDL-9657 cleaning abstractype code merging from head

This commit is contained in:
pichetp
2007-04-26 23:37:38 +00:00
parent 4ca7cf3473
commit e27f1fc122
@@ -3,6 +3,10 @@
///////////////////////////////////////////////////////////////
/// ABSTRACT SUPERCLASS FOR QUSTION TYPES THAT USE DATASETS ///
///////////////////////////////////////////////////////////////
/**
* @package questionbank
* @subpackage questiontypes
*/
require_once($CFG->libdir.'/filelib.php');
@@ -76,42 +80,6 @@ class question_dataset_dependent_questiontype extends default_questiontype {
return true;
}
function print_question_formulation_and_controls(&$question, &$state, $cmoptions,
$options) {
// Substitute variables in questiontext before giving the data to the
// virtual type for printing
$virtualqtype = $this->get_virtual_qtype();
$unit = $virtualqtype->get_default_numerical_unit($question);
foreach ($question->options->answers as $answer) {
$answer->answer = $this->substitute_variables($answer->answer,
$state->options->dataset);
}
$question->questiontext = $this->substitute_variables(
$question->questiontext, $state->options->dataset);
$virtualqtype->print_question_formulation_and_controls($question,
$state, $cmoptions, $options);
}
function grade_responses(&$question, &$state, $cmoptions) {
// Forward the grading to the virtual qtype
foreach ($question->options->answers as $answer) {
$answer->answer = $this->substitute_variables($answer->answer,
$state->options->dataset);
}
$virtualqtype = $this->get_virtual_qtype();
return $virtualqtype->grade_responses($question, $state, $cmoptions) ;
}
// ULPGC ecastro
function check_response(&$question, &$state) {
// Forward the checking to the virtual qtype
foreach ($question->options->answers as $answer) {
$answer->answer = $this->substitute_variables($answer->answer,
$state->options->dataset);
}
$virtualqtype = $this->get_virtual_qtype();
return $virtualqtype->check_response($question, $state) ;
}
function substitute_variables($str, $dataset) {
foreach ($dataset as $name => $value) {
@@ -414,116 +382,6 @@ class question_dataset_dependent_questiontype extends default_questiontype {
/*
function save_question($question, &$form, $course) {
// For dataset dependent questions a wizard is used for editing
// questions. Therefore saving the question is delayed until
// we're through with the whole wizard.
global $SESSION;
$this->validate_form($form);
// See where we're coming from
switch($form->wizardpage) {
case 'question':
unset($SESSION->datasetdependent); // delete any remaining data
// from previous wizards
if (empty($form->id)) {
$SESSION->datasetdependent->question = $form;
$question = $this->create_runtime_question($question, $form);
} else {
$question = parent::save_question($question, $form, $course);
}
break;
case 'datasetdefinitions':
$SESSION->datasetdependent->datasetdefinitions = $form;
if (empty($form->id)) {
$question = $this->create_runtime_question($question, $SESSION->datasetdependent->question);
} else {
$this->save_dataset_definitions($form);
$this->get_question_options($question);
//unset($SESSION->datasetdependent->datasetdefinitions);
}
//$this->get_question_options($question);
break;
case 'datasets':
if (!empty($form->addbutton) && isset($SESSION->datasetdependent->question)) {
echo "saving";
$question = parent::save_question($question, $SESSION->datasetdependent->question, $course);
$SESSION->datasetdependent->datasetdefinitions->id = $question->id;
$this->save_dataset_definitions($SESSION->datasetdependent->datasetdefinitions);
//$this->get_dataset_definitions($question);
unset($SESSION->datasetdependent);
}
dump($question);
if (empty($question->id)) {
$question = $this->create_runtime_question($question, $SESSION->datasetdependent->question);
} else {
$this->get_question_options($question);
}
break;
default:
error('Incorrect or no wizard page specified!');
break;
}
return $question;
}
*/
/*
function create_runtime_question($question, $form) {
$question->name = trim($form->name);
$question->questiontext = trim($form->questiontext);
$question->questiontextformat = $form->questiontextformat;
$question->parent = isset($form->parent)? $form->parent : 0;
$question->length = $this->actual_number_of_questions($question);
$question->penalty = isset($form->penalty) ? $form->penalty : 0;
if (empty($form->image)) {
$question->image = "";
} else {
$question->image = $form->image;
}
if (empty($question->name)) {
$question->name = strip_tags($question->questiontext);
if (empty($question->name)) {
$question->name = '-';
}
}
if ($question->penalty > 1 or $question->penalty < 0) {
$question->errors['penalty'] = get_string('invalidpenalty', 'quiz');
}
if (isset($form->defaultgrade)) {
$question->defaultgrade = $form->defaultgrade;
}
return $question;
}
*/
/*
function validate_form($form) {
switch($form->wizardpage) {
case 'question':
error('Validation for the wizardpage "question" needs to be ' .
'defined in the inheriting questiontype.');
case 'datasetdefinitions':
// Nothing to validate
$SESSION->datasetdependent->datasetdefinitions = $form;
break;
case 'datasets':
break;
default:
error('Incorrect or no wizard page specified!');
break;
}
return true;
}
*/
/// Dataset functionality
function pick_question_dataset($question, $datasetitem) {
// Select a dataset in the following format: