Calculated question function find all question dataset names
From MoodleDocs
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable. |
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 fullclone($allpossibledatasets); //fullclone() necessary; array of objects }