MDL-41885 modules now declare use of question bank

* FEATURE_USES_QUESTION_BANK is now a module_supports flag which declares
  that an activity uses the question engine.

* question_module_uses_questions can be used to determine if a module
  uses the question bank.
This commit is contained in:
Dan Poltawski
2013-09-26 09:49:34 +08:00
parent f5dfefdc87
commit b07ef13be2
5 changed files with 33 additions and 1 deletions
+20
View File
@@ -2054,3 +2054,23 @@ function question_page_type_list($pagetype, $parentcontext, $currentcontext) {
return $types;
}
}
/**
* Does an activity module use the question bank?
*
* @param string $modname The name of the module (without mod_ prefix).
* @return bool true if the module uses questions.
*/
function question_module_uses_questions($modname) {
if (plugin_supports('mod', $modname, FEATURE_USES_QUESTIONS)) {
return true;
}
$component = 'mod_'.$modname;
if (component_callback_exists($component, 'question_pluginfile')) {
debugging("{$component} uses questions but doesn't declare FEATURE_USES_QUESTIONS", DEBUG_DEVELOPER);
return true;
}
return false;
}