本文整理汇总了PHP中enrol_course_updated函数的典型用法代码示例。如果您正苦于以下问题:PHP enrol_course_updated函数的具体用法?PHP enrol_course_updated怎么用?PHP enrol_course_updated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enrol_course_updated函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: define_execution
public function define_execution()
{
global $DB;
$course = $DB->get_record('course', array('id' => $this->get_courseid()), '*', MUST_EXIST);
if ($DB->record_exists('enrol', array('courseid' => $this->get_courseid(), 'enrol' => 'manual'))) {
// Something already added instances, do not add default instances.
$plugins = enrol_get_plugins(true);
foreach ($plugins as $plugin) {
$plugin->restore_sync_course($course);
}
} else {
// Looks like a newly created course.
enrol_course_updated(true, $course, null);
}
}
开发者ID:Jinelle,项目名称:moodle,代码行数:15,代码来源:restore_stepslib.php
示例2: update_course
/**
* Update a course.
*
* Please note this functions does not verify any access control,
* the calling code is responsible for all validation (usually it is the form definition).
*
* @param object $data - all the data needed for an entry in the 'course' table
* @param array $editoroptions course description editor options
* @return void
*/
function update_course($data, $editoroptions = NULL)
{
global $CFG, $DB;
$data->timemodified = time();
$oldcourse = $DB->get_record('course', array('id' => $data->id), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $oldcourse->id);
if ($editoroptions) {
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
}
if (!isset($data->category) or empty($data->category)) {
// prevent nulls and 0 in category field
unset($data->category);
}
$movecat = (isset($data->category) and $oldcourse->category != $data->category);
if (!isset($data->visible)) {
// data not from form, add missing visibility info
$data->visible = $oldcourse->visible;
}
if ($data->visible != $oldcourse->visible) {
// reset the visibleold flag when manually hiding/unhiding course
$data->visibleold = $data->visible;
} else {
if ($movecat) {
$newcategory = $DB->get_record('course_categories', array('id' => $data->category));
if (empty($newcategory->visible)) {
// make sure when moving into hidden category the course is hidden automatically
$data->visible = 0;
}
}
}
// Update with the new data
$DB->update_record('course', $data);
$course = $DB->get_record('course', array('id' => $data->id));
if ($movecat) {
$newparent = get_context_instance(CONTEXT_COURSECAT, $course->category);
context_moved($context, $newparent);
}
fix_course_sortorder();
// Test for and remove blocks which aren't appropriate anymore
blocks_remove_inappropriate($course);
// Save any custom role names.
save_local_role_names($course->id, $data);
// update enrol settings
enrol_course_updated(false, $course, $data);
add_to_log($course->id, "course", "update", "edit.php?id={$course->id}", $course->id);
// Trigger events
events_trigger('course_updated', $course);
}
开发者ID:numbas,项目名称:moodle,代码行数:58,代码来源:lib.php
示例3: update_course
/**
* Update a course.
*
* Please note this functions does not verify any access control,
* the calling code is responsible for all validation (usually it is the form definition).
*
* @param object $data - all the data needed for an entry in the 'course' table
* @param array $editoroptions course description editor options
* @return void
*/
function update_course($data, $editoroptions = NULL)
{
global $DB;
$data->timemodified = time();
$oldcourse = course_get_format($data->id)->get_course();
$context = context_course::instance($oldcourse->id);
if ($editoroptions) {
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
}
if ($overviewfilesoptions = course_overviewfiles_options($data->id)) {
$data = file_postupdate_standard_filemanager($data, 'overviewfiles', $overviewfilesoptions, $context, 'course', 'overviewfiles', 0);
}
// Check we don't have a duplicate shortname.
if (!empty($data->shortname) && $oldcourse->shortname != $data->shortname) {
if ($DB->record_exists_sql('SELECT id from {course} WHERE shortname = ? AND id <> ?', array($data->shortname, $data->id))) {
throw new moodle_exception('shortnametaken', '', '', $data->shortname);
}
}
// Check we don't have a duplicate idnumber.
if (!empty($data->idnumber) && $oldcourse->idnumber != $data->idnumber) {
if ($DB->record_exists_sql('SELECT id from {course} WHERE idnumber = ? AND id <> ?', array($data->idnumber, $data->id))) {
throw new moodle_exception('courseidnumbertaken', '', '', $data->idnumber);
}
}
if (!isset($data->category) or empty($data->category)) {
// prevent nulls and 0 in category field
unset($data->category);
}
$changesincoursecat = $movecat = (isset($data->category) and $oldcourse->category != $data->category);
if (!isset($data->visible)) {
// data not from form, add missing visibility info
$data->visible = $oldcourse->visible;
}
if ($data->visible != $oldcourse->visible) {
// reset the visibleold flag when manually hiding/unhiding course
$data->visibleold = $data->visible;
$changesincoursecat = true;
} else {
if ($movecat) {
$newcategory = $DB->get_record('course_categories', array('id' => $data->category));
if (empty($newcategory->visible)) {
// make sure when moving into hidden category the course is hidden automatically
$data->visible = 0;
}
}
}
// Update with the new data
$DB->update_record('course', $data);
// make sure the modinfo cache is reset
rebuild_course_cache($data->id);
// update course format options with full course data
course_get_format($data->id)->update_course_format_options($data, $oldcourse);
$course = $DB->get_record('course', array('id' => $data->id));
if ($movecat) {
$newparent = context_coursecat::instance($course->category);
$context->update_moved($newparent);
}
$fixcoursesortorder = $movecat || isset($data->sortorder) && $oldcourse->sortorder != $data->sortorder;
if ($fixcoursesortorder) {
fix_course_sortorder();
}
// purge appropriate caches in case fix_course_sortorder() did not change anything
cache_helper::purge_by_event('changesincourse');
if ($changesincoursecat) {
cache_helper::purge_by_event('changesincoursecat');
}
// Test for and remove blocks which aren't appropriate anymore
blocks_remove_inappropriate($course);
// Save any custom role names.
save_local_role_names($course->id, $data);
// update enrol settings
enrol_course_updated(false, $course, $data);
// Trigger a course updated event.
$event = \core\event\course_updated::create(array('objectid' => $course->id, 'context' => context_course::instance($course->id), 'other' => array('shortname' => $course->shortname, 'fullname' => $course->fullname)));
$event->set_legacy_logdata(array($course->id, 'course', 'update', 'edit.php?id=' . $course->id, $course->id));
$event->trigger();
if ($oldcourse->format !== $course->format) {
// Remove all options stored for the previous format
// We assume that new course format migrated everything it needed watching trigger
// 'course_updated' and in method format_XXX::update_course_format_options()
$DB->delete_records('course_format_options', array('courseid' => $course->id, 'format' => $oldcourse->format));
}
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:93,代码来源:lib.php
示例4: process_group_tag
//.........这里部分代码省略.........
foreach ($group->coursecode as $coursecode) {
$coursecode = trim($coursecode);
if (!$DB->get_field('course', 'id', array('idnumber' => $coursecode))) {
if (!$createnewcourses) {
$this->log_line("Course {$coursecode} not found in Moodle's course idnumbers.");
} else {
// Set shortname to description or description to shortname if one is set but not the other.
$nodescription = !isset($group->description);
$noshortname = !isset($group->shortName);
if ($nodescription && $noshortname) {
// If neither short nor long description are set let if fail
$this->log_line("Neither long nor short name are set for {$coursecode}");
} else {
if ($nodescription) {
// If short and ID exist, then give the long short's value, then give short the ID's value
$group->description = $group->shortName;
$group->shortName = $coursecode;
} else {
if ($noshortname) {
// If long and ID exist, then map long to long, then give short the ID's value.
$group->shortName = $coursecode;
}
}
}
// Create the (hidden) course(s) if not found
$courseconfig = get_config('moodlecourse');
// Load Moodle Course shell defaults
$course = new stdClass();
$course->fullname = $group->description;
$course->shortname = $group->shortName;
if (!empty($group->fulldescription)) {
$course->summary = format_text($group->fulldescription, FORMAT_HTML);
}
$course->idnumber = $coursecode;
$course->format = $courseconfig->format;
$course->visible = $courseconfig->visible;
$course->numsections = $courseconfig->numsections;
$course->hiddensections = $courseconfig->hiddensections;
$course->newsitems = $courseconfig->newsitems;
$course->showgrades = $courseconfig->showgrades;
$course->showreports = $courseconfig->showreports;
$course->maxbytes = $courseconfig->maxbytes;
$course->groupmode = $courseconfig->groupmode;
$course->groupmodeforce = $courseconfig->groupmodeforce;
$course->enablecompletion = $courseconfig->enablecompletion;
$course->completionstartonenrol = $courseconfig->completionstartonenrol;
// Insert default names for teachers/students, from the current language
// Handle course categorisation (taken from the group.org.orgunit field if present)
if (strlen($group->category) > 0) {
// If the category is defined and exists in Moodle, we want to store it in that one
if ($catid = $DB->get_field('course_categories', 'id', array('name' => $group->category))) {
$course->category = $catid;
} else {
if ($createnewcategories) {
// Else if we're allowed to create new categories, let's create this one
$newcat = new stdClass();
$newcat->name = $group->category;
$newcat->visible = 0;
$catid = $DB->insert_record('course_categories', $newcat);
$course->category = $catid;
$this->log_line("Created new (hidden) category, #{$catid}: {$newcat->name}");
} else {
// If not found and not allowed to create, stick with default
$this->log_line('Category ' . $group->category . ' not found in Moodle database, so using default category instead.');
$course->category = 1;
}
}
} else {
$course->category = 1;
}
$course->timecreated = time();
$course->startdate = time();
// Choose a sort order that puts us at the start of the list!
$course->sortorder = 0;
$courseid = $DB->insert_record('course', $course);
// Setup default enrolment plugins
$course->id = $courseid;
enrol_course_updated(true, $course, null);
// Setup the blocks
$course = $DB->get_record('course', array('id' => $courseid));
blocks_add_default_course_blocks($course);
$section = new stdClass();
$section->course = $course->id;
// Create a default section.
$section->section = 0;
$section->summaryformat = FORMAT_HTML;
$section->id = $DB->insert_record("course_sections", $section);
add_to_log(SITEID, "course", "new", "view.php?id={$course->id}", "{$course->fullname} (ID {$course->id})");
$this->log_line("Created course {$coursecode} in Moodle (Moodle ID is {$course->id})");
}
} else {
if ($recstatus == 3 && ($courseid = $DB->get_field('course', 'id', array('idnumber' => $coursecode)))) {
// If course does exist, but recstatus==3 (delete), then set the course as hidden
$DB->set_field('course', 'visible', '0', array('id' => $courseid));
}
}
}
// End of foreach(coursecode)
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:lib.php
示例5: update_course
/**
* Update a course.
*
* Please note this functions does not verify any access control,
* the calling code is responsible for all validation (usually it is the form definition).
*
* @param object $data - all the data needed for an entry in the 'course' table
* @param array $editoroptions course description editor options
* @return void
*/
function update_course($data, $editoroptions = NULL)
{
global $CFG, $DB;
$data->timemodified = time();
$oldcourse = course_get_format($data->id)->get_course();
$context = context_course::instance($oldcourse->id);
if ($editoroptions) {
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
}
if ($overviewfilesoptions = course_overviewfiles_options($data->id)) {
$data = file_postupdate_standard_filemanager($data, 'overviewfiles', $overviewfilesoptions, $context, 'course', 'overviewfiles', 0);
}
if (!isset($data->category) or empty($data->category)) {
// prevent nulls and 0 in category field
unset($data->category);
}
$changesincoursecat = $movecat = (isset($data->category) and $oldcourse->category != $data->category);
if (!isset($data->visible)) {
// data not from form, add missing visibility info
$data->visible = $oldcourse->visible;
}
if ($data->visible != $oldcourse->visible) {
// reset the visibleold flag when manually hiding/unhiding course
$data->visibleold = $data->visible;
$changesincoursecat = true;
} else {
if ($movecat) {
$newcategory = $DB->get_record('course_categories', array('id' => $data->category));
if (empty($newcategory->visible)) {
// make sure when moving into hidden category the course is hidden automatically
$data->visible = 0;
}
}
}
// Update with the new data
$DB->update_record('course', $data);
// make sure the modinfo cache is reset
rebuild_course_cache($data->id);
// update course format options with full course data
course_get_format($data->id)->update_course_format_options($data, $oldcourse);
$course = $DB->get_record('course', array('id' => $data->id));
if ($movecat) {
$newparent = context_coursecat::instance($course->category);
context_moved($context, $newparent);
}
fix_course_sortorder();
// purge appropriate caches in case fix_course_sortorder() did not change anything
cache_helper::purge_by_event('changesincourse');
if ($changesincoursecat) {
cache_helper::purge_by_event('changesincoursecat');
}
// Test for and remove blocks which aren't appropriate anymore
blocks_remove_inappropriate($course);
// Save any custom role names.
save_local_role_names($course->id, $data);
// update enrol settings
enrol_course_updated(false, $course, $data);
add_to_log($course->id, "course", "update", "edit.php?id={$course->id}", $course->id);
// Trigger events
events_trigger('course_updated', $course);
if ($oldcourse->format !== $course->format) {
// Remove all options stored for the previous format
// We assume that new course format migrated everything it needed watching trigger
// 'course_updated' and in method format_XXX::update_course_format_options()
$DB->delete_records('course_format_options', array('courseid' => $course->id, 'format' => $oldcourse->format));
}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:77,代码来源:lib.php
示例6: process_group_tag
//.........这里部分代码省略.........
if (preg_match('{<org>.*?<orgunit>(.*?)</orgunit>.*?</org>}is', $tagcontents, $matches)) {
$group->category = trim($matches[1]);
}
$recstatus = $this->get_recstatus($tagcontents, 'group');
if (empty($group->coursecode)) {
$this->log_line('Error: Unable to find course code in \'group\' element.');
} else {
// First, truncate the course code if desired.
if (intval($truncatecoursecodes) > 0) {
$group->coursecode = $truncatecoursecodes > 0 ? substr($group->coursecode, 0, intval($truncatecoursecodes)) : $group->coursecode;
}
// For compatibility with the (currently inactive) course aliasing, we need this to be an array.
$group->coursecode = array($group->coursecode);
// Third, check if the course(s) exist.
foreach ($group->coursecode as $coursecode) {
$coursecode = trim($coursecode);
if (!$DB->get_field('course', 'id', array('idnumber' => $coursecode))) {
if (!$createnewcourses) {
$this->log_line("Course {$coursecode} not found in Moodle's course idnumbers.");
} else {
// Create the (hidden) course(s) if not found
$courseconfig = get_config('moodlecourse');
// Load Moodle Course shell defaults.
// New course.
$course = new stdClass();
foreach ($this->coursemappings as $courseattr => $imsname) {
if ($imsname == 'ignore') {
continue;
}
// Check if the IMS file contains the mapped tag, otherwise fallback on coursecode.
if ($imsname == 'coursecode') {
$course->{$courseattr} = $coursecode;
} else {
if (!empty($group->{$imsname})) {
$course->{$courseattr} = $group->{$imsname};
} else {
$this->log_line('No ' . $imsname . ' description tag found for ' . $coursecode . ' coursecode, using ' . $coursecode . ' instead');
$course->{$courseattr} = $coursecode;
}
}
}
$course->idnumber = $coursecode;
$course->format = $courseconfig->format;
$course->visible = $courseconfig->visible;
$course->newsitems = $courseconfig->newsitems;
$course->showgrades = $courseconfig->showgrades;
$course->showreports = $courseconfig->showreports;
$course->maxbytes = $courseconfig->maxbytes;
$course->groupmode = $courseconfig->groupmode;
$course->groupmodeforce = $courseconfig->groupmodeforce;
$course->enablecompletion = $courseconfig->enablecompletion;
// Insert default names for teachers/students, from the current language.
// Handle course categorisation (taken from the group.org.orgunit field if present).
if (!empty($group->category)) {
// If the category is defined and exists in Moodle, we want to store it in that one.
if ($catid = $DB->get_field('course_categories', 'id', array('name' => $group->category))) {
$course->category = $catid;
} else {
if ($createnewcategories) {
// Else if we're allowed to create new categories, let's create this one.
$newcat = new stdClass();
$newcat->name = $group->category;
$newcat->visible = 0;
$catid = $DB->insert_record('course_categories', $newcat);
$course->category = $catid;
$this->log_line("Created new (hidden) category, #{$catid}: {$newcat->name}");
} else {
// If not found and not allowed to create, stick with default.
$this->log_line('Category ' . $group->category . ' not found in Moodle database, so using ' . 'default category instead.');
$course->category = $this->get_default_category_id();
}
}
} else {
$course->category = $this->get_default_category_id();
}
$course->timecreated = time();
$course->startdate = time();
// Choose a sort order that puts us at the start of the list!
$course->sortorder = 0;
$courseid = $DB->insert_record('course', $course);
// Setup default enrolment plugins.
$course->id = $courseid;
enrol_course_updated(true, $course, null);
// Setup the blocks.
$course = $DB->get_record('course', array('id' => $courseid));
blocks_add_default_course_blocks($course);
// Create default 0-section.
course_create_sections_if_missing($course, 0);
add_to_log(SITEID, "course", "new", "view.php?id={$course->id}", "{$course->fullname} (ID {$course->id})");
$this->log_line("Created course {$coursecode} in Moodle (Moodle ID is {$course->id})");
}
} else {
if ($recstatus == 3 && ($courseid = $DB->get_field('course', 'id', array('idnumber' => $coursecode)))) {
// If course does exist, but recstatus==3 (delete), then set the course as hidden.
$DB->set_field('course', 'visible', '0', array('id' => $courseid));
}
}
}
}
}
开发者ID:covex-nn,项目名称:moodle,代码行数:101,代码来源:lib.php
注:本文中的enrol_course_updated函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论