• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_all_sections函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: callback_weeks_get_section_name

/**
 * Gets the name for the provided section.
 *
 * @param stdClass $course
 * @param stdClass $section
 * @return string
 */
function callback_weeks_get_section_name($course, $section)
{
    // We can't add a node without text
    if (!empty($section->name)) {
        // Return the name the user set
        return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
    } else {
        if ($section->section == 0) {
            // Return the section0name
            return get_string('section0name', 'format_weeks');
        } else {
            // Got to work out the date of the week so that we can show it
            $sections = get_all_sections($course->id);
            $weekdate = $course->startdate + 7200;
            foreach ($sections as $sec) {
                if ($sec->id == $section->id) {
                    break;
                } else {
                    if ($sec->section != 0) {
                        $weekdate += 604800;
                    }
                }
            }
            $strftimedateshort = ' ' . get_string('strftimedateshort');
            $weekday = userdate($weekdate, $strftimedateshort);
            $endweekday = userdate($weekdate + 518400, $strftimedateshort);
            return $weekday . ' - ' . $endweekday;
        }
    }
}
开发者ID:nmicha,项目名称:moodle,代码行数:37,代码来源:lib.php


示例2: all_sections_data

function all_sections_data()
{
    $sections = array();
    $all_sections = get_all_sections();
    while ($row = mysql_fetch_assoc($all_sections)) {
        $sections[$row['id']] = $row['crn'];
    }
    return $sections;
}
开发者ID:reidHoruff,项目名称:dbproj,代码行数:9,代码来源:helpers.php


示例3: list_sections

function list_sections()
{
    $sections = get_all_sections();
    $names = array();
    while ($row = mysql_fetch_assoc($sections)) {
        $names[] = $row['crn'];
    }
    dom::h3('section-title', 'List Sections:');
    dom::push_div('section');
    dom::ul($names);
    dom::pop();
}
开发者ID:reidHoruff,项目名称:dbproj,代码行数:12,代码来源:lists.php


示例4: FN_update_course

