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 08:02:27 浏览: 26
这是 PHP 语言的代码。这段代码主要是对数据进行预处理。它会读取表单数据中的默认值,并根据这些值来加载相应的内容。其中,它会根据传入的 ID 来加载相应的内容,然后设置最高分数、显示选项等。此外,它还会根据条件来设置默认操作,并对编辑器默认值进行设置。最后,它会将参数和元数据合并为一个 JSON 对象,并添加所需的编辑器资源。
相关问题
tf26报ModuleNotFoundError: No module named 'keras_preprocessing'
在 TensorFlow 2.6 中,`keras_preprocessing` 已经被整合到 TensorFlow 中,你无需单独安装或导入它。
如果你在导入 `keras_preprocessing` 时遇到 "ModuleNotFoundError: No module named 'keras_preprocessing'" 错误,可能是因为你使用了旧版本的代码或语法。
在 TensorFlow 2.6 中,你应该使用 `tf.keras.preprocessing` 来代替 `keras_preprocessing`。请确保你已正确导入 TensorFlow 和 `tf.keras.preprocessing`,并使用正确的导入语句。例如:
```python
import tensorflow as tf
from tensorflow.keras.preprocessing import image
# 使用 tf.keras.preprocessing 中的相关功能
```
确保你的 TensorFlow 版本是最新的,并使用 `tf.keras.preprocessing` 来访问预处理相关的功能。不要尝试单独安装和导入独立的 `keras_preprocessing` 库。
ModuleNotFoundError: No module named 'keras_preprocessing'
这是一个Python错误,通常是由于缺少keras_preprocessing模块导致的。您可以通过安装该模块来解决此错误。您可以在终端中运行以下命令来安装该模块:pip install keras_preprocessing。如果您已经安装了该模块但仍然遇到此错误,请确保您的Python环境正确配置,并将您的代码与其他人共享以获得更多帮助。