当前位置: 首页>>代码示例>>PHP>>正文


PHP context_course类代码示例

本文整理汇总了PHP中context_course的典型用法代码示例。如果您正苦于以下问题:PHP context_course类的具体用法?PHP context_course怎么用?PHP context_course使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了context_course类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_block

 protected function process_block($data)
 {
     global $DB;
     $data = (object) $data;
     $restore = $this->get_setting_value('restore_quickmail_history');
     $overwrite = $this->get_setting_value('overwrite_quickmail_history');
     // Delete current history, if any
     if ($overwrite) {
         $params = array('courseid' => $this->get_courseid());
         $DB->delete_records('block_quickmail_log', $params);
     }
     if ($restore and isset($data->emaillogs['log'])) {
         global $DB;
         $current = context_course::instance($this->get_courseid());
         $params = array('backupid' => $this->get_restoreid(), 'itemname' => 'context', 'newitemid' => $current->id);
         $id = $DB->get_record('backup_ids_temp', $params)->itemid;
         foreach ($data->emaillogs['log'] as $log) {
             $this->process_log($log, $id, $current);
         }
     }
     if (isset($data->emaillogs['block_level_setting'])) {
         foreach ($data->emaillogs['block_level_setting'] as $block_level_setting) {
             $this->process_block_level_setting($block_level_setting, $this->get_courseid());
         }
     }
 }
开发者ID:amunguia,项目名称:block_quickmail,代码行数:26,代码来源:restore_quickmail_stepslib.php

示例2: get_content

 public function get_content()
 {
     global $COURSE, $USER;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = var_export($this->context, true);
     $coursecontext = context_course::instance($COURSE->id);
     if (has_capability('block/demostudent:addinstance', $coursecontext)) {
         // If DemoStudent has not yet been enrolled, allow user to create/enrol one.
         $demostudentusername = generate_demostudent_name($USER->username);
         $demostudentuser = get_complete_user_data('username', $demostudentusername);
         if (!$demostudentuser || !is_enrolled($coursecontext, $demostudentuser)) {
             $this->render_view('firstuse');
         } else {
             $this->render_view('instructor');
         }
     } else {
         if (has_capability('block/demostudent:seedemostudentblock', $coursecontext)) {
             $this->render_view('demostudent');
         } else {
             // If the user does not need to see the block, do not display it at all.
             $this->content->text = '';
             $this->content->footer = '';
         }
     }
     return $this->content;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:29,代码来源:block_demostudent.php

示例3: test_filter

 /**
  * Tests that the filter applies the required changes.
  *
  * @return void
  */
 public function test_filter()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     filter_manager::reset_caches();
     filter_set_global_state('data', TEXTFILTER_ON);
     $course1 = $this->getDataGenerator()->create_course();
     $coursecontext1 = context_course::instance($course1->id);
     $course2 = $this->getDataGenerator()->create_course();
     $coursecontext2 = context_course::instance($course2->id);
     $sitecontext = context_course::instance(SITEID);
     $site = get_site();
     $this->add_simple_database_instance($site, array('SiteEntry'));
     $this->add_simple_database_instance($course1, array('CourseEntry'));
     $html = '<p>I like CourseEntry and SiteEntry</p>';
     // Testing at course level (both site and course).
     $filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext1));
     $this->assertRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
     $this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
     // Testing at site level (only site).
     $filtered = format_text($html, FORMAT_HTML, array('context' => $sitecontext));
     $this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
     $this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
     // Changing to another course to test the caches invalidation (only site).
     $filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext2));
     $this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
     $this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:filter_test.php

