Merge branch 'MDL-86592-main' of https://github.com/davewoloszyn/moodle
This commit is contained in:
@@ -69,19 +69,37 @@ if ($hassiteconfig && \core_analytics\manager::is_analytics_enabled()) {
|
||||
$ADMIN->add('analytics', $settings);
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
|
||||
// Select the site prediction's processor.
|
||||
$predictionprocessors = \core_analytics\manager::get_all_prediction_processors();
|
||||
$predictors = array();
|
||||
$predictors = [];
|
||||
foreach ($predictionprocessors as $fullclassname => $predictor) {
|
||||
$pluginname = substr($fullclassname, 1, strpos($fullclassname, '\\', 1) - 1);
|
||||
$predictors[$fullclassname] = new lang_string('pluginname', $pluginname);
|
||||
}
|
||||
$settings->add(new \core_analytics\admin_setting_predictor('analytics/predictionsprocessor',
|
||||
new lang_string('defaultpredictionsprocessor', 'analytics'), new lang_string('predictionsprocessor_help', 'analytics'),
|
||||
\core_analytics\manager::default_mlbackend(), $predictors)
|
||||
$settings->add(
|
||||
new \core_analytics\admin_setting_predictor(
|
||||
'analytics/predictionsprocessor',
|
||||
new lang_string('defaultpredictionsprocessor', 'analytics'),
|
||||
new lang_string('predictionsprocessor_help', 'analytics'),
|
||||
\core_analytics\manager::default_mlbackend(),
|
||||
$predictors,
|
||||
)
|
||||
);
|
||||
// Warn if current processor is not configured.
|
||||
// We are avoiding doing this check in write_config because it is likely the default
|
||||
// mlbackend_python plugin is not configured and will output warnings during install.
|
||||
$currentprocessor = get_config('analytics', 'predictionsprocessor');
|
||||
if (!empty($currentprocessor)) {
|
||||
$currentprocessor = new $currentprocessor;
|
||||
$currentprocessorisready = $currentprocessor->is_ready();
|
||||
if ($currentprocessorisready !== true) {
|
||||
$settings->add(new admin_setting_description(
|
||||
'processornotready',
|
||||
'',
|
||||
html_writer::tag('div', $currentprocessorisready, ['class' => 'alert alert-danger'])
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Log store.
|
||||
$logmanager = get_log_manager();
|
||||
|
||||
@@ -51,17 +51,6 @@ class admin_setting_predictor extends \admin_setting_configselect {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Calling it here without checking if it is ready because we check it below and show it as a controlled case.
|
||||
$selectedprocessor = \core_analytics\manager::get_predictions_processor($data, false);
|
||||
|
||||
if (!during_initial_install() && !moodle_needs_upgrading()) {
|
||||
// TODO: Do not check if the processor is ready during installation or upgrade. See MDL-84481.
|
||||
$isready = $selectedprocessor->is_ready();
|
||||
if ($isready !== true) {
|
||||
return get_string('errorprocessornotready', 'analytics', $isready);
|
||||
}
|
||||
}
|
||||
|
||||
$currentvalue = get_config('analytics', 'predictionsprocessor');
|
||||
if (!empty($currentvalue) && $currentvalue != str_replace('\\\\', '\\', $data)) {
|
||||
// Clear all models data.
|
||||
|
||||
Reference in New Issue
Block a user