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


PHP course_get_display函数代码示例

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


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

示例1: move_section_to

/**
 * Moves a section within a course, from a position to another.
 * Be very careful: $section and $destination refer to section number,
 * not id!.
 *
 * @param object $course
 * @param int $section Section number (not id!!!)
 * @param int $destination
 * @return boolean Result
 */
function move_section_to($course, $section, $destination)
{
    /// Moves a whole course section up and down within the course
    global $USER, $DB;
    if (!$destination && $destination != 0) {
        return true;
    }
    if ($destination > $course->numsections) {
        return false;
    }
    // Get all sections for this course and re-order them (2 of them should now share the same section number)
    if (!($sections = $DB->get_records_menu('course_sections', array('course' => $course->id), 'section ASC, id ASC', 'id, section'))) {
        return false;
    }
    $movedsections = reorder_sections($sections, $section, $destination);
    // Update all sections. Do this in 2 steps to avoid breaking database
    // uniqueness constraint
    $transaction = $DB->start_delegated_transaction();
    foreach ($movedsections as $id => $position) {
        if ($sections[$id] !== $position) {
            $DB->set_field('course_sections', 'section', -$position, array('id' => $id));
        }
    }
    foreach ($movedsections as $id => $position) {
        if ($sections[$id] !== $position) {
            $DB->set_field('course_sections', 'section', $position, array('id' => $id));
        }
    }
    // Adjust destination to reflect the actual section
    $moveup = false;
    if ($section > $destination) {
        $destination++;
        $moveup = true;
    }
    // If we move the highlighted section itself, then just highlight the destination.
    // Adjust the higlighted section location if we move something over it either direction.
    if ($section == $course->marker) {
        course_set_marker($course, $destination);
    } elseif ($moveup && $section > $course->marker && $course->marker >= $destination) {
        course_set_marker($course, $course->marker + 1);
    } elseif (!$moveup && $section < $course->marker && $course->marker <= $destination) {
        course_set_marker($course, $course->marker - 1);
    }
    // if the focus is on the section that is being moved, then move the focus along
    if (course_get_display($course->id) == $section) {
        course_set_display($course->id, $destination);
    }
    $transaction->allow_commit();
    return true;
}
开发者ID:numbas,项目名称:moodle,代码行数:60,代码来源:lib.php

示例2: load_generic_course_sections

 /**
  * Generically loads the course sections into the course's navigation.
  *
  * @param stdClass $course
  * @param navigation_node $coursenode
  * @param string $courseformat The course format
  * @return array An array of course section nodes
  */
 public function load_generic_course_sections(stdClass $course, navigation_node $coursenode, $courseformat = 'unknown')
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . '/course/lib.php';
     list($sections, $activities) = $this->generate_sections_and_activities($course);
     $namingfunction = 'callback_' . $courseformat . '_get_section_name';
     $namingfunctionexists = function_exists($namingfunction);
     $viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
     $urlfunction = 'callback_' . $courseformat . '_get_section_url';
     if (empty($CFG->navlinkcoursesections) || !function_exists($urlfunction)) {
         $urlfunction = null;
     }
     $keyfunction = 'callback_' . $courseformat . '_request_key';
     $key = course_get_display($course->id);
     if (defined('AJAX_SCRIPT') && AJAX_SCRIPT == '0' && function_exists($keyfunction) && $this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         $key = optional_param($keyfunction(), $key, PARAM_INT);
     }
     $navigationsections = array();
     foreach ($sections as $sectionid => $section) {
         $section = clone $section;
         if ($course->id == SITEID) {
             $this->load_section_activities($coursenode, $section->section, $activities);
         } else {
             if (!$viewhiddensections && !$section->visible || !$this->showemptysections && !$section->hasactivites) {
                 continue;
             }
             if ($namingfunctionexists) {
                 $sectionname = $namingfunction($course, $section, $sections);
             } else {
                 $sectionname = get_string('section') . ' ' . $section->section;
             }
             $url = null;
             if (!empty($urlfunction)) {
                 $url = $urlfunction($course->id, $section->section);
             }
             $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
             $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
             $sectionnode->hidden = !$section->visible;
             if ($key != '0' && $section->section != '0' && $section->section == $key && $this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites) {
                 $sectionnode->make_active();
                 $this->load_section_activities($sectionnode, $section->section, $activities);
             }
             $section->sectionnode = $sectionnode;
             $navigationsections[$sectionid] = $section;
         }
     }
     return $navigationsections;
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:56,代码来源:navigationlib.php

