Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
lib.php File Reference

Classes

class  course_request
 This class pertains to course requests and contains methods associated with create, approving, and removing course requests. More...
 

Functions

 add_course_module ($mod)
 MODULE FUNCTIONS /////////////////////////////////////////////////////////////////.
 
 average_number_of_courses_modules ()
 Average number of course modules.
 
 average_number_of_participants (bool $onlyactive=false, int $lastloginsince=null)
 Calculate the average number of enrolled participants per course.
 
 build_mnet_logs_array ($hostid, $course, $user=0, $date=0, $order="l.time ASC", $limitfrom='', $limitnum='', $modname="", $modid=0, $modaction="", $groupid=0)
 
 can_delete_course ($courseid)
 Can the current user delete this course? Course creators have exception, 1 day after the creation they can sill delete the course.
 
 can_download_from_backup_filearea ($filearea, context $context, stdClass $user=null)
 Return whether the user can download from the specified backup file area in the given context.
 
 can_edit_in_category ($categoryid=0)
 Does the user have permission to edit things in this category?
 
 compare_activities_by_time_asc ($a, $b)
 Compare two objects to find out their correct order based on timestamp (to be used by usort).
 
 compare_activities_by_time_desc ($a, $b)
 Compare two objects to find out their correct order based on timestamp (to be used by usort).
 
 core_course_core_calendar_get_valid_event_timestart_range (\calendar_event $event, $course)
 This function calculates the minimum and maximum cutoff values for the timestart of the given event.
 
 core_course_drawer ()
 Render the message drawer to be included in the top of the body of each page.
 
 core_course_inplace_editable ($itemtype, $itemid, $newvalue)
 Implements callback inplace_editable() allowing to edit values in-place.
 
 course_add_cm_to_section ($courseorid, $cmid, $sectionnum, $beforemod=null)
 Adds an existing module to the section.
 
 course_ajax_enabled ($course)
 Determine whether course ajax should be enabled for the specified course.
 
 course_allowed_module ($course, $modname, stdClass $user=null)
 Is the user allowed to add this type of module to this course?
 
 course_can_delete_section ($course, $section)
 Checks if the current user can delete a section (if course format allows it and user has proper permissions).
 
 course_can_view_participants ($context)
 Returns true if the user can view the participant page, false otherwise,.
 
 course_change_sortorder_after_course ($courseorid, $moveaftercourseid)
 Changes the sort order of courses in a category so that the first course appears after the second.
 
 course_change_sortorder_by_one ($course, $up)
 Changes the course sortorder by one, moving it up or down one in respect to sort order.
 
 course_change_visibility ($courseid, $show=true)
 Changes the visibility of a course.
 
 course_check_module_updates_since ($cm, $from, $fileareas=array(), $filter=array())
 Check module updates since a given time.
 
 course_check_updates ($course, $tocheck, $filter=array())
 Check for course updates in the given context level instances (only modules supported right Now)
 
 course_classify_courses_for_timeline (array $courses)
 Group a list of courses into either past, future, or in progress.
 
 course_classify_end_date ($course)
 This function calculates the end date to use for display classification purposes, incorporating the grace period, if any.
 
 course_classify_for_timeline ($course, $user=null, $completioninfo=null)
 This function classifies a course as past, in progress or future.
 
 course_classify_start_date ($course)
 This function calculates the start date to use for display classification purposes, incorporating the grace period, if any.
 
 course_create_section ($courseorid, $position=0, $skipcheck=false)
 Creates a course section and adds it to the specified position.
 
 course_create_sections_if_missing ($courseorid, $sections)
 Creates missing course section(s) and rebuilds course cache.
 
 course_delete_module ($cmid, $async=false)
 This function will handle the whole deletion process of a module.
 
 course_delete_section ($course, $section, $forcedeleteifnotempty=true, $async=false)
 This method will delete a course section and may delete all modules inside it.
 
 course_delete_section_async ($section, $forcedeleteifnotempty=true)
 Course section deletion, using an adhoc task for deletion of the modules it contains.
 
 course_filter_courses_by_customfield ( $courses, $customfieldname, $customfieldvalue, int $limit=0)
 Search the given $courses for any that have a $customfieldname value that matches the given $customfieldvalue, up to the specified $limit.
 
 course_filter_courses_by_favourites ( $courses, $favouritecourseids, int $limit=0)
 Search the given $courses for any that match the given $classification up to the specified $limit.
 
 course_filter_courses_by_timeline_classification ( $courses, string $classification, int $limit=0)
 Search the given $courses for any that match the given $classification up to the specified $limit.
 
 course_format_ajax_support ($format)
 Returns the information about the ajax support in the given source format.
 
 course_format_name ($course, $max=100)
 given a course object with shortname & fullname, this function will truncate the the number of chars allowed and add ... if it was too long
 
 course_format_uses_sections ($format)
 Tells if current course format uses sections.
 
 course_get_cm_edit_actions (cm_info $mod, $indent=-1, $sr=null)
 Returns the list of all editing actions that current user can perform on the module.
 
 course_get_cm_move (cm_info $mod, $sr=null)
 Returns the move action.
 
 course_get_communication_instance_data (int $courseid)
 Get course specific data for configuring a communication instance.
 
 course_get_course_dates_for_user_id (stdClass $course, int $userid)
 Calculate the course start date and offset for the given user id.
 
 course_get_course_dates_for_user_ids (stdClass $course, array $userids)
 Calculate the course start date and offset for the given user ids.
 
 course_get_courseimage (\stdClass $course)
 Get the current course image for the given course.
 
 course_get_enrolled_courses_for_logged_in_user (int $limit=0, int $offset=0, string $sort=null, string $fields=null, int $dbquerylimit=COURSE_DB_QUERY_LIMIT, array $includecourses=[], array $hiddencourses=[])
 Get the list of enrolled courses for the current user.
 
 course_get_enrolled_courses_for_logged_in_user_from_search (int $limit=0, int $offset=0, string $sort=null, string $fields=null, int $dbquerylimit=COURSE_DB_QUERY_LIMIT, array $searchcriteria=[], array $options=[])
 Get the list of enrolled courses the current user searched for.
 
 course_get_recent_courses (int $userid=null, int $limit=0, int $offset=0, string $sort=null)
 Returns a list of the most recently courses accessed by a user.
 
 course_get_tagged_course_modules ($tag, $exclusivemode=false, $fromcontextid=0, $contextid=0, $recursivecontext=1, $page=0)
 Returns course modules tagged with a specified tag ready for output on tag/index.php page.
 
 course_get_tagged_courses ($tag, $exclusivemode=false, $fromctx=0, $ctx=0, $rec=1, $page=0)
 Returns courses tagged with a specified tag.
 
 course_get_url ($courseorid, $section=null, $options=array())
 The URL to use for the specified course (with section)
 
 course_get_user_administration_options ($course, $context)
 Return an object with the list of administration options in a course that are available or not for the current user.
 
 course_get_user_navigation_options ($context, $course=null)
 Return an object with the list of navigation options in a course that are avaialable or not for the current user.
 
 course_integrity_check ($courseid, $rawmods=null, $sections=null, $fullcheck=false, $checkonly=false)
 Checks the integrity of the course data.
 
 course_module_bulk_update_calendar_events ($modulename, $courseid=0)
 Update all instances through out the site or in a course.
 
 course_module_calendar_event_update_process ($instance, $cm)
 Calendar events for a module instance are updated.
 
 course_module_flag_for_async_deletion ($cmid)
 Schedule a course module for deletion in the background using an adhoc task.
 
 course_module_instance_pending_deletion ($courseid, $modulename, $instanceid)
 Checks whether the course module, as defined by modulename and instanceid, is scheduled for deletion within the given course.
 
 course_module_update_calendar_events ($modulename, $instance=null, $cm=null)
 This function updates the calendar events from the information stored in the module table and the course module table.
 
 course_modules_pending_deletion (int $courseid, bool $onlygradable=false)
 Checks whether the given course has any course modules scheduled for adhoc deletion.
 
 course_output_fragment_new_base_form ($args)
 Renders the course copy form for the modal on the course management screen.
 
 course_overviewfiles_options ($course)
 Returns options to use in course overviewfiles filemanager.
 
 course_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 course_require_view_participants ($context)
 Checks if a user can view the participant page, if not throws an exception.
 
 course_set_marker ($courseid, $marker)
 Set highlighted section.
 
 course_update_communication_instance_data (stdClass $data)
 Update a course using communication configuration data.
 
 course_update_section ($course, $section, $data)
 Updates the course section.
 
 course_validate_dates ($coursedata)
 Validates course start and end dates.
 
 course_view ($context, $sectionnumber=0)
 Trigger course viewed event.
 
 create_course ($data, $editoroptions=NULL)
 Create a course and either return a $course object.
 
 create_module ($moduleinfo)
 Create a module.
 
 delete_mod_from_section ($modid, $sectionid)
 
 duplicate_module ($course, $cm, int $sectionid=null, bool $changename=true)
 Api to duplicate a module.
 
 get_category_or_system_context ($categoryid)
 Return the course category context for the category with id $categoryid, except that if $categoryid is 0, return the system context.
 
 get_hidden_courses_on_timeline ($user=null)
 Get a list of hidden courses.
 
 get_module_types_names ($plural=false, $resetcache=false)
 Returns an array where the key is the module name (component name without 'mod_') and the value is a lang_string object with a human-readable string.
 
 get_section_name ($courseorid, $section)
 Returns the display name of the given section that the course prefers.
 
 get_sorted_course_formats ($enabledonly=false)
 Returns the sorted list of available course formats, filtered by enabled if necessary.
 
 include_course_ajax ($course, $usedmodules=array(), $enabledmodules=null, $config=null)
 Include the relevant javascript and language strings for the resource toolbox YUI module.
 
 include_course_editor (course_format $format)
 Include and configure the course editor modules.
 
 make_log_url ($module, $url)
 
 mod_duplicate_activity ($course, $cm, $sr=null)
 Duplicate a module on the course for ajax.
 
 move_courses ($courseids, $categoryid)
 Efficiently moves many courses around while maintaining sortorder in order.
 
 move_section_to ($course, $section, $destination, $ignorenumsections=false)
 Moves a section within a course, from a position to another.
 
 moveto_module ($mod, $section, $beforemod=NULL)
 Move the module object $mod to the specified $section If $beforemod exists then that is the module before which $modid should be inserted.
 
 print_course_request_buttons ($context)
 Print the buttons relating to course requests.
 
 reorder_sections ($sections, $origin_position, $target_position)
 Reordering algorithm for course sections.
 
 save_local_role_names ($courseid, $data)
 Save the Your name for 'Some role' strings.
 
 set_coursemodule_groupmode ($id, $groupmode)
 Change the group mode of a course module.
 
 set_coursemodule_idnumber ($id, $idnumber)
 
 set_coursemodule_name ($id, $name)
 Changes the course module name.
 
 set_coursemodule_visible ($id, $visible, $visibleoncoursepage=1, bool $rebuildcache=true)
 Set the visibility of a module and inherent properties.
 
 set_downloadcontent (int $id, bool $downloadcontent)
 Set downloadcontent value to course module.
 
 set_section_visible ($courseid, $sectionnumber, $visibility)
 For a given course section, marks it visible or hidden, and does the same for every activity in that section.
 
 update_course ($data, $editoroptions=NULL)
 Update a course.
 
 update_module ($moduleinfo)
 Update a module.
 

