Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
Class communication
Copyright: | 2017 Marina Glancy |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 373 lines (18 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
api:: (12 methods):
call()
call_rest()
process_curl_exception()
update_registration()
get_hub_info()
get_courses()
unregister_site()
unregister_courses()
register_course()
add_screenshot()
download_course_backup()
upload_course_backup()
call($function, array $data = [], $allowpublic = false) X-Ref |
Calls a remote function exposed via web services on the hub. param: string $function name of WS function param: array $data parameters of WS function param: bool $allowpublic allow request without registration on the hub return: mixed depends on the function |
call_rest($token, $function, array $data) X-Ref |
Performs a REST request to the hub site (using the GET method). param: string $token param: string $function param: array $data return: mixed |
process_curl_exception($token, $curloutput) X-Ref |
Analyses exception received from the hub server. param: string $token token used for CURL request param: array $curloutput output from CURL request |
update_registration(array $siteinfo) X-Ref |
Update site registration on the hub. param: array $siteinfo |
get_hub_info() X-Ref |
Returns information about the hub. Example of the return array: { "courses": 384, "description": "Official Moodle sites directory.", "downloadablecourses": 0, "enrollablecourses": 0, "hublogo": 1, "language": "en", "name": "moodle", "sites": 274175, "url": "https://stats.moodle.org", "imgurl": "https://stats.moodle.org/local/hub/webservice/download.php?filetype=hubscreenshot" } return: array |
get_courses($search, $downloadable, $enrollable, $options) X-Ref |
Calls WS function hub_get_courses param: string $search search string param: bool $downloadable return downloadable courses param: bool $enrollable return enrollable courses param: array|\stdClass $options other options from the list of allowed options: return: array of two elements: [$courses, $coursetotal] |
unregister_site() X-Ref |
Unregister the site |
unregister_courses($courseids) X-Ref |
Unpublish courses param: int[]|int $courseids |
register_course($courseinfo) X-Ref |
Publish one course param: array|\stdClass $courseinfo return: int id of the published course on the hub |
add_screenshot($hubcourseid, \stored_file $file, $screenshotnumber) X-Ref |
Uploads a screenshot for the published course param: int $hubcourseid id of the published course on the hub, it must be published from this site param: \stored_file $file param: int $screenshotnumber ordinal number of the screenshot |
download_course_backup($hubcourseid, $path) X-Ref |
Downloads course backup param: int $hubcourseid id of the course on the hub param: string $path local path (in tempdir) to save the downloaded backup to. |
upload_course_backup($hubcourseid, \stored_file $backupfile) X-Ref |
Uploads a course backup param: int $hubcourseid id of the published course on the hub, it must be published from this site param: \stored_file $backupfile |