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

PHP get_course_display_name_for_list函数代码示例

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

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



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

示例1: get_items

 /**
  * Returns a list of items in the recycle bin for this course.
  *
  * @return array the list of items.
  */
 public function get_items()
 {
     global $DB;
     $items = $DB->get_records('tool_recyclebin_category', array('categoryid' => $this->_categoryid));
     foreach ($items as $item) {
         $item->name = get_course_display_name_for_list($item);
     }
     return $items;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:category_bin.php


示例2: get_instance_name

 /**
  * Returns localised name of enrol instance
  *
  * @param stdClass $instance (null is accepted too)
  * @return string
  */
 public function get_instance_name($instance)
 {
     global $DB;
     if (empty($instance)) {
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol);
     } else {
         if (empty($instance->name)) {
             $enrol = $this->get_name();
             $course = $DB->get_record('course', array('id' => $instance->customint1));
             if ($course) {
                 $coursename = format_string(get_course_display_name_for_list($course));
             } else {
                 // Use course id, if course is deleted.
                 $coursename = $instance->customint1;
             }
             return get_string('pluginname', 'enrol_' . $enrol) . ' (' . $coursename . ')';
         } else {
             return format_string($instance->name);
         }
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:28,代码来源:lib.php


示例3: course_overview

 /**
  * Construct contents of course_overview block
  *
  * @param array $courses list of courses in sorted order
  * @param array $overviews list of course overviews
  * @return string html to be displayed in course_overview block
  */
 public function course_overview($courses, $overviews)
 {
     $html = '';
     $config = get_config('block_course_overview');
     $ismovingcourse = false;
     $courseordernumber = 0;
     $maxcourses = count($courses);
     $userediting = false;
     // Intialise string/icon etc if user is editing and courses > 1
     if ($this->page->user_is_editing() && count($courses) > 1) {
         $userediting = true;
         // If ajaxenabled then include DND JS and replace link with move image.
         if (ajaxenabled()) {
             $this->page->requires->js_init_call('M.block_course_overview.add_handles');
         }
         // Check if course is moving
         $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
         $movingcourseid = optional_param('courseid', 0, PARAM_INT);
     }
     // Render first movehere icon.
     if ($ismovingcourse) {
         // Remove movecourse param from url.
         $this->page->ensure_param_not_in_url('movecourse');
         // Show moving course notice, so user knows what is being moved.
         $html .= $this->output->box_start('notice');
         $a = new stdClass();
         $a->fullname = $courses[$movingcourseid]->fullname;
         $a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
         $html .= get_string('movingcourse', 'block_course_overview', $a);
         $html .= $this->output->box_end();
         $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
         // Create move icon, so it can be used.
         $movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
         $moveurl = html_writer::link($moveurl, $movetofirsticon);
         $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
     }
     foreach ($courses as $key => $course) {
         // If moving course, then don't show course which needs to be moved.
         if ($ismovingcourse && $course->id == $movingcourseid) {
             continue;
         }
         $html .= $this->output->box_start('coursebox', "course-{$course->id}");
         $html .= html_writer::start_tag('div', array('class' => 'course_title'));
         // If user is editing, then add move icons.
         if ($userediting && !$ismovingcourse) {
             $moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
             $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
             $moveurl = html_writer::link($moveurl, $moveicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
         }
         // No need to pass title through s() here as it will be done automatically by html_writer.
         $attributes = array('title' => $course->fullname);
         if ($course->id > 0) {
             if (empty($course->visible)) {
                 $attributes['class'] = 'dimmed';
             }
             $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
             $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
             $link = html_writer::link($courseurl, $coursefullname, $attributes);
             $html .= $this->output->heading($link, 2, 'title');
         } else {
             $html .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
         }
         $html .= $this->output->box('', 'flush');
         $html .= html_writer::end_tag('div');
         if (!empty($config->showchildren) && $course->id > 0) {
             // List children here.
             if ($children = block_course_overview_get_child_shortnames($course->id)) {
                 $html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
             }
         }
         // If user is moving courses, then down't show overview.
         if (isset($overviews[$course->id]) && !$ismovingcourse) {
             $html .= $this->activity_display($course->id, $overviews[$course->id]);
         }
         $html .= $this->output->box('', 'flush');
         $html .= $this->output->box_end();
         $courseordernumber++;
         if ($ismovingcourse) {
             $moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
             $a = new stdClass();
             $a->movingcoursename = $courses[$movingcourseid]->fullname;
             $a->currentcoursename = $course->fullname;
             $movehereicon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('moveafterhere', 'block_course_overview', $a), 'title' => get_string('movehere')));
             $moveurl = html_writer::link($moveurl, $movehereicon);
             $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
         }
     }
     // Wrap course list in a div and return.
     return html_writer::tag('div', $html, array('class' => 'course_list'));
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:98,代码来源:renderer.php


示例4: setValue

 /**
  * Set the value of this element. If values can be added or are unknown, we will
  * make sure they exist in the options array.
  * @param string|array $value The value to set.
  * @return boolean
  */
 public function setValue($value)
 {
     global $DB;
     $values = (array) $value;
     $coursestofetch = array();
     foreach ($values as $onevalue) {
         if (!$this->optionExists($onevalue) && $onevalue !== '_qf__force_multiselect_submission') {
             array_push($coursestofetch, $onevalue);
         }
     }
     if (empty($coursestofetch)) {
         return $this->setSelected(array());
     }
     // There is no API function to load a list of course from a list of ids.
     $ctxselect = context_helper::get_preload_record_columns_sql('ctx');
     $fields = array('c.id', 'c.category', 'c.sortorder', 'c.shortname', 'c.fullname', 'c.idnumber', 'c.startdate', 'c.visible', 'c.cacherev');
     list($whereclause, $params) = $DB->get_in_or_equal($coursestofetch, SQL_PARAMS_NAMED, 'id');
     $sql = "SELECT " . join(',', $fields) . ", {$ctxselect}\n                FROM {course} c\n                JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextcourse\n                WHERE c.id " . $whereclause . " ORDER BY c.sortorder";
     $list = $DB->get_records_sql($sql, array('contextcourse' => CONTEXT_COURSE) + $params);
     $coursestoselect = array();
     foreach ($list as $course) {
         context_helper::preload_from_record($course);
         // Make sure we can see the course.
         if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
             continue;
         }
         $label = get_course_display_name_for_list($course);
         $this->addOption($label, $course->id);
         array_push($coursestoselect, $course->id);
     }
     return $this->setSelected($coursestoselect);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:38,代码来源:course.php


示例5: get_remote_courses

 function get_remote_courses()
 {
     global $CFG, $USER, $OUTPUT;
     if (!is_enabled_auth('mnet')) {
         // no need to query anything remote related
         return;
     }
     $icon = '<img src="' . $OUTPUT->pix_url('i/mnethost') . '" class="icon" alt="" />';
     // shortcut - the rest is only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     if ($courses = get_my_remotecourses()) {
         $this->content->items[] = get_string('remotecourses', 'mnet');
         $this->content->icons[] = '';
         foreach ($courses as $course) {
             $coursecontext = context_course::instance($course->id);
             $this->content->items[] = "<a title=\"" . format_string($course->shortname, true, array('context' => $coursecontext)) . "\" " . "href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&amp;wantsurl=/course/view.php?id={$course->remoteid}\">" . $icon . format_string(get_course_display_name_for_list($course)) . "</a>";
         }
         // if we listed courses, we are done
         return true;
     }
     if ($hosts = get_my_remotehosts()) {
         $this->content->items[] = get_string('remotehosts', 'mnet');
         $this->content->icons[] = '';
         foreach ($USER->mnet_foreign_host_array as $somehost) {
             $this->content->items[] = $somehost['count'] . get_string('courseson', 'mnet') . '<a title="' . $somehost['name'] . '" href="' . $somehost['url'] . '">' . $icon . $somehost['name'] . '</a>';
         }
         // if we listed hosts, done
         return true;
     }
     return false;
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:33,代码来源:block_course_list.php


示例6: serialize

<td><p><em>Day, time</em></p><p><em>Day, time</em></p></td>
</tr>
<tr>
<td><strong>Lecturer</strong></td>
<td>************</td>
<td><a href="mailto:***@kent.ac.uk">***@kent.ac.uk</a></td>
<td>01227 82****</td>
<td><p><em>Day, time</em></p><p><em>Day, time</em></p></td></tr></tbody></table><em>
</em>
HTML5;
$rule = \tool_cat\rule::from_record(array('id' => \tool_cat\rule::FAKE_RULE_ID, 'order' => 1, 'rule' => 'prepend_to', 'target' => 'section', 'targetid' => 0, 'datatype' => 'text', 'data' => serialize(array('text' => $summary))));
$rule->apply($courses);
// Apply first section.
foreach ($courses as $course) {
    // We can't use a rule for this.
    $DB->set_field('course_sections', 'name', get_course_display_name_for_list($course), array('course' => $course->id, 'section' => 0));
    // Prepend an announcements forum.
    $rule = \tool_cat\rule::from_record(array('id' => \tool_cat\rule::FAKE_RULE_ID, 'order' => 1, 'rule' => 'append_to', 'target' => 'course', 'targetid' => null, 'datatype' => 'news', 'data' => serialize(array('intro' => 'Announcements relating to ' . $course->shortname . ' will be posted here.', 'showdescription' => 1))));
    $rule->apply(array($course));
    // Append a discussion forum.
    $rule = \tool_cat\rule::from_record(array('id' => \tool_cat\rule::FAKE_RULE_ID, 'order' => 1, 'rule' => 'append_to', 'target' => 'section', 'targetid' => '0', 'datatype' => 'activity', 'data' => serialize(array('activity' => 'forum', 'name' => 'Discussion Forum ', 'intro' => '<p>(optional) Use this Discussion Forum to discuss the material of ' . $course->shortname . ' with other students and/or staff.</p><p>Please note that posts seeking (or providing) direct solutions to coursework, either assessed or unassessed, are not permitted.</p>', 'showdescription' => 1))));
    $rule->apply(array($course));
}
// Apply a rule to prepend to the section.
$rule = \tool_cat\rule::from_record(array('id' => \tool_cat\rule::FAKE_RULE_ID, 'order' => 1, 'rule' => 'prepend_to', 'target' => 'section', 'targetid' => '0', 'datatype' => 'activity', 'data' => serialize(array('activity' => 'aspirelists', 'name' => 'Reading list'))));
$rule->apply($courses);
// Append a URL mod to the 7th section.
$rule = \tool_cat\rule::from_record(array('id' => \tool_cat\rule::FAKE_RULE_ID, 'order' => 1, 'rule' => 'append_to', 'target' => 'section', 'targetid' => '6', 'datatype' => 'activity', 'data' => serialize(array('activity' => 'url', 'name' => 'Past exam papers Link', 'url' => ''))));
$rule->apply($courses);
// So we can work something out.
print_r(array_keys($courses));
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:31,代码来源:maths.php


示例7: report_selector_form

 /**
  * This function is used to generate and display selector form
  *
  * @param report_courselog_renderable $reportlog log report.
  */
 public function report_selector_form(report_courselog_renderable $reportlog)
 {
     echo html_writer::start_tag('form', array('class' => 'logselecform', 'action' => $reportlog->url, 'method' => 'get'));
     echo html_writer::start_div();
     echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chooselog', 'value' => '1'));
     echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showusers', 'value' => $reportlog->showusers));
     echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showcourses', 'value' => $reportlog->showcourses));
     $selectedcourseid = empty($reportlog->course) ? 0 : $reportlog->course->id;
     // Add course selector.
     $sitecontext = context_system::instance();
     $courses = $reportlog->get_course_list();
     if (!empty($courses) && $reportlog->showcourses) {
         echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
         echo html_writer::select($courses, "id", $selectedcourseid, null);
     } else {
         $courses = array();
         $courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . ($selectedcourseid == SITEID ? ' (' . get_string('site') . ') ' : '');
         echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
         echo html_writer::select($courses, "id", $selectedcourseid, false);
         // Check if user is admin and this came because of limitation on number of courses to show in dropdown.
         if (has_capability('report/log:view', $sitecontext)) {
             $a = new stdClass();
             $a->url = new moodle_url('/report/courselog/index.php', array('chooselog' => 0, 'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid, 'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid, 'showcourses' => 1, 'showusers' => $reportlog->showusers));
             $a->url = $a->url->out(false);
             print_string('logtoomanycourses', 'moodle', $a);
         }
     }
     // Add group selector.
     $groups = $reportlog->get_group_list();
     if (!empty($groups)) {
         echo html_writer::label(get_string('selectagroup'), 'menugroup', false, array('class' => 'accesshide'));
         echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups"));
     }
     // Add user selector.
     $users = $reportlog->get_user_list();
     if ($reportlog->showusers) {
         echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
         echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"));
     } else {
         $users = array();
         if (!empty($reportlog->userid)) {
             $users[$reportlog->userid] = $reportlog->get_selected_user_fullname();
         } else {
             $users[0] = get_string('allparticipants');
         }
         echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
         echo html_writer::select($users, "user", $reportlog->userid, false);
         $a = new stdClass();
         $a->url = new moodle_url('/report/courselog/index.php', array('chooselog' => 0, 'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid, 'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid, 'showusers' => 1, 'showcourses' => $reportlog->showcourses));
         $a->url = $a->url->out(false);
         print_string('logtoomanyusers', 'moodle', $a);
     }
     // Add date selector.
     $dates = $reportlog->get_date_options();
     echo html_writer::label(get_string('date'), 'menudate', false, array('class' => 'accesshide'));
     echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays"));
     // Add activity selector.
     $activities = $reportlog->get_activities_list();
     echo html_writer::label(get_string('activities'), 'menumodid', false, array('class' => 'accesshide'));
     echo html_writer::select($activities, "modid", $reportlog->modid, get_string("allactivities"));
     // Add actions selector.
     echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide'));
     echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, get_string("allactions"));
     // Add edulevel.
     $edulevel = $reportlog->get_edulevel_options();
     echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide'));
     echo html_writer::select($edulevel, 'edulevel', $reportlog->edulevel, false);
     // Add reader option.
     // If there is some reader available then only show submit button.
     $readers = $reportlog->get_readers(true);
     if (!empty($readers)) {
         if (count($readers) == 1) {
             $attributes = array('type' => 'hidden', 'name' => 'logreader', 'value' => key($readers));
             echo html_writer::empty_tag('input', $attributes);
         } else {
             echo html_writer::label(get_string('selectlogreader', 'report_courselog'), 'menureader', false, array('class' => 'accesshide'));
             echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false);
         }
         echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('gettheselogs')));
     }
     echo html_writer::end_div();
     echo html_writer::end_tag('form');
 }
