Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 36... Línea 36...
36
class manager {
36
class manager {
Línea 37... Línea 37...
37
 
37
 
38
    /**
38
    /**
39
     * Default mlbackend
39
     * Default mlbackend
40
     */
40
     */
Línea 41... Línea 41...
41
    const DEFAULT_MLBACKEND = '\mlbackend_php\processor';
41
    const DEFAULT_MLBACKEND = '\mlbackend_python\processor';
42
 
42
 
43
    /**
43
    /**
44
     * Name of the file where components declare their models.
44
     * Name of the file where components declare their models.
Línea 255... Línea 255...
255
     * @return bool
255
     * @return bool
256
     */
256
     */
257
    public static function is_mlbackend_used($plugin) {
257
    public static function is_mlbackend_used($plugin) {
258
        $models = self::get_all_models();
258
        $models = self::get_all_models();
259
        foreach ($models as $model) {
259
        foreach ($models as $model) {
-
 
260
            try {
260
            $processor = $model->get_predictions_processor();
261
                $processor = $model->get_predictions_processor();
261
            $noprefixnamespace = ltrim(get_class($processor), '\\');
262
                $noprefixnamespace = ltrim(get_class($processor), '\\');
262
            $processorplugin = substr($noprefixnamespace, 0, strpos($noprefixnamespace, '\\'));
263
                $processorplugin = substr($noprefixnamespace, 0, strpos($noprefixnamespace, '\\'));
263
            if ($processorplugin == $plugin) {
264
                if ($processorplugin == $plugin) {
264
                return true;
265
                    return true;
-
 
266
                }
-
 
267
            } catch (\Exception $e) {
-
 
268
                // The model does not have a predictions processor.
-
 
269
                continue;
265
            }
270
            }
266
        }
271
        }
Línea 267... Línea 272...
267
 
272
 
268
        // Default predictions processor.
273
        // Default predictions processor.
Línea 298... Línea 303...
298
 
303
 
299
        return self::$alltimesplittings;
304
        return self::$alltimesplittings;
Línea 300... Línea 305...
300
    }
305
    }
301
 
-
 
302
    /**
-
 
303
     * @deprecated since Moodle 3.7 use get_time_splitting_methods_for_evaluation instead
-
 
304
     */
-
 
305
    public static function get_enabled_time_splitting_methods() {
-
 
306
        throw new coding_exception(__FUNCTION__ . '() has been removed. You can use self::get_time_splitting_methods_for_evaluation if ' .
-
 
307
            'you want to get the default time splitting methods for evaluation, or you can use self::get_all_time_splittings if ' .
-
 
308
            'you want to get all the time splitting methods available on this site.');
-
 
309
    }
-
 
310
 
306
 
311
    /**
307
    /**
312
     * Returns the time-splitting methods for model evaluation.
308
     * Returns the time-splitting methods for model evaluation.
313
     *
309
     *
314
     * @param  bool $all Return all the time-splitting methods that can potentially be used for evaluation or the default ones.
310
     * @param  bool $all Return all the time-splitting methods that can potentially be used for evaluation or the default ones.
Línea 531... Línea 527...
531
     * @throws \coding_exception
527
     * @throws \coding_exception
532
     * @param  \context $context
528
     * @param  \context $context
533
     * @param  int|null $newmodelid A new model to add to the list of models with insights in the provided context.
529
     * @param  int|null $newmodelid A new model to add to the list of models with insights in the provided context.
534
     * @return int[]
530
     * @return int[]
535
     */
531
     */
536
    public static function cached_models_with_insights(\context $context, int $newmodelid = null) {
532
    public static function cached_models_with_insights(\context $context, ?int $newmodelid = null) {
Línea 537... Línea 533...
537
 
533
 
538
        $cache = \cache::make('core', 'contextwithinsights');
534
        $cache = \cache::make('core', 'contextwithinsights');
539
        $modelids = $cache->get($context->id);
535
        $modelids = $cache->get($context->id);
540
        if ($modelids === false) {
536
        if ($modelids === false) {
Línea 776... Línea 772...
776
            if (!isset($model['enabled'])) {
772
            if (!isset($model['enabled'])) {
777
                $model['enabled'] = false;
773
                $model['enabled'] = false;
778
            } else {
774
            } else {
779
                $model['enabled'] = clean_param($model['enabled'], PARAM_BOOL);
775
                $model['enabled'] = clean_param($model['enabled'], PARAM_BOOL);
780
            }
776
            }
-
 
777
 
-
 
778
            // For the core models only, automatically remove references to modules that do not
-
 
779
            // exist. This allows you to install without error if there are missing plugins.
-
 
780
            if ($componentname === 'moodle') {
-
 
781
                $updatedindicators = [];
-
 
782
                $allmodules = [];
-
 
783
                foreach ($model['indicators'] as $indicator) {
-
 
784
                    if (preg_match('~^\\\\mod_([^\\\\]+)\\\\~', $indicator, $matches)) {
-
 
785
                        if (!$allmodules) {
-
 
786
                            // The first time, get all modules.
-
 
787
                            $allmodules = \core\plugin_manager::instance()->get_present_plugins('mod');
-
 
788
                        }
-
 
789
                        if (!array_key_exists($matches[1], $allmodules)) {
-
 
790
                            // Module does not exist, so skip indicator.
-
 
791
                            continue;
-
 
792
                        }
-
 
793
                    }
-
 
794
                    $updatedindicators[] = $indicator;
-
 
795
                }
-
 
796
                $model['indicators'] = $updatedindicators;
-
 
797
            }
781
        }
798
        }
Línea 782... Línea 799...
782
 
799
 
Línea 783... Línea 800...
783
        static::validate_models_declaration($models);
800
        static::validate_models_declaration($models);
Línea 939... Línea 956...
939
     * @throws \coding_exception
956
     * @throws \coding_exception
940
     * @param  array|null $contextlevels The list of context levels provided by the analyser. Null if all of them.
957
     * @param  array|null $contextlevels The list of context levels provided by the analyser. Null if all of them.
941
     * @param  string|null $query
958
     * @param  string|null $query
942
     * @return array Associative array with contextid as key and the short version of the context name as value.
959
     * @return array Associative array with contextid as key and the short version of the context name as value.
943
     */
960
     */
944
    public static function get_potential_context_restrictions(?array $contextlevels = null, string $query = null) {
961
    public static function get_potential_context_restrictions(?array $contextlevels = null, ?string $query = null) {
945
        global $DB;
962
        global $DB;
Línea 946... Línea 963...
946
 
963
 
947
        if (empty($contextlevels) && !is_null($contextlevels)) {
964
        if (empty($contextlevels) && !is_null($contextlevels)) {
948
            return false;
965
            return false;