示例3: move_section_to

/**
 * Moves a section within a course, from a position to another.
 * Be very careful: $section and $destination refer to section number,
 * not id!.
 *
 * @param object $course
 * @param int $section Section number (not id!!!)
 * @param int $destination
 * @return boolean Result
 */
function move_section_to($course, $section, $destination)
{
    /// Moves a whole course section up and down within the course
    global $USER, $DB;
    if (!$destination && $destination != 0) {
        return true;
    }
    if ($destination > $course->numsections) {
        return false;
    }
    // Get all sections for this course and re-order them (2 of them should now share the same section number)
    if (!($sections = $DB->get_records_menu('course_sections', array('course' => $course->id), 'section ASC, id ASC', 'id, section'))) {
        return false;
    }
    $sections = reorder_sections($sections, $section, $destination);
    // Update all sections
    foreach ($sections as $id => $position) {
        $DB->set_field('course_sections', 'section', $position, array('id' => $id));
    }
    // if the focus is on the section that is being moved, then move the focus along
    if (course_get_display($course->id) == $section) {
        course_set_display($course->id, $destination);
    }
    return true;
}
开发者ID:hitphp,项目名称:moodle,代码行数:35,代码来源:lib.php

示例4: load_generic_course_sections

    /**
     * Generically loads the course sections into the course's navigation.
     *
     * @param stdClass $course
     * @param navigation_node $coursenode
     * @param string $name The string that identifies each section. e.g Topic, or Week
     * @param string $activeparam The url used to identify the active section
     * @return array An array of course section nodes
     */
    public function load_generic_course_sections(stdClass $course, navigation_node $coursenode, $courseformat='unknown') {
        global $CFG, $DB, $USER;

        require_once($CFG->dirroot.'/course/lib.php');

        if (!$this->cache->cached('modinfo'.$course->id)) {
            $this->cache->set('modinfo'.$course->id, get_fast_modinfo($course));
        }
        $modinfo = $this->cache->{'modinfo'.$course->id};

        if (!$this->cache->cached('coursesections'.$course->id)) {
            $this->cache->set('coursesections'.$course->id, array_slice(get_all_sections($course->id), 0, $course->numsections+1, true));
        }
        $sections = $this->cache->{'coursesections'.$course->id};

        $viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);

        $activesection = course_get_display($course->id);

        $namingfunction = 'callback_'.$courseformat.'_get_section_name';
        $namingfunctionexists = (function_exists($namingfunction));

        $activeparamfunction = 'callback_'.$courseformat.'_request_key';
        if (function_exists($activeparamfunction)) {
            $activeparam = $activeparamfunction();
        } else {
            $activeparam = 'section';
        }
        $navigationsections = array();
        foreach ($sections as $sectionid=>$section) {
            $section = clone($section);
            if ($course->id == SITEID) {
                $this->load_section_activities($coursenode, $section->section, $modinfo);
            } else {
                if ((!$viewhiddensections && !$section->visible) || (!$this->showemptysections && !array_key_exists($section->section, $modinfo->sections))) {
                    continue;
                }
                if ($namingfunctionexists) {
                    $sectionname = $namingfunction($course, $section, $sections);
                } else {
                    $sectionname = get_string('section').' '.$section->section;
                }
                //$url = new moodle_url('/course/view.php', array('id'=>$course->id));
                $url = null;
                $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
                $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
                $sectionnode->hidden = (!$section->visible);
                if ($this->page->context->contextlevel != CONTEXT_MODULE && ($sectionnode->isactive || ($activesection && $section->section == $activesection))) {
                    $sectionnode->force_open();
                    $this->load_section_activities($sectionnode, $section->section, $modinfo);
                }
                $section->sectionnode = $sectionnode;
                $navigationsections[$sectionid] = $section;
            }
        }
        return $navigationsections;
    }
开发者ID:nikita777,项目名称:moodle,代码行数:66,代码来源:navigationlib.php