开发者ID:posttechguy,项目名称:moodle-tbst2-report_log,代码行数:88,代码来源:renderer.php


示例8: print_course

/**
 * Print a description of a course, suitable for browsing in a list.
 *
 * @param object $course the course object.
 * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
 */
function print_course($course, $highlightterms = '')
{
    global $CFG, $USER, $DB, $OUTPUT;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    // Rewrite file URLs so that they are correct
    $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
    echo html_writer::start_tag('div', array('class' => 'coursebox clearfix'));
    echo html_writer::start_tag('div', array('class' => 'info'));
    echo html_writer::start_tag('h3', array('class' => 'name'));
    $linkhref = new moodle_url('/course/view.php', array('id' => $course->id));
    $coursename = get_course_display_name_for_list($course);
    $linktext = highlight($highlightterms, format_string($coursename));
    $linkparams = array('title' => get_string('entercourse'));
    if (empty($course->visible)) {
        $linkparams['class'] = 'dimmed';
    }
    echo html_writer::link($linkhref, $linktext, $linkparams);
    echo html_writer::end_tag('h3');
    /// first find all roles that are supposed to be displayed
    if (!empty($CFG->coursecontact)) {
        $managerroles = explode(',', $CFG->coursecontact);
        $namesarray = array();
        $rusers = array();
        if (!isset($course->managers)) {
            $rusers = get_role_users($managerroles, $context, true, 'ra.id AS raid, u.id, u.username, u.firstname, u.lastname,
                 r.name AS rolename, r.sortorder, r.id AS roleid', 'r.sortorder ASC, u.lastname ASC');
        } else {
            //  use the managers array if we have it for perf reasosn
            //  populate the datastructure like output of get_role_users();
            foreach ($course->managers as $manager) {
                $u = new stdClass();
                $u = $manager->user;
                $u->roleid = $manager->roleid;
                $u->rolename = $manager->rolename;
                $rusers[] = $u;
            }
        }
        /// Rename some of the role names if needed
        if (isset($context)) {
            $aliasnames = $DB->get_records('role_names', array('contextid' => $context->id), '', 'roleid,contextid,name');
        }
        $namesarray = array();
        $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
        foreach ($rusers as $ra) {
            if (isset($namesarray[$ra->id])) {
                //  only display a user once with the higest sortorder role
                continue;
            }
            if (isset($aliasnames[$ra->roleid])) {
                $ra->rolename = $aliasnames[$ra->roleid]->name;
            }
            $fullname = fullname($ra, $canviewfullnames);
            $namesarray[$ra->id] = format_string($ra->rolename) . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $ra->id, 'course' => SITEID)), $fullname);
        }
        if (!empty($namesarray)) {
            echo html_writer::start_tag('ul', array('class' => 'teachers'));
            foreach ($namesarray as $name) {
                echo html_writer::tag('li', $name);
            }
            echo html_writer::end_tag('ul');
        }
    }
    echo html_writer::end_tag('div');
    // End of info div
    echo html_writer::start_tag('div', array('class' => 'summary'));
    $options = new stdClass();
    $options->noclean = true;
    $options->para = false;
    $options->overflowdiv = true;
    if (!isset($course->summaryformat)) {
        $course->summaryformat = FORMAT_MOODLE;
    }
    echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
    if ($icons = enrol_get_course_info_icons($course)) {
        echo html_writer::start_tag('div', array('class' => 'enrolmenticons'));
        foreach ($icons as $icon) {
            echo $OUTPUT->render($icon);
        }
        echo html_writer::end_tag('div');
        // End of enrolmenticons div
    }
    echo html_writer::end_tag('div');
    // End of summary div
    echo html_writer::end_tag('div');
    // End of coursebox div
}
开发者ID:numbas,项目名称:moodle,代码行数:92,代码来源:lib.php


