本文整理汇总了PHP中question_bank::get_all_qtypes方法的典型用法代码示例。如果您正苦于以下问题:PHP question_bank::get_all_qtypes方法的具体用法?PHP question_bank::get_all_qtypes怎么用?PHP question_bank::get_all_qtypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_bank
的用法示例。
在下文中一共展示了question_bank::get_all_qtypes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
* @param \qubaid_condition $qubaids the usages to consider when counting previous uses of each question.
* @param array $usedquestions questionid => number of times used count. If we should allow for
* further existing uses of a question in addition to the ones in $qubaids.
*/
public function __construct(\qubaid_condition $qubaids, array $usedquestions = array())
{
$this->qubaids = $qubaids;
$this->recentlyusedquestions = $usedquestions;
foreach (\question_bank::get_all_qtypes() as $qtype) {
if (!$qtype->is_usable_by_random()) {
$this->excludedqtypes[] = $qtype->name();
}
}
}
示例2: try_importing_using_qtypes
/**
* Import for questiontype plugins
* Do not override.
* @param data mixed The segment of data containing the question
* @param question object processed (so far) by standard import code if appropriate
* @param extra mixed any additional format specific data that may be passed by the format
* @param qtypehint hint about a question type from format
* @return object question object suitable for save_options() or false if cannot handle
*/
public function try_importing_using_qtypes($data, $question = null, $extra = null,
$qtypehint = '') {
// work out what format we are using
$formatname = substr(get_class($this), strlen('qformat_'));
$methodname = "import_from_$formatname";
//first try importing using a hint from format
if (!empty($qtypehint)) {
$qtype = question_bank::get_qtype($qtypehint, false);
if (is_object($qtype) && method_exists($qtype, $methodname)) {
$question = $qtype->$methodname($data, $question, $this, $extra);
if ($question) {
return $question;
}
}
}
// loop through installed questiontypes checking for
// function to handle this question
foreach (question_bank::get_all_qtypes() as $qtype) {
if (method_exists($qtype, $methodname)) {
if ($question = $qtype->$methodname($data, $question, $this, $extra)) {
return $question;
}
}
}
return false;
}
示例3: search
/**
* Search question types for the specified string
*
* @param string $query The string to search for in question types
* @return array
*/
public function search($query)
{
global $CFG;
if ($result = parent::search($query)) {
return $result;
}
$found = false;
$textlib = textlib_get_instance();
require_once $CFG->dirroot . '/question/engine/bank.php';
foreach (question_bank::get_all_qtypes() as $qtype) {
if (strpos($textlib->strtolower($qtype->local_name()), $query) !== false) {
$found = true;
break;
}
}
if ($found) {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
} else {
return array();
}
}
示例4: init_qtype_lists
/**
* This method needs to be called before the ->excludedqtypes and
* ->manualqtypes fields can be used.
*/
protected function init_qtype_lists() {
if (!is_null($this->excludedqtypes)) {
return; // Already done.
}
$excludedqtypes = array();
$manualqtypes = array();
foreach (question_bank::get_all_qtypes() as $qtype) {
$quotedname = "'" . $qtype->name() . "'";
if (!$qtype->is_usable_by_random()) {
$excludedqtypes[] = $quotedname;
} else if ($qtype->is_manual_graded()) {
$manualqtypes[] = $quotedname;
}
}
$this->excludedqtypes = implode(',', $excludedqtypes);
$this->manualqtypes = implode(',', $manualqtypes);
}
示例5: dirname
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once dirname(__FILE__) . '/../config.php';
require_once $CFG->libdir . '/questionlib.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/pluginlib.php';
require_once $CFG->libdir . '/tablelib.php';
// Check permissions.
require_login();
$systemcontext = context_system::instance();
require_capability('moodle/question:config', $systemcontext);
$canviewreports = has_capability('report/questioninstances:view', $systemcontext);
admin_externalpage_setup('manageqtypes');
$thispageurl = new moodle_url('/admin/qtypes.php');
$qtypes = question_bank::get_all_qtypes();
$pluginmanager = plugin_manager::instance();
// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql("\n SELECT qtype, COUNT(1) as numquestions, SUM(hidden) as numhidden\n FROM {question} GROUP BY qtype", array());
$needed = array();
foreach ($qtypes as $qtypename => $qtype) {
if (!isset($counts[$qtypename])) {
$counts[$qtypename] = new stdClass();
$counts[$qtypename]->numquestions = 0;
$counts[$qtypename]->numhidden = 0;
}
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0 || $pluginmanager->other_plugins_that_require($qtype->plugin_name());
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
}
$needed['missingtype'] = true;
// The system needs the missing question type.
示例6: get_all_response_file_areas
/**
* @return array all the file area names that may contain response files.
*/
public static function get_all_response_file_areas()
{
$variables = array();
foreach (question_bank::get_all_qtypes() as $qtype) {
$variables += $qtype->response_file_areas();
}
$areas = array();
foreach (array_unique($variables) as $variable) {
$areas[] = 'response_' . $variable;
}
return $areas;
}
示例7: initialise_editing_javascript
/**
* Initialise the JavaScript for the general editing. (JavaScript for popups
* is handled with the specific code for those.)
*
* @param \stdClass $course the course settings from the database.
* @param \stdClass $quiz the quiz settings from the database.
* @param structure $structure object containing the structure of the quiz.
* @param \question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return bool Always returns true
*/
protected function initialise_editing_javascript($course, $quiz, structure $structure, \question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl)
{
$config = new \stdClass();
$config->resourceurl = '/mod/quiz/edit_rest.php';
$config->sectionurl = '/mod/quiz/edit_rest.php';
$config->pageparams = array();
$config->questiondecimalpoints = $quiz->questiondecimalpoints;
$config->pagehtml = $this->new_page_template($structure, $contexts, $pagevars, $pageurl);
$config->addpageiconhtml = $this->add_page_icon_template($structure, $quiz);
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes', 'M.mod_quiz.init_resource_toolbox', array(array('courseid' => $course->id, 'quizid' => $quiz->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)));
unset($config->pagehtml);
unset($config->addpageiconhtml);
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes', 'M.mod_quiz.init_section_toolbox', array(array('courseid' => $course->id, 'quizid' => $quiz->id, 'format' => $course->format, 'ajaxurl' => $config->sectionurl, 'config' => $config)));
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_section_dragdrop', array(array('courseid' => $course->id, 'quizid' => $quiz->id, 'ajaxurl' => $config->sectionurl, 'config' => $config)), null, true);
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_resource_dragdrop', array(array('courseid' => $course->id, 'quizid' => $quiz->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)), null, true);
// Require various strings for the command toolbox.
$this->page->requires->strings_for_js(array('clicktohideshow', 'deletechecktype', 'deletechecktypename', 'edittitle', 'edittitleinstructions', 'emptydragdropregion', 'hide', 'markedthistopic', 'markthistopic', 'move', 'movecontent', 'moveleft', 'movesection', 'page', 'question', 'selectall', 'show', 'tocontent'), 'moodle');
$this->page->requires->strings_for_js(array('addpagebreak', 'confirmremovequestion', 'dragtoafter', 'dragtostart', 'numquestionsx', 'removepagebreak'), 'quiz');
foreach (\question_bank::get_all_qtypes() as $qtype => $notused) {
$this->page->requires->string_for_js('pluginname', 'qtype_' . $qtype);
}
return true;
}
示例8: action
function action($action)
{
$qtypes = question_bank::get_all_qtypes();
if (!isset($qtypes[$this->plugin])) {
return get_string('unknownquestiontype', 'question', $this->plugin);
}
switch ($action) {
case 'enable':
unset_config($this->plugin . '_disabled', 'question');
break;
case 'disable':
set_config($this->plugin . '_disabled', 1, 'question');
break;
}
return 0;
}
示例9: __construct
/**
* @global core_renderer $OUTPUT
* @param string $name
* @param string $visiblename
* @param string $description
* @param array $defaultsetting
*/
public function __construct($name, $visiblename, $description, $defaultsetting = null)
{
global $OUTPUT;
$choices = array();
$icons = array();
$qtypes = question_bank::get_all_qtypes();
// some qtypes do not need workaround
unset($qtypes['missingtype']);
unset($qtypes['random']);
// question_bank::sort_qtype_array() expects array(name => local_name)
$qtypenames = array_map(function ($qtype) {
return $qtype->local_name();
}, $qtypes);
foreach (question_bank::sort_qtype_array($qtypenames) as $name => $label) {
$choices[$name] = $label;
$icons[$name] = ' ' . $OUTPUT->pix_icon('icon', '', $qtypes[$name]->plugin_name()) . ' ';
}
parent::__construct($name, $visiblename, $description, $defaultsetting, $choices, $icons);
}
示例10: initialise_editing_javascript
/**
* Initialise the JavaScript for the general editing. (JavaScript for popups
* is handled with the specific code for those.)
*
* @param \stdClass $course the course settings from the database.
* @param \stdClass $quiz the quiz settings from the database.
* @return bool Always returns true
*/
protected function initialise_editing_javascript($course, $quiz) {
$config = new \stdClass();
$config->resourceurl = '/mod/quiz/edit_rest.php';
$config->sectionurl = '/mod/quiz/edit_rest.php';
$config->pageparams = array();
$config->questiondecimalpoints = $quiz->questiondecimalpoints;
// Include toolboxes.
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes',
'M.mod_quiz.init_resource_toolbox',
array(array(
'courseid' => $course->id,
'quizid' => $quiz->id,
'ajaxurl' => $config->resourceurl,
'config' => $config,
))
);
$this->page->requires->yui_module('moodle-mod_quiz-toolboxes',
'M.mod_quiz.init_section_toolbox',
array(array(
'courseid' => $course->id,
'quizid' => $quiz->id,
'format' => $course->format,
'ajaxurl' => $config->sectionurl,
'config' => $config,
))
);
// Include course dragdrop.
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_section_dragdrop',
array(array(
'courseid' => $course->id,
'quizid' => $quiz->id,
'ajaxurl' => $config->sectionurl,
'config' => $config,
)), null, true);
$this->page->requires->yui_module('moodle-mod_quiz-dragdrop', 'M.mod_quiz.init_resource_dragdrop',
array(array(
'courseid' => $course->id,
'quizid' => $quiz->id,
'ajaxurl' => $config->resourceurl,
'config' => $config,
)), null, true);
// Require various strings for the command toolbox.
$this->page->requires->strings_for_js(array(
'moveleft',
'deletechecktype',
'deletechecktypename',
'edittitle',
'edittitleinstructions',
'show',
'hide',
'clicktochangeinbrackets',
'markthistopic',
'markedthistopic',
'move',
'movesection',
'movecontent',
'selectall',
'tocontent',
'emptydragdropregion'
), 'moodle');
$this->page->requires->strings_for_js(array(
'confirmremovequestion',
'dragtoafter',
'dragtostart',
), 'quiz');
foreach (\question_bank::get_all_qtypes() as $qtype => $notused) {
$this->page->requires->string_for_js('pluginname', 'qtype_' . $qtype);
}
return true;
}