public function check_dependencies(\stdClass $modeldata, bool $ignoreversionmismatches) : ?string {

        $siteversions = \core_component::get_all_versions();

        // Possible issues.
        $missingcomponents = [];
        $versionmismatches = [];
        $missingclasses = [];

        // We first check that this site has the required dependencies and the required versions.
        foreach ($modeldata->dependencies as $component => $importversion) {

            if (empty($siteversions[$component])) {

                if ($component === 'core') {
                    $component = 'Moodle';
                }
                $missingcomponents[$component] = $component . ' (' . $importversion . ')';
                continue;
            }

            if ($siteversions[$component] == $importversion) {
                // All good here.
                continue;
            }

            if (!$ignoreversionmismatches) {
                if ($component === 'core') {
                    $component = 'Moodle';
                }
                $versionmismatches[$component] = $component . ' (' . $importversion . ')';
            }
        }

        // Checking that each of the components is available.
        if (!$target = manager::get_target($modeldata->target)) {
            $missingclasses[] = $modeldata->target;
        }

        if (!$timesplitting = manager::get_time_splitting($modeldata->timesplitting)) {
            $missingclasses[] = $modeldata->timesplitting;
        }

        // Indicators.
        foreach ($modeldata->indicators as $indicatorclass) {
            if (!$indicator = manager::get_indicator($indicatorclass)) {
                $missingclasses[] = $indicatorclass;
            }
        }

        // ML backend.
        if (!empty($modeldata->processor)) {
            if (!$processor = \core_analytics\manager::get_predictions_processor($modeldata->processor, false)) {
                $missingclasses[] = $indicatorclass;
            }
        }

        if (!empty($missingcomponents)) {
            return get_string('errorimportmissingcomponents', 'analytics', join(', ', $missingcomponents));
        }

        if (!empty($versionmismatches)) {
            return get_string('errorimportversionmismatches', 'analytics', implode(', ', $versionmismatches));
        }

        if (!empty($missingclasses)) {
            $a = (object)[
                'missingclasses' => implode(', ', $missingclasses),
            ];
            return get_string('errorimportmissingclasses', 'analytics', $a);
        }

        // No issues found.
        return null;
    }