示例9: report_log_print_mnet_selector_form


//.........这里部分代码省略.........
        $courseusers = $DB->get_records('user', array('deleted' => 0), 'lastaccess DESC', 'id, ' . get_all_user_name_fields(true), $limitfrom, $limitnum);
    }
    if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
        $showusers = 1;
    }
    if ($showusers) {
        if ($courseusers) {
            foreach ($courseusers as $courseuser) {
                $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
            }
        }
        $users[$CFG->siteguest] = get_string('guestuser');
    }
    // Get all the hosts that have log records
    $sql = "select distinct\n                h.id,\n                h.name\n            from\n                {mnet_host} h,\n                {mnet_log} l\n            where\n                h.id = l.hostid\n            order by\n                h.name";
    if ($hosts = $DB->get_records_sql($sql)) {
        foreach ($hosts as $host) {
            $hostarray[$host->id] = $host->name;
        }
    }
    $hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
    asort($hostarray);
    $dropdown = array();
    foreach ($hostarray as $hostid => $name) {
        $courses = array();
        $sites = array();
        if ($CFG->mnet_localhost_id == $hostid) {
            if (has_capability('report/log:view', $sitecontext) && $showcourses) {
                if ($ccc = $DB->get_records("course", null, "fullname", "id,shortname,fullname,category")) {
                    foreach ($ccc as $cc) {
                        if ($cc->id == SITEID) {
                            $sites["{$hostid}/{$cc->id}"] = format_string($cc->fullname) . ' (' . get_string('site') . ')';
                        } else {
                            $courses["{$hostid}/{$cc->id}"] = format_string(get_course_display_name_for_list($cc));
                        }
                    }
                }
            }
        } else {
            if (has_capability('report/log:view', $sitecontext) && $showcourses) {
                $sql = "SELECT DISTINCT course, coursename FROM {mnet_log} where hostid = ?";
                if ($ccc = $DB->get_records_sql($sql, array($hostid))) {
                    foreach ($ccc as $cc) {
                        if (1 == $cc->course) {
                            // TODO: this might be wrong - site course may have another id
                            $sites["{$hostid}/{$cc->course}"] = $cc->coursename . ' (' . get_string('site') . ')';
                        } else {
                            $courses["{$hostid}/{$cc->course}"] = $cc->coursename;
                        }
                    }
                }
            }
        }
        asort($courses);
        $dropdown[] = array($name => $sites + $courses);
    }
    $activities = array();
    $selectedactivity = "";
    $modinfo = get_fast_modinfo($course);
    if (!empty($modinfo->cms)) {
        $section = 0;
        $thissection = array();
        foreach ($modinfo->cms as $cm) {
            if (!$cm->uservisible || !$cm->has_view()) {
                continue;
            }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:67,代码来源:locallib.php


示例10: get_content

 /**
  *  get content
  */
 public function get_content()
 {
     global $OUTPUT, $CFG;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     // get courses list in wich logged user was enrolled
     $courses = block_resources_get_all_resources();
     if (!$courses) {
         $this->content->text .= 'There are no courses';
         return $this->content;
     }
     // --------- cycle by courses
     foreach ($courses as $course) {
         if ($course->resources || $course->videoresources) {
             // render corse box
             $this->content->text .= $OUTPUT->box_start('coursebox', "course-{$course->id}") . html_writer::start_tag('div', array('class' => 'course_title'));
             $attributes = array('title' => $course->fullname);
             if ($course->id > 0) {
                 if (empty($course->visible)) {
                     $attributes['class'] = 'dimmed';
                 }
                 $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
                 $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
                 $link = html_writer::link($courseurl, $coursefullname, $attributes);
                 $this->content->text .= $OUTPUT->heading($link, 2, 'title');
             } else {
                 $this->content->text .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
             }
             // render resources
             foreach ($course->resources as $resource) {
                 /// --- Render one resource item
                 $this->content->text .= html_writer::start_div('resource_item') . html_writer::start_div('resource_body') . html_writer::start_div('resource_title') . html_writer::link($resource->url, $resource->title, array('target' => '_blank', 'class' => 'resourcelink', 'data-objectid' => $resource->id));
                 $this->content->text .= html_writer::end_div();
                 // end of resource_title
                 // render Author and source
                 if (!empty($resource->author)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'Author') . ': ' . $resource->author . html_writer::end_div();
                 }
                 if (!empty($resource->source)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'Source') . ': ' . $resource->source . html_writer::end_div();
                 }
                 if (!empty($resource->avgrate)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'AVG rating') . ': ' . $resource->avgrate . html_writer::end_div();
                 }
                 //echo html_writer::div($resource->description, 'resource_description');
                 $this->content->text .= html_writer::end_div();
                 // end of Resource body ---
                 $this->content->text .= html_writer::end_div();
                 // end of Resource Item ---
             }
             // render videoresources
             foreach ($course->videoresources as $videoresource) {
                 /// --- Render one resource item
                 $url = new moodle_url("{$CFG->wwwroot}/mod/videoresource/view.php", array('id' => $videoresource->id));
                 $this->content->text .= html_writer::start_div('resource_item') . html_writer::start_div('resource_body') . html_writer::start_div('resource_title') . html_writer::link($url->out(false), $videoresource->name, array('target' => '_blank', 'class' => 'resourcelink', 'data-objectid' => $videoresource->id));
                 $this->content->text .= html_writer::end_div();
                 // end of resource_title
                 //echo html_writer::div($resource->description, 'resource_description');
                 $this->content->text .= html_writer::end_div();
                 // end of Resource body ---
                 $this->content->text .= html_writer::end_div();
                 // end of Resource Item ---
             }
             //$this->content->text .= $OUTPUT->box('', 'flush');
             $this->content->text .= html_writer::end_tag('div');
             $this->content->text .= $OUTPUT->box_end();
         }
     }
     if (!empty($this->content->text)) {
         $this->content->text .= html_writer::link($CFG->wwwroot . '/blocks/resources/tocsv.php', 'Download list (CSV)');
     } else {
         $this->content->text .= 'There are no resources';
         //$this->content->text .= $OUTPUT->notification(get_string('no_resources', 'resourcelib'), 'redirectmessage');
     }
     return $this->content;
 }
