public function data_preprocessing(&$defaultvalues) { global $DB; $core = \mod_hvp\framework::instance(); $content = null; if (!empty($defaultvalues['id'])) { // Load Content. $content = $core->loadContent($defaultvalues['id']); } $this->set_max_grade($content, $defaultvalues); // Aaah.. we meet again h5pfile! $draftitemid = file_get_submitted_draft_itemid('h5pfile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_hvp', 'package', 0); $defaultvalues['h5pfile'] = $draftitemid; $this->set_display_options($defaultvalues); // Determine default action. if (!get_config('mod_hvp', 'hub_is_enabled') && $content === null && $DB->get_field_sql("SELECT id FROM {hvp_libraries} WHERE runnable = 1", null, IGNORE_MULTIPLE) === false) { $defaultvalues['h5paction'] = 'upload'; } // Set editor defaults. $defaultvalues['h5plibrary'] = ($content === null ? 0 : H5PCore::libraryToString($content['library'])); // Combine params and metadata in one JSON object. $params = ($content === null ? '{}' : $core->filterParameters($content)); $maincontentdata = array('params' => json_decode($params)); if (isset($content['metadata'])) { $maincontentdata['metadata'] = $content['metadata']; } $defaultvalues['h5pparams'] = json_encode($maincontentdata, true); // Completion settings check. if (empty($defaultvalues['completionusegrade'])) { $defaultvalues['completionpass'] = 0; // Forced unchecked. } // Add required editor assets. require_once('locallib.php'); $mformid = $this->_form->getAttribute('id'); \hvp_add_editor_assets($content === null ? null : $defaultvalues['id'], $mformid); }
时间: 2024-01-12 16:02:27 浏览: 79
data_preprocessing:该存储库与所有数据预处理和功能工程有关
这是 PHP 语言的代码。这段代码主要是对数据进行预处理。它会读取表单数据中的默认值,并根据这些值来加载相应的内容。其中,它会根据传入的 ID 来加载相应的内容,然后设置最高分数、显示选项等。此外,它还会根据条件来设置默认操作,并对编辑器默认值进行设置。最后,它会将参数和元数据合并为一个 JSON 对象,并添加所需的编辑器资源。
阅读全文