本文整理汇总了PHP中plugin_supports函数的典型用法代码示例。如果您正苦于以下问题:PHP plugin_supports函数的具体用法?PHP plugin_supports怎么用?PHP plugin_supports使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plugin_supports函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
//$mform->addElement('html', get_string('unplagexplain', 'plagiarism_unplag'));
$mform->addElement('checkbox', 'unplag_use', get_string('useunplag', 'plagiarism_unplag'));
$mform->addElement('text', 'unplag_client_id', get_string('unplag_client_id', 'plagiarism_unplag'));
$mform->addHelpButton('unplag_client_id', 'unplag_client_id', 'plagiarism_unplag');
$mform->addRule('unplag_client_id', null, 'required', null, 'client');
$mform->setType('unplag_client_id', PARAM_TEXT);
$mform->addElement('text', 'unplag_api_secret', get_string('unplag_api_secret', 'plagiarism_unplag'));
$mform->addHelpButton('unplag_api_secret', 'unplag_api_secret', 'plagiarism_unplag');
$mform->addRule('unplag_api_secret', null, 'required', null, 'client');
$mform->setType('unplag_api_secret', PARAM_TEXT);
$mform->addElement('text', 'unplag_lang', get_string('unplag_lang', 'plagiarism_unplag'));
$mform->addHelpButton('unplag_lang', 'unplag_lang', 'plagiarism_unplag');
$mform->addRule('unplag_lang', null, 'required', null, 'client');
$mform->setDefault('unplag_lang', 'en-US');
$mform->setType('unplag_lang', PARAM_TEXT);
$mform->addElement('textarea', 'unplag_student_disclosure', get_string('studentdisclosure', 'plagiarism_unplag'), 'wrap="virtual" rows="6" cols="50"');
$mform->addHelpButton('unplag_student_disclosure', 'studentdisclosure', 'plagiarism_unplag');
$mform->setDefault('unplag_student_disclosure', get_string('studentdisclosuredefault', 'plagiarism_unplag'));
$mform->setType('unplag_student_disclosure', PARAM_TEXT);
$mods = core_component::get_plugin_list('mod');
foreach ($mods as $mod => $modname) {
if (plugin_supports('mod', $mod, FEATURE_PLAGIARISM)) {
$modstring = 'unplag_enable_mod_' . $mod;
$mform->addElement('checkbox', $modstring, get_string('unplag_enableplugin', 'plagiarism_unplag', $mod));
}
}
$this->add_action_buttons(true);
}
示例2: __construct
/**
* Constructor - instantiates one object of this class
*/
public function __construct($name, $blockid, $moduleid = null, $plan = null)
{
global $DB;
// Check blockid exists
if (!($block = $DB->get_record('block_instances', array('id' => $blockid)))) {
throw new backup_task_exception('block_task_block_instance_not_found', $blockid);
}
$this->blockid = $blockid;
$this->blockname = $block->blockname;
$this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id;
$this->moduleid = $moduleid;
$this->modulename = null;
$this->parentcontextid = null;
// If moduleid passed, check exists, supports moodle2 format and save info
// Check moduleid exists
if (!empty($moduleid)) {
if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) {
throw new backup_task_exception('block_task_coursemodule_not_found', $moduleid);
}
// Check activity supports this moodle2 backup format
if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) {
throw new backup_task_exception('block_task_activity_lacks_moodle2_backup_support', $coursemodule->modname);
}
$this->moduleid = $moduleid;
$this->modulename = $coursemodule->modname;
$this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
}
parent::__construct($name, $plan);
}
示例3: definition
protected function definition()
{
global $CFG;
$mform =& $this->_form;
$mform->addElement('html', get_string('compilatioexplain', 'plagiarism_compilatio'));
$mform->addElement('checkbox', 'compilatio_use', get_string('usecompilatio', 'plagiarism_compilatio'));
$mform->addElement('text', 'compilatio_api', get_string('compilatio_api', 'plagiarism_compilatio'));
$mform->addHelpButton('compilatio_api', 'compilatio_api', 'plagiarism_compilatio');
$mform->addRule('compilatio_api', null, 'required', null, 'client');
$mform->setDefault('compilatio_api', 'http://service.compilatio.net/webservices/CompilatioUserClient2.wsdl');
$mform->addElement('passwordunmask', 'compilatio_password', get_string('compilatio_password', 'plagiarism_compilatio'));
$mform->addHelpButton('compilatio_password', 'compilatio_password', 'plagiarism_compilatio');
$mform->addRule('compilatio_password', null, 'required', null, 'client');
$mform->addElement('textarea', 'compilatio_student_disclosure', get_string('studentdisclosure', 'plagiarism_compilatio'), 'wrap="virtual" rows="6" cols="50"');
$mform->addHelpButton('compilatio_student_disclosure', 'studentdisclosure', 'plagiarism_compilatio');
$mform->setDefault('compilatio_student_disclosure', get_string('studentdisclosuredefault', 'plagiarism_compilatio'));
$mods = get_plugin_list('mod');
foreach ($mods as $mod => $modname) {
if (plugin_supports('mod', $mod, FEATURE_PLAGIARISM)) {
$modstring = 'compilatio_enable_mod_' . $mod;
$mform->addElement('checkbox', $modstring, get_string('compilatio_enableplugin', 'plagiarism_compilatio', get_string('pluginname', 'mod_' . $mod)));
}
}
$this->add_action_buttons(true);
}
示例4: definition
/**
* Defines forms elements
* @see: https://docs.moodle.org/dev/lib/formslib.php_Form_Definition
*/
public function definition()
{
$mform = $this->_form;
$modinfo = $this->_customdata;
//let's create an array of those plugins that support the completion features
$supportedmods = array();
foreach ($modinfo->get_used_module_names() as $modtype => $modname) {
if (plugin_supports('mod', $modtype, FEATURE_COMPLETION_TRACKS_VIEWS, 0)) {
$supportedmods[$modtype] = $modname;
}
}
foreach ($modinfo->get_section_info_all() as $sectid => $sectinfo) {
//skip the first section because in snap we turn it into a menu
if (!$sectid) {
continue;
}
//skip the section if the id is greater than what is allowed by the course
//if($sectid > $course->numsections) continue;
//skip the section if not visible or not avilable
//if(!$sectinfo->visible || !$sectinfo->available) continue;
//skip section if it doesn't have any modules
if (empty($modinfo->sections[$sectid])) {
continue;
}
//add the section name as a header
$mform->addElement('html', '<h3 class="section-header">' . $sectinfo->name . '</h3>');
//iterate the modules within the section
foreach ($modinfo->sections[$sectid] as $modid) {
//completion = completion
//completionexpected
$mod = $modinfo->cms[$modid];
//if this is a subheader, then add it
if ($mod->modname == 'subheader') {
$mform->addElement('html', '<div class="subheader">' . $mod->name . '</div>');
continue;
}
//check to see if this plugin supports completion tracking
if (!isset($supportedmods[$mod->modname])) {
continue;
}
//create the html for the module icon
$icon = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(), 'class' => 'icon', 'alt' => ' ', 'role' => 'presentation'));
$mform->addElement('advcheckbox', 'mod_' . $modid, false, $icon . ' ' . $mod->name, null, array('0', $modid));
//if completion is already set, then check the checkbox
if ($mod->completion) {
$mform->setDefault('mod_' . $modid, true);
}
}
}
//add the action buttons
$this->add_action_buttons();
}
示例5: get_content
function get_content()
{
global $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
$archetypes = array();
foreach ($modinfo->cms as $cm) {
// Exclude activities which are not visible or have no link (=label)
if (!$cm->uservisible or !$cm->has_view()) {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}
core_collator::asort($modfullnames);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = $OUTPUT->pix_icon('icon', '', 'mod_page', array('class' => 'icon'));
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/resources.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
} else {
$icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" />';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
}
}
return $this->content;
}
示例6: __construct
/**
* Constructor - instantiates one object of this class
*
* @param string $name the task identifier
* @param int $moduleid course module id (id in course_modules table)
* @param backup_plan|null $plan the backup plan instance this task is part of
*/
public function __construct($name, $moduleid, $plan = null)
{
// Check moduleid exists
if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) {
throw new backup_task_exception('activity_task_coursemodule_not_found', $moduleid);
}
// Check activity supports this moodle2 backup format
if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) {
throw new backup_task_exception('activity_task_activity_lacks_moodle2_backup_support', $coursemodule->modname);
}
$this->moduleid = $moduleid;
$this->sectionid = $coursemodule->section;
$this->modulename = $coursemodule->modname;
$this->activityid = $coursemodule->instance;
$this->contextid = context_module::instance($this->moduleid)->id;
parent::__construct($name, $plan);
}
示例7: definition
public function definition()
{
$mform =& $this->_form;
$mform->addElement('html', get_string('urkundexplain', 'plagiarism_urkund'));
$mform->addElement('checkbox', 'urkund_use', get_string('useurkund', 'plagiarism_urkund'));
$mform->addElement('text', 'urkund_api', get_string('urkund_api', 'plagiarism_urkund'));
$mform->addHelpButton('urkund_api', 'urkund_api', 'plagiarism_urkund');
$mform->addRule('urkund_api', null, 'required', null, 'client');
$mform->setDefault('urkund_api', 'https://secure.urkund.com/api/submissions');
$mform->setType('urkund_api', PARAM_URL);
$mform->addElement('text', 'urkund_username', get_string('urkund_username', 'plagiarism_urkund'));
$mform->addHelpButton('urkund_username', 'urkund_username', 'plagiarism_urkund');
$mform->addRule('urkund_username', null, 'required', null, 'client');
$mform->setType('urkund_username', PARAM_TEXT);
$mform->addElement('passwordunmask', 'urkund_password', get_string('urkund_password', 'plagiarism_urkund'));
$mform->addHelpButton('urkund_password', 'urkund_password', 'plagiarism_urkund');
$mform->addRule('urkund_password', null, 'required', null, 'client');
$mform->setType('urkund_password', PARAM_TEXT);
$mform->addElement('text', 'urkund_lang', get_string('urkund_lang', 'plagiarism_urkund'));
$mform->addHelpButton('urkund_lang', 'urkund_lang', 'plagiarism_urkund');
$mform->addRule('urkund_lang', null, 'required', null, 'client');
$mform->setDefault('urkund_lang', 'en-US');
$mform->setType('urkund_lang', PARAM_TEXT);
$mform->addElement('textarea', 'urkund_student_disclosure', get_string('studentdisclosure', 'plagiarism_urkund'), 'wrap="virtual" rows="6" cols="50"');
$mform->addHelpButton('urkund_student_disclosure', 'studentdisclosure', 'plagiarism_urkund');
$mform->setDefault('urkund_student_disclosure', get_string('studentdisclosuredefault', 'plagiarism_urkund'));
$mform->setType('urkund_student_disclosure', PARAM_TEXT);
$mform->addElement('checkbox', 'urkund_optout', get_string('urkund_enableoptout', 'plagiarism_urkund'), '<br/>' . get_string('urkund_enableoptoutdesc', 'plagiarism_urkund'));
$mform->setDefault('urkund_optout', true);
$mform->addElement('text', 'urkund_wordcount', get_string('wordcount', 'plagiarism_urkund'));
$mform->addHelpButton('urkund_wordcount', 'wordcount', 'plagiarism_urkund');
$mform->setType('urkund_wordcount', PARAM_INT);
$mform->addRule('urkund_wordcount', null, 'required', null, 'client');
$mform->setDefault('urkund_wordcount', '50');
$mods = core_component::get_plugin_list('mod');
foreach ($mods as $mod => $modname) {
if (plugin_supports('mod', $mod, FEATURE_PLAGIARISM)) {
$modstring = 'urkund_enable_mod_' . $mod;
$mform->addElement('checkbox', $modstring, get_string('urkund_enableplugin', 'plagiarism_urkund', $mod));
if ($modname == 'assign') {
$mform->setDefault($modstring, 1);
}
}
}
$this->add_action_buttons(true);
}
示例8: get_content
function get_content()
{
global $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$modinfo = get_fast_modinfo($course);
$modfullnames = array();
$archetypes = array();
foreach ($modinfo->cms as $cm) {
if (!$cm->uservisible or $cm->modname === 'label') {
continue;
}
if (array_key_exists($cm->modname, $modfullnames)) {
continue;
}
if (!array_key_exists($cm->modname, $archetypes)) {
$archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
}
if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
if (!array_key_exists('resources', $modfullnames)) {
$modfullnames['resources'] = get_string('resources');
}
} else {
$modfullnames[$cm->modname] = $cm->modplural;
}
}
textlib_get_instance()->asort($modfullnames);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
$icon = '<img src="' . $OUTPUT->pix_url('f/html') . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/resources.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
} else {
$icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" /> ';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
}
}
return $this->content;
}
示例9: course_get_cm_edit_actions_reduced
/**
* Returns the list of all editing actions that current user can perform on the module
*
* @param cm_info $mod The module to produce editing buttons for
* @param int $indent The current indenting (default -1 means no move left-right actions)
* @param int $sr The section to link back to (used for creating the links)
* @return array array of action_link or pix_icon objects
*/
function course_get_cm_edit_actions_reduced(cm_info $mod, $indent = -1, $sr = null)
{
global $COURSE, $SITE;
static $str;
$coursecontext = context_course::instance($mod->course);
$modcontext = context_module::instance($mod->id);
$editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
$dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
//No permission to edit anything.
if (!has_any_capability($editcaps, $modcontext) and !has_all_capabilities($dupecaps, $coursecontext)) {
return array();
}
$hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
if (!isset($str)) {
$str = get_strings(array('delete', 'move', 'moveright', 'moveleft', 'editsettings', 'duplicate', 'hide', 'show'), 'moodle');
$str->assign = get_string('assignroles', 'role');
$str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
$str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
$str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
}
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
if ($sr !== null) {
$baseurl->param('sr', $sr);
}
$actions = array();
// Duplicate (require both target import caps to be able to duplicate and backup2 support, see modduplicate.php)
// Note that restoring on front page is never allowed.
if ($mod->course != SITEID && has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
$actions['duplicate'] = new action_menu_link_secondary(new moodle_url($baseurl, array('duplicate' => $mod->id)), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->duplicate, array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sr' => $sr));
}
// Delete.
if ($hasmanageactivities) {
$actions['delete'] = new action_menu_link_secondary(new moodle_url($baseurl, array('delete' => $mod->id)), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->delete, array('class' => 'editing_delete', 'data-action' => 'delete'));
}
return $actions;
}
示例10: process_enrol
/**
* Create enrolment instances.
*
* This has to be called after creation of roles
* and before adding of role assignments.
*
* @param mixed $data
* @return void
*/
public function process_enrol($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id; // We'll need this later
$restoretype = plugin_supports('enrol', $data->enrol, ENROL_RESTORE_TYPE, null);
if ($restoretype !== ENROL_RESTORE_EXACT and $restoretype !== ENROL_RESTORE_NOUSERS) {
// TODO: add complex restore support via custom class
debugging("Skipping '{$data->enrol}' enrolment plugin. Will be implemented before 2.0 release", DEBUG_DEVELOPER);
$this->set_mapping('enrol', $oldid, 0);
return;
}
// Perform various checks to decide what to do with the enrol plugin
if (!array_key_exists($data->enrol, enrol_get_plugins(false))) {
// TODO: decide if we want to switch to manual enrol - we need UI for this
debugging("Enrol plugin data can not be restored because it is not installed");
$this->set_mapping('enrol', $oldid, 0);
return;
}
if (!enrol_is_enabled($data->enrol)) {
// TODO: decide if we want to switch to manual enrol - we need UI for this
debugging("Enrol plugin data can not be restored because it is not enabled");
$this->set_mapping('enrol', $oldid, 0);
return;
}
// map standard fields - plugin has to process custom fields from own restore class
$data->roleid = $this->get_mappingid('role', $data->roleid);
//TODO: should we move the enrol start and end date here?
// always add instance, if the course does not support multiple instances it just returns NULL
$enrol = enrol_get_plugin($data->enrol);
$courserec = $DB->get_record('course', array('id' => $this->get_courseid())); // Requires object, uses only id!!
if ($newitemid = $enrol->add_instance($courserec, (array)$data)) {
// ok
} else {
if ($instances = $DB->get_records('enrol', array('courseid'=>$courserec->id, 'enrol'=>$data->enrol))) {
// most probably plugin that supports only one instance
$newitemid = key($instances);
} else {
debugging('Can not create new enrol instance or reuse existing');
$newitemid = 0;
}
}
if ($restoretype === ENROL_RESTORE_NOUSERS) {
// plugin requests to prevent restore of any users
$newitemid = 0;
}
$this->set_mapping('enrol', $oldid, $newitemid);
}
示例11: internal_get_state
/**
* Calculates the completion state for an activity and user.
*
* Internal function. Not private, so we can unit-test it.
*
* @param stdClass|cm_info $cm Activity
* @param int $userid ID of user
* @param stdClass $current Previous completion information from database
* @return mixed
*/
public function internal_get_state($cm, $userid, $current)
{
global $USER, $DB, $CFG;
// Get user ID
if (!$userid) {
$userid = $USER->id;
}
// Check viewed
if ($cm->completionview == COMPLETION_VIEW_REQUIRED && $current->viewed == COMPLETION_NOT_VIEWED) {
return COMPLETION_INCOMPLETE;
}
// Modname hopefully is provided in $cm but just in case it isn't, let's grab it
if (!isset($cm->modname)) {
$cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module));
}
$newstate = COMPLETION_COMPLETE;
// Check grade
if (!is_null($cm->completiongradeitemnumber)) {
require_once $CFG->libdir . '/gradelib.php';
$item = grade_item::fetch(array('courseid' => $cm->course, 'itemtype' => 'mod', 'itemmodule' => $cm->modname, 'iteminstance' => $cm->instance, 'itemnumber' => $cm->completiongradeitemnumber));
if ($item) {
// Fetch 'grades' (will be one or none)
$grades = grade_grade::fetch_users_grades($item, array($userid), false);
if (empty($grades)) {
// No grade for user
return COMPLETION_INCOMPLETE;
}
if (count($grades) > 1) {
$this->internal_systemerror("Unexpected result: multiple grades for\n item '{$item->id}', user '{$userid}'");
}
$newstate = self::internal_get_grade_state($item, reset($grades));
if ($newstate == COMPLETION_INCOMPLETE) {
return COMPLETION_INCOMPLETE;
}
} else {
$this->internal_systemerror("Cannot find grade item for '{$cm->modname}'\n cm '{$cm->id}' matching number '{$cm->completiongradeitemnumber}'");
}
}
if (plugin_supports('mod', $cm->modname, FEATURE_COMPLETION_HAS_RULES)) {
$function = $cm->modname . '_get_completion_state';
if (!function_exists($function)) {
$this->internal_systemerror("Module {$cm->modname} claims to support\n FEATURE_COMPLETION_HAS_RULES but does not have required\n {$cm->modname}_get_completion_state function");
}
if (!$function($this->course, $cm, $userid, COMPLETION_AND)) {
return COMPLETION_INCOMPLETE;
}
}
return $newstate;
}
示例12: course_allowed_module
/**
* Is the user allowed to add this type of module to this course?
* @param object $course the course settings. Only $course->id is used.
* @param string $modname the module name. E.g. 'forum' or 'quiz'.
* @return bool whether the current user is allowed to add this type of module to this course.
*/
function course_allowed_module($course, $modname)
{
global $DB;
if (is_numeric($modname)) {
throw new coding_exception('Function course_allowed_module no longer
supports numeric module ids. Please update your code to pass the module name.');
}
$capability = 'mod/' . $modname . ':addinstance';
if (!get_capability_info($capability)) {
// Debug warning that the capability does not exist, but no more than once per page.
static $warned = array();
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if (!isset($warned[$modname]) && $archetype !== MOD_ARCHETYPE_SYSTEM) {
debugging('The module ' . $modname . ' does not define the standard capability ' . $capability, DEBUG_DEVELOPER);
$warned[$modname] = 1;
}
// If the capability does not exist, the module can always be added.
return true;
}
$coursecontext = context_course::instance($course->id);
return has_capability($capability, $coursecontext);
}
示例13: get_supported_activities
/**
* Get the activities supported by the format.
*
* Here we ignore the modules that do not have a page of their own, like the label.
*
* @return array array($module => $name of the module).
*/
public static function get_supported_activities()
{
$availabletypes = get_module_types_names();
foreach ($availabletypes as $module => $name) {
if (plugin_supports('mod', $module, FEATURE_NO_VIEW_LINK, false)) {
unset($availabletypes[$module]);
}
}
return $availabletypes;
}
示例14: standard_coursemodule_elements
//.........这里部分代码省略.........
if ($this->_features->idnumber) {
$mform->addElement('text', 'cmidnumber', get_string('idnumbermod'));
$mform->setType('cmidnumber', PARAM_RAW);
$mform->addHelpButton('cmidnumber', 'idnumbermod');
}
if ($this->_features->groups) {
$options = array(NOGROUPS => get_string('groupsnone'), SEPARATEGROUPS => get_string('groupsseparate'), VISIBLEGROUPS => get_string('groupsvisible'));
$mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $options, NOGROUPS);
$mform->addHelpButton('groupmode', 'groupmode', 'group');
}
if ($this->_features->groupings) {
// Groupings selector - used to select grouping for groups in activity.
$options = array();
if ($groupings = $DB->get_records('groupings', array('courseid' => $COURSE->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name);
}
}
core_collator::asort($options);
$options = array(0 => get_string('none')) + $options;
$mform->addElement('select', 'groupingid', get_string('grouping', 'group'), $options);
$mform->addHelpButton('groupingid', 'grouping', 'group');
}
if (!empty($CFG->enableavailability)) {
// Add special button to end of previous section if groups/groupings
// are enabled.
if ($this->_features->groups || $this->_features->groupings) {
$mform->addElement('static', 'restrictgroupbutton', '', html_writer::tag('button', get_string('restrictbygroup', 'availability'), array('id' => 'restrictbygroup', 'disabled' => 'disabled')));
}
// Availability field. This is just a textarea; the user interface
// interaction is all implemented in JavaScript.
$mform->addElement('header', 'availabilityconditionsheader', get_string('restrictaccess', 'availability'));
// Note: This field cannot be named 'availability' because that
// conflicts with fields in existing modules (such as assign).
// So it uses a long name that will not conflict.
$mform->addElement('textarea', 'availabilityconditionsjson', get_string('accessrestrictions', 'availability'));
// The _cm variable may not be a proper cm_info, so get one from modinfo.
if ($this->_cm) {
$modinfo = get_fast_modinfo($COURSE);
$cm = $modinfo->get_cm($this->_cm->id);
} else {
$cm = null;
}
\core_availability\frontend::include_all_javascript($COURSE, $cm);
}
// Conditional activities: completion tracking section
if (!isset($completion)) {
$completion = new completion_info($COURSE);
}
if ($completion->is_enabled()) {
$mform->addElement('header', 'activitycompletionheader', get_string('activitycompletion', 'completion'));
// Unlock button for if people have completed it (will
// be removed in definition_after_data if they haven't)
$mform->addElement('submit', 'unlockcompletion', get_string('unlockcompletion', 'completion'));
$mform->registerNoSubmitButton('unlockcompletion');
$mform->addElement('hidden', 'completionunlocked', 0);
$mform->setType('completionunlocked', PARAM_INT);
$trackingdefault = COMPLETION_TRACKING_NONE;
// If system and activity default is on, set it.
if ($CFG->completiondefault && $this->_features->defaultcompletion) {
$trackingdefault = COMPLETION_TRACKING_MANUAL;
}
$mform->addElement('select', 'completion', get_string('completion', 'completion'), array(COMPLETION_TRACKING_NONE => get_string('completion_none', 'completion'), COMPLETION_TRACKING_MANUAL => get_string('completion_manual', 'completion')));
$mform->setDefault('completion', $trackingdefault);
$mform->addHelpButton('completion', 'completion', 'completion');
// Automatic completion once you view it
$gotcompletionoptions = false;
if (plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, false)) {
$mform->addElement('checkbox', 'completionview', get_string('completionview', 'completion'), get_string('completionview_desc', 'completion'));
$mform->disabledIf('completionview', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
$gotcompletionoptions = true;
}
// Automatic completion once it's graded
if (plugin_supports('mod', $this->_modname, FEATURE_GRADE_HAS_GRADE, false)) {
$mform->addElement('checkbox', 'completionusegrade', get_string('completionusegrade', 'completion'), get_string('completionusegrade_desc', 'completion'));
$mform->disabledIf('completionusegrade', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
$mform->addHelpButton('completionusegrade', 'completionusegrade', 'completion');
$gotcompletionoptions = true;
// If using the rating system, there is no grade unless ratings are enabled.
if ($this->_features->rating) {
$mform->disabledIf('completionusegrade', 'assessed', 'eq', 0);
}
}
// Automatic completion according to module-specific rules
$this->_customcompletionelements = $this->add_completion_rules();
foreach ($this->_customcompletionelements as $element) {
$mform->disabledIf($element, 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
}
$gotcompletionoptions = $gotcompletionoptions || count($this->_customcompletionelements) > 0;
// Automatic option only appears if possible
if ($gotcompletionoptions) {
$mform->getElement('completion')->addOption(get_string('completion_automatic', 'completion'), COMPLETION_TRACKING_AUTOMATIC);
}
// Completion expected at particular date? (For progress tracking)
$mform->addElement('date_selector', 'completionexpected', get_string('completionexpected', 'completion'), array('optional' => true));
$mform->addHelpButton('completionexpected', 'completionexpected', 'completion');
$mform->disabledIf('completionexpected', 'completion', 'eq', COMPLETION_TRACKING_NONE);
}
$this->standard_hidden_coursemodule_elements();
}
示例15: ss_print_section
//.........这里部分代码省略.........
echo '<div>';
}
echo format_text($extra, FORMAT_HTML, $labelformatoptions);
echo "</div>";
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!isset($groupings)) {
$groupings = groups_get_all_groupings($course->id);
}
echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>';
}
} else { // Normal activity
$instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id);
# echo format_string($modinfo->cms[$modnumber]->intro, true, $course->id);
# echo format_string($modinfo->cms[$modnumber]->name, true, $course->id);
# print_r($modinfo->cms[$modnumber]);
$customicon = $modinfo->cms[$modnumber]->icon;
if (!empty($customicon)) {
if (substr($customicon, 0, 4) === 'mod/') {
list($modname, $iconname) = explode('/', substr($customicon, 4), 2);
$icon = $OUTPUT->pix_url($iconname, $modname);
} else {
$icon = $OUTPUT->pix_url($customicon);
}
} else {
$icon = $OUTPUT->pix_url('icon', $mod->modname);
}
//Accessibility: for files get description via icon, this is very ugly hack!
$altname = '';
$altname = $mod->modfullname;
if (!empty($customicon)) {
$archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
$mimetype = mimeinfo_from_icon('type', $customicon);
$altname = get_mimetype_description($mimetype);
}
}
// Avoid unnecessary duplication.
if (false !== stripos($instancename, $altname)) {
$altname = '';
}
// File type after name, for alphabetic lists (screen reader).
if ($altname) {
$altname = get_accesshide(' '.$altname);
}
// We may be displaying this just in order to show information
// about visibility, without the actual link
if ($mod->uservisible) {
// Display normal module link
if (!$accessiblebutdim) {
$linkcss = '';
$accesstext ='';
} else {
$linkcss = ' class="dimmed" ';
$accesstext = '<span class="accesshide">'.
get_string('hiddenfromstudents').': </span>';
}
echo '<a '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.
'<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename',$mod->modname).'" /> '.
$accesstext.'<span class="instancename">'.$instancename.$altname.'</span></a>';