开发者ID:TheFridayInstitute,项目名称:moodle_block_resources,代码行数:82,代码来源:block_resources.php


示例11: fill_table

 /**
  * Fill the table for displaying.
  *
  * @param bool $activitylink If this report link to the activity report or the user report.
  * @param bool $studentcoursesonly Only show courses that the user is a student of.
  */
 public function fill_table($activitylink = false, $studentcoursesonly = false)
 {
     global $CFG, $DB, $OUTPUT, $USER;
     if ($studentcoursesonly && count($this->studentcourseids) == 0) {
         return false;
     }
     // Only show user's courses instead of all courses.
     if ($this->courses) {
         $coursesdata = $this->setup_courses_data($studentcoursesonly);
         foreach ($coursesdata as $coursedata) {
             $course = $coursedata['course'];
             $coursecontext = $coursedata['context'];
             $finalgrade = $coursedata['finalgrade'];
             $courseitem = $coursedata['courseitem'];
             $coursename = format_string(get_course_display_name_for_list($course), true, array('context' => $coursecontext));
             // Link to the activity report version of the user grade report.
             if ($activitylink) {
                 $courselink = html_writer::link(new moodle_url('/course/user.php', array('mode' => 'grade', 'id' => $course->id, 'user' => $this->user->id)), $coursename);
             } else {
                 $courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $coursename);
             }
             $data = array($courselink, grade_format_gradevalue($finalgrade, $courseitem, true));
             if ($this->showrank['any']) {
                 if ($this->showrank[$course->id] && !is_null($finalgrade)) {
                     $rank = $coursedata['rank'];
                     $numusers = $coursedata['numusers'];
                     $data[] = "{$rank}/{$numusers}";
                 } else {
                     // No grade, no rank.
                     // Or this course wants rank hidden.
                     $data[] = '-';
                 }
             }
             $this->table->add_data($data);
         }
         return true;
     } else {
         echo $OUTPUT->notification(get_string('notenrolled', 'grades'), 'notifymessage');
         return false;
     }
 }
