本文整理汇总了PHP中get_all_mods函数的典型用法代码示例。如果您正苦于以下问题:PHP get_all_mods函数的具体用法?PHP get_all_mods怎么用?PHP get_all_mods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_mods函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $USER, $CFG;
// TODO: FIX: HACK: (any other tags I should add? :P)
// Hacker's improvised caching scheme: avoid fetching the mod
// data from db if the course format has already fetched them
if (!isset($GLOBALS['modnamesplural']) || !isset($GLOBALS['modnamesused'])) {
require_once $CFG->dirroot . '/course/lib.php';
if (!empty($this->instance)) {
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
}
} else {
$modnamesplural = $GLOBALS['modnamesplural'];
$modnamesused = $GLOBALS['modnamesused'];
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (isset($modnamesused) && $modnamesused) {
foreach ($modnamesused as $modname => $modfullname) {
if ($modname != 'label') {
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $this->instance->pageid . '">' . $modnamesplural[$modname] . '</a>';
$this->content->icons[] = '<img src="' . $CFG->modpixpath . '/' . $modname . '/icon.gif" class="icon" alt="" />';
}
}
}
return $this->content;
}
示例2: definition
function definition() {
global $DB, $USER, $CFG;
$mform = & $this->_form;
$mform->addElement('header', 'crformheader', get_string('usermodactions', 'block_cobalt_reports'), '');
$columns = $DB->get_columns('user');
$modules = array();
// Fix for http://tracker.moodle.org/browse/CONTRIB-2945
require_once($CFG->dirroot . "/course/lib.php");
get_all_mods($this->_customdata['report']->courseid, $mods, $modnames, $modnamesplural, $modnamesused);
if ($mods) {
foreach ($mods as $m) {
$instance = $DB->get_record("$m->modname", array("id" => "$m->instance"));
$modules[$m->id] = $instance->name;
}
}
$mform->addElement('select', 'cmid', get_string('module', 'block_cobalt_reports'), $modules);
$this->_customdata['compclass']->add_form_elements($mform, $this);
// buttons
$this->add_action_buttons(true, get_string('add'));
}
示例3: edit_form_add
public function edit_form_add(&$mform)
{
global $COURSE, $CFG;
require_once $CFG->dirroot . '/course/lib.php';
get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesusesd);
$modinfo = unserialize((string) $COURSE->modinfo);
$modules = array();
foreach ($mods as $mod) {
$instancename = urldecode($modinfo[$mod->id]->name);
$instancename = format_string($instancename, true, $COURSE->id);
$modules[$mod->id] = shorten_text($mod->modfullname . ': ' . $instancename, 28);
}
natcasesort($modules);
// Add our choose option to the front
$options = array(0 => get_string('choose', 'pagemenu')) + $modules;
$mform->addElement('select', 'moduleid', get_string('addmodule', 'pagemenu'), $options);
$mform->setType('moduleid', PARAM_INT);
}
示例4: definition
function definition()
{
global $USER, $CFG, $db;
$mform =& $this->_form;
$mform->addElement('header', '', get_string('usermodactions', 'block_configurable_reports'), '');
$columns = $db->MetaColumns($CFG->prefix . 'user');
$modules = array();
get_all_mods($this->_customdata['report']->courseid, $mods, $modnames, $modnamesplural, $modnamesused);
if ($mods) {
foreach ($mods as $m) {
$instance = get_record("{$m->modname}", "id", "{$m->instance}");
$modules[$m->id] = $instance->name;
}
}
$mform->addElement('select', 'cmid', get_string('module', 'block_configurable_reports'), $modules);
$this->_customdata['compclass']->add_form_elements($mform, $this);
// buttons
$this->add_action_buttons(true, get_string('add'));
}
示例5: cms_render
function cms_render($pagedata, $course)
{
global $sections, $USER;
// Insert dynamic content
// content marked as private should be shown with a special style to people with editing rights
// and should not be shown to others
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$canedit = has_capability('format/cms:editpage', $context, $USER->id);
$private = $canedit ? '<div class="private">$1</div>' : '';
$search = array("#\\[\\[INCLUDE (.+?)\\]\\]#ie", "#\\[\\[SCRIPT (.+?)\\]\\]#ie", "#\\[\\[PAGE (.+?)\\]\\]#ie", "#\\[\\[NEWS\\]\\]#ie", "#\\[\\[PRIVATE (.+?)\\]\\]#is", "#\\[\\[TOC\\]\\]#ie", "#\\[\\[([^\\[\\]]+?)\\s*\\|\\s*(.+?)\\]\\]#es", "#\\._\\.#ie");
$replace = array('cms_safe_include("$1", true)', 'cms_safe_include("$1", false)', 'cms_include_page("$1", $course)', 'cms_render_news($course)', $private, 'cms_print_toc($pagedata->id)', 'cms_render_link("$1" ,"$2")', '');
$body = preg_replace($search, $replace, $pagedata->body);
// Search sections.
preg_match_all("/{#section([0-9]+)}/i", $body, $match);
$cmssections = $match[1];
// At this point allow only course level not site level.
if (!empty($cmssections)) {
foreach ($cmssections as $cmssection) {
if (!empty($sections[$cmssection])) {
$thissection = $sections[$cmssection];
} else {
unset($thissection);
// make sure that the section doesn't exist.
if (!record_exists('course_sections', 'section', $cmssection, 'course', $course->id)) {
$thissection->course = $course->id;
// Create a new section structure
$thissection->section = $cmssection;
$thissection->summary = '';
$thissection->visible = 1;
if (!($thissection->id = insert_record('course_sections', $thissection))) {
notify('Error inserting new topic!');
}
} else {
$thissection = get_record('course_sections', 'course', $course->id, 'section', $cmssection);
}
}
if (!empty($thissection)) {
if (empty($mods)) {
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
}
$showsection = ($canedit or $thissection->visible or !$course->hiddensections);
if ($showsection) {
$content = '<div id="cms-section-' . $cmssection . '">';
$content .= cms_get_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
$content .= cms_section_add_menus($course, $cmssection, $modnames, false);
}
$content .= '</div>';
$body = preg_replace("/{#section{$cmssection}}/", $content, $body);
}
} else {
$body = preg_replace("/{#section{$cmssection}}/", "", $body);
}
}
}
$options = new stdClass();
$options->noclean = true;
return format_text(stripslashes($body), FORMAT_HTML, $options);
}
示例6: 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;
}
}
//.........这里部分代码省略.........
示例7: offline_get_dynamic_files
/**
* Retrieve all dynamic files
*
* @return string[] The array of dynamic files
*/
function offline_get_dynamic_files()
{
global $CFG, $COURSE, $USER, $DB;
require_once $CFG->dirroot . '/course/lib.php';
// Include homepage and accessible course pages
$files = array('.', $CFG->wwwroot . '/', $CFG->wwwroot . '/index.php', $CFG->wwwroot . '/lib/offline/go_offline.js', $CFG->wwwroot . '/user/editadvanced.php?id=' . $USER->id);
// get all accessible courses
if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary'));
} else {
if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or $DB->count_records('course') <= FRONTPAGECOURSELIMIT) {
$categories = get_child_categories(0);
if (is_array($categories) && count($categories) == 1) {
$category = array_shift($categories);
$courses = get_courses_wmanagers($category->id, 'c.sortorder ASC', array('password', 'summary', 'currency'));
} else {
$courses = get_courses_wmanagers('all', 'c.sortorder ASC', array('password', 'summary', 'currency'));
}
unset($categories);
}
}
// make sure the course is visible and retrieve other modules and main course pages
foreach ($courses as $course) {
if ($course->visible == 1 || has_capability('moodle/course:viewhiddencourses', $course->context)) {
$files[] = $CFG->wwwroot . '/course/view.php?id=' . $course->id;
//Get all the module main pages
foreach (get_list_of_plugins() as $module) {
if ($module != 'label') {
$files[] = $CFG->wwwroot . '/mod/' . $module . '/index.php?id=' . $course->id;
}
}
//Get all the relevant forums
require_once $CFG->dirroot . '/mod/forum/lib.php';
$forums = forum_get_readable_forums($USER->id, $course->id);
foreach ($forums as $forum) {
$files[] = $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id;
}
$modinfo =& get_fast_modinfo($course);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
foreach ($mods as $mod) {
if ($mod->modname == 'forum') {
$files[] = $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id;
$cm = get_coursemodule_from_id('forum', $mod->id);
$discussions = forum_get_discussions($cm);
foreach ($discussions as $d) {
$files[] = $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $d->discussion;
}
}
}
//Get all the relevant assignments
foreach ($modinfo->instances['assignment'] as $cm) {
if (!$cm->uservisible) {
continue;
}
$files[] = $CFG->wwwroot . '/mod/assignment/view.php?id=' . $cm->id;
}
}
}
$files = str_replace('&', '&', $files);
return $files;
}
示例8: get_course_modules
/**
* Generate the list of modules for the given course.
*
* @param stdClass $course The course to get modules for
*/
protected function get_course_modules($course)
{
global $CFG;
$mods = $modnames = $modnamesplural = $modnamesused = array();
// This function is included when we include course/lib.php at the top
// of this file
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
$resources = array();
$activities = array();
foreach ($modnames as $modname => $modnamestr) {
if (!course_allowed_module($course, $modname)) {
continue;
}
$libfile = "{$CFG->dirroot}/mod/{$modname}/lib.php";
if (!file_exists($libfile)) {
continue;
}
include_once $libfile;
$gettypesfunc = $modname . '_get_types';
if (function_exists($gettypesfunc)) {
$types = $gettypesfunc();
foreach ($types as $type) {
if (!isset($type->modclass) || !isset($type->typestr)) {
debugging('Incorrect activity type in ' . $modname);
continue;
}
if ($type->modclass == MOD_CLASS_RESOURCE) {
$resources[html_entity_decode($type->type, ENT_QUOTES, 'UTF-8')] = $type->typestr;
} else {
$activities[html_entity_decode($type->type, ENT_QUOTES, 'UTF-8')] = $type->typestr;
}
}
} else {
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
$resources[$modname] = $modnamestr;
} else {
// all other archetypes are considered activity
$activities[$modname] = $modnamestr;
}
}
}
return array($resources, $activities);
}
示例9: certificate_get_mods
/**
* Get all the modules
*
* @return array
*/
function certificate_get_mods()
{
global $COURSE, $CFG, $DB;
$strtopic = get_string("topic");
$strweek = get_string("week");
$strsection = get_string("section");
// Collect modules data
get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesused);
$modules = 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 = $strtopic;
break;
case "weeks":
$sectionlabel = $strweek;
break;
default:
$sectionlabel = $strsection;
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
if (empty($mods[$sectionmod])) {
continue;
}
$mod = $mods[$sectionmod];
$mod->courseid = $COURSE->id;
$instance = $DB->get_record($mod->modname, array('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)) {
$modules[$mod->id] = $sectionlabel . ' ' . $section->section . ' : ' . $instance->name;
}
}
}
}
}
}
return $modules;
}
示例10: render_subpage
/**
* Render contents of main part of subpage
* @param mod_subpage $subpage
* @param course_modinfo $modinfo
* @param array $sections
* @param boolean $editing whether the user is allowed to edit this page
* @param int $moveitem (currently not used)
* @param boolean $movesection whether the user is allowed to move sections
* @return string html for display
*/
public function render_subpage($subpage, $modinfo, $sections, $editing, $moveitem, $movesection)
{
global $PAGE, $OUTPUT, $CFG, $USER;
$this->subpagecm = $subpage->get_course_module()->id;
if (!empty($USER->activitycopy) && $movesection) {
$content = $this->render_cancel_link($this->subpagecm);
} else {
$content = '';
}
$content .= $this->render_intro($subpage);
$streditsummary = get_string('editsummary');
$strdelete = get_string('delete');
if ($editing) {
$strmoveup = get_string('moveup');
$strmovedown = get_string('movedown');
$strhide = get_string('hide');
$strshow = get_string('show');
$strstealth = get_string('stealth', 'subpage');
$strunstealth = get_string('unstealth', 'subpage');
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $subpage->get_course()->id);
get_all_mods($subpage->get_course()->id, $mods, $modnames, $modnamesplural, $modnamesused);
foreach ($mods as $modid => $unused) {
if (!isset($modinfo->cms[$modid])) {
rebuild_course_cache($subpage->get_course()->id);
$modinfo =& get_fast_modinfo($subpage->get_course());
debugging('Rebuilding course cache', DEBUG_DEVELOPER);
break;
}
}
$lastpageorder = $subpage->get_last_section_pageorder();
if ($subpage->get_course()->format == 'weeks') {
$content .= html_writer::start_tag('ul', array('class' => 'weeks'));
} else {
$content .= html_writer::start_tag('ul', array('class' => 'topics'));
}
foreach ($sections as $section) {
// Check to see whether cms within the section are visible or not
// If all cms are not visible then we don't show the section at all,
// unless editing
$visible = false;
if ($section->sequence) {
// get cm_info for this resources
$instances = explode(',', $section->sequence);
} else {
$instances = array();
}
foreach ($instances as $instance) {
$cm = $modinfo->get_cm($instance);
// check to see whether cm is visible
if ($cm->uservisible) {
$visible = true;
break;
}
}
// If section is empty so should be hidden, record that in object
$section->autohide = !$visible;
$content .= html_writer::start_tag('li', array('class' => 'section main clearfix', 'id' => 'section-' . $section->section));
$content .= html_writer::tag('div', ' ', array('class' => 'left side'));
$content .= html_writer::start_tag('div', array('class' => 'right side'));
if ($editing && has_capability('moodle/course:update', $coursecontext)) {
// Show the hide/show eye
if ($section->visible) {
$content .= html_writer::start_tag('a', array('href' => 'view.php?id=' . $subpage->get_course_module()->id . '&hide=' . $section->section . '&sesskey=' . sesskey() . '#section-' . $section->id, 'title' => $strhide));
$content .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon hide', 'alt' => $strhide));
$content .= html_writer::end_tag('a');
} else {
$content .= html_writer::start_tag('a', array('href' => 'view.php?id=' . $subpage->get_course_module()->id . '&show=' . $section->section . '&sesskey=' . sesskey() . '#section-' . $section->id, 'title' => $strshow));
$content .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon show', 'alt' => $strshow));
$content .= html_writer::end_tag('a');
}
// Show the stealth/unstealth section link
if ($section->stealth) {
$content .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'stealth.php'));
$content .= html_writer::start_tag('div');
$content .= html_writer::empty_tag('input', array('name' => 'id', 'value' => $subpage->get_course_module()->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'sesskey', 'value' => sesskey(), 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'unstealth', 'value' => $section->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'icon', 'src' => $OUTPUT->pix_url('unstealth', 'mod_subpage'), 'type' => 'image', 'title' => $strunstealth, 'alt' => $strunstealth));
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('form');
} else {
$content .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'stealth.php'));
$content .= html_writer::start_tag('div');
$content .= html_writer::empty_tag('input', array('name' => 'id', 'value' => $subpage->get_course_module()->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'sesskey', 'value' => sesskey(), 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'stealth', 'value' => $section->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'icon', 'src' => $OUTPUT->pix_url('stealth', 'mod_subpage'), 'type' => 'image', 'title' => $strstealth, 'alt' => $strstealth));
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('form');
//.........这里部分代码省略.........
示例11: print_student_grade
/**
* Simply prints all grade of one student from all modules from a given course
* used in the grade book for student view, and grade button under user profile
* @param int $userid;
* @param int $courseid;
*/
function print_student_grade($user, $course)
{
global $CFG;
if (!empty($user)) {
$grades[$user->id] = array();
// Collect all grades in this array
$gradeshtml[$user->id] = array();
// Collect all grades html formatted in this array
$totals[$user->id] = array();
// Collect all totals in this array
}
$strmax = get_string("maximumshort");
/// Collect modules data
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
// prints table
// flag for detecting whether to print table header or not
$nograde = 0;
for ($i = 0; $i <= $course->numsections; $i++) {
if (isset($sections[$i])) {
// should always be true
$section = $sections[$i];
if ($section->sequence) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $sectionmod) {
$mod = $mods[$sectionmod];
if (empty($mod->modname)) {
continue;
// Just in case, see MDL-7150
}
if (!($instance = get_record($mod->modname, 'id', $mod->instance))) {
continue;
}
if (!($cm = get_coursemodule_from_instance($mod->modname, $mod->instance))) {
continue;
}
if (!$cm->visible) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('moodle/course:viewhiddenactivities', $modcontext)) {
continue;
}
}
$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->maxgrade)) {
if ($mod->visible) {
$maxgrade = $modgrades->maxgrade;
} else {
$maxgrade = $modgrades->maxgrade;
}
} else {
$maxgrade = '';
}
if ($maxgrade) {
if (!$nograde) {
echo '<table align="center" class="grades"><tr><th scope="col">' . get_string('activity') . '</th><th scope="col">' . get_string('yourgrade', 'grades') . '</th><th scope="col">' . get_string('maxgrade', 'grades') . '</th></tr>';
}
$nograde++;
$link_id = grade_get_module_link($course->id, $mod->instance, $mod->module);
$link = $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $link_id->id;
echo '<tr>';
if (!empty($modgrades->grades[$user->id])) {
$currentgrade = $modgrades->grades[$user->id];
echo "<td><a href='{$link}'>{$mod->modfullname}: " . format_string($instance->name, true) . "</a></td><td>{$currentgrade}</td><td>{$maxgrade}</td>";
} else {
echo "<td><a href='{$link}'>{$mod->modfullname}: " . format_string($instance->name, true) . "</a></td><td>" . get_string('nograde') . "</td><td>{$maxgrade}</td>";
}
echo '</tr>';
}
}
}
}
}
}
}
}
// a new Moodle nesting record? ;-)
if ($nograde) {
echo '</table>';
}
}
示例12: allmetadata_print_big_search_form
function allmetadata_print_big_search_form($course)
{
global $CFG;
global $words, $subject, $searchcourseid, $phrase, $user, $userid, $modname, $fullwords, $notwords, $datefrom, $dateto;
print_simple_box(get_string('searchallmetadataintro', 'allmetadata'), 'center', '', '', 'searchbox', 'intro');
print_simple_box_start("center");
echo "<script type=\"text/javascript\" language=\"javascript\">\n";
echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n";
echo "var timetoitems = ['today','tomonth','toyear','tohour','tominute'];\n";
echo "</script>\n";
echo '<form name="search" action="search_allmetadata.php" method="get">';
echo '<input type="hidden" value="' . $course->id . '" name="id" alt="">';
echo '<table cellpadding="10" class="searchbox" id="form">';
echo '<tr>';
echo '<td class="c0">' . get_string('searchwords', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="words" value="' . s($words) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchphrase', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="phrase" value="' . s($phrase) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchnotwords', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="notwords" value="' . s($notwords) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchfullwords', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="fullwords" value="' . s($fullwords) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchdatefrom', 'allmetadata') . ':</td>';
echo '<td class="c1">';
echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'allmetadata') . '" onclick="return lockoptions(\'search\', \'timefromrestrict\', timefromitems)" /> ';
if (empty($dateto)) {
$datefrom = make_timestamp(2000, 1, 1, 0, 0, 0);
}
print_date_selector('fromday', 'frommonth', 'fromyear', $datefrom);
print_time_selector('fromhour', 'fromminute', $datefrom);
echo '<input type="hidden" name="hfromday" value="0" />';
echo '<input type="hidden" name="hfrommonth" value="0" />';
echo '<input type="hidden" name="hfromyear" value="0" />';
echo '<input type="hidden" name="hfromhour" value="0" />';
echo '<input type="hidden" name="hfromminute" value="0" />';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchdateto', 'allmetadata') . ':</td>';
echo '<td class="c1">';
echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'allmetadata') . '" onclick="return lockoptions(\'search\', \'timetorestrict\', timetoitems)" /> ';
if (empty($dateto)) {
$dateto = time() + 3600;
}
print_date_selector('today', 'tomonth', 'toyear', $dateto);
print_time_selector('tohour', 'tominute', $dateto);
echo '<input type="hidden" name="htoday" value="0" />';
echo '<input type="hidden" name="htomonth" value="0" />';
echo '<input type="hidden" name="htoyear" value="0" />';
echo '<input type="hidden" name="htohour" value="0" />';
echo '<input type="hidden" name="htominute" value="0" />';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchsubject', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="subject" value="' . s($subject) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchuser', 'allmetadata') . ':</td>';
echo '<td class="c1"><input type="text" size="35" name="user" value="' . s($user) . '" alt=""></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchwhichmetadatas', 'allmetadata') . ':</td>';
echo '<td class="c1">';
//Metadata Modules available
//function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused)
$allmods = get_all_mods($course->id, &$mods, &$modnames, &$modnamesplural, &$modnamesused);
$metamods = array();
if (array_key_exists("metadatadc", $modnamesplural)) {
$metamods = array_merge(array("metadatadc" => get_string('modulenameplural', 'metadatadc')), $metamods);
//array_unshift($metamods, get_string('modulenameplural', 'metadatadc'));
}
if (array_key_exists("metadatalom", $modnamesplural)) {
$metamods = array_merge(array("metadatalom" => get_string('modulenameplural', 'metadatalom')), $metamods);
//array_unshift($metamods, get_string('modulenameplural', 'metadatalom'));
}
if (count($metamods) == 1) {
//choose_from_menu($options, $name, $selected='', $nothing='choose', $script='', $nothingvalue='0', $return=false, $disabled=false, $tabindex=0)
choose_from_menu($metamods, 'metamodname', '', 'choose', '');
} elseif (count($metamods) > 1) {
array_unshift($metamods, get_string('allmetadata', 'allmetadata'));
choose_from_menu($metamods, 'metamodname', '', 'choose', '');
} else {
echo '<strong>' . get_string('nometadata', 'allmetadata') . '</strong>';
}
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="c0">' . get_string('searchwhichcourse', 'allmetadata') . ':</td>';
echo '<td class="c1">';
//Courses available
//get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
//.........这里部分代码省略.........
示例13: display
function display()
{
global $CFG, $PAGE, $COURSE;
require_capability('moodle/course:manageactivities', $this->context);
get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesused);
// Right now storing modules in a section corresponding to the current
// page - probably should all be section 0 though
if ($COURSE->id == SITEID) {
$section = 1;
// Front page only has section 1 - so use 1 as default
} else {
if (isset($page->id)) {
$section = $page->id;
} else {
$section = 0;
}
}
$PAGE->print_tabs('activities');
print_box_start('boxwidthwide boxaligncenter pageeditingtable', 'editing-table');
print_section_add_menus($COURSE, $section, $modnames);
if (!empty($modnamesused)) {
$modinfo = get_fast_modinfo($COURSE);
$vars = new stdClass();
$vars->delete = get_string("delete");
$vars->update = get_string("update");
$vars->sesskey = sesskey();
foreach ($modnamesused as $module => $modnamestr) {
$orderby = 'i.name';
$fields = 'i.id, i.name, m.name ' . sql_as() . ' module, c.id ' . sql_as() . 'cmid, c.visible';
// Going to be executing SQL that could fail on purpose - avoid debug messages
$debug = $CFG->debug;
// Store current value
$CFG->debug = false;
// disable_debugging() doesn't seem to work
// Check for field named type
if (execute_sql("SELECT type FROM {$CFG->prefix}{$module} WHERE 1 = 2", false)) {
// Has type - incorperate it into the sql
$orderby = "i.type, {$orderby}";
$fields = "{$fields}, i.type";
}
// Restore debug value
$CFG->debug = $debug;
$instances = get_records_sql("SELECT {$fields}\n FROM {$CFG->prefix}course_modules c,\n {$CFG->prefix}modules m,\n {$CFG->prefix}{$module} i\n WHERE i.course = {$COURSE->id}\n AND m.name = '{$module}'\n AND c.instance = i.id\n AND c.module = m.id\n ORDER BY {$orderby}");
if (!empty($instances)) {
$lasttype = '';
print "<h2><a href=\"{$CFG->wwwroot}/mod/{$module}/index.php?id={$COURSE->id}\">{$modnamestr}</a></h2>\n";
print "<ul class=\"activity-list\">\n";
foreach ($instances as $instance) {
if (!empty($instance->type) and $lasttype != $instance->type) {
if (!empty($lasttype)) {
// Switching types and it isn't the first time, close previously opened list
print "</ul>\n</li>\n";
}
// Try to get a name for the type (check module first)
$strtype = get_string($instance->type, $module);
if (strpos($strtype, '[') !== false) {
$strtype = get_string($module . ':' . $instance->type, 'format_page');
}
print "<li><div class=\"plus-minus\"><p><span class=\"no-space\"><strong>{$strtype}</strong></span></p></div>\n<ul>\n";
$lasttype = $instance->type;
}
if (!empty($modinfo->cms[$instance->cmid]->icon)) {
$icon = "{$CFG->pixpath}/" . urldecode($modinfo->cms[$instance->cmid]->icon);
} else {
$icon = "{$CFG->modpixpath}/{$module}/icon.gif";
}
if (empty($instance->visible)) {
$linkclass = ' class="dimmed"';
} else {
$linkclass = '';
}
print '<li>';
print '<img src="' . $icon . '" class="icon" />';
print "<a{$linkclass} href=\"{$CFG->wwwroot}/mod/{$module}/view.php?id={$instance->cmid}\">" . format_string(strip_tags($instance->name), true, $COURSE->id) . '</a> ';
print '<span class="commands">';
print "<a title=\"{$vars->update}\" href=\"{$CFG->wwwroot}/course/mod.php?update={$instance->cmid}&sesskey={$vars->sesskey}\">";
print "<img src=\"{$CFG->pixpath}/t/edit.gif\" class=\"icon-edit\" alt=\"{$vars->update}\" /></a> ";
print "<a title=\"{$vars->delete}\" href=\"{$CFG->wwwroot}/course/format/page/format.php?id={$COURSE->id}&action=deletemod&sesskey={$vars->sesskey}&cmid={$instance->cmid}\">";
print "<img src=\"{$CFG->pixpath}/t/delete.gif\" class=\"icon-edit\" alt=\"{$vars->delete}\" /></a></span>";
print "</li>\n";
}
if (!empty($lasttype)) {
// Close type list since we know it was opened
print "</ul>\n</li>\n";
}
print "</ul>\n";
}
}
} else {
print_box(get_string('noacivitiesfound', 'format_page'));
}
print_box_end();
}
示例14: get_course_mods
function get_course_mods($id, $username = '')
{
global $CFG, $DB;
$username = utf8_decode($username);
$username = strtolower($username);
if ($username) {
$user = get_complete_user_data('username', $username);
}
$sections = get_all_sections($id);
$forum = forum_get_course_forum($id, 'news');
$news_forum_id = $forum->id;
get_all_mods($id, $mods, $modnames, $modnamesplural, $modnamesused);
$context = get_context_instance(CONTEXT_COURSE, $id);
$e = array();
foreach ($sections as $section) {
if (!$section->visible) {
continue;
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
$resource['completion_info'] = '';
if ($username) {
$cm = get_coursemodule_from_id(false, $mod->id);
if (!coursemodule_visible_for_user($cm, $user->id)) {
if (!$mod->showavailability) {
// Mod not visible, and no completion info to show
continue;
}
$resource['available'] = 0;
$ci = new condition_info($mod);
$resource['completion_info'] = $ci->get_full_information();
} else {
$resource['available'] = 1;
}
} else {
$resource['available'] = 1;
}
$e[$section->section]['section'] = $section->section;
$e[$section->section]['name'] = $section->name;
$e[$section->section]['summary'] = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
$e[$section->section]['summary'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $e[$section->section]['summary']);
$resource['id'] = $mod->id;
$resource['name'] = $mod->name;
$resource['mod'] = $mod->modname;
// Format for mod->icon is: f/type-24
$type = substr($mod->icon, 2);
$parts = explode('-', $type);
$type = $parts[0];
$resource['type'] = $type;
//In forum, type is unused, so we use it for forum type: news/general
if ($mod->modname == 'forum') {
$cm = get_coursemodule_from_id('forum', $mod->id);
if ($cm->instance == $news_forum_id) {
$resource['type'] = 'news';
}
}
$e[$section->section]['mods'][] = $resource;
}
}
return $e;
}
示例15: topicsadv_format_rename_section_links
/**
* セクション内のリンクを全て書き換える
* ※convert.phpを読み込むこと
*
*
* @param &object $course
* @param int $sectionid
* @param string $directoryname : 書き換え後のディレクトリ名(全てのリンクを書き換える)
* @param bool $ismcopy : TRUE:ファイルをコピーする, FALSE:リンクの書き換えのみ
* @param bool $ismessage : TRUE:処理メッセージを表示する, FALSE:処理メッセージを表示しない
*/
function topicsadv_format_rename_section_links(&$course, $sectionid, $directoryname, $iscopy = true, $ismessage = true)
{
global $CFG;
$status = '';
// セクション内の全てのモジュールを読み込む
get_all_mods($course->id, &$mods, &$modnames, &$modnamesplural, &$modnamesused);
// セクションの概要を追加
$sectionobject = new stdClass();
$sectionobject->modname = 'course_section';
$sectionobject->section = $sectionid;
$mods[] = $sectionobject;
foreach ($mods as $mod) {
// セクション内の確認
if ($mod->section == $sectionid) {
// 各モジュールのリンクを取得
if (function_exists($mod->modname . '_get_links') && function_exists($mod->modname . '_rename_links')) {
// コンテンツ内のリンク一覧を取得
$func = $mod->modname . '_get_links';
$links = $func($course, $mod);
// リンクがある場合はリンクの張り替えを行う
if (is_array($links)) {
// ディレクトリの作成
if ($iscopy) {
if (!check_dir_exists($CFG->dataroot . '/' . $course->id . '/' . $directoryname, true)) {
error("Can't create directory");
}
}
foreach ($links as $link) {
// 元ファイルのファイル名取得
$pathinfo = pathinfo($link);
if ($link != $course->id . '/' . $directoryname . '/' . $pathinfo['basename']) {
// モジュールファイルをコピーする
// 20080323空白が%20のときは変換する
$directoryname = preg_replace('|%20|', ' ', $directoryname);
$pathinfo['basename'] = preg_replace('|%20|', ' ', $pathinfo['basename']);
if ($iscopy && (file_exists($CFG->dataroot . '/' . $link) && !file_exists($CFG->dataroot . '/' . $course->id . '/' . $directoryname . '/' . $pathinfo['basename']))) {
copy($CFG->dataroot . '/' . $link, $CFG->dataroot . '/' . $course->id . '/' . $directoryname . '/' . $pathinfo['basename']);
}
// モジュールリンクを置換する
$func = $mod->modname . '_rename_links';
$func($course, $mod, $link, $course->id . '/' . $directoryname . '/' . $pathinfo['basename']);
if ($ismessage) {
$status .= '<li>' . $link . ' --> ' . $course->id . '/' . $directoryname . '/' . $pathinfo['basename'] . '</li>';
}
}
}
}
} else {
// 注意事項の追加
if ($ismessage) {
notify($mod->modfullname . get_string('notrename', 'format_topicsadv'));
}
}
}
}
// 結果表示
if ($status) {
echo '<ul>' . $status . '</ul>';
}
// コースのキャッシュを再構築
rebuild_course_cache($course->id, true);
}