Development:Calculated question function find all question dataset names: Difference between revisions
From MoodleDocs
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Description of the function | Description of the function find_all_question_dataset_names() | ||
This is an adaptation of the actual code in datasetdependent/datasetdefinition.php | |||
function find_all_question_dataset_names(&$question, &$mandatorydatasets, &$possibledatasets) { | function find_all_question_dataset_names(&$question, &$mandatorydatasets, &$possibledatasets) { | ||
// Returns the possible dataset names found in the text and answers | // Returns the possible dataset names found in the text and answers |
Revision as of 22:25, 17 October 2006
Description of the function find_all_question_dataset_names() This is an adaptation of the actual code in datasetdependent/datasetdefinition.php
function find_all_question_dataset_names(&$question, &$mandatorydatasets, &$possibledatasets) { // Returns the possible dataset names found in the text and answers $possibledatasets = $this->find_dataset_names($question->questiontext); foreach ($question->options->answers as $answer) { $mandatorydatasets += $this ->find_dataset_names($answer->answer); } } // construct the complete list with a single entry for each dataset name $allpossibledatasets=array(); foreach ($mandatorydatasets as $datasetname) { if (!isset($allpossibledatasets[$datasetname])) { $allpossibledatasets[$datasetname]=$datasetname; } } foreach ($possibledatasets as $datasetname) { if (!isset($allpossibledatasets[$datasetname])) { $allpossibledatasets[$datasetname]=$datasetname; } } return clone($allpossibledatasets); }