本文整理汇总了PHP中cm_info类的典型用法代码示例。如果您正苦于以下问题:PHP cm_info类的具体用法?PHP cm_info怎么用?PHP cm_info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cm_info类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Cosntructor.
*
* @param \stdClass $collaborate
* @param \stdClass $cm
* @param \context_module $context
* @param \mod_collaborate_renderer $renderer
*/
public function __construct(\stdClass $collaborate, \cm_info $cm, \context_module $context, \mod_collaborate_renderer $renderer)
{
$this->collaborate = $collaborate;
$this->cm = $cm;
$this->context = $context;
$this->renderer = $renderer;
$this->course = $cm->get_course();
}
开发者ID:mpetrowi,项目名称:moodle-mod_collaborate,代码行数:16,代码来源:view_service.php
示例2: __construct
/**
* Constructor
*
* @param \stdClass $collaborate
* @param \cm_info $cm
* @param \context_module $context;
* @param \stdClass $user;
* @throws \coding_exception
* @throws \require_login_exception
*/
public function __construct(\stdClass $collaborate, \cm_info $cm, \context_module $context, \stdClass $user)
{
global $DB;
$this->collaborate = $collaborate;
$this->course = $cm->get_course();
$this->cm = $cm;
$this->id = $cm->instance;
$this->context = $context;
$this->user = $user;
$this->collaborate = $DB->get_record('collaborate', array('id' => $this->id), '*', MUST_EXIST);
$this->api = api::get_api();
}
开发者ID:mpetrowi,项目名称:moodle-mod_collaborate,代码行数:22,代码来源:forward_service.php
示例3: mod_stopwatch_update_timer
/**
*
* @param cm_info $cm
* @param stdClass $stopwatch
* @param int $duration
*/
function mod_stopwatch_update_timer(cm_info $cm, $stopwatch, $duration)
{
global $USER, $DB, $CFG;
require_once $CFG->libdir . '/completionlib.php';
$record = $DB->get_record('stopwatch_user', array('stopwatchid' => $cm->instance, 'courseid' => $cm->course, 'userid' => $USER->id));
if ($record) {
$data = array('id' => $record->id, 'timemodified' => time(), 'duration' => $duration);
$DB->update_record('stopwatch_user', $data);
} else {
$data = array('courseid' => $cm->course, 'stopwatchid' => $cm->instance, 'userid' => $USER->id, 'timecreated' => time(), 'timemodified' => time(), 'duration' => $duration);
$DB->insert_record('stopwatch_user', $data);
}
// Update completion state
$completion = new completion_info($cm->get_course());
if ($completion->is_enabled($cm) && $stopwatch->completiontimed) {
$completion->update_state($cm, COMPLETION_COMPLETE);
}
}
开发者ID:marinaglancy,项目名称:moodle-mod_stopwatch,代码行数:24,代码来源:locallib.php
示例4: navbuttons_mod_assignment_showbuttons
/**
* @param cm_info $cm
* @return bool
*/
function navbuttons_mod_assignment_showbuttons($cm)
{
global $DB, $CFG, $USER;
if (!($assignment = $DB->get_record('assignment', array('id' => $cm->instance)))) {
return true;
// Not quite sure what went wrong
}
$type = $assignment->assignmenttype;
if ($type == 'offline') {
return true;
// Cannot track 'offline' assignments
}
require_once $CFG->dirroot . '/mod/assignment/type/' . $type . '/assignment.class.php';
$class = 'assignment_' . $type;
/** @var assignment_base $instance */
$instance = new $class($cm->id, $assignment, $cm, $cm->get_course());
if (!($submission = $instance->get_submission($USER->id))) {
return false;
// No submission
}
if ($type == 'upload' || $type == 'uploadpdf') {
if ($instance->drafts_tracked()) {
if ($instance->is_finalized($submission)) {
return true;
// Upload submission is 'finalised'
} else {
return false;
}
}
}
if ($submission->timemodified > 0) {
return true;
// Submission has a 'modified' time
}
return false;
}
开发者ID:kbwebsolutions,项目名称:moodle-navbuttons,代码行数:40,代码来源:activityready.php
示例5: forum_is_user_group_discussion
/**
* Returns whether the discussion group is visible by the current user or not.
*
* @since Moodle 2.8, 2.7.1, 2.6.4
* @param cm_info $cm The discussion course module
* @param int $discussiongroupid The discussion groupid
* @return bool
*/
function forum_is_user_group_discussion(cm_info $cm, $discussiongroupid)
{
if ($discussiongroupid == -1 || $cm->effectivegroupmode != SEPARATEGROUPS) {
return true;
}
if (isguestuser()) {
return false;
}
if (has_capability('moodle/site:accessallgroups', context_module::instance($cm->id)) || in_array($discussiongroupid, $cm->get_modinfo()->get_groups($cm->groupingid))) {
return true;
}
return false;
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:21,代码来源:lib.php
示例6: folder_cm_info_view
/**
* Overwrites the content in the course-module object with the folder files list
* if folder.display == FOLDER_DISPLAY_INLINE
*
* @param cm_info $cm
*/
function folder_cm_info_view(cm_info $cm)
{
global $PAGE;
if ($cm->uservisible && $cm->get_custom_data() && has_capability('mod/folder:view', $cm->context)) {
// Restore folder object from customdata.
// Note the field 'customdata' is not empty IF AND ONLY IF we display contens inline.
// Otherwise the content is default.
$folder = $cm->get_custom_data();
$folder->id = (int) $cm->instance;
$folder->course = (int) $cm->course;
$folder->display = FOLDER_DISPLAY_INLINE;
$folder->name = $cm->name;
if (empty($folder->intro)) {
$folder->intro = '';
}
if (empty($folder->introformat)) {
$folder->introformat = FORMAT_MOODLE;
}
// display folder
$renderer = $PAGE->get_renderer('mod_folder');
$cm->set_content($renderer->display_folder($folder));
}
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:29,代码来源:lib.php
示例7: __construct
/**
* Constructor for the base assign class.
*
* Note: For $coursemodule you can supply a stdclass if you like, but it
* will be more efficient to supply a cm_info object.
*
* @param mixed $coursemodulecontext context|null the course module context
* (or the course context if the coursemodule has not been
* created yet).
* @param mixed $coursemodule the current course module if it was already loaded,
* otherwise this class will load one from the context as required.
* @param mixed $course the current course if it was already loaded,
* otherwise this class will load one from the context as required.
*/
public function __construct($coursemodulecontext, $coursemodule, $course)
{
$this->context = $coursemodulecontext;
$this->course = $course;
// Ensure that $this->coursemodule is a cm_info object (or null).
$this->coursemodule = cm_info::create($coursemodule);
// Temporary cache only lives for a single request - used to reduce db lookups.
$this->cache = array();
$this->submissionplugins = $this->load_plugins('assignsubmission');
$this->feedbackplugins = $this->load_plugins('assignfeedback');
}
开发者ID:mercysmart,项目名称:naikelas,代码行数:25,代码来源:locallib.php
示例8: test_create
/**
* Tests the function for constructing a cm_info from mixed data.
*/
public function test_create()
{
global $CFG, $DB;
$this->resetAfterTest();
// Create a course and an activity.
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$page = $generator->create_module('page', array('course' => $course->id, 'name' => 'Annie'));
// Null is passed through.
$this->assertNull(cm_info::create(null));
// Stdclass object turns into cm_info.
$cm = cm_info::create((object) array('id' => $page->cmid, 'course' => $course->id));
$this->assertInstanceOf('cm_info', $cm);
$this->assertEquals('Annie', $cm->name);
// A cm_info object stays as cm_info.
$this->assertSame($cm, cm_info::create($cm));
// Invalid object (missing fields) causes error.
try {
cm_info::create((object) array('id' => $page->cmid));
$this->fail();
} catch (Exception $e) {
$this->assertInstanceOf('coding_exception', $e);
}
// Create a second hidden activity.
$hiddenpage = $generator->create_module('page', array('course' => $course->id, 'name' => 'Annie', 'visible' => 0));
// Create 2 user accounts, one is a manager who can see everything.
$user = $generator->create_user();
$generator->enrol_user($user->id, $course->id);
$manager = $generator->create_user();
$generator->enrol_user($manager->id, $course->id, $DB->get_field('role', 'id', array('shortname' => 'manager'), MUST_EXIST));
// User can see the normal page but not the hidden one.
$cm = cm_info::create((object) array('id' => $page->cmid, 'course' => $course->id), $user->id);
$this->assertTrue($cm->uservisible);
$cm = cm_info::create((object) array('id' => $hiddenpage->cmid, 'course' => $course->id), $user->id);
$this->assertFalse($cm->uservisible);
// Manager can see the hidden one too.
$cm = cm_info::create((object) array('id' => $hiddenpage->cmid, 'course' => $course->id), $manager->id);
$this->assertTrue($cm->uservisible);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:42,代码来源:modinfolib_test.php
示例9: course_get_cm_move
/**
* Returns the move action.
*
* @param cm_info $mod The module to produce a move button for
* @param int $sr The section to link back to (used for creating the links)
* @return The markup for the move action, or an empty string if not available.
*/
function course_get_cm_move(cm_info $mod, $sr = null)
{
global $OUTPUT;
static $str;
static $baseurl;
$modcontext = context_module::instance($mod->id);
$hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
if (!isset($str)) {
$str = get_strings(array('move'));
}
if (!isset($baseurl)) {
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
if ($sr !== null) {
$baseurl->param('sr', $sr);
}
}
if ($hasmanageactivities) {
$pixicon = 'i/dragdrop';
if (!course_ajax_enabled($mod->get_course())) {
// Override for course frontpage until we get drag/drop working there.
$pixicon = 't/move';
}
return html_writer::link(new moodle_url($baseurl, array('copy' => $mod->id)), $OUTPUT->pix_icon($pixicon, $str->move, 'moodle', array('class' => 'iconsmall', 'title' => '')), array('class' => 'editing_move', 'data-action' => 'move'));
}
return '';
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:33,代码来源:lib.php
示例10: course_get_cm_rename_action
/**
* Returns the rename action.
*
* @deprecated since 3.1
* @param cm_info $mod The module to produce editing buttons for
* @param int $sr The section to link back to (used for creating the links)
* @return The markup for the rename action, or an empty string if not available.
*/
function course_get_cm_rename_action(cm_info $mod, $sr = null)
{
global $COURSE, $OUTPUT;
static $str;
static $baseurl;
debugging('Function course_get_cm_rename_action() is deprecated. Please use inplace_editable ' . 'https://docs.moodle.org/dev/Inplace_editable', DEBUG_DEVELOPER);
$modcontext = context_module::instance($mod->id);
$hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
if (!isset($str)) {
$str = get_strings(array('edittitle'));
}
if (!isset($baseurl)) {
$baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
}
if ($sr !== null) {
$baseurl->param('sr', $sr);
}
// AJAX edit title.
if ($mod->has_view() && $hasmanageactivities && course_ajax_enabled($COURSE) && ($mod->course == $COURSE->id || $mod->course == SITEID)) {
// we will not display link if we are on some other-course page (where we should not see this module anyway)
return html_writer::span(html_writer::link(new moodle_url($baseurl, array('update' => $mod->id)), $OUTPUT->pix_icon('t/editstring', '', 'moodle', array('class' => 'iconsmall visibleifjs', 'title' => '')), array('class' => 'editing_title', 'data-action' => 'edittitle', 'title' => $str->edittitle)));
}
return '';
}
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:deprecatedlib.php
示例11: get_print_section_cm_text
/**
* Obtains shared data that is used in print_section when displaying a
* course-module entry.
*
* Calls format_text or format_string as appropriate, and obtains the correct icon.
*
* This data is also used in other areas of the code.
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
* @param object $course Moodle course object
* @return array An array with the following values in this order:
* $content (optional extra content for after link),
* $instancename (text of link)
*/
function get_print_section_cm_text(cm_info $cm, $course)
{
global $OUTPUT;
// Get course context
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Get content from modinfo if specified. Content displays either
// in addition to the standard link (below), or replaces it if
// the link is turned off by setting ->url to null.
if (($content = $cm->get_content()) !== '') {
$labelformatoptions = new stdClass();
$labelformatoptions->noclean = true;
$labelformatoptions->overflowdiv = true;
$labelformatoptions->context = $coursecontext;
$content = format_text($content, FORMAT_HTML, $labelformatoptions);
} else {
$content = '';
}
$stringoptions = new stdClass();
$stringoptions->context = $coursecontext;
$instancename = format_string($cm->name, true, $stringoptions);
return array($content, $instancename);
}
开发者ID:hitphp,项目名称:moodle,代码行数:35,代码来源:lib.php
示例12: block_intuitel_get_completion_status
/**
* Retrieves the completion status of the LO for an specific user (100 if this is completed and 0 if not), returns NULL if completion tracking is not enabled for that LO (or the entire course) and if the LO corresponds to a section or course LO
* @author elever
* @param cm_info $coursemodule_info : Moodle object with information of a module in a course
* @param int $userid : moodle identifier of the user
* @return int $completion_status | null
*/
function block_intuitel_get_completion_status(\cm_info $coursemodule_info, $userid)
{
$completion = new \completion_info($coursemodule_info->get_course());
if ($completion->is_enabled($coursemodule_info) > 0) {
//check if completion is enabled for a particular course and activity, returns 0 if it is not enabled, 1 if completion is enabled and is manual and 2 if automatic
$completion_status = $completion->get_data($coursemodule_info, false, $userid);
//this object has also information about viewed...is the row of the related table in the database
$completion_status = $completion_status->completionstate;
if ($completion_status > 0) {
$completion_status = 100;
// moodle completion system retrieves 0 when the activity is not completed, 1 when the activity is completed (regardless of mark), 2 when the activity is completed with a passed mark, 3 when the activity is completed but with a fail mark
}
} else {
$completion_status = null;
}
return $completion_status;
}
开发者ID:juacas,项目名称:moodle-block_intuitel,代码行数:24,代码来源:locallib.php
示例13: dataform_cm_info_view
/**
* Overwrites the content in the course-module object with the Dataform view content
* if dataform.inlineview is not empty
*
* @param cm_info $cm
*/
function dataform_cm_info_view(cm_info $cm)
{
global $PAGE, $CFG, $OUTPUT;
if (!$cm->uservisible) {
return;
}
// Default content if not displaying inline view.
if (!($dataform = $cm->customdata) or empty($dataform->inlineview)) {
return;
}
if (!empty($dataform->embedded)) {
$content = mod_dataform_dataform::get_content_embedded($dataform->id, $dataform->inlineview);
} else {
$content = mod_dataform_dataform::get_content_inline($dataform->id, $dataform->inlineview);
}
if (!empty($content)) {
$cm->set_content($content);
}
}
开发者ID:parksandwildlife,项目名称:learning,代码行数:25,代码来源:lib.php
示例14: send_response
/**
* Send the details of the newly created activity back to the client browser
*
* @param cm_info $mod details of the mod just created
*/
protected function send_response($mod)
{
global $OUTPUT, $PAGE;
$courserenderer = $PAGE->get_renderer('core', 'course');
$resp = new stdClass();
$resp->error = self::ERROR_OK;
$resp->icon = $mod->get_icon_url()->out();
$resp->name = $mod->name;
if ($mod->has_view()) {
$resp->link = $mod->get_url()->out();
} else {
$resp->link = null;
}
$resp->content = $mod->get_content();
$resp->elementid = 'module-' . $mod->id;
$actions = course_get_cm_edit_actions($mod, 0, $mod->sectionnum);
$resp->commands = ' ' . $courserenderer->course_section_cm_edit_actions($actions);
$resp->onclick = $mod->get_on_click();
$resp->visible = $mod->visible;
// if using groupings, then display grouping name
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', $this->context)) {
$groupings = groups_get_all_groupings($this->course->id);
$resp->groupingname = format_string($groupings[$mod->groupingid]->name);
}
echo $OUTPUT->header();
echo json_encode($resp);
die;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:33,代码来源:dnduploadlib.php
示例15: opencast_cm_info_view
function opencast_cm_info_view(cm_info $cm) {
$details = $cm->customdata;
if ($details) {
$cm->set_after_link(' ' . html_writer::tag('span', $details,
array('class' => 'resourcelinkdetails')));
}
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:8,代码来源:lib.php
示例16: course_section_cm_availability
/**
* Renders HTML to show course module availability information (for someone who isn't allowed
* to see the activity itself, or for staff)
*
* @param cm_info $mod
* @param array $displayoptions
* @return string
*/
public function course_section_cm_availability(cm_info $mod, $displayoptions = array())
{
global $CFG;
if (!$mod->uservisible) {
// this is a student who is not allowed to see the module but might be allowed
// to see availability info (i.e. "Available from ...")
if (!empty($mod->availableinfo)) {
$formattedinfo = \core_availability\info::format_info($mod->availableinfo, $mod->get_course());
$output = html_writer::tag('div', $formattedinfo, array('class' => 'availabilityinfo'));
}
return $output;
}
// this is a teacher who is allowed to see module but still should see the
// information that module is not available to all/some students
$modcontext = context_module::instance($mod->id);
$canviewhidden = has_capability('moodle/course:viewhiddenactivities', $modcontext);
if ($canviewhidden && !empty($CFG->enableavailability)) {
// Don't add availability information if user is not editing and activity is hidden.
if ($mod->visible || $this->page->user_is_editing()) {
$hidinfoclass = '';
if (!$mod->visible) {
$hidinfoclass = 'hide';
}
$ci = new \core_availability\info_module($mod);
$fullinfo = $ci->get_full_information();
if ($fullinfo) {
$formattedinfo = \core_availability\info::format_info($fullinfo, $mod->get_course());
return html_writer::div($formattedinfo, 'availabilityinfo ' . $hidinfoclass);
}
}
}
return '';
}
开发者ID:rushi963,项目名称:moodle,代码行数:41,代码来源:renderer.php
示例17: get_print_section_cm_text
/**
* Obtains shared data that is used in print_section when displaying a
* course-module entry.
*
* Deprecated. Instead of:
* list($content, $name) = get_print_section_cm_text($cm, $course);
* use:
* $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
* $name = $cm->get_formatted_name();
*
* @deprecated since 2.5
* @see cm_info::get_formatted_content()
* @see cm_info::get_formatted_name()
*
* This data is also used in other areas of the code.
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
* @param object $course (argument not used)
* @return array An array with the following values in this order:
* $content (optional extra content for after link),
* $instancename (text of link)
*/
function get_print_section_cm_text(cm_info $cm, $course)
{
debugging('Function get_print_section_cm_text() is deprecated. Please use ' . 'cm_info::get_formatted_content() and cm_info::get_formatted_name()', DEBUG_DEVELOPER);
return array($cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)), $cm->get_formatted_name());
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:26,代码来源:deprecatedlib.php
示例18: mod_subcourse_cm_info_view
/**
* This will provide summary info about the user's grade in the subcourse below the link on
* the course/view.php page
*
* @param cm_info $cm
* @return void
*/
function mod_subcourse_cm_info_view(cm_info $cm)
{
global $USER, $CFG;
$html = '';
require_once $CFG->dirroot . '/grade/querylib.php';
$currentgrade = grade_get_course_grade($USER->id, $cm->course);
$html .= html_writer::empty_tag('br');
$html .= html_writer::start_tag('span');
$html .= get_string('currentgrade', 'subcourse') . ' ' . $currentgrade->str_grade;
$html .= html_writer::end_tag('span');
$cm->set_after_link($html);
}
开发者ID:nadavkav,项目名称:moodle-mod_subcourse,代码行数:19,代码来源:lib.php
示例19: __construct
/**
* Constructor for the base assign class.
*
* Note: For $coursemodule you can supply a stdclass if you like, but it
* will be more efficient to supply a cm_info object.
*
* @param mixed $coursemodulecontext context|null the course module context
* (or the course context if the coursemodule has not been
* created yet).
* @param mixed $coursemodule the current course module if it was already loaded,
* otherwise this class will load one from the context as required.
* @param mixed $course the current course if it was already loaded,
* otherwise this class will load one from the context as required.
*/
public function __construct($coursemodulecontext, $coursemodule, $course)
{
global $SESSION;
$this->context = $coursemodulecontext;
$this->course = $course;
// Ensure that $this->coursemodule is a cm_info object (or null).
$this->coursemodule = cm_info::create($coursemodule);
// Temporary cache only lives for a single request - used to reduce db lookups.
$this->cache = array();
$this->submissionplugins = $this->load_plugins('assignsubmission');
$this->feedbackplugins = $this->load_plugins('assignfeedback');
// Extra entropy is required for uniqid() to work on cygwin.
$this->useridlistid = clean_param(uniqid('', true), PARAM_ALPHANUM);
if (!isset($SESSION->mod_assign_useridlist)) {
$SESSION->mod_assign_useridlist = [];
}
}
开发者ID:tehanuyor,项目名称:moodle,代码行数:31,代码来源:locallib.php
示例20: glossary_can_view_entry
/**
* Checks if the current user can see the glossary entry.
*
* @since Moodle 3.1
* @param stdClass $entry
* @param cm_info $cminfo
* @return bool
*/
function glossary_can_view_entry($entry, $cminfo) {
global $USER;
$cm = $cminfo->get_course_module_record();
$context = \context_module::instance($cm->id);
// Recheck uservisible although it should have already been checked in core_search.
if ($cminfo->uservisible === false) {
return false;
}
// Check approval.
if (empty($entry->approved) && $entry->userid != $USER->id && !has_capability('mod/glossary:approve', $context)) {
return false;
}
return true;
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:26,代码来源:lib.php
注:本文中的cm_info类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论