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


PHP course_ajax_enabled函数代码示例

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


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

示例1: load_course_settings

 /**
  * This function loads the course settings that are available for the user
  *
  * @param bool $forceopen If set to true the course node will be forced open
  * @return navigation_node|false
  */
 protected function load_course_settings($forceopen = false)
 {
     global $CFG;
     $course = $this->page->course;
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
     // note: do not test if enrolled or viewing here because we need the enrol link in Course administration section
     $coursenode = $this->add(get_string('courseadministration'), null, self::TYPE_COURSE, null, 'courseadmin');
     if ($forceopen) {
         $coursenode->force_open();
     }
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Add the turn on/off settings
         if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
             // We are on the course page, retain the current page params e.g. section.
             $baseurl = clone $this->page->url;
             $baseurl->param('sesskey', sesskey());
         } else {
             // Edit on the main course page.
             $baseurl = new moodle_url('/course/view.php', array('id' => $course->id, 'return' => $this->page->url->out_as_local_url(false), 'sesskey' => sesskey()));
         }
         $editurl = clone $baseurl;
         if ($this->page->user_is_editing()) {
             $editurl->param('edit', 'off');
             $editstring = get_string('turneditingoff');
         } else {
             $editurl->param('edit', 'on');
             $editstring = get_string('turneditingon');
         }
         $coursenode->add($editstring, $editurl, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
         // Add the module chooser toggle
         $modchoosertoggleurl = clone $baseurl;
         if ($this->page->user_is_editing() && course_ajax_enabled($course)) {
             if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
                 $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'off');
             } else {
                 $modchoosertogglestring = get_string('modchooserenable', 'moodle');
                 $modchoosertoggleurl->param('modchooser', 'on');
             }
             $modchoosertoggle = $coursenode->add($modchoosertogglestring, $modchoosertoggleurl, self::TYPE_SETTING);
             $modchoosertoggle->add_class('modchoosertoggle');
             $modchoosertoggle->add_class('visibleifjs');
             user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
         }
         if ($this->page->user_is_editing()) {
             // Removed as per MDL-22732
             // $this->add_course_editing_links($course);
         }
         // Add the course settings link
         $url = new moodle_url('/course/edit.php', array('id' => $course->id));
         $coursenode->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         // Add the course completion settings link
         if ($CFG->enablecompletion && $course->enablecompletion) {
             $url = new moodle_url('/course/completion.php', array('id' => $course->id));
             $coursenode->add(get_string('completion', 'completion'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
         }
     }
     // add enrol nodes
     enrol_add_course_navigation($coursenode, $course);
     // Manage filters
     if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
         $url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
     }
     // Add view grade report is permitted
     $reportavailable = false;
     if (has_capability('moodle/grade:viewall', $coursecontext)) {
         $reportavailable = true;
     } else {
         if (!empty($course->showgrades)) {
             $reports = get_plugin_list('gradereport');
             if (is_array($reports) && count($reports) > 0) {
                 // Get all installed reports
                 arsort($reports);
                 // user is last, we want to test it first
                 foreach ($reports as $plugin => $plugindir) {
                     if (has_capability('gradereport/' . $plugin . ':view', $coursecontext)) {
                         //stop when the first visible plugin is found
                         $reportavailable = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($reportavailable) {
         $url = new moodle_url('/grade/report/index.php', array('id' => $course->id));
         $gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', ''));
     }
     //  Add outcome if permitted
     if (!empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $coursecontext)) {
         $url = new moodle_url('/grade/edit/outcome/course.php', array('id' => $course->id));
         $coursenode->add(get_string('outcomes', 'grades'), $url, self::TYPE_SETTING, null, 'outcomes', new pix_icon('i/outcomes', ''));
     }
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:navigationlib.php

示例2: include_course_ajax

/**
 * Include the relevant javascript and language strings for the resource
 * toolbox YUI module
 *
 * @param integer $id The ID of the course being applied to
 * @param array $usedmodules An array containing the names of the modules in use on the page
 * @param array $enabledmodules An array containing the names of the enabled (visible) modules on this site
 * @param stdClass $config An object containing configuration parameters for ajax modules including:
 *          * resourceurl   The URL to post changes to for resource changes
 *          * sectionurl    The URL to post changes to for section changes
 *          * pageparams    Additional parameters to pass through in the post
 * @return bool
 */
function include_course_ajax($course, $usedmodules = array(), $enabledmodules = null, $config = null)
{
    global $CFG, $PAGE, $SITE;
    // Ensure that ajax should be included
    if (!course_ajax_enabled($course)) {
        return false;
    }
    if (!$config) {
        $config = new stdClass();
    }
    // The URL to use for resource changes
    if (!isset($config->resourceurl)) {
        $config->resourceurl = '/course/rest.php';
    }
    // The URL to use for section changes
    if (!isset($config->sectionurl)) {
        $config->sectionurl = '/course/rest.php';
    }
    // Any additional parameters which need to be included on page submission
    if (!isset($config->pageparams)) {
        $config->pageparams = array();
    }
    // Include toolboxes
    $PAGE->requires->yui_module('moodle-course-toolboxes', 'M.course.init_resource_toolbox', array(array('courseid' => $course->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)));
    $PAGE->requires->yui_module('moodle-course-toolboxes', 'M.course.init_section_toolbox', array(array('courseid' => $course->id, 'format' => $course->format, 'ajaxurl' => $config->sectionurl, 'config' => $config)));
    // Include course dragdrop
    if (course_format_uses_sections($course->format)) {
        $PAGE->requires->yui_module('moodle-course-dragdrop', 'M.course.init_section_dragdrop', array(array('courseid' => $course->id, 'ajaxurl' => $config->sectionurl, 'config' => $config)), null, true);
        $PAGE->requires->yui_module('moodle-course-dragdrop', 'M.course.init_resource_dragdrop', array(array('courseid' => $course->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)), null, true);
    }
    // Require various strings for the command toolbox
    $PAGE->requires->strings_for_js(array('moveleft', 'deletechecktype', 'deletechecktypename', 'edittitle', 'edittitleinstructions', 'show', 'hide', 'groupsnone', 'groupsvisible', 'groupsseparate', 'clicktochangeinbrackets', 'markthistopic', 'markedthistopic', 'movesection', 'movecoursemodule', 'movecoursesection', 'movecontent', 'tocontent', 'emptydragdropregion', 'afterresource', 'aftersection', 'totopofsection'), 'moodle');
    // Include section-specific strings for formats which support sections.
    if (course_format_uses_sections($course->format)) {
        $PAGE->requires->strings_for_js(array('showfromothers', 'hidefromothers'), 'format_' . $course->format);
    }
    // For confirming resource deletion we need the name of the module in question
    foreach ($usedmodules as $module => $modname) {
        $PAGE->requires->string_for_js('pluginname', $module);
    }
    // Load drag and drop upload AJAX.
    require_once $CFG->dirroot . '/course/dnduploadlib.php';
    dndupload_add_to_course($course, $enabledmodules);
    return true;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:58,代码来源:lib.php

示例3: course_get_cm_rename_action

/**
 * Returns the rename action.
 *
 * @deprecated since 3.1
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $sr The section to link back to (used for creating the links)
 * @return The markup for the rename action, or an empty string if not available.
 */
function course_get_cm_rename_action(cm_info $mod, $sr = null)
{
    global $COURSE, $OUTPUT;
    static $str;
    static $baseurl;
    debugging('Function course_get_cm_rename_action() is deprecated. Please use inplace_editable ' . 'https://docs.moodle.org/dev/Inplace_editable', DEBUG_DEVELOPER);
    $modcontext = context_module::instance($mod->id);
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('edittitle'));
    }
    if (!isset($baseurl)) {
        $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
    }
    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }
    // AJAX edit title.
    if ($mod->has_view() && $hasmanageactivities && course_ajax_enabled($COURSE) && ($mod->course == $COURSE->id || $mod->course == SITEID)) {
        // we will not display link if we are on some other-course page (where we should not see this module anyway)
        return html_writer::span(html_writer::link(new moodle_url($baseurl, array('update' => $mod->id)), $OUTPUT->pix_icon('t/editstring', '', 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')), array('class' => 'editing_title', 'data-action' => 'edittitle', 'title' => $str->edittitle)));
    }
    return '';
}
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:deprecatedlib.php

示例4: course_section_add_cm_control

 /**
  * Renders HTML for the menus to add activities and resources to the current course
  *
  * Note, if theme overwrites this function and it does not use modchooser,
  * see also {@link core_course_renderer::add_modchoosertoggle()}
  *
  * @param stdClass $course
  * @param int $section relative section number (field course_sections.section)
  * @param int $sectionreturn The section to link back to
  * @param array $displayoptions additional display options, for example blocks add
  *     option 'inblock' => true, suggesting to display controls vertically
  * @return string
  */
 function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array())
 {
     global $CFG;
     $vertical = !empty($displayoptions['inblock']);
     // check to see if user can add menus and there are modules to add
     if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id)) || !$this->page->user_is_editing() || !($modnames = get_module_types_names()) || empty($modnames)) {
         return '';
     }
     // Retrieve all modules with associated metadata
     $modules = get_module_metadata($course, $modnames, $sectionreturn);
     $urlparams = array('section' => $section);
     // We'll sort resources and activities into two lists
     $activities = array(MOD_CLASS_ACTIVITY => array(), MOD_CLASS_RESOURCE => array());
     foreach ($modules as $module) {
         if (isset($module->types)) {
             // This module has a subtype
             // NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
             $subtypes = array();
             foreach ($module->types as $subtype) {
                 $link = $subtype->link->out(true, $urlparams);
                 $subtypes[$link] = $subtype->title;
             }
             // Sort module subtypes into the list
             $activityclass = MOD_CLASS_ACTIVITY;
             if ($module->archetype == MOD_CLASS_RESOURCE) {
                 $activityclass = MOD_CLASS_RESOURCE;
             }
             if (!empty($module->title)) {
                 // This grouping has a name
                 $activities[$activityclass][] = array($module->title => $subtypes);
             } else {
                 // This grouping does not have a name
                 $activities[$activityclass] = array_merge($activities[$activityclass], $subtypes);
             }
         } else {
             // This module has no subtypes
             $activityclass = MOD_CLASS_ACTIVITY;
             if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
                 $activityclass = MOD_CLASS_RESOURCE;
             } else {
                 if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
                     // System modules cannot be added by user, do not add to dropdown
                     continue;
                 }
             }
             $link = $module->link->out(true, $urlparams);
             $activities[$activityclass][$link] = $module->title;
         }
     }
     $straddactivity = get_string('addactivity');
     $straddresource = get_string('addresource');
     $sectionname = get_section_name($course, $section);
     $strresourcelabel = get_string('addresourcetosection', null, $sectionname);
     $stractivitylabel = get_string('addactivitytosection', null, $sectionname);
     $output = html_writer::start_tag('div', array('class' => 'section_add_menus', 'id' => 'add_menus-section-' . $section));
     if (!$vertical) {
         $output .= html_writer::start_tag('div', array('class' => 'horizontal'));
     }
     if (!empty($activities[MOD_CLASS_RESOURCE])) {
         $select = new url_select($activities[MOD_CLASS_RESOURCE], '', array('' => $straddresource), "ressection{$section}");
         $select->set_help_icon('resources');
         $select->set_label($strresourcelabel, array('class' => 'accesshide'));
         $output .= $this->output->render($select);
     }
     if (!empty($activities[MOD_CLASS_ACTIVITY])) {
         $select = new url_select($activities[MOD_CLASS_ACTIVITY], '', array('' => $straddactivity), "section{$section}");
         $select->set_help_icon('activities');
         $select->set_label($stractivitylabel, array('class' => 'accesshide'));
         $output .= $this->output->render($select);
     }
     if (!$vertical) {
         $output .= html_writer::end_tag('div');
     }
     $output .= html_writer::end_tag('div');
     if (course_ajax_enabled($course) && $course->id == $this->page->course->id) {
         // modchooser can be added only for the current course set on the page!
         $straddeither = get_string('addresourceoractivity');
         // The module chooser link
         $modchooser = html_writer::start_tag('div', array('class' => 'mdl-right'));
         $modchooser .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
         $icon = $this->output->pix_icon('t/add', '');
         $span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
         $modchooser .= html_writer::tag('span', $icon . $span, array('class' => 'section-modchooser-link'));
         $modchooser .= html_writer::end_tag('div');
         $modchooser .= html_writer::end_tag('div');
         // Wrap the normal output in a noscript div
         $usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault);