function FN_update_course($form, $oldformat = false)
{
    global $CFG;
    /// Updates course specific variables.
    /// Variables are: 'showsection0', 'showannouncements'.
    $config_vars = array('showsection0', 'showannouncements', 'sec0title', 'showhelpdoc', 'showclassforum', 'showclasschat', 'logo', 'mycourseblockdisplay', 'showgallery', 'gallerydefault', 'usesitegroups', 'mainheading', 'topicheading', 'activitytracking', 'ttmarking', 'ttgradebook', 'ttdocuments', 'ttstaff', 'defreadconfirmmess', 'usemandatory', 'expforumsec');
    foreach ($config_vars as $config_var) {
        if ($varrec = get_record('course_config_FN', 'courseid', $form->id, 'variable', $config_var)) {
            $varrec->value = $form->{$config_var};
            update_record('course_config_FN', $varrec);
        } else {
            $varrec->courseid = $form->id;
            $varrec->variable = $config_var;
            $varrec->value = $form->{$config_var};
            insert_record('course_config_FN', $varrec);
        }
    }
    /// We need to have the sections created ahead of time for the weekly nav to work,
    /// so check and create here.
    if (!($sections = get_all_sections($form->id))) {
        $sections = array();
    }
    for ($i = 0; $i <= $form->numsections; $i++) {
        if (empty($sections[$i])) {
            $section = new Object();
            $section->course = $form->id;
            // Create a new section structure
            $section->section = $i;
            $section->summary = "";
            $section->visible = 1;
            if (!($section->id = insert_record("course_sections", $section))) {
                notify("Error inserting new section!");
            }
        }
    }
    /// Check for a change to an FN format. If so, set some defaults as well...
    if ($oldformat != 'FN') {
        /// Set the news (announcements) forum to no force subscribe, and no posts or discussions.
        require_once $CFG->dirroot . '/mod/forum/lib.php';
        $news = forum_get_course_forum($form->id, 'news');
        $news->open = 0;
        $news->forcesubscribe = 0;
        update_record('forum', $news);
    }
    rebuild_course_cache($form->id);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:46,代码来源:lib.php


示例5: FN_update_course

function FN_update_course($form, $oldformat = false, $resubmission = false)
{
    global $CFG, $DB, $OUTPUT;
    $config_vars = array('showsection0', 'sec0title', 'mainheading', 'topicheading', 'maxtabs');
    foreach ($config_vars as $config_var) {
        if ($varrec = $DB->get_record('course_config_fn', array('courseid' => $form->id, 'variable' => $config_var))) {
            $varrec->value = $form->{$config_var};
            $DB->update_record('course_config_fn', $varrec);
        } else {
            $varrec->courseid = $form->id;
            $varrec->variable = $config_var;
            $varrec->value = $form->{$config_var};
            $DB->insert_record('course_config_fn', $varrec);
        }
    }
    /// We need to have the sections created ahead of time for the weekly nav to work,
    /// so check and create here.
    if (!($sections = get_all_sections($form->id))) {
        $sections = array();
    }
    for ($i = 0; $i <= $form->numsections; $i++) {
        if (empty($sections[$i])) {
            $section = new Object();
            $section->course = $form->id;
            // Create a new section structure
            $section->section = $i;
            $section->summary = "";
            $section->visible = 1;
            if (!($section->id = $DB->insert_record("course_sections", $section))) {
                $OUTPUT->notification("Error inserting new section!");
            }
        }
    }
    /// Check for a change to an FN format. If so, set some defaults as well...
    if ($oldformat != 'FN') {
        /// Set the news (announcements) forum to no force subscribe, and no posts or discussions.
        require_once $CFG->dirroot . '/mod/forum/lib.php';
        $news = forum_get_course_forum($form->id, 'news');
        $news->open = 0;
        $news->forcesubscribe = 0;
        $DB->update_record('forum', $news);
    }
    rebuild_course_cache($form->id);
}
开发者ID:oncampus,项目名称:mooin_course_format_octabs,代码行数:44,代码来源:lib.php


示例6: project_backup_format_data

/**
 * Moodleから呼び出されるバックアップモジュール
 * 
 * @param stream $bf
 * @param object $preferences
 * @return bool
 */
function project_backup_format_data($bf, $preferences)
{
    $status = true;
    // コースセクション一覧を読み込む
    // $preferences->sectionが設定されている場合は1つのタイトルのみ
    if ($sections = get_all_sections($preferences->backup_course)) {
        fwrite($bf, start_tag("SECTIONTITLES", 3, true));
        foreach ($sections as $section) {
            if ((empty($preferences->backup_section) || $preferences->backup_section == $section->section) && $section->id > 0 && ($sectiontitle = get_record('course_project_title', 'sectionid', $section->id))) {
                fwrite($bf, start_tag("SECTIONTITLE", 4, true));
                fwrite($bf, full_tag("ID", 5, false, $sectiontitle->id));
                fwrite($bf, full_tag("SECTIONID", 5, false, $sectiontitle->sectionid));
                fwrite($bf, full_tag("DIRECTORYNAME", 5, false, $sectiontitle->directoryname));
                fwrite($bf, end_tag("SECTIONTITLE", 4, true));
            } else {
                continue;
            }
        }
        $status = fwrite($bf, end_tag("SECTIONTITLES", 3, true));
    } else {
        $status = false;
    }
    return $status;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:backuplib.php


示例7: getmoddata

function getmoddata($courseid, $requestid)
{
    global $DB;
    //fetch info and ids about the modules in this course
    $course = $DB->get_record('course', array('id' => $courseid));
    $modinfo =& get_fast_modinfo($course);
    get_all_mods($courseid, $mods, $modnames, $modnamesplural, $modnamesused);
    $sections = get_all_sections($courseid);
    /* Displays the type of mod name - assignment/ quiz etc 
       foreach($modnames as $modname) {
       array_push($return['messages'],$modname);
       }
       */
    $sectionarray = array();
    foreach ($sections as $section) {
        //$sectionarray[$section->id] = get_section_name($course,$section);
        //here we will store all the mods for the section
        $sectionarray[$section->section] = array();
    }
    //for each mod add its name and id to an array for its section
    foreach ($mods as $mod) {
        //$modname = htmlspecialchars($modinfo->cms[$mod->id]->name, ENT_QUOTES);
        $modname = htmlspecialchars($mod->name, ENT_QUOTES);
        $modtype = $mod->modfullname;
        $sectionid = $modinfo->cms[$mod->id]->sectionnum;
        array_push($sectionarray[$sectionid], "<module sectionid='" . $sectionid . "' modid='" . $mod->id . "' modname='" . $modname . "'  modtype='" . $modtype . "'  />");
    }
    //init xml output
    $xml_output = "<course courseid='" . $courseid . "'>";
    //go through each section adding a sect header and all the modules in it
    foreach ($sections as $section) {
        //$sectionarray[$section->id] = get_section_name($course,$section);
        //here we will store all the mods for the section
        $sectionname = htmlspecialchars(get_section_name($course, $section), ENT_QUOTES);
        $xml_output .= "<section sectionid='" . $section->section . "' sectionname='" . $sectionname . "'>";
        foreach ($sectionarray[$section->section] as $line) {
            $xml_output .= "\t" . $line;
        }
        $xml_output .= "</section>";
    }
    //close off xml output
    $xml_output .= "</course>";
    //"section", "section, id, course, name, summary, summaryformat, sequence, visible");
    //Return the data
    //$xml_output = prepareXMLReturn($return,$requestid);
    return $xml_output;
}
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:47,代码来源:poodllfilelib.php


示例8: fetchcourseitems

 function fetchcourseitems($courseid)
 {
     global $CFG, $DB;
     $xml_output = "";
     if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
         print_error('invalidcourseid');
     }
     require_course_login($course);
     //$modinfo =& get_fast_modinfo($course);
     $modinfo = get_fast_modinfo($course);
     get_all_mods($courseid, $mods, $modnames, $modnamesplural, $modnamesused);
     if (!($sections = get_all_sections($courseid))) {
         $xml_output .= 'Error finding or creating section structures for this course';
     }
     //loop through the sections
     foreach ($sections as $thissection) {
         //display a section seperator for each secton
         if (!$thissection->visible) {
             $xml_output .= "\t<item label='---------(hidden)" . "' url='' />\n";
             continue;
         } else {
             $xml_output .= "\t<item label='-----------------" . "' url='' />\n";
         }
         //loop through all the mods for each section
         $sectionmods = explode(",", $thissection->sequence);
         foreach ($sectionmods as $modnumber) {
             if (empty($mods[$modnumber])) {
                 continue;
             }
             $mod = $mods[$modnumber];
             if (isset($modinfo->cms[$modnumber])) {
                 if (!$modinfo->cms[$modnumber]->uservisible) {
                     // visibility shortcut
                     continue;
                 }
                 //here we get the name of the mod. We need to encode it
                 //because the xml breaks otherwise when there arequotes etc.
                 $instancename = htmlspecialchars($modinfo->cms[$modnumber]->name, ENT_QUOTES);
             } else {
                 if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) {
                     // module not installed
                     continue;
                 }
                 if (!coursemodule_visible_for_user($mod)) {
                     // full visibility check
                     continue;
                 }
                 //we have a mod, but for some reasonwe could not establish its name.
                 $instancename = "mod with no name";
             }
             //end of if isset
             //this works for now, but ultimately we will need to ad the "extra" paramaters from $modinfo
             $xml_output .= "\t<item label='" . $instancename . "' url='" . urlencode($CFG->wwwroot . "/mod/" . $mod->modname . "/view.php?id=" . $modnumber) . "' />\n";
         }
         //end of for each mod
     }
     //end of for each section
     return $xml_output;
 }
