Este error ocurre cuando el plugin de disponibilidad por idioma (availability_language) está mal instalado o corrupto, impidiendo el acceso a los cursos en Moodle.
mkdir -p availability/condition/language/classes
mkdir -p availability/condition/language/lang/en
chmod -R 755 language
chown -R www-data:www-data language
INSERT INTO mo_config_plugins (plugin, name, value)
VALUES (‘availability_language’, ‘version’, ‘2019111800’);
Nota: Este proceso fue probado exitosamente en Moodle 3.8.2. Para otras versiones, asegúrate de usar la versión correcta del plugin.
cat > language/version.php << ‘EOF’
<?php
defined(‘MOODLE_INTERNAL’) || die();
$plugin->version = 2019111800;
$plugin->requires = 2019111200; // Moodle 3.8
$plugin->component = ‘availability_language’;
$plugin->maturity = MATURITY_STABLE;
EOF
cat > language/classes/condition.php << ‘EOF’
<?php
namespace availability_language;
defined(‘MOODLE_INTERNAL’) || die();
class condition extends \core_availability\condition {
protected $languageid;
public function __construct($structure) {
if (!empty($structure->id)) {
$this->languageid = $structure->id;
}
}
public function save() {
return (object)array(‘type’ => ‘language’, ‘id’ => $this->languageid);
}
public function is_available($not, \core_availability\info $info, $grabthelot, $userid) {
$current = current_language();
$allow = ($current === $this->languageid);
if ($not) {
$allow = !$allow;
}
return $allow;
}
public function get_description($full, $not, \core_availability\info $info) {
$langs = get_string_manager()->get_list_of_languages();
$langname = $langs[$this->languageid];
if ($not) {
return get_string(‘not_language’, ‘availability_language’, $langname);
} else {
return get_string(‘requires_language’, ‘availability_language’, $langname);
}
}
}
EOF
cat > language/lang/en/availability_language.php << ‘EOF’
<?php
defined(‘MOODLE_INTERNAL’) || die();
$string[‘description’] = ‘Require students to use a specific language’;
$string[‘getdescription’] = ‘The student must use {$a}’;
$string[‘getdescriptionnot’] = ‘The student must not use {$a}’;
$string[‘missing’] = ‘You must select a language’;
$string[‘pluginname’] = ‘Restriction by language’;
$string[‘requires_language’] = ‘You must use {$a}’;
$string[‘not_language’] = ‘You must not use {$a}’;
$string[‘title’] = ‘Language’;
EOF
chmod -R 755 language
chown -R www-data:www-data language