示例5: defined

 * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
 * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
 *
 * @copyright &copy; 2006 The Open University
 * @author N.D.Freear@open.ac.uk, and others.
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package
 */
defined('MOODLE_INTERNAL') || die;
require_once $CFG->libdir . '/filelib.php';
require_once $CFG->libdir . '/completionlib.php';
$topic = optional_param('topic', -1, PARAM_INT);
if ($topic != -1) {
    $displaysection = course_set_display($course->id, $topic);
} else {
    $displaysection = course_get_display($course->id);
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if ($marker >= 0 && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
    $course->marker = $marker;
    $DB->set_field("course", "marker", $marker, array("id" => $course->id));
}
$streditsummary = get_string('editsummary');
$stradd = get_string('add');
$stractivities = get_string('activities');
$strshowalltopics = get_string('showalltopics');
$strtopic = get_string('topic');
$strgroups = get_string('groups');
$strgroupmy = get_string('groupmy');
$editing = $PAGE->user_is_editing();
if ($editing) {
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:format.php

示例6: load_generic_course_sections

 /**
  * Generically loads the course sections into the course's navigation.
  *
  * @param stdClass $course
  * @param navigation_node $coursenode
  * @param string $courseformat The course format
  * @return array An array of course section nodes
  */
 public function load_generic_course_sections(stdClass $course, navigation_node $coursenode, $courseformat = 'unknown')
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . '/course/lib.php';
     list($sections, $activities) = $this->generate_sections_and_activities($course);
     $namingfunction = 'callback_' . $courseformat . '_get_section_name';
     $namingfunctionexists = function_exists($namingfunction);
     $activesection = course_get_display($course->id);
     $viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
     $navigationsections = array();
     foreach ($sections as $sectionid => $section) {
         $section = clone $section;
         if ($course->id == SITEID) {
             $this->load_section_activities($coursenode, $section->section, $activities);
         } else {
             if (!$viewhiddensections && !$section->visible || !$this->showemptysections && !$section->hasactivites) {
                 continue;
             }
             if ($namingfunctionexists) {
                 $sectionname = $namingfunction($course, $section, $sections);
             } else {
                 $sectionname = get_string('section') . ' ' . $section->section;
             }
             //$url = new moodle_url('/course/view.php', array('id'=>$course->id));
             $url = null;
             $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
             $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
             $sectionnode->hidden = !$section->visible;
             if ($this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites && ($sectionnode->isactive || $activesection && $section->section == $activesection)) {
                 $sectionnode->force_open();
                 $this->load_section_activities($sectionnode, $section->section, $activities);
             }
             $section->sectionnode = $sectionnode;
             $navigationsections[$sectionid] = $section;
         }
     }
     return $navigationsections;
 }
开发者ID:hatone,项目名称:moodle,代码行数:46,代码来源:navigationlib.php

示例7: specialization

 /**
  * specialization
  */
 function specialization()
 {
     global $COURSE, $DB, $USER, $displaysection, $section;
     // set default config values
     $defaults = array('title' => get_string('defaulttitle', 'block_taskchain_navigation'), 'showcourse' => 0, 'coursenamefield' => 'shortname', 'coursenametext' => '', 'coursegradeposition' => 0, 'minimumdepth' => 0, 'maximumdepth' => 0, 'categoryskipempty' => 0, 'categoryskiphidden' => 0, 'categoryskipzeroweighted' => 0, 'categorycollapse' => 0, 'categoryshortnames' => 0, 'categoryshowweighting' => 0, 'categoryignorechars' => '', 'categoryprefixlength' => 0, 'categoryprefixchars' => '', 'categoryprefixlong' => 0, 'categoryprefixkeep' => 0, 'categorysuffixlength' => 0, 'categorysuffixchars' => '', 'categorysuffixlong' => 0, 'categorysuffixkeep' => 0, 'sectionshowhidden' => 2, 'sectionshowburied' => 0, 'sectionshowungraded' => 0, 'sectionshowzeroweighted' => 0, 'sectionshowuncategorized' => 0, 'sectiontitletags' => '', 'sectionshorttitles' => 0, 'sectionignorecase' => 0, 'sectionignorechars' => '', 'sectionprefixlength' => 0, 'sectionprefixchars' => '', 'sectionprefixlong' => 0, 'sectionprefixkeep' => 0, 'sectionsuffixlength' => 0, 'sectionsuffixchars' => '', 'sectionsuffixlong' => 0, 'sectionsuffixkeep' => 0, 'gradedisplay' => 1, 'showaverages' => 1, 'highgrade' => 90, 'mediumgrade' => 60, 'lowgrade' => 0, 'showactivitygrades' => '', 'sectionjumpmenu' => 1, 'sectionnumbers' => 1, 'singlesection' => 1, 'defaultsection' => 1, 'arrowup' => '', 'arrowdown' => '', 'gradebooklink' => 0, 'accesscontrol' => 0, 'hiddensections' => 0, 'hiddensectionstitle' => 0, 'hiddensectionsstyle' => 0, 'namelength' => 28, 'headlength' => 10, 'taillength' => 10, 'currentsection' => 0, 'groupsmenu' => 0, 'groupslabel' => 0, 'groupscountusers' => 0, 'groupssort' => 0, 'loginasmenu' => 0, 'loginassort' => 1, 'moodlecss' => 2, 'externalcss' => '', 'internalcss' => '');
     if (!isset($this->config)) {
         $this->config = new stdClass();
     }
     foreach ($defaults as $name => $value) {
         if (!isset($this->config->{$name})) {
             $this->config->{$name} = $value;
         }
     }
     // load user-defined title (may be empty)
     $this->title = $this->config->title;
     if (empty($COURSE->context)) {
         $COURSE->context = self::context(CONTEXT_COURSE, $COURSE->id);
     }
     $this->config->numsections = self::get_numsections($COURSE);
     // make sure user is only shown one course section at a time
     if (isset($USER->id) && isset($COURSE->id) && $this->config->singlesection) {
         $update = false;
         if (function_exists('course_get_display')) {
             // Moodle <= 2.2
             $displaysection = course_get_display($COURSE->id);
         } else {
             // Moodle >= 2.3
             $name = get_class($this) . '_course' . $COURSE->id;
             $displaysection = get_user_preferences($name, 0);
             if ($section == 0) {
                 $section = $displaysection;
             } else {
                 if ($displaysection == $section) {
                     // do nothing
                 } else {
                     $displaysection = $section;
                     $update = true;
                 }
             }
         }
         if ($displaysection == 0) {
             // no course section is currently selected for this user
             if ($displaysection = $this->config->defaultsection) {
                 // use default display section
             } else {
                 if ($displaysection = $COURSE->marker) {
                     // use highlighted section
                 } else {
                     // use first visible section
                     $select = 'course = ? AND section > ? AND visible = ?';
                     $params = array($COURSE->id, 0, 1);
                     $displaysection = $DB->get_field_select('course_sections', 'MIN(section)', $select, $params);
                 }
             }
             $update = true;
         }
         if ($update) {
             if (function_exists('course_set_display')) {
                 // Moodle <= 2.2
                 course_set_display($COURSE->id, $displaysection);
             } else {
                 // Moodle >= 2.3
                 $name = get_class($this) . '_course' . $COURSE->id;
                 set_user_preference($name, $displaysection);
             }
         }
     }
     // disable up/down arrows on Moodle >= 2.3
     if (function_exists('course_get_format')) {
         $this->config->arrowup = '';
         $this->config->arrowdown = '';
     }
     // disable hiddensections functionality, if the block is in the right column
     if (isset($this->instance->region) && $this->instance->region == BLOCK_POS_RIGHT) {
         $this->config->hiddensections = 0;
     }
     if (has_capability('moodle/course:manageactivities', $COURSE->context)) {
         $this->fix_course_format();
         $this->fix_section_visibility();
         $this->fix_course_marker();
     }
     $this->config->displaysection = $displaysection;
     $this->config->courseformat = $this->get_course_format($COURSE);
     $this->config->sectiontype = $this->get_section_type();
     $this->config->coursestartdate = $COURSE->startdate;
 }
开发者ID:gbateson,项目名称:moodle-block_taskchain_navigation,代码行数:89,代码来源:block_taskchain_navigation.php


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