//.........这里部分代码省略.........
开发者ID:rushi963,项目名称:moodle,代码行数:101,代码来源:renderer.php

示例5: include_course_ajax

/**
 * Include the relevant javascript and language strings for the resource
 * toolbox YUI module
 *
 * @param integer $id The ID of the course being applied to
 * @param array $usedmodules An array containing the names of the modules in use on the page
 * @param array $enabledmodules An array containing the names of the enabled (visible) modules on this site
 * @param stdClass $config An object containing configuration parameters for ajax modules including:
 *          * resourceurl   The URL to post changes to for resource changes
 *          * sectionurl    The URL to post changes to for section changes
 *          * pageparams    Additional parameters to pass through in the post
 * @return bool
 */
function include_course_ajax($course, $usedmodules = array(), $enabledmodules = null, $config = null)
{
    global $PAGE, $SITE;
    // Ensure that ajax should be included
    if (!course_ajax_enabled($course)) {
        return false;
    }
    if (!$config) {
        $config = new stdClass();
    }
    // The URL to use for resource changes
    if (!isset($config->resourceurl)) {
        $config->resourceurl = '/course/rest.php';
    }
    // The URL to use for section changes
    if (!isset($config->sectionurl)) {
        $config->sectionurl = '/course/rest.php';
    }
    // Any additional parameters which need to be included on page submission
    if (!isset($config->pageparams)) {
        $config->pageparams = array();
    }
    // Include toolboxes
    $PAGE->requires->yui_module('moodle-course-toolboxes', 'M.course.init_resource_toolbox', array(array('courseid' => $course->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)));
    $PAGE->requires->yui_module('moodle-course-toolboxes', 'M.course.init_section_toolbox', array(array('courseid' => $course->id, 'format' => $course->format, 'ajaxurl' => $config->sectionurl, 'config' => $config)));
    // Include course dragdrop
    if ($course->id != $SITE->id) {
        $PAGE->requires->yui_module('moodle-course-dragdrop', 'M.course.init_section_dragdrop', array(array('courseid' => $course->id, 'ajaxurl' => $config->sectionurl, 'config' => $config)), null, true);
        $PAGE->requires->yui_module('moodle-course-dragdrop', 'M.course.init_resource_dragdrop', array(array('courseid' => $course->id, 'ajaxurl' => $config->resourceurl, 'config' => $config)), null, true);
    }
    // Include blocks dragdrop
    $params = array('courseid' => $course->id, 'pagetype' => $PAGE->pagetype, 'pagelayout' => $PAGE->pagelayout, 'regions' => $PAGE->blocks->get_regions());
    $PAGE->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true);
    // Require various strings for the command toolbox
    $PAGE->requires->strings_for_js(array('moveleft', 'deletechecktype', 'deletechecktypename', 'edittitle', 'edittitleinstructions', 'show', 'hide', 'groupsnone', 'groupsvisible', 'groupsseparate', 'clicktochangeinbrackets', 'markthistopic', 'markedthistopic', 'move', 'movesection'), 'moodle');
    // Include format-specific strings
    if ($course->id != $SITE->id) {
        $PAGE->requires->strings_for_js(array('showfromothers', 'hidefromothers'), 'format_' . $course->format);
    }
    // For confirming resource deletion we need the name of the module in question
    foreach ($usedmodules as $module => $modname) {
        $PAGE->requires->string_for_js('pluginname', $module);
    }
    // Load drag and drop upload AJAX.
    dndupload_add_to_course($course, $enabledmodules);
    // Add the module chooser
    $PAGE->requires->yui_module('moodle-course-modchooser', 'M.course.init_chooser', array(array('courseid' => $course->id)));
    $PAGE->requires->strings_for_js(array('addresourceoractivity', 'modchooserenable', 'modchooserdisable'), 'moodle');
    return true;
}
开发者ID:nmicha,项目名称:moodle,代码行数:63,代码来源:lib.php