开发者ID:dg711,项目名称:moodle,代码行数:47,代码来源:lib.php


示例12: test_get_course_display_name_for_list

 function test_get_course_display_name_for_list()
 {
     global $CFG;
     $course = (object) array('shortname' => 'FROG101', 'fullname' => 'Introduction to pond life');
     // Store config value in case other tests rely on it
     $oldcfg = $CFG->courselistshortnames;
     $CFG->courselistshortnames = 0;
     $this->assertEqual('Introduction to pond life', get_course_display_name_for_list($course));
     $CFG->courselistshortnames = 1;
     $this->assertEqual('FROG101 Introduction to pond life', get_course_display_name_for_list($course));
     $CFG->courselistshortnames = $oldcfg;
 }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:12,代码来源:testcourselib.php


示例13: _print_single_course

 /**
  * Build the HTML to display a single course in a filtered list
  *
  * @param object $course The course to display
  * @return string HTML to display a link to a course
  */
 private function _print_single_course($course)
 {
     global $CFG, $USER;
     $dimmed = $course->visible ? '' : ' dimmed';
     $linkcss = "fcl-course-link" . $dimmed;
     $new = '';
     if ($this->fclconfig->showstatus) {
         if (isset($USER->lastcourseaccess[$course->id])) {
             if ($course->timemodified > $USER->lastcourseaccess[$course->id]) {
                 if (!isset($USER->currentcourseaccess[$course->id])) {
                     $new = html_writer::tag('i', '', array('class' => 'fa fa-star green' . $dimmed, 'title' => get_string('updated', 'block_filtered_course_list'), 'data-toggle' => "tooltip", 'data-content' => get_string('updated', 'block_filtered_course_list'), 'href' => '#'));
                 }
             }
         } else {
             if (!isset($USER->currentcourseaccess[$course->id])) {
                 $new = html_writer::tag('i', '', array('class' => 'fa fa-asterisk red' . $dimmed, 'title' => get_string('neverseen', 'block_filtered_course_list'), 'data-toggle' => "tooltip", 'data-content' => get_string('neverseen', 'block_filtered_course_list'), 'href' => '#'));
             }
         }
     }
     $html = html_writer::tag('li', $new . ' ' . html_writer::tag('a', get_course_display_name_for_list($course), array('href' => $CFG->wwwroot . '/course/view.php?id=' . $course->id, 'title' => format_string($course->shortname), 'class' => $linkcss)));
     return $html;
 }