Variables

const COURSE_CHOOSER_FOOTER_NONE 'hidden'
 
const COURSE_CUSTOMFIELD 'customfield'
 
const COURSE_CUSTOMFIELD_EMPTY -1
 Searching for all courses that have no value for the specified custom field.
 
const COURSE_DB_QUERY_LIMIT 1000
 
const COURSE_FAVOURITES 'favourites'
 
const COURSE_MAX_COURSES_PER_DROPDOWN 1000
 
const COURSE_MAX_LOGS_PER_PAGE 1000
 
const COURSE_MAX_RECENT_PERIOD 172800
 
const COURSE_MAX_SUMMARIES_PER_PAGE 10
 Number of courses to display when summaries are included.
 
const COURSE_MAX_USERS_PER_DROPDOWN 1000
 
const COURSE_TIMELINE_ALL 'all'
 
const COURSE_TIMELINE_ALLINCLUDINGHIDDEN 'allincludinghidden'
 
const COURSE_TIMELINE_FUTURE 'future'
 
const COURSE_TIMELINE_HIDDEN 'hidden'
 
const COURSE_TIMELINE_INPROGRESS 'inprogress'
 
const COURSE_TIMELINE_PAST 'past'
 
const COURSE_TIMELINE_SEARCH 'search'
 
const DOWNLOAD_COURSE_CONTENT_DISABLED 0
 
const DOWNLOAD_COURSE_CONTENT_ENABLED 1
 
const DOWNLOAD_COURSE_CONTENT_SITE_DEFAULT 2
 
const EXCELROWS 65535
 
const FIRSTUSEDEXCELROW 3
 
const FRONTPAGEALLCOURSELIST '6'
 
const FRONTPAGECATEGORYCOMBO '4'
 
const FRONTPAGECATEGORYNAMES '2'
 
const FRONTPAGECOURSESEARCH '7'
 
const FRONTPAGEENROLLEDCOURSELIST '5'
 
const FRONTPAGENEWS '0'
 
const MOD_CLASS_ACTIVITY 0
 
const MOD_CLASS_RESOURCE 1