示例4: init

 private function init()
 {
     if (!$this->isInit) {
         $this->isInit = true;
         // Discover location of editor plugin.
         $editor_plugin = WIRISpluginWrapper::get_wiris_plugin();
         $this->installed = !empty($editor_plugin);
         // Return if editor plugin is not installed.
         if (!$this->installed) {
             global $COURSE, $PAGE;
             $coursecontext = context_course::instance($COURSE->id);
             if (has_capability('moodle/site:config', $coursecontext)) {
                 // Display missing WIRIS editor plugin dependency error
                 $PAGE->requires->js('/filter/wiris/js/message.js', false);
             }
             return null;
         }
         // Init haxe environment.
         if (!class_exists('com_wiris_system_CallWrapper')) {
             require_once $editor_plugin->path . '/integration/lib/com/wiris/system/CallWrapper.class.php';
         }
         com_wiris_system_CallWrapper::getInstance()->init($editor_plugin->path . '/integration');
         // Start haxe environment.
         $this->begin();
         // Create PluginBuilder with Moodle specific configuration.
         require_once 'MoodleConfigurationUpdater.php';
         $this->moodleConfig = new com_wiris_plugin_configuration_MoodleConfigurationUpdater($editor_plugin);
         $this->instance = com_wiris_plugin_api_PluginBuilder::getInstance();
         $this->instance->addConfigurationUpdater($this->moodleConfig);
         $this->instance->addConfigurationUpdater(new com_wiris_plugin_web_PhpConfigurationUpdater());
         // Stop haxe environment.
         $this->end();
     }
 }
开发者ID:mads233,项目名称:moodle-filter_wiris,代码行数:34,代码来源:wirispluginwrapper.php

示例5: get_document

 /**
  * Returns the document associated with this course.
  *
  * @param stdClass $record
  * @param array    $options
  * @return \core_search\document
  */
 public function get_document($record, $options = array())
 {
     try {
         $context = \context_course::instance($record->id);
     } catch (\moodle_exception $ex) {
         // Notify it as we run here as admin, we should see everything.
         debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' . $ex->getMessage(), DEBUG_DEVELOPER);
         return false;
     }
     // Prepare associative array with data from DB.
     $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
     $doc->set('title', content_to_text($record->fullname, false));
     $doc->set('content', content_to_text($record->summary, $record->summaryformat));
     $doc->set('contextid', $context->id);
     $doc->set('courseid', $record->id);
     $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
     $doc->set('modified', $record->timemodified);
     $doc->set('description1', $record->shortname);
     // Check if this document should be considered new.
     if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
         // If the document was created after the last index time, it must be new.
         $doc->set_is_new(true);
     }
     return $doc;
 }
开发者ID:sirromas,项目名称:lms,代码行数:32,代码来源:mycourse.php

示例6: create_from_course

 /**
  * Create the event from course record.
  *
  * @param \stdClass $course
  * @return course_module_instance_list_viewed
  */
 public static function create_from_course(\stdClass $course)
 {
     $params = array('context' => \context_course::instance($course->id));
     $event = \mod_book\event\course_module_instance_list_viewed::create($params);
     $event->add_record_snapshot('course', $course);
     return $event;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:course_module_instance_list_viewed.php

示例7: get_content

 function get_content()
 {
     global $CFG, $DB, $OUTPUT, $COURSE;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if (!has_capability('block/course_files_license:viewlist', context_course::instance($COURSE->id))) {
         return $this->content;
     }
     $context = context_course::instance($COURSE->id);
     $contextcheck = $context->path . '/%';
     // Get the top file files used on the course by size.
     $filelist = block_course_files_license_get_coursefilelist();
     if ($filelist) {
         $this->content->text = '<p class="justify">' . get_string('files_to_idenfity', 'block_course_files_license') . '</p>';
         $this->content->text .= '<a class="btn btn-block btn-danger btn-sm" href="';
         $this->content->text .= new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $COURSE->id)) . '">';
         $this->content->text .= '<i class="fa fa-exclamation-triangle"></i> ';
         $this->content->text .= get_string('filelist', 'block_course_files_license') . '</a>';
     } else {
         $this->content->text = '<p class="justify">' . get_string('all_files_idenfitied', 'block_course_files_license') . '</p>';
         $this->content->text = '<a class="btn btn-block btn-success btn-sm" href="';
         $this->content->text .= new moodle_url('/blocks/course_files_license/view.php', array('courseid' => $COURSE->id)) . '">';
         $this->content->text .= '<i class="fa fa-info-circle"></i> ';
         $this->content->text .= get_string('filelist', 'block_course_files_license') . '</a>';
     }
     return $this->content;
 }