开发者ID:gabrielrosset,项目名称:moodle-filter_poodll,代码行数:59,代码来源:dataset_manager.php


示例9: get_context_instance

 $new_course["student"] = $course->student;
 $new_course["students"] = $course->students;
 $new_course["enrollmentkey"] = !empty($course->password);
 $new_course["numsections"] = $course->numsections;
 $new_course["marker"] = $course->marker;
 $new_course["allows_guests_without_key"] = $course->guest == 1;
 $new_course["allows_guests_with_key"] = $course->guest == 2;
 if ($CFG->rolesactive) {
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $new_course["can_edit"] = has_capability('moodle/course:manageactivities', $context);
 } else {
     if ($course->id != 1) {
         $new_course["can_edit"] = isteacher($course->id, $USER->id, true);
     }
 }
 $course_sections = get_all_sections($course->id, 'fullname ASC', 0, 1);
 $sections_array = array();
 get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
 foreach ($course_sections as $section) {
     $show_hidden_sections = FALSE;
     if ($CFG->rolesactive) {
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         $show_hidden_sections = has_capability('moodle/course:viewhiddensections', $context);
     } else {
         $show_hidden_sections = isteacher($course->id, $USER->id, true);
     }
     $showsection = ($section->visible or $show_hidden_sections);
     $new_section = array();
     $new_section[" id"] = $section->id;
     $new_section["sequence"] = $section->sequence;
     $new_section["section"] = $section->section;
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:main.php


示例10: add_course_editing_links

 /**
  * Adds branches and links to the settings navigation to add course activities
  * and resources.
  *
  * @param stdClass $course
  */
 protected function add_course_editing_links($course)
 {
     global $CFG;
     require_once $CFG->dirroot . '/course/lib.php';
     // Add `add` resources|activities branches
     $structurefile = $CFG->dirroot . '/course/format/' . $course->format . '/lib.php';
     if (file_exists($structurefile)) {
         require_once $structurefile;
         $requestkey = call_user_func('callback_' . $course->format . '_request_key');
         $formatidentifier = optional_param($requestkey, 0, PARAM_INT);
     } else {
         $requestkey = get_string('section');
         $formatidentifier = optional_param($requestkey, 0, PARAM_INT);
     }
     $sections = get_all_sections($course->id);
     $addresource = $this->add(get_string('addresource'));
     $addactivity = $this->add(get_string('addactivity'));
     if ($formatidentifier !== 0) {
         $addresource->force_open();
         $addactivity->force_open();
     }
     $this->get_course_modules($course);
     $textlib = textlib_get_instance();
     foreach ($sections as $section) {
         if ($formatidentifier !== 0 && $section->section != $formatidentifier) {
             continue;
         }
         $sectionurl = new moodle_url('/course/view.php', array('id' => $course->id, $requestkey => $section->section));
         if ($section->section == 0) {
             $sectionresources = $addresource->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
             $sectionactivities = $addactivity->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
         } else {
             $sectionname = get_section_name($course, $section);
             $sectionresources = $addresource->add($sectionname, $sectionurl, self::TYPE_SETTING);
             $sectionactivities = $addactivity->add($sectionname, $sectionurl, self::TYPE_SETTING);
         }
         foreach ($resources as $value => $resource) {
             $url = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey(), 'section' => $section->section));
             $pos = strpos($value, '&type=');
             if ($pos !== false) {
                 $url->param('add', $textlib->substr($value, 0, $pos));
                 $url->param('type', $textlib->substr($value, $pos + 6));
             } else {
                 $url->param('add', $value);
             }
             $sectionresources->add($resource, $url, self::TYPE_SETTING);
         }
         $subbranch = false;
         foreach ($activities as $activityname => $activity) {
             if ($activity === '--') {
                 $subbranch = false;
                 continue;
             }
             if (strpos($activity, '--') === 0) {
                 $subbranch = $sectionactivities->add(trim($activity, '-'));
                 continue;
             }
             $url = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey(), 'section' => $section->section));
             $pos = strpos($activityname, '&type=');
             if ($pos !== false) {
                 $url->param('add', $textlib->substr($activityname, 0, $pos));
                 $url->param('type', $textlib->substr($activityname, $pos + 6));
             } else {
                 $url->param('add', $activityname);
             }
             if ($subbranch !== false) {
                 $subbranch->add($activity, $url, self::TYPE_SETTING);
             } else {
                 $sectionactivities->add($activity, $url, self::TYPE_SETTING);
             }
         }
     }
 }
