diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 20f59496af4..7cfd5d728db 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -1237,7 +1237,11 @@ class plugintype_qtype extends plugintype_base implements plugintype_interface { * @see plugintype_interface::init_display_name() */ public function init_display_name() { - $this->displayname = get_string($this->name, 'qtype_' . $this->name); + if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) { + $this->displayname = get_string('pluginname', $this->type . '_' . $this->name); + } else { + $this->displayname = get_string($this->name, 'qtype_' . $this->name); + } } } @@ -1250,7 +1254,11 @@ class plugintype_qformat extends plugintype_base implements plugintype_interface * @see plugintype_interface::init_display_name() */ public function init_display_name() { - $this->displayname = get_string($this->name, 'qformat_' . $this->name); + if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) { + $this->displayname = get_string('pluginname', $this->type . '_' . $this->name); + } else { + $this->displayname = get_string($this->name, 'qformat_' . $this->name); + } } } diff --git a/lib/questionlib.php b/lib/questionlib.php index 36327077d03..683488ad65f 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1191,29 +1191,27 @@ function question_categorylist($categoryid) { */ function get_import_export_formats($type) { global $CFG; + require_once($CFG->dirroot . '/question/format.php'); - $fileformats = get_plugin_list('qformat'); + $formatclasses = get_plugin_list_with_class('qformat', '', 'format.php'); $fileformatname = array(); - require_once($CFG->dirroot . '/question/format.php'); - foreach ($fileformats as $fileformat => $fdir) { - $formatfile = $fdir . '/format.php'; - if (is_readable($formatfile)) { - include_once($formatfile); - } else { - continue; - } + foreach ($formatclasses as $component => $formatclass) { - $classname = 'qformat_' . $fileformat; - $formatclass = new $classname(); + $format = new $formatclass(); if ($type == 'import') { - $provided = $formatclass->provide_import(); + $provided = $format->provide_import(); } else { - $provided = $formatclass->provide_export(); + $provided = $format->provide_export(); } if ($provided) { - $fileformatnames[$fileformat] = get_string($fileformat, 'qformat_' . $fileformat); + list($notused, $fileformat) = explode('_', $component, 2); + if (get_string_manager()->string_exists('pluginname', $component)) { + $fileformatnames[$fileformat] = get_string('pluginname', $component); + } else { + $fileformatnames[$fileformat] = get_string($fileformat, $component); + } } } diff --git a/question/export.php b/question/export.php index 172afa5fb80..9cdf49799c9 100644 --- a/question/export.php +++ b/question/export.php @@ -27,6 +27,7 @@ require_once(dirname(__FILE__) . '/../config.php'); require_once($CFG->dirroot . '/question/editlib.php'); require_once($CFG->dirroot . '/question/export_form.php'); +require_once($CFG->dirroot . '/question/format.php'); list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = question_edit_setup('export', '/question/export.php'); diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index 12f16e4eecc..abc78886c0c 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -74,7 +74,11 @@ class question_type { * You should not need to override this method, the default behaviour should be fine. */ public function local_name() { - return get_string($this->name(), $this->plugin_name()); + if (get_string_manager()->string_exists('pluginname', $this->plugin_name())) { + $this->displayname = get_string('pluginname', $this->plugin_name()); + } else { + $this->displayname = get_string($this->name(), $this->plugin_name()); + } } /**