开发者ID:pombredanne,项目名称:moodle-block_course_files_license,代码行数:34,代码来源:block_course_files_license.php

示例8: get_instance_info

 /**
  * Return self-enrolment instance information.
  *
  * @param int $instanceid instance id of self enrolment plugin.
  * @return array instance information.
  * @throws moodle_exception
  */
 public static function get_instance_info($instanceid)
 {
     global $DB, $CFG;
     require_once $CFG->libdir . '/enrollib.php';
     $params = self::validate_parameters(self::get_instance_info_parameters(), array('instanceid' => $instanceid));
     // Retrieve self enrolment plugin.
     $enrolplugin = enrol_get_plugin('self');
     if (empty($enrolplugin)) {
         throw new moodle_exception('invaliddata', 'error');
     }
     // Note that we can't use validate_context because the user is not enrolled in the course.
     require_login(null, false, null, false, true);
     $enrolinstance = $DB->get_record('enrol', array('id' => $params['instanceid']), '*', MUST_EXIST);
     $course = $DB->get_record('course', array('id' => $enrolinstance->courseid), '*', MUST_EXIST);
     $context = context_course::instance($course->id);
     if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
         throw new moodle_exception('coursehidden');
     }
     $instanceinfo = (array) $enrolplugin->get_enrol_info($enrolinstance);
     if (isset($instanceinfo['requiredparam']->enrolpassword)) {
         $instanceinfo['enrolpassword'] = $instanceinfo['requiredparam']->enrolpassword;
     }
     unset($instanceinfo->requiredparam);
     return $instanceinfo;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:32,代码来源:externallib.php

示例9: definition

 /**
  * Definition of the form
  */
 function definition()
 {
     global $USER, $CFG, $COURSE;
     $coursecontext = context_course::instance($COURSE->id);
     $mform =& $this->_form;
     $editoroptions = $this->_customdata['editoroptions'];
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('groupname', 'group'), 'maxlength="254" size="50"');
     $mform->addRule('name', get_string('required'), 'required', null, 'client');
     $mform->setType('name', PARAM_TEXT);
     $mform->addElement('text', 'idnumber', get_string('idnumbergroup'), 'maxlength="100" size="10"');
     $mform->addHelpButton('idnumber', 'idnumbergroup');
     $mform->setType('idnumber', PARAM_RAW);
     $mform->setAdvanced('idnumber');
     if (!has_capability('moodle/course:changeidnumber', $coursecontext)) {
         $mform->hardFreeze('idnumber');
     }
     $mform->addElement('editor', 'description_editor', get_string('groupdescription', 'group'), null, $editoroptions);
     $mform->setType('description_editor', PARAM_RAW);
     $mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey', 'group'));
     $mform->addHelpButton('enrolmentkey', 'enrolmentkey', 'group');
     $mform->setType('enrolmentkey', PARAM_RAW);
     if (!empty($CFG->gdversion)) {
         $options = array(get_string('no'), get_string('yes'));
         $mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);
         $mform->addElement('filepicker', 'imagefile', get_string('newpicture', 'group'));
         $mform->addHelpButton('imagefile', 'newpicture', 'group');
     }
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:37,代码来源:group_form.php