开发者ID:sharpchi,项目名称:moodle-blocks_filtered_course_list,代码行数:28,代码来源:block_filtered_course_list.php


示例14: oublog_import_getbloginfo

/**
 * Returns blog info - cm, oublog
 * Also checks is a valid blog for import
 * (Throws exception on access error)
 * @param int $cmid
 * @param int $userid
 * @return array (cm id, oublog id, context id, blog name, course shortname)
 */
function oublog_import_getbloginfo($cmid, $userid = 0)
{
    global $DB, $USER;
    if ($userid == 0) {
        $userid = $USER->id;
    }
    $bcourse = $DB->get_record_select('course', 'id = (SELECT course FROM {course_modules} WHERE id = ?)', array($cmid), '*', MUST_EXIST);
    $bmodinfo = get_fast_modinfo($bcourse, $userid);
    $bcm = $bmodinfo->get_cm($cmid);
    if ($bcm->modname !== 'oublog') {
        throw new moodle_exception('invalidcoursemodule', 'error');
    }
    if (!($boublog = $DB->get_record('oublog', array('id' => $bcm->instance)))) {
        throw new moodle_exception('invalidcoursemodule', 'error');
    }
    $bcontext = context_module::instance($bcm->id);
    $canview = $bcm->uservisible;
    if ($canview) {
        $canview = has_capability('mod/oublog:view', $bcontext, $userid);
    }
    if ($boublog->global) {
        // Ignore uservisible for global blog and only check cap.
        $canview = has_capability('mod/oublog:viewpersonal', context_system::instance(), $userid);
    }
    if (!$canview || !$boublog->global && $boublog->individual == OUBLOG_NO_INDIVIDUAL_BLOGS) {
        // Not allowed to get pages from selected blog.
        throw new moodle_exception('import_notallowed', 'oublog', '', oublog_get_displayname($boublog));
    }
    if ($boublog->global) {
        $boublogname = $DB->get_field('oublog_instances', 'name', array('oublogid' => $boublog->id, 'userid' => $userid));
        $shortname = '';
    } else {
        $boublogname = $bcm->get_course()->shortname . ' ' . get_course_display_name_for_list($bcm->get_course()) . ' : ' . $bcm->get_formatted_name();
        $shortname = $bcm->get_course()->shortname;
    }
    return array($bcm->id, $boublog->id, $bcontext->id, $boublogname, $shortname);
}
开发者ID:eugeneventer,项目名称:moodle-mod_oublog,代码行数:45,代码来源:locallib.php


示例15: get_visible_name

 /**
  * Returns localised visible name.
  *
  * @return string
  */
 public function get_visible_name()
 {
     return $this->course->id == SITEID ? get_string('frontpage', 'admin') : format_string(get_course_display_name_for_list($this->course), true, array('context' => $this->context));
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:9,代码来源:file_info_context_course.php


示例16: search_courses

 /**
  * Search courses following the specified criteria.
  *
  * @param string $criterianame  Criteria name (search, modulelist (only admins), blocklist (only admins), tagid)
  * @param string $criteriavalue Criteria value
  * @param int $page             Page number (for pagination)
  * @param int $perpage          Items per page
  * @param array $requiredcapabilities Optional list of required capabilities (used to filter the list).
  * @param int $limittoenrolled  Limit to only enrolled courses
  * @return array of course objects and warnings
  * @since Moodle 3.0
  * @throws moodle_exception
  */
 public static function search_courses($criterianame, $criteriavalue, $page = 0, $perpage = 0, $requiredcapabilities = array(), $limittoenrolled = 0)
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $warnings = array();
     $parameters = array('criterianame' => $criterianame, 'criteriavalue' => $criteriavalue, 'page' => $page, 'perpage' => $perpage, 'requiredcapabilities' => $requiredcapabilities);
     $params = self::validate_parameters(self::search 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_course_mods函数代码示例发布时间:2022-05-15
下一篇:
PHP get_course_context函数代码示例发布时间: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