Calculated question function find all question dataset names: Difference between revisions
From MoodleDocs
No edit summary |
m (Note about plan not to migrate this page to the new developer resources. See template for more info.) |
||
Line 1: | Line 1: | ||
{{Template:WillNotMigrate}} | |||
Description of the function find_all_question_dataset_names() | Description of the function find_all_question_dataset_names() | ||
This is an adaptation of the actual code in datasetdependent/datasetdefinition.php | This is an adaptation of the actual code in datasetdependent/datasetdefinition.php |
Latest revision as of 14:13, 24 June 2022
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 }