Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Moodle Mobile 2 (Ionic 1) Customization

From MoodleDocs

Overview

In this document are described the general steps for building your custom Mobile app.

Creating your custom application

Remember that if you only want to change the global styles of the app, you can use an extra CSS file in your Moodle installation without needing to recompile the app.

Basic custom settings

In your Moodle installation you can specify a extra CSS file in the Mobile settings section

You can edit the config.json file for: - Adding a default language - Add some presets in the login screen (url and username) pointing to your installation

Development environment

See Moodle_Mobile#Testing_and_developing

It is recommended that you have a local web server (app and moodle installation under localhost or the same local domain).

You will need:

  • A Moodle installation with Web Services (REST) enabled - see Web services documentation
  • Administration -> Plugins -> Web Services -> External Services -> Enable mobile web service
  • Administration -> Plugins -> Web Services -> Protocols -> Enable REST
  • Administration -> Users -> Permission -> Define roles -> Edit the Authenticated user role -> Allow webservice/rest:use
  • A local copy of the Mobile HTML5 App with the Debugging options Enabled

Web Services Development

In most cases your plugin/s will need Web Services to get data from your Moodle installation. It is recommended that you first develop the Web Services that you will need (see Web Services).

  • Create a new External Service in your Moodle installation, adding a services.php file in your new local plugin or creating manually the service in your Moodle installation.(Plugins -> Web Services) See External services description for more info. Remember the key name of the service, because you will need it later.

Plugin Development

See Moodle Mobile Plugins Development and Moodle Mobile Developing a plugin tutorial

For developing the plugin you need:

  • Edit the /config.json file to:
  • Add the extra plugins you implement
  • Indicate the WS service name you are going to use in your Moodle installation (Remember, that you need to create a WS Service indicating the functions available for your custom app)
  • Add your custom default lang file (es, ca, fr ...) (the language file must exists in the app's lang/ folder)
  • Change the app login form presets
  • Add your own css files, custom images, etc..

Testing and developing

Google Chrome browser

In order to be able to access any domain via AJAX from the local file:/// protocol, you must run Google Chrome in Unsafe mode adding this param:

--allow-file-access-from-files --disable-web-security

IMPORTANT: I strongly recommend you create a new link or application launch called "Google Unsafe" and use it only for testing the app.

"Path to chrome\chrome.exe" --allow-file-access-from-files --disable-web-security

With Google Chrome and the F12 or "Developer tools" you can emulate mobile devices changing user-agent, orientation, resolution, geo-location, touch events, etc..

Just open the Developers tools, click on the wheel bottom-right corner to see the Override options.

It's interesting also disabling the Cache (in general options)

Ripple

Requirements: Google Chrome browser + Ripple mobile environment emulator plugin (http://ripple.tinyhippos.com/)

You must run Google Chrome in Unsafe mode adding this param:

--allow-file-access-from-files --disable-web-security

IMPORTANT: I strongly recommend you create a new link or application launch called "Google Unsafe" and use it only for testing the app.

"Path to chrome\chrome.exe" --allow-file-access-from-files --disable-web-security

Open the index.html file in the Google Chrome unsafe and click on the Ripple icon to activate the emulator.

Once opened in the Ripple settings block, change Cross Domain Proxy to Disabled.

Please note that some functionalities (camera, audio recording, contact) will not work in the emulator.

Platform SDK

Install the Android or iPhone SDK and follow instructions in http://phonegap.com/start/.


Local web server

If you deploy the html files in a server under the same domain that the Moodle you are going to connect to you can test the application without emulator or changing the Security settings of your browser.

In other words

Your Moodle at http://myhost.com/moodle

Your app at http://myhost.com/umm/

Note that the mobile - related modules will not work.

Building

There are two options for building the app, aka compile it to different devices:

Phonegap Build

Phonegap Build is an online service that let you to build the app automatically for different platforms. The main advantage is that simplify a lot the process of building.

You just put your customizations in a github account and Phonegaps automatically build the app for different platforms pulling your github code.

Notice that the free version is for open repositories, but you can use the non-free version for private repositories.


Platform SDK

Using the target platform SDK you can build also your app, there is a good tutorial in Phonegap page for starting: http://docs.phonegap.com/en/2.4.0/guide_getting-started_index.md.html#Getting%20Started%20Guides


Differences between building in Phonegap and platform SDK

The main differences are:

  • In Phonegap Build you define a generic config.xml file with the icons, name of the app, and related info. For other platforms SDK you need to add this information in the files required by the SDK.
  • Phonegap Build supports two plugins used by the application: Generic Push Notifications and Childbrowser. If you want to compile the app in your SDK you need to install this plugins. See: https://build.phonegap.com/docs/plugins
  • The Android app uses an Android specific plugin called WebIntent(not supported by Phonegap Build) for opening files using the standard app selector, if you build the app using Phonegap Build a basic solution for opening files will be used. You need to install this plugin also if you want to compile the app using the Android SDK