示例10: specific_definition

 protected function specific_definition($mform)
 {
     global $CFG, $PAGE, $COURSE;
     $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
     $mform->addElement('text', 'config_title', get_string('configspottitle', 'block_informationspot'));
     $mform->setType('config_title', PARAM_TEXT);
     $fileoptions = array('subdirs' => false, 'maxfiles' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'web_image', 'return_types' => FILE_INTERNAL);
     $mform->addElement('filemanager', 'config_imagespot', get_string('configspotfile', 'block_informationspot'), $fileoptions);
     $mform->addElement('editor', 'config_text', get_string('configspottext', 'block_informationspot'));
     $mform->setType('config_text', PARAM_RAW);
     $mform->addElement('text', 'config_buttontext', get_string('configspotbutton', 'block_informationspot'));
     $mform->setType('config_buttontext', PARAM_TEXT);
     $mform->addElement('text', 'config_buttonlink', get_string('configspotlink', 'block_informationspot'));
     $mform->setType('config_buttonlink', PARAM_URL);
     $choices = array();
     $choices['always'] = get_string('always', 'block_informationspot');
     if ($PAGE->context === context_course::instance(SITEID)) {
         $choices['beforelogin'] = get_string('beforelogin', 'block_informationspot');
         $choices['afterlogin'] = get_string('afterlogin', 'block_informationspot');
         //$choices['onetimebefore'] = get_string('onetimebefore', 'block_informationspot');
         //$choices['onetimeafter'] = get_string('onetimeafter', 'block_informationspot');
     } else {
         // $choices['onetime'] = get_string('onetime', 'block_informationspot');
     }
     if (count($choices) > 1) {
         $mform->addElement('select', 'config_showspot', get_string('configshowspot', 'block_informationspot'), $choices, 'always');
     } else {
         $mform->addElement('hidden', 'config_showspot', 'always');
         $mform->setType('configshowsspot', PARAM_TEXT);
     }
 }
开发者ID:bobopinna,项目名称:moodle-blocks_informationspot,代码行数:31,代码来源:edit_form.php

