// Execute it sending the standard error to $output.
$result = exec($cmd . ' 2>&1', $output, $exitcode);
- if ($result === self::REQUIRED_PIP_PACKAGE_VERSION) {
+ $vercheck = self::check_pip_package_version($result);
+
+ if ($vercheck === 0) {
return true;
}
}
if ($result) {
- $a = (object)array('installed' => $result, 'required' => self::REQUIRED_PIP_PACKAGE_VERSION);
- return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
+ $a = [
+ 'installed' => $result,
+ 'required' => self::REQUIRED_PIP_PACKAGE_VERSION,
+ ];
+
+ if ($vercheck < 0) {
+ return get_string('packageinstalledshouldbe', 'mlbackend_python', $a);
+
+ } else if ($vercheck > 0) {
+ return get_string('packageinstalledtoohigh', 'mlbackend_python', $a);
+ }
}
return get_string('pythonpackagenotinstalled', 'mlbackend_python', $cmd);
*/
$string['packageinstalledshouldbe'] = '"moodlemlbackend" python package should be updated. The required version is "{$a->required}" and the installed version is "{$a->installed}"';
+$string['packageinstalledtoohigh'] = '"moodlemlbackend" python package is not compatible with this Moodle version. The required version is "{$a->required}" or higher as long as it is API-compatible. The installed version "{$a->installed}" is too high.';
$string['pluginname'] = 'Python machine learning backend';
$string['privacy:metadata'] = 'The Python machine learning backend plugin does not store any personal data.';
$string['pythonpackagenotinstalled'] = '"moodlemlbackend" python package is not installed or there is a problem with it. Please execute "{$a}" from command line interface for more info';