Development:Calculated question function find all question dataset names: различия между версиями
Материал из База знаний Центра ПУСК МФТИ
1>Ppichet Нет описания правки |
м 1 версия импортирована |
(нет различий)
| |
Текущая версия от 08:51, 21 октября 2024
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
}