示例11: print_badges_list

    public function print_badges_list($badges, $userid, $profile = false, $external = false) {
        global $USER, $CFG;
        foreach ($badges as $badge) {
            if (!$external) {
                $context = ($badge->type == BADGE_TYPE_SITE) ? context_system::instance() : context_course::instance($badge->courseid);
                $bname = $badge->name;
                $imageurl = moodle_url::make_pluginfile_url($context->id, 'badges', 'badgeimage', $badge->id, '/', 'f1', false);
            } else {
                $bname = $badge->assertion->badge->name;
                $imageurl = $badge->imageUrl;
            }

            $name = html_writer::tag('span', $bname, array('class' => 'badge-name'));

            $image = html_writer::empty_tag('img', array('src' => $imageurl, 'class' => 'badge-image'));
            if (!empty($badge->dateexpire) && $badge->dateexpire < time()) {
                $image .= $this->output->pix_icon('i/expired',
                        get_string('expireddate', 'badges', userdate($badge->dateexpire)),
                        'moodle',
                        array('class' => 'expireimage'));
                $name .= '(' . get_string('expired', 'badges') . ')';
            }

            $download = $status = $push = '';
            if (($userid == $USER->id) && !$profile) {
                $url = new moodle_url('mybadges.php', array('download' => $badge->id, 'hash' => $badge->uniquehash, 'sesskey' => sesskey()));
                $notexpiredbadge = (empty($badge->dateexpire) || $badge->dateexpire > time());
                $backpackexists = badges_user_has_backpack($USER->id);
                if (!empty($CFG->badges_allowexternalbackpack) && $notexpiredbadge && $backpackexists) {
                    $assertion = new moodle_url('/badges/assertion.php', array('b' => $badge->uniquehash));
                    $action = new component_action('click', 'addtobackpack', array('assertion' => $assertion->out(false)));
                    $push = $this->output->action_icon(new moodle_url('#'), new pix_icon('t/backpack', get_string('addtobackpack', 'badges')), $action);
                }

                $download = $this->output->action_icon($url, new pix_icon('t/download', get_string('download')));
                if ($badge->visible) {
                    $url = new moodle_url('mybadges.php', array('hide' => $badge->issuedid, 'sesskey' => sesskey()));
                    $status = $this->output->action_icon($url, new pix_icon('t/hide', get_string('makeprivate', 'badges')));
                } else {
                    $url = new moodle_url('mybadges.php', array('show' => $badge->issuedid, 'sesskey' => sesskey()));
                    $status = $this->output->action_icon($url, new pix_icon('t/show', get_string('makepublic', 'badges')));
                }
            }

            if (!$profile) {
                $url = new moodle_url('badge.php', array('hash' => $badge->uniquehash));
            } else {
                if (!$external) {
                    $url = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
                } else {
                    $hash = hash('md5', $badge->hostedUrl);
                    $url = new moodle_url('/badges/external.php', array('hash' => $hash, 'user' => $userid));
                }
            }
            $actions = html_writer::tag('div', $push . $download . $status, array('class' => 'badge-actions'));
            $items[] = html_writer::link($url, $image . $actions . $name, array('title' => $bname));
        }

        return html_writer::alist($items, array('class' => 'badges'));
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:60,代码来源:renderer.php

示例12: create_from_course

 public static function create_from_course(\stdClass $course)
 {
     $params = array('context' => \context_course::instance($course->id));
     $event = self::create($params);
     $event->add_record_snapshot('course', $course);
     return $event;
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:7,代码来源:course_module_instance_list_viewed.php

示例13: definition

 function definition()
 {
     global $CFG, $DB;
     $mform = $this->_form;
     list($instance, $plugin, $course) = $this->_customdata;
     $coursecontext = context_course::instance($course->id);
     $enrol = enrol_get_plugin('cohort');
     $groups = array(0 => get_string('none'));
     foreach (groups_get_all_groups($course->id) as $group) {
         $groups[$group->id] = format_string($group->name, true, array('context' => $coursecontext));
     }
     $mform->addElement('header', 'general', get_string('pluginname', 'enrol_cohort'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $mform->setType('name', PARAM_TEXT);
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_cohort'), $options);
     if ($instance->id) {
         if ($cohort = $DB->get_record('cohort', array('id' => $instance->customint1))) {
             $cohorts = array($instance->customint1 => format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid))));
         } else {
             $cohorts = array($instance->customint1 => get_string('error'));
         }
         $mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
         $mform->setConstant('customint1', $instance->customint1);
         $mform->hardFreeze('customint1', $instance->customint1);
     } else {
         $cohorts = array('' => get_string('choosedots'));
         $allcohorts = cohort_get_available_cohorts($coursecontext, 0, 0, 0);
         foreach ($allcohorts as $c) {
             $cohorts[$c->id] = format_string($c->name);
         }
         $mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
         $mform->addRule('customint1', get_string('required'), 'required', null, 'client');
     }
     $roles = get_assignable_roles($coursecontext);
     $roles[0] = get_string('none');
     $roles = array_reverse($roles, true);
     // Descending default sortorder.
     $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles);
     $mform->setDefault('roleid', $enrol->get_config('roleid'));
     if ($instance->id and !isset($roles[$instance->roleid])) {
         if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
             $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS, true);
             $roles[$instance->roleid] = role_get_name($role, $coursecontext);
         } else {
             $roles[$instance->roleid] = get_string('error');
         }
     }
     $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_cohort'), $groups);
     $mform->addElement('hidden', 'courseid', null);
     $mform->setType('courseid', PARAM_INT);
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
     if ($instance->id) {
         $this->add_action_buttons(true);
     } else {
         $this->add_action_buttons(true, get_string('addinstance', 'enrol'));
     }
     $this->set_data($instance);
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:60,代码来源:edit_form.php