开发者ID:nigeldaley,项目名称:moodle,代码行数:79,代码来源:navigationlib.php


示例11: certificate_get_mod_grades

function certificate_get_mod_grades()
{
    global $course, $CFG;
    $strgrade = get_string('grade', 'certificate');
    /// Collect modules data
    get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
    $printgrade = array();
    $sections = get_all_sections($course->id);
    // Sort everything the same as the course
    for ($i = 0; $i <= $course->numsections; $i++) {
        // should always be true
        if (isset($sections[$i])) {
            $section = $sections[$i];
            if ($section->sequence) {
                switch ($course->format) {
                    case 'topics':
                        $sectionlabel = get_string('topic');
                        break;
                    case 'weeks':
                        $sectionlabel = get_string('week');
                        break;
                    default:
                        $sectionlabel = get_string('section');
                }
                $sectionmods = explode(",", $section->sequence);
                foreach ($sectionmods as $sectionmod) {
                    if (empty($mods[$sectionmod])) {
                        continue;
                    }
                    $mod = $mods[$sectionmod];
                    $mod->courseid = $course->id;
                    $instance = get_record($mod->modname, 'id', $mod->instance);
                    if ($grade_items = grade_get_grade_items_for_activity($mod)) {
                        $mod_item = grade_get_grades($course->id, 'mod', $mod->modname, $mod->instance);
                        $item = reset($mod_item->items);
                        if (isset($item->grademax)) {
                            $printgrade[$mod->id] = $sectionlabel . ' ' . $section->section . ' : ' . $instance->name . ' ' . $strgrade;
                        }
                    }
                }
            }
        }
    }
    if (isset($printgrade)) {
        $gradeoptions['0'] = get_string('no');
        $gradeoptions['1'] = get_string('coursegrade', 'certificate');
        foreach ($printgrade as $key => $value) {
            $gradeoptions[$key] = $value;
        }
    } else {
        $gradeoptions['0'] = get_string('nogrades', 'certificate');
    }
    return $gradeoptions;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:54,代码来源:lib.php


示例12: get_all_mods

// this will add a new class to the header so we can style differently
$PAGE->print_header(get_string('course') . ': %fullname%', NULL, '', $bodytags);
// Course wrapper start.
echo '<div class="course-content">';
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
if (!($sections = get_all_sections($course->id))) {
    // No sections found
    // Double-check to be extra sure
    if (!($section = get_record('course_sections', 'course', $course->id, 'section', 0))) {
        $section->course = $course->id;
        // Create a default section.
        $section->section = 0;
        $section->visible = 1;
        $section->id = insert_record('course_sections', $section);
    }
    if (!($sections = get_all_sections($course->id))) {
        // Try again
        error('Error finding or creating section structures for this course');
    }
}
if (empty($course->modinfo)) {
    // Course cache was never made.
    rebuild_course_cache($course->id);
    if (!($course = get_record('course', 'id', $course->id))) {
        error("That's an invalid course id");
    }
}
// Include the actual course format.
require $CFG->dirroot . '/course/format/' . $course->format . '/format.php';
// Content wrapper end.
echo "</div>\n\n";
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:view.php


示例13: get_course_contents

 /**
  * Get course contents
  *
  * @param int $courseid course id
  * @param array $options These options are not used yet, might be used in later version
  * @return array
  * @since Moodle 2.2
  */
 public static function get_course_contents($courseid, $options = array())
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/course/lib.php";
     //validate parameter
     $params = self::validate_parameters(self::get_course_contents_parameters(), array('courseid' => $courseid, 'options' => $options));
     //retrieve the course
     $course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST);
     //check course format exist
     if (!file_exists($CFG->dirroot . '/course/format/' . $course->format . '/lib.php')) {
         throw new moodle_exception('cannotgetcoursecontents', 'webservice', '', null, get_string('courseformatnotfound', 'error', '', $course->format));
     } else {
         require_once $CFG->dirroot . '/course/format/' . $course->format . '/lib.php';
     }
     // now security checks
     $context = context_course::instance($course->id, IGNORE_MISSING);
     try {
         self::validate_context($context);
     } catch (Exception $e) {
         $exceptionparam = new stdClass();
         $exceptionparam->message = $e->getMessage();
         $exceptionparam->courseid = $course->id;
         throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
     }
     $canupdatecourse = has_capability('moodle/course:update', $context);
     //create return value
     $coursecontents = array();
     if ($canupdatecourse or $course->visible or has_capability('moodle/course:viewhiddencourses', $context)) {
         //retrieve sections
         $modinfo = get_fast_modinfo($course);
         $sections = get_all_sections($course->id);
         //for each sections (first displayed to last displayed)
         foreach ($sections as $key => $section) {
             $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $section->visible or !$course->hiddensections);
             if (!$showsection) {
                 continue;
             }
             // reset $sectioncontents
             $sectionvalues = array();
             $sectionvalues['id'] = $section->id;
             $sectionvalues['name'] = get_section_name($course, $section);
             $sectionvalues['visible'] = $section->visible;
             list($sectionvalues['summary'], $sectionvalues['summaryformat']) = external_format_text($section->summary, $section->summaryformat, $context->id, 'course', 'section', $section->id);
             $sectioncontents = array();
             //for each module of the section
             foreach ($modinfo->sections[$section->section] as $cmid) {
                 //matching /course/lib.php:print_section() logic
                 $cm = $modinfo->cms[$cmid];
                 // stop here if the module is not visible to the user
                 if (!$cm->uservisible) {
                     continue;
                 }
                 $module = array();
                 //common info (for people being able to see the module or availability dates)
                 $module['id'] = $cm->id;
                 $module['name'] = format_string($cm->name, true);
                 $module['modname'] = $cm->modname;
                 $module['modplural'] = $cm->modplural;
                 $module['modicon'] = $cm->get_icon_url()->out(false);
                 $module['indent'] = $cm->indent;
                 $modcontext = context_module::instance($cm->id);
                 if (!empty($cm->showdescription)) {
                     $module['description'] = $cm->get_content();
                 }
                 //url of the module
                 $url = $cm->get_url();
                 if ($url) {
                     //labels don't have url
                     $module['url'] = $cm->get_url()->out();
                 }
                 $canviewhidden = has_capability('moodle/course:viewhiddenactivities', context_module::instance($cm->id));
                 //user that can view hidden module should know about the visibility
                 $module['visible'] = $cm->visible;
                 //availability date (also send to user who can see hidden module when the showavailabilyt is ON)
                 if ($canupdatecourse or $CFG->enableavailability && $canviewhidden && $cm->showavailability) {
                     $module['availablefrom'] = $cm->availablefrom;
                     $module['availableuntil'] = $cm->availableuntil;
                 }
                 $baseurl = 'webservice/pluginfile.php';
                 //call $modulename_export_contents
                 //(each module callback take care about checking the capabilities)
                 require_once $CFG->dirroot . '/mod/' . $cm->modname . '/lib.php';
                 $getcontentfunction = $cm->modname . '_export_contents';
                 if (function_exists($getcontentfunction)) {
                     if ($contents = $getcontentfunction($cm, $baseurl)) {
                         $module['contents'] = $contents;
                     }
                 }
                 //assign result to $sectioncontents
                 $sectioncontents[] = $module;
             }
             $sectionvalues['modules'] = $sectioncontents;
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:externallib.php


示例14: print_body

 /**
  * Print out the course page. Use the course 'format.php' file. This may make sense to replace with a
  * function at some point, but for now, many things trigger on its existence.
  *
  */
 function print_body()
 {
     /// These globals are needed for the included 'format.php' file.
     global $CFG, $USER, $SESSION, $COURSE, $THEME, $course;
     global $mods, $modnames, $modnamesplural, $modnamesused, $sections;
     /// These are needed in various library functions.
     global $PAGE, $pageblocks, $section, $marker;
     /// These are needed in various library functions.
     global $preferred_width_left, $preferred_width_right;
     /// These may be used in blocks.
     // Course wrapper start.
     echo '<div class="course-content">';
     get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
     if (!($sections = get_all_sections($course->id))) {
         // No sections found
         // Double-check to be extra sure
         if (!($section = get_record('course_sections', 'course', $course->id, 'section', 0))) {
             $section->course = $course->id;
             // Create a default section.
             $section->section = 0;
             $section->visible = 1;
             $section->id = insert_record('course_sections', $section);
         }
         if (!($sections = get_all_sections($course->id))) {
             // Try again
             error('Error finding or creating section structures for this course');
         }
     }
     if (empty($course->modinfo)) {
         // Course cache was never made.
         rebuild_course_cache($course->id);
         if (!($course = get_record('course', 'id', $course->id))) {
             error("That's an invalid course id");
         }
     }
     // Include the actual course format.
     require $CFG->dirroot . '/course/format/' . $course->format . '/format.php';
     // Content wrapper end.
     echo "</div>\n\n";
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:45,代码来源:course_format.class.php


示例15: get_course_grade

function get_course_grade($id)
{
    global $course, $CFG, $USER;
    $course = get_record("course", "id", $id);
    $strgrades = get_string("grades");
    $strgrade = get_string("grade");
    $strmax = get_string("maximumshort");
    $stractivityreport = get_string("activityreport");
    /// Get a list of all students
    $columnhtml = array();
    // Accumulate column html in this array.
    $grades = array();
    // Collect all grades in this array
    $maxgrades = array();
    // Collect all max grades in this array
    $totalgrade = 0;
    $totalmaxgrade = 1.0E-6;
    /// Collect modules data
    $test = get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
    /// Search through all the modules, pulling out grade data
    $sections = get_all_sections($course->id);
    // Sort everything the same as the course
    for ($i = 0; $i <= $course->numsections; $i++) {
        if (isset($sections[$i])) {
            // should always be true
            $section = $sections[$i];
            if (!empty($section->sequence)) {
                $sectionmods = explode(",", $section->sequence);
                foreach ($sectionmods as $sectionmod) {
                    $mod = $mods[$sectionmod];
                    if ($mod->visible) {
                        $instance = get_record("{$mod->modname}", "id", "{$mod->instance}");
                        $libfile = "{$CFG->dirroot}/mod/{$mod->modname}/lib.php";
                        if (file_exists($libfile)) {
                            require_once $libfile;
                            $gradefunction = $mod->modname . "_grades";
                            if (function_exists($gradefunction)) {
                                // Skip modules without grade function
                                if ($modgrades = $gradefunction($mod->instance)) {
                                    if (empty($modgrades->grades[$USER->id])) {
                                        $grades[] = "";
                                    } else {
                                        $grades[] = $modgrades->grades[$USER->id];
                                        $totalgrade += (double) $modgrades->grades[$USER->id];
                                    }
                                    if (empty($modgrades->maxgrade) || empty($modgrades)) {
                                        $maxgrades[] = "";
                                    } else {
                                        $maxgrades[] = $modgrades->maxgrade;
                                        $totalmaxgrade += $modgrades->maxgrade;
                                    }
                                }
                            }
                            $gradefunction = $mod->modname . "_get_user_grades";
                            if (function_exists($gradefunction)) {
                                // Skip modules without grade function
                                if ($modgrades = $gradefunction($mod->instance)) {
                                    /*                                    if (empty($modgrades->grades[$USER->id])) {
                                                                            $grades[]  = "";
                                                                        } else {
                                                                            $grades[]  = $modgrades->grades[$USER->id];
                                                                            $totalgrade += (float)$modgrades->grades[$USER->id];
                                                                        }
                                                                        if (empty($modgrades->maxgrade) || empty($modgrades)) {
                                                                            $maxgrades[] = "";
                                                                        } else {
                                                                            $maxgrades[]    = $modgrades->maxgrade;
                                                                            $totalmaxgrade += $modgrades->maxgrade;
                                                                        }*/
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $coursegrade->percentage = round($totalgrade * 100 / $totalmaxgrade, 2);
    $coursegrade->points = $totalgrade;
    return $coursegrade;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:81,代码来源:lib.php


示例16: sections

 function sections($config)
 {
     global $COURSE, $CFG, $USER, $THEME;
     // probably inefficient, but it works
     get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesused);
     // sections
     $sections = get_all_sections($COURSE->id);
     // name for sections
     $sectionname = get_string("name{$COURSE->format}", "format_{$COURSE->format}");
     // TODO: this fallback should be unnecessary
     if ($sectionname == "[[name{$COURSE->format}]]") {
         $sectionname = get_string("name{$COURSE->format}");
     }
     $return = array();
     // check what the course format is like
     // highlight for current week or highlighted topic
     if (in_array($COURSE->format, array('weeks', 'weekscss'))) {
         $format = 'week';
         $highlight = ceil((time() - $COURSE->startdate) / 604800);
     } else {
         $format = 'topic';
         $highlight = $COURSE->marker;
     }
     $modinfo = unserialize($COURSE->modinfo);
     // I think $display is the section currently being displayed
     // Why are we calling course_set_display?
     // For Moodle 2.0 we should just use $PAGE and check type
     // and also $PAGE->activityrecord
     $path = str_replace($CFG->httpswwwroot . '/', '', $CFG->pagepath);
     if (substr($path, 0, 7) == 'course/') {
         //TODO: this code is hackish, we shouldn't use course_set_display
         # get current section being displayed
         $week = optional_param('week', -1, PARAM_INT);
         if ($week != -1) {
             // the course format should already be doing this
             $display = course_set_display($COURSE->id, $week);
         } else {
             if (isset($USER->display[$COURSE->id])) {
                 $display = $USER->display[$COURSE->id];
             } else {
                 $display = course_set_display($COURSE->id, 0);
             }
         }
     } elseif (substr($path, 0, 4) == 'mod/') {
         // Moodle 2: use $PAGE->activityrecord->section;
         $id = optional_param('id', -1, PARAM_INT);
         if ($id == -1) {
             $display = 0;
         } else {
             $sql = "select section from {$CFG->prefix}course_sections where id=(select section from {$CFG->prefix}course_modules where id={$id})";
             $row = get_record_sql($sql);
             $display = $row->section;
         }
     } else {
         $display = 0;
     }
     foreach ($sections as $section) {
         // don't show the flowing sections
         if (!($section->visible && $section->section && $section->section <= $COURSE->numsections)) {
             continue;
         }
         $text = trim($section->summary);
         if (empty($text)) {
             $text = ucwords($sectionname) . " " . $section->section;
         } else {
             $text = $this->truncate_html(filter_text($text, $COURSE->id), $config);
         }
         // expand section if it's the one currently displayed
         $expand = false;
         if ($section->section == $display) {
             $expand = true;
         }
         $sectionstyle = 'yui_menu_icon_section';
         // highlight marked section
         if ($section->section == $highlight) {
             $sectionstyle .= ' highlight';
         }
         $iconpath = $CFG->wwwroot;
         if ($THEME->custompix) {
             $iconpath .= "/theme/" . current_theme() . "/pix";
         } else {
             $iconpath .= '/pix';
             //$iconpath .= '/';
         }
         $iconpath = $CFG->wwwroot . "/theme/" . current_theme() . "/pix";
         // decide what URL we want to use
         // A lot of this should really be done by the course format
         //
         // = intoaction config values =
         // * 'introhide' link to the section page (this effectively
         //   hides the other sections
         // * 'introscroll' link to the fragment id of the section on
         //   on the current page
         // whether or not any of the sections are hidden
         $hidden = false;
         foreach (array('topic', 'week') as $param) {
             if (isset($_GET[$param]) && $_GET[$param] != 'all') {
                 $hidden = true;
             }
         }
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:outline.php


示例17: get_content

 function get_content()
 {
     global $USER, $CFG;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     $course = get_record('course', 'id', $this->instance->pageid);
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $isediting = isediting($this->instance->pageid) && has_capability('moodle/course:manageactivities', $context);
     $ismoving = ismoving($this->instance->pageid);
     $sections = get_all_sections($this->instance->pageid);
     if (!empty($sections) && isset($sections[0])) {
         $section = $sections[0];
     }
     if (!empty($section) || $isediting) {
         get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
     }
     $groupbuttons = $course->groupmode;
     $groupbuttonslink = !$course->groupmodeforce;
     if ($ismoving) {
         $strmovehere = get_string('movehere');
         $strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
         $strcancel = get_string('cancel');
         $stractivityclipboard = $USER->activitycopyname;
     }
     /// Casting $course->modinfo to string prevents one notice when the field is null
     $modinfo = unserialize((string) $course->modinfo);
     $editbuttons = '';
     if ($ismoving) {
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/t/move.gif&quo 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_all_subcategories函数代码示例发布时间:2022-05-15
下一篇:
PHP get_all_roles函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap