本文整理汇总了PHP中get_course函数的典型用法代码示例。如果您正苦于以下问题:PHP get_course函数的具体用法?PHP get_course怎么用?PHP get_course使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_course函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: block_my_course_progress_get_course_image_url
/**
* Returns the url of the first image contained in the course summary file area
* @param int $id the course id
* @return string the url to the image
*/
function block_my_course_progress_get_course_image_url($id)
{
global $CFG;
require_once $CFG->libdir . "/filelib.php";
$course = get_course($id);
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
if ($isimage) {
return file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
}
}
return false;
}
开发者ID:Regaez,项目名称:moodle-block_my_course_progress,代码行数:22,代码来源:locallib.php
示例2: mycourses
protected function mycourses($CFG, $sidebar)
{
$mycourses = enrol_get_users_courses($_SESSION['USER']->id);
$courselist = array();
foreach ($mycourses as $key => $val) {
$courselist[] = $val->id;
}
$content = '';
for ($x = 1; $x <= sizeof($courselist); $x++) {
$course = get_course($courselist[$x - 1]);
$title = $course->fullname;
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if (!$isimage) {
$url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
}
}
$content .= '<div class="view view-second view-mycourse ' . ($x % 3 == 0 ? 'view-nomargin' : '') . '">
<img src="' . $url . '" />
<div class="mask">
<h2>' . $title . '</h2>
<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $courselist[$x - 1] . '" class="info">Enter</a>
</div>
</div>';
}
return $content;
}
开发者ID:simonsCatalyst,项目名称:simonsCatalyst-keats,代码行数:33,代码来源:renderers.php
示例3: definition
function definition()
{
global $DB, $PAGE, $OUTPUT;
$id = required_param('id', PARAM_INT);
// course module
if (!($cm = get_coursemodule_from_id('blended', $id))) {
error("Course Module ID was incorrect");
}
if (!($course = get_course($cm->course))) {
error("Course is misconfigured");
}
if (!($blended = $DB->get_record('blended', array('id' => $cm->instance)))) {
error("Course module is incorrect");
}
$form =& $this->_form;
$calificables = new grade_tree($course->id);
$items = $calificables->items;
$ins = array();
$assignmentname = array();
// Obtenemos las referencias a toda la informaci�n sobre los modulos dentro del curso
$modinfo = get_fast_modinfo($course->id);
foreach ($modinfo->instances as $abc) {
foreach ($abc as $cmd) {
foreach ($items as $r => $ite) {
$ins[$r] = $ite->iteminstance;
if ($cmd->instance == $ins[$r]) {
$assignmentname[$r] = $cmd->name;
}
}
}
}
$form->addElement('select', 'activities', 'Selecciona la Tarea', $assignmentname);
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:33,代码来源:select_activity_form.php
示例4: local_compile_extends_settings_navigation
/**
* Add a "Compile" menu link to the Course Admin block as the top link.
*
* @author Gerald Albion
* date 2014-10-31
* @copyright 2014 Royal Roads University
* @param object $settingsnav Main navigation object.
* @param object $context Course context.
*/
function local_compile_extends_settings_navigation($settingsnav, $context)
{
// Context must be course.
if ($context->contextlevel != CONTEXT_COURSE) {
return;
}
// Must be in a valid course: Cannot be course id 0.
if ($context->instanceid == 0) {
return;
}
// Must be in a valid course: Course must be retrievable.
if (!($course = get_course($context->instanceid))) {
return;
}
// Must be enrolled or otherwise allowed to view the course.
if (!(is_enrolled($context) || is_viewing($context))) {
return;
}
// Must have a course admin menu in which to add link.
if (!($coursenode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE))) {
return;
}
// Good to go. Build the menu item.
$url = new moodle_url('/local/compile/list_modules.php', array('id' => $course->id));
$newnode = navigation_node::create(get_string('menucaption', 'local_compile'), $url, navigation_node::NODETYPE_LEAF, 'compile', 'compile', new pix_icon('i/settings', ''));
// We want to put this link at the top: find the existing top (first) node.
$firstnode = $coursenode->get_children_key_list()[0];
// Add the menu item to the menu, before the first node.
$coursenode->add_node($newnode, $firstnode);
}
开发者ID:royalroads,项目名称:RRU-Moodle,代码行数:39,代码来源:lib.php
示例5: section_activities
function section_activities($secid,$cid){
$course=get_course($cid);
$modinfo = get_fast_modinfo($course);
$mods = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
$sec_array = get_sections($sections);
$arr = array();
$cnt=0;
//preparing an array which contains sections and activities
foreach ($mods as $mod) {
$arr[$cnt++]=array('secid'=>$mod->section,'modid'=>$mod->id,'modname'=>$mod->name,'modcontent'=>$mod->content);
//print_r($mod->name);
}
//returns the all activities associated to perticular section in a course
function get_activities($sectionid,$arr)
{
$cnt=0;
$sec_activity_array = array();
for($i=0;$i<count($arr);$i++) {
if($arr[$i]['secid']==$sectionid){
$sec_activity_array[$cnt] = array('modid'=>$arr[$i]['modid'],'modname'=>$arr[$i]['modname'],'modcontent'=>$arr[$i]['modcontent']);
$cnt++;
}
}
return $sec_activity_array;
}
// Get all course sections in a array
function get_sections($sections)
{ $cnt=0;
$sec_array = array();
foreach ($sections as $sec) {
$sec_array[$cnt++] = array('secid'=>$sec->id,'secname'=>$sec->name);
}
return $sec_array;
}
$activities=get_activities($secid,$arr);
$html='';global $CFG;
for($i=0;$i<count($activities);$i++) {
$html .= '<tr >
<td ><span class="mod' . $activities[$i]['modid'] . '">' . ($i + 1) . '</span></td>
<td ><span class="mod' . $activities[$i]['modid'] . '">' . $activities[$i]['modname'] . '</span></td>
<td ><span class="mod' . $activities[$i]['modid'] . '">' . $activities[$i]['modcontent'] . '</span></td>
<td >
<button class="showhide" id="show" value=' . $activities[$i]['modid'] . '>
<img alt="start" src="'.$CFG->wwwroot.'/teacher/testcenter/images/start.png" width="16px"/></button>
<button class="showhide" id="hide" value=' . $activities[$i]['modid'] . '>
<img alt="stop" src="'.$CFG->wwwroot.'/teacher/testcenter/images/stop.png" width="16px"/></button>
</td>
</tr>';
}
echo $html;
}//end of section_activities() function
开发者ID:kmahesh541,项目名称:mitclone,代码行数:58,代码来源:testcenterutil.php
示例6: get_assign
/**
* Get assign instance.
*
* NOTE: to be used from observers only.
*
* @throws \coding_exception
* @return \assign
*/
public function get_assign()
{
if ($this->is_restored()) {
throw new \coding_exception('get_assign() is intended for event observers only');
}
if (!isset($this->assign)) {
debugging('assign property should be initialised in each event', DEBUG_DEVELOPER);
global $CFG;
require_once $CFG->dirroot . '/mod/assign/locallib.php';
$cm = get_coursemodule_from_id('assign', $this->contextinstanceid, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$this->assign = new \assign($this->get_context(), $cm, $course);
}
return $this->assign;
}
开发者ID:evltuma,项目名称:moodle,代码行数:23,代码来源:base.php
示例7: definition
function definition()
{
global $DB, $PAGE, $OUTPUT;
$id = optional_param('id', 0, PARAM_INT);
$a = optional_param('a', 0, PARAM_INT);
if ($id) {
if (!($cm = get_coursemodule_from_id('blended', $id))) {
print_error("Course Module ID was incorrect");
}
if (!($course = get_course($cm->course))) {
print_error("Course is misconfigured");
}
if (!($blended = $DB->get_record('blended', array('id' => $cm->instance)))) {
print_error("Course module is incorrect");
}
if (!($context = context_course::instance($course->id))) {
print_error("Context ID is incorrect");
}
} else {
if (!($blended = $DB->get_record('blended', array('id' => $a)))) {
print_error("Course module is incorrect");
}
if (!($course = $DB->get_record('course', array('id' => $blended->course)))) {
print_error("Course is misconfigured");
}
if (!($cm = get_coursemodule_from_instance("blended", $blended->id, $course->id))) {
print_error("Course Module ID was incorrect");
}
if (!($context = context_course::instance($course->id))) {
print_error("Context ID is incorrect");
}
}
$form =& $this->_form;
$t = 0;
$agrupamientos = array();
$agrupamientos[$t] = 'Eliga';
if ($groups = groups_get_all_groupings($course->id)) {
foreach ($groups as $group) {
$t++;
$agrupamientos[$t] = $group->name;
}
}
//Select Elements
$form->addElement('select', 'grouping', get_string('select_grouping', 'blended'), $agrupamientos);
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:45,代码来源:grouping_form.php
示例8: create_instance
/**
* Create a questionnaire activity.
* @param array $record Will be changed in this function.
* @param array $options
* @return questionnaire
*/
public function create_instance($record = array(), array $options = array())
{
if (is_array($record)) {
$record = (object) $record;
}
$defaultquestionnairesettings = array('qtype' => 0, 'respondenttype' => 'fullname', 'resp_eligible' => 'all', 'resp_view' => 0, 'useopendate' => true, 'opendate' => 0, 'useclosedate' => true, 'closedate' => 0, 'resume' => 0, 'navigate' => 0, 'grade' => 0, 'sid' => 0, 'timemodified' => time(), 'completionsubmit' => 0, 'autonum' => 3, 'create' => 'new-0');
foreach ($defaultquestionnairesettings as $name => $value) {
if (!isset($record->{$name})) {
$record->{$name} = $value;
}
}
$instance = parent::create_instance($record, $options);
$cm = get_coursemodule_from_instance('questionnaire', $instance->id);
$course = get_course($cm->course);
$questionnaire = new questionnaire(0, $instance, $course, $cm, false);
$this->questionnaires[$instance->id] = $questionnaire;
return $questionnaire;
}
开发者ID:remotelearner,项目名称:moodle-mod_questionnaire,代码行数:24,代码来源:lib.php
示例9: execute
public function execute()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/mod/ratingallocate/locallib.php';
$site = get_site();
// parse customdata passed
$customdata = $this->get_custom_data();
$userid = $customdata->userid;
$ratingallocateid = $customdata->ratingallocateid;
//get instance of ratingallocate
$ratingallocate = $DB->get_record(this_db\ratingallocate::TABLE, array(this_db\ratingallocate::ID => $ratingallocateid), '*', MUST_EXIST);
$courseid = $ratingallocate->course;
$course = get_course($courseid);
$cm = get_coursemodule_from_instance('ratingallocate', $ratingallocate->id, $courseid);
$context = \context_module::instance($cm->id);
$ratingallocateobj = new \ratingallocate($ratingallocate, $course, $cm, $context);
$ratingallocateobj->notify_users_distribution($userid);
}
开发者ID:andrewhancox,项目名称:moodle-mod_ratingallocate,代码行数:18,代码来源:send_distribution_notification.php
示例10: local_metagroups_sync
/**
* Run synchronization process
*
* @param progress_trace $trace
* @param int|null $courseid or null for all courses
* @return void
*/
function local_metagroups_sync(progress_trace $trace, $courseid = null)
{
global $DB;
if ($courseid !== null) {
$courseids = array($courseid);
} else {
$courseids = local_metagroups_parent_courses();
}
foreach (array_unique($courseids) as $courseid) {
$parent = get_course($courseid);
// If parent course doesn't use groups, we can skip synchronization.
if (groups_get_course_groupmode($parent) == NOGROUPS) {
continue;
}
$trace->output($parent->fullname, 1);
$children = local_metagroups_child_courses($parent->id);
foreach ($children as $childid) {
$child = get_course($childid);
$trace->output($child->fullname, 2);
$groups = groups_get_all_groups($child->id);
foreach ($groups as $group) {
if (!($metagroup = $DB->get_record('groups', array('courseid' => $parent->id, 'idnumber' => $group->id)))) {
$metagroup = new stdClass();
$metagroup->courseid = $parent->id;
$metagroup->idnumber = $group->id;
$metagroup->name = $group->name;
$metagroup->id = groups_create_group($metagroup, false, false);
}
$trace->output($metagroup->name, 3);
$users = groups_get_members($group->id);
foreach ($users as $user) {
groups_add_member($metagroup->id, $user->id, 'local_metagroups', $group->id);
}
}
}
}
}
开发者ID:stanta,项目名称:moodle-local_metagroups,代码行数:44,代码来源:locallib.php
示例11: course_grid
/**
* Output the HTML grid of courses
* @param array $courses the list of enrolled courses
* @return string HTML fragment
*/
function course_grid($courses)
{
global $CFG;
require_once $CFG->dirroot . '/blocks/my_course_progress/locallib.php';
$html = sprintf('<div class="grid__container">');
// LOOP THROUGH EACH COURSE AND GET THE OUTPUT
foreach ($courses as $c) {
$course = get_course($c->id);
// OPEN GRID ITEM
$html .= sprintf('<div class="grid__item">');
// RENDER THE COURSE DETAILS
$html .= $this->course($course);
// IF COURSE HAS COMPLETION STATS, DO
if (!!$course->enablecompletion) {
// TODO: GET COMPLETION PERCENTAGE
$percentage = block_my_course_progress_get_completion_percentage((int) $course->id);
// RENDER THE COURSE PROGRESS
$html .= $this->progress($percentage);
}
// CLOSE GRID ITEM
$html .= sprintf('</div>');
}
return $html;
}
开发者ID:Regaez,项目名称:moodle-block_my_course_progress,代码行数:29,代码来源:renderer.php
示例12: while
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<?php
$i = 1;
while ($a = mysqli_fetch_array($papers)) {
?>
<tr>
<td><?php
echo get_course($a['course']);
?>
</td>
<td><?php
echo get_branch($a['course'], $a['branch']);
?>
</td>
<td><?php
echo $a['semester'];
?>
</td>
<td><?php
echo $a['file_name'];
?>
</td>
<td>
开发者ID:ncs-jss,项目名称:library,代码行数:31,代码来源:view_question_papers.php
示例13: test_get_course
public function test_get_course()
{
global $DB, $PAGE, $SITE;
$this->resetAfterTest();
// First test course will be current course ($COURSE).
$course1obj = $this->getDataGenerator()->create_course(array('shortname' => 'FROGS'));
$PAGE->set_course($course1obj);
// Second test course is not current course.
$course2obj = $this->getDataGenerator()->create_course(array('shortname' => 'ZOMBIES'));
// Check it does not make any queries when requesting the $COURSE/$SITE.
$before = $DB->perf_get_queries();
$result = get_course($course1obj->id);
$this->assertEquals($before, $DB->perf_get_queries());
$this->assertSame('FROGS', $result->shortname);
$result = get_course($SITE->id);
$this->assertEquals($before, $DB->perf_get_queries());
// Check it makes 1 query to request other courses.
$result = get_course($course2obj->id);
$this->assertSame('ZOMBIES', $result->shortname);
$this->assertEquals($before + 1, $DB->perf_get_queries());
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:21,代码来源:datalib_test.php
示例14: enrol_user
/**
* Self enrol the current user in the given course.
*
* @param int $courseid id of course
* @param string $password enrolment key
* @param int $instanceid instance id of self enrolment plugin
* @return array of warnings and status result
* @since Moodle 3.0
* @throws moodle_exception
*/
public static function enrol_user($courseid, $password = '', $instanceid = 0)
{
global $CFG;
require_once $CFG->libdir . '/enrollib.php';
$params = self::validate_parameters(self::enrol_user_parameters(), array('courseid' => $courseid, 'password' => $password, 'instanceid' => $instanceid));
$warnings = array();
$course = get_course($params['courseid']);
$context = context_course::instance($course->id);
self::validate_context(context_system::instance());
if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
throw new moodle_exception('coursehidden');
}
// Retrieve the self enrolment plugin.
$enrol = enrol_get_plugin('self');
if (empty($enrol)) {
throw new moodle_exception('canntenrol', 'enrol_self');
}
// We can expect multiple self-enrolment instances.
$instances = array();
$enrolinstances = enrol_get_instances($course->id, true);
foreach ($enrolinstances as $courseenrolinstance) {
if ($courseenrolinstance->enrol == "self") {
// Instance specified.
if (!empty($params['instanceid'])) {
if ($courseenrolinstance->id == $params['instanceid']) {
$instances[] = $courseenrolinstance;
break;
}
} else {
$instances[] = $courseenrolinstance;
}
}
}
if (empty($instances)) {
throw new moodle_exception('canntenrol', 'enrol_self');
}
// Try to enrol the user in the instance/s.
$enrolled = false;
foreach ($instances as $instance) {
$enrolstatus = $enrol->can_self_enrol($instance);
if ($enrolstatus === true) {
if ($instance->password and $params['password'] !== $instance->password) {
// Check if we are using group enrolment keys.
if ($instance->customint1) {
require_once $CFG->dirroot . "/enrol/self/locallib.php";
if (!enrol_self_check_group_enrolment_key($course->id, $params['password'])) {
$warnings[] = array('item' => 'instance', 'itemid' => $instance->id, 'warningcode' => '2', 'message' => get_string('passwordinvalid', 'enrol_self'));
continue;
}
} else {
if ($enrol->get_config('showhint')) {
$hint = core_text::substr($instance->password, 0, 1);
$warnings[] = array('item' => 'instance', 'itemid' => $instance->id, 'warningcode' => '3', 'message' => s(get_string('passwordinvalidhint', 'enrol_self', $hint)));
continue;
} else {
$warnings[] = array('item' => 'instance', 'itemid' => $instance->id, 'warningcode' => '4', 'message' => get_string('passwordinvalid', 'enrol_self'));
continue;
}
}
}
// Do the enrolment.
$data = array('enrolpassword' => $params['password']);
$enrol->enrol_self($instance, (object) $data);
$enrolled = true;
break;
} else {
$warnings[] = array('item' => 'instance', 'itemid' => $instance->id, 'warningcode' => '1', 'message' => $enrolstatus);
}
}
$result = array();
$result['status'] = $enrolled;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:evltuma,项目名称:moodle,代码行数:84,代码来源:externallib.php
示例15: forum_get_discussions
/**
* Get all discussions in a forum
*
* @global object
* @global object
* @global object
* @uses CONTEXT_MODULE
* @uses VISIBLEGROUPS
* @param object $cm
* @param string $forumsort
* @param bool $fullpost
* @param int $unused
* @param int $limit
* @param bool $userlastmodified
* @param int $page
* @param int $perpage
* @param int $groupid if groups enabled, get discussions for this group overriding the current group.
* Use FORUM_POSTS_ALL_USER_GROUPS for all the user groups
* @param int $updatedsince retrieve only discussions updated since the given time
* @return array
*/
function forum_get_discussions($cm, $forumsort = "", $fullpost = true, $unused = -1, $limit = -1, $userlastmodified = false, $page = -1, $perpage = 0, $groupid = -1, $updatedsince = 0)
{
global $CFG, $DB, $USER;
$timelimit = '';
$now = round(time(), -2);
$params = array($cm->instance);
$modcontext = context_module::instance($cm->id);
if (!has_capability('mod/forum:viewdiscussion', $modcontext)) {
/// User must have perms to view discussions
return array();
}
if (!empty($CFG->forum_enabletimedposts)) {
/// Users must fulfill timed posts
if (!has_capability('mod/forum:viewhiddentimedposts', $modcontext)) {
$timelimit = " AND ((d.timestart <= ? AND (d.timeend = 0 OR d.timeend > ?))";
$params[] = $now;
$params[] = $now;
if (isloggedin()) {
$timelimit .= " OR d.userid = ?";
$params[] = $USER->id;
}
$timelimit .= ")";
}
}
if ($limit > 0) {
$limitfrom = 0;
$limitnum = $limit;
} else {
if ($page != -1) {
$limitfrom = $page * $perpage;
$limitnum = $perpage;
} else {
$limitfrom = 0;
$limitnum = 0;
}
}
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) {
if (empty($modcontext)) {
$modcontext = context_module::instance($cm->id);
}
// Special case, we received a groupid to override currentgroup.
if ($groupid > 0) {
$course = get_course($cm->course);
if (!groups_group_visible($groupid, $course, $cm)) {
// User doesn't belong to this group, return nothing.
return array();
}
$currentgroup = $groupid;
} else {
if ($groupid === -1) {
$currentgroup = groups_get_activity_group($cm);
} else {
// Get discussions for all groups current user can see.
$currentgroup = null;
}
}
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
if ($currentgroup) {
$groupselect = "AND (d.groupid = ? OR d.groupid = -1)";
$params[] = $currentgroup;
} else {
$groupselect = "";
}
} else {
// Separate groups.
// Get discussions for all groups current user can see.
if ($currentgroup === null) {
$mygroups = array_keys(groups_get_all_groups($cm->course, $USER->id, $cm->groupingid, 'g.id'));
if (empty($mygroups)) {
$groupselect = "AND d.groupid = -1";
} else {
list($insqlgroups, $inparamsgroups) = $DB->get_in_or_equal($mygroups);
$groupselect = "AND (d.groupid = -1 OR d.groupid {$insqlgroups})";
$params = array_merge($params, $inparamsgroups);
}
} else {
if ($currentgroup) {
$groupselect = "AND (d.groupid = ? OR d.groupid = -1)";
//.........这里部分代码省略.........
开发者ID:rezaies,项目名称:moodle,代码行数:101,代码来源:lib.php
示例16: notify_changed
/**
* Used to notify the completion system (if necessary) that a user's grade
* has changed, and clear up a possible score cache.
*
* @param bool $deleted True if grade was actually deleted
*/
protected function notify_changed($deleted)
{
global $CFG;
// Condition code may cache the grades for conditional availability of
// modules or sections. (This code should use a hook for communication
// with plugin, but hooks are not implemented at time of writing.)
if (!empty($CFG->enableavailability) && class_exists('\\availability_grade\\callbacks')) {
\availability_grade\callbacks::grade_changed($this->userid);
}
require_once $CFG->libdir . '/completionlib.php';
// Bail out immediately if completion is not enabled for site (saves loading
// grade item & requiring the restore stuff).
if (!completion_info::is_enabled_for_site()) {
return;
}
// Ignore during restore, as completion data will be updated anyway and
// doing it now will result in incorrect dates (it will say they got the
// grade completion now, instead of the correct time).
if (class_exists('restore_controller', false) && restore_controller::is_executing()) {
return;
}
// Load information about grade item
$this->load_grade_item();
// Only course-modules have completion data
if ($this->grade_item->itemtype != 'mod') {
return;
}
// Use $COURSE if available otherwise get it via item fields
$course = get_course($this->grade_item->courseid, false);
// Bail out if completion is not enabled for course
$completion = new completion_info($course);
if (!$completion->is_enabled()) {
return;
}
// Get course-module
$cm = get_coursemodule_from_instance($this->grade_item->itemmodule, $this->grade_item->iteminstance, $this->grade_item->courseid);
// If the course-module doesn't exist, display a warning...
if (!$cm) {
// ...unless the grade is being deleted in which case it's likely
// that the course-module was just deleted too, so that's okay.
if (!$deleted) {
debugging("Couldn't find course-module for module '" . $this->grade_item->itemmodule . "', instance '" . $this->grade_item->iteminstance . "', course '" . $this->grade_item->courseid . "'");
}
return;
}
// Pass information on to completion system
$completion->inform_grade_changed($cm, $this->grade_item, $this, $deleted);
}
开发者ID:sriysk,项目名称:moodle-integration,代码行数:54,代码来源:grade_grade.php
示例17: calendar_get_course_cached
/**
* Get current course cache
*
* @param array $coursecache list of course cache
* @param int $courseid id of the course
* @return stdClass $coursecache[$courseid] return the specific course cache
*/
function calendar_get_course_cached(&$coursecache, $courseid)
{
if (!isset($coursecache[$courseid])) {
$coursecache[$courseid] = get_course($courseid);
}
return $coursecache[$courseid];
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:14,代码来源:lib.php
示例18: test_coursebyshortname
public function test_coursebyshortname()
{
$expected = get_course($this->courses[0]->id);
$actual = $this->courseservice->coursebyshortname($this->courses[0]->shortname);
$this->assertEquals($expected, $actual);
}
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:6,代码来源:services_course_test.php
示例19: get_course
/**
* Returns a record from course database table plus additional fields
* that course format defines
*
* @return stdClass
*/
public function get_course()
{
global $DB;
if (!$this->courseid) {
return null;
}
if ($this->course === false) {
$this->course = get_course($this->courseid);
$options = $this->get_format_options();
$dbcoursecolumns = null;
foreach ($options as $optionname => $optionvalue) {
if (isset($this->course->{$optionname})) {
// Course format options must not have the same names as existing columns in db table "course".
if (!isset($dbcoursecolumns)) {
$dbcoursecolumns = $DB->get_columns('course');
}
if (isset($dbcoursecolumns[$optionname])) {
debugging('The option name ' . $optionname . ' in course format ' . $this->format . ' is invalid because the field with the same name exists in {course} table', DEBUG_DEVELOPER);
continue;
}
}
$this->course->{$optionname} = $optionvalue;
}
}
return $this->course;
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:32,代码来源:lib.php
示例20: dirname
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package mod_zoom
* @copyright 2015 UC Regents
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->libdir . '/moodlelib.php';
$id = required_param('id', PARAM_INT);
// Course_module ID.
if ($id) {
$cm = get_coursemodule_from_id('zoom', $id, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$zoom = $DB->get_record('zoom', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
error('You must specify a course_module ID');
}
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
require_capability('mod/zoom:view', $context);
// Check whether user had a grade. If no, then assign full credits to him or her.
$gradelist = grade_get_grades($course->id, 'mod', 'zoom', $cm->instance, $USER->id);
// Assign full credits for user who has no grade yet, if this meeting is gradable
// (i.e. the grade type is not "None").
if (!empty($gradelist->items) && empty($gradelist->items[0]->grades[$USER->id]->grade)) {
$grademax = $gradelist->items[0]->grademax;
$grades = array('rawgrade' => $grademax, 'userid' => $USER->id, 'usermodified' => $USER->id, 'dategraded' => '', 'feedbackformat' => '', 'feedback' => '');
开发者ID:uofr,项目名称:moodle-mod_zoom,代码行数:31,代码来源:loadmeeting.php
注:本文中的get_course函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论