Download the PHP package otago/moodle without Composer

On this page you can find all versions of the php package otago/moodle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package moodle

Moodle SilverStripe module

Easily connect Moodle to SilverStripe via the web services REST API.

Project Setup

And you've installed the module! The examples/MoodleExamplePage.php.example file contains three example web service requests that to help you get started.

You'll need to configure moodle.yml with a password/username or a token supplied by Moodle. (Under Site administration > Advanced features > Plugins > Web services > Manage tokens)

Example moodle.yml file:

Your Moodle instance will need to be configured to accept web service requests.

Example calls

/**
 * returns a user's profile
 * @return \Dataobject|null
 */
public function getUserProfile() {
    // connect to moodle
    $moodle = MoodleWebservice::connect();
    if(!$moodle) {
        return Debug::message('Failed to connect to Moodle Webservice');
    }

    // create a user list containing one generic user
    $params = array('userlist' => array(
        (object) array(
            'userid'=>'2',
            'courseid' => '1'
        )
    ));

    // call the function core_user_get_course_user_profiles
    $userprofile = $moodle->call ('core_user_get_course_user_profiles', $params);

    // return it
    return $userprofile->Data();
}

Example 2: get a list of programmes from a user

$moodle = MoodleWebservice::connect();
if(!$moodle) {
    return Debug::message('Failed to connect to Moodle Webservice');
}

// find programmes belonging to this user
$params = array('userid' => '2');
$courselist = $moodle->call ('core_enrol_get_users_courses', $params);
return $courselist->Data();

Example 3: find a user by their email address

$moodle = MoodleWebservice::connect();
if(!$moodle) {
    return Debug::message('Failed to connect to Moodle Webservice');
}

$params = array('values' => array('[email protected]'), 'field' => 'email');
$userdata = $moodle->call ('core_user_get_users_by_field', $params);

return $userdata->Data();

Configure Moodle

The most difficult integration task for this module will be configuring your Moodle instance to allow web service requests. There are many resources on the web explaining how to do this, but by far the most helpful is the Moodle check list under Site administration > Advanced features > Plugins > Web services > Overview.

Moodle configuration summary:

  1. Create a user that will be used for the service
  2. Create the roll for this user, with access to the web services
  3. Assign your new roll to the user
  4. Create an external service Note: Moodle 2.5 users will have to manually set the shortname in the db
  5. Add the functions you want to call to the external service

Requirements

  1. cURL PHP module
  2. Moodle 2.2+ for JSON/REST
  3. SilverStripe 3.x

Integration Tests

  1. Create MoodleExamplePage on a test instance
  2. Save and load the page
  3. Update MoodleExamplePage.php to relevent user IDs
  4. View the raw output by using Debug::show(); on the output from $moodle->call()

Troubleshooting & Useful Tools

I recommend using Advanced REST Client for Google Chrome for debugging purposes.

debuging your moodleWebService:

  • Make sure your $params match the API docs (Under Site administration > Advanced features > Plugins > Web services > API Documentation)
  • Moodle's API Documentation can be notirious to read, make sure you tripple check the varibles you're using
  • Debug::show() your call()
  • die(print_r($url, true)); inside MoodleWebservice->call()
  • Make sure it's working using Advanced REST Client

common errors

Contributing changes

License

BSD


All versions of moodle with dependencies

PHP Build Version
Package Version
Requires silverstripe/framework Version 5.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package otago/moodle contains the following files

Loading the files please wait ....