示例14: define_structure

 /**
  * Define structure.
  */
 protected function define_structure()
 {
     global $DB;
     $userinfo = $this->get_setting_value('users');
     // Define each element separated.
     $xpconfig = new backup_nested_element('config', array('courseid'), array('enabled', 'enablelog', 'keeplogs', 'levels', 'lastlogpurge', 'enableladder', 'enableinfos', 'levelsdata', 'enablelevelupnotif', 'enablecustomlevelbadges', 'maxactionspertime', 'timeformaxactions', 'timebetweensameactions', 'identitymode', 'rankmode', 'neighbours'));
     $xpfilters = new backup_nested_element('filters');
     $xpfilter = new backup_nested_element('filter', array('courseid'), array('ruledata', 'points', 'sortorder'));
     $xplevels = new backup_nested_element('xps');
     $xplevel = new backup_nested_element('xp', array('courseid'), array('userid', 'xp', 'lvl'));
     $xplogs = new backup_nested_element('logs');
     $xplog = new backup_nested_element('log', array('courseid'), array('userid', 'eventname', 'xp', 'time'));
     // Prepare the structure.
     $xp = $this->prepare_block_structure($xpconfig);
     $xpfilters->add_child($xpfilter);
     $xp->add_child($xpfilters);
     if ($userinfo) {
         $xplevels->add_child($xplevel);
         $xp->add_child($xplevels);
         $xplogs->add_child($xplog);
         $xp->add_child($xplogs);
     }
     // Define sources.
     $xpconfig->set_source_table('block_xp_config', array('courseid' => backup::VAR_COURSEID));
     $xpfilter->set_source_table('block_xp_filters', array('courseid' => backup::VAR_COURSEID));
     $xplevel->set_source_table('block_xp', array('courseid' => backup::VAR_COURSEID));
     $xplog->set_source_table('block_xp_log', array('courseid' => backup::VAR_COURSEID));
     // Annotations.
     $xplevel->annotate_ids('user', 'userid');
     $xplog->annotate_ids('user', 'userid');
     $xp->annotate_files('block_xp', 'badges', null, context_course::instance($this->get_courseid())->id);
     // Return the root element.
     return $xp;
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:37,代码来源:backup_xp_stepslib.php

示例15: definition

 function definition()
 {
     global $CFG, $DB;
     $mform = $this->_form;
     $course = $this->_customdata;
     $coursecontext = context_course::instance($course->id);
     $enrol = enrol_get_plugin('cohort');
     $cohorts = array('' => get_string('choosedots'));
     list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($coursecontext));
     $sql = "SELECT id, name, contextid\n                  FROM {cohort}\n                 WHERE contextid {$sqlparents}\n              ORDER BY name ASC";
     $rs = $DB->get_recordset_sql($sql, $params);
     foreach ($rs as $c) {
         $context = get_context_instance_by_id($c->contextid);
         if (!has_capability('moodle/cohort:view', $context)) {
             continue;
         }
         $cohorts[$c->id] = format_string($c->name);
     }
     $rs->close();
     $roles = get_assignable_roles($coursecontext);
     $roles[0] = get_string('none');
     $roles = array_reverse($roles, true);
     // descending default sortorder
     $mform->addElement('header', 'general', get_string('pluginname', 'enrol_cohort'));
     $mform->addElement('select', 'cohortid', get_string('cohort', 'cohort'), $cohorts);
     $mform->addRule('cohortid', get_string('required'), 'required', null, 'client');
     $mform->addElement('select', 'roleid', get_string('role'), $roles);
     $mform->addRule('roleid', get_string('required'), 'required', null, 'client');
     $mform->setDefault('roleid', $enrol->get_config('roleid'));
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
     $this->add_action_buttons(true, get_string('addinstance', 'enrol'));
     $this->set_data(array('id' => $course->id));
 }
开发者ID:nigeli,项目名称:moodle,代码行数:34,代码来源:addinstance_form.php


注:本文中的context_course类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。