示例6: include_course_ajax

 /**
  * Include the relevant javascript and language strings for the resource
  * toolbox YUI module
  *
  * @param integer $id The ID of the course being applied to
  * @param array $usedmodules An array containing the names of the modules in use on the page
  * @param array $enabledmodules An array containing the names of the enabled (visible) modules on this site
  * @param stdClass $config An object containing configuration parameters for ajax modules including:
  *          * resourceurl   The URL to post changes to for resource changes
  *          * sectionurl    The URL to post changes to for section changes
  *          * pageparams    Additional parameters to pass through in the post
  * @return bool
  */
 protected static function include_course_ajax($course, $usedmodules = array(), $enabledmodules = null, $config = null)
 {
     global $CFG, $PAGE;
     // Only include course AJAX for supported formats.
     if (!course_ajax_enabled($course)) {
         return false;
     }
     // Require various strings for the command toolbox.
     $PAGE->requires->strings_for_js(['afterresource', 'aftersection', 'clicktochangeinbrackets', 'deletechecktype', 'deletechecktypename', 'edittitle', 'edittitleinstructions', 'emptydragdropregion', 'groupsnone', 'groupsvisible', 'groupsseparate', 'hide', 'markthistopic', 'markedthistopic', 'moveleft', 'movesection', 'movecoursemodule', 'movecoursesection', 'movecontent', 'show', 'tocontent', 'totopofsection'], 'moodle');
     $PAGE->requires->strings_for_js(['error:failedtochangesectionvisibility', 'error:failedtohighlightsection', 'error:failedtochangeassetvisibility', 'error:failedtoduplicateasset'], 'theme_snap');
     // Include section-specific strings for formats which support sections.
     if (course_format_uses_sections($course->format)) {
         $PAGE->requires->strings_for_js(array('showfromothers', 'hidefromothers'), 'format_' . $course->format);
     }
     // For confirming resource deletion we need the name of the module in question.
     foreach ($usedmodules as $module => $modname) {
         $PAGE->requires->string_for_js('pluginname', $module);
     }
     // Load drag and drop upload AJAX.
     require_once $CFG->dirroot . '/course/dnduploadlib.php';
     self::dndupload_add_to_course($course, $enabledmodules);
     return true;
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:36,代码来源:shared.php


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