Moodle for mobile

Adding mobile support to my plugin

 
Picture of Mike Churchward
Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers
Hi -

I'm undertaking an effort to add mobile support to my questionnaire plugin (see CONTRIB-6222), and documenting the efforts as I go. I am using all of the developer documentation, but I have and will run into questions, so I'm going to ask them here. Hopefully this effort will help make it easier for others to do the same.

I have some questions, that are based on trying to understand the mechanics of what I am doing... I'm using the quiz module as my example, as it seems to do similar thing in the mobile app that I would like the questionnaire to do. When I look at a quiz in the mobile app, I see a screen that shows me something like the attached image:


What service provides that screen? It looks like a formatted version of the standard quiz view screen, but what makes that happen? If I do the same for an unsupported plugin (e.g. Feedback), I just get a screen telling me that it is unsupported. What "unlocks" a plugin to make this display happen? Nothing in the 'classes/external.php' file seems to provide display information. Is it the existence of the 'view_quiz' function in the mod_quiz_external class?

If there is a document that better explains this, you can just point me to that.

Next, part of the process requires me to create a Moodle Mobile Plugin. The example given is for the certificate module. There are a number of javascript files that get created in a structure and then zipped up into the 'mobile' subdirectory (https://github.com/jleyva/moodle-mod_certificate/tree/CONTRIB-6313/mobile). But the actual files that are in this zip file are not contained within the repo. Obviously, we would want to keep these files somewhere intact as well. What is the convention for keeping these files with the repo?

Thanks in advance.

 
Average of ratings: -
Picture of Marcus Green
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

I have made a mobile version of my Gapfill question type and decided to keep the files in an entirely separate repo, i.e.

https://github.com/marcusgreen/mma-qtype-gapfill

When I build the mobile addon I use a batch file that copies the zip into the web version folder. Your question has made me realise that for anyone looking at the browser code would have no idea where the mobile code is kept.

 
Average of ratings: -
Picture of Juan Leyva
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Mike,

 Keep track of the mobile add-on files: As Marcus said, was is recommended is to create a separate git repo with the mobile code.

The code that implements the quiz activity in the app is in the addons/mod/quiz folder: https://github.com/moodlehq/moodlemobile2/tree/master/www/addons/mod/quiz

Any core module supported in the app has its own directory in www/addons, for adding support to the questionnaire module you will have to create a questionnaire directory there.

I wouldn't recommend you to review the quiz code, is the most complex add-on in the app. If you want to review something close to the app, there is a WIP that may help you (the feedback module).

Code and issues in the tracker are here:

MDL Epic: https://tracker.moodle.org/browse/MDL-57796
Mobile Epic: https://tracker.moodle.org/browse/MOBILE-1998

What I'd suggest you to do, is first to review in the MDL Epic all the Web Services required. There are a few that are quite standard and you can reuse the code from other modules: mod_feedback_get_feedbacks_by_courses, mod_feedback_view_feedback, mod_feedback_get_access_information.

PS: We are working in a tutorial, additional documentation for supporting modules in the app. The idea is to do a presentation in the UK moot

Juan



 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Juan -

Thanks. I'll look at that work. I need to think more about where the code sits, as I want to make sure that people interested in developing can find it easily.

Can you answer some of the tech questions ahead of the tutorial? It would help me understand and help me explain.

What service/file allows a view action to occur? That is, something indicates to the mobile app that the module has been supported, and allows it to use the module's view.php function (I believe), rather than display the "unsupported" message.

mike
 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Juan -

I'm still in search of the lowest requirement to remove the "plugin that is not yet supported" message. So far, I have created the "main.js" file and the handlers in the services directory and packaged them all up into a zip file using the Automatic packaging method. And, I have added the db/mobile.php file and moved the zip file created from the previous action into a "mobile/mod_questionnaire.zip". I also added the 'mod_questionnaire_view_questionnaire' service. But I still get the "not supported" message.

I am reluctant to carry on developing without gaining the basic understanding of what I need for the plugin to be recognized - even if it throws errors. Can you help me determine what that basic thing is I am still missing?

mike

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hello Mike,

the Mobile app has a "delegate" for course modules ($mmCourseDelegate). It's an Angular service that knows which modules are supported in the current Moodle site. If the user accesses a module that isn't registered in this delegate, the app will show a message saying that the module isn't supported.

The app has several delegates. Basically, a delegate allows addons to be shown at certain places of the app or to support certain features. Module addons can use 3 delegates:

  • $mmCourseDelegate: To support he module in the app, that way the user can open your module in a course. Required.
  • $mmContentLinksDelegate: To handle links to your module. For example, with this delegate you can open your module in the app if a user clicks a certain link in the app (the default behaviour is to open it in browser). Optional.
  • $mmCoursePrefetchDelegate: To support prefetching the module (for offline). Optional.

So in order to get rid of the message you need to register your Mobile addon in $mmCourseDelegate. This is an example of how to register your addon:

https://github.com/moodlehq/moodlemobile2/blob/master/www/addons/mod/chat/main.js#L56

And here is the implementation of this '$mmaModChatHandlers.courseContent':

https://github.com/moodlehq/moodlemobile2/blob/master/www/addons/mod/chat/services/handlers.js#L34

The documentation of the registerContentHandler function explains which data needs to be passed to the function and which functions must be implemented by the "handler".

https://github.com/moodlehq/moodlemobile2/blob/master/www/core/components/course/services/delegate.js#L45

It's a bit confusing at first, but once you get used to it this system makes it easier to develop addons for the app.


To develop a remote addon, we recommend downloading the app's code (or forking it) and develop the addon as a local addon in the app, like it was a new addon in a custom app you're creating. It makes it easier and faster to develop and test it. You'll have to setup your development environment in order to do so. Once your addon works in this copy of the app, then you should package it and upload it as a remote addon in your site.

Please let us know if you have any other question smile

Kind regards,

Dani

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Thanks Daniel -

I have tried what you said, and redid it using your examples. 


The main.js is here - https://github.com/mchurchward/moodle-mod_questionnaire/blob/MB32_PART2_ATTEMPT1/addons/main.js

The handlers.js is here - https://github.com/mchurchward/moodle-mod_questionnaire/blob/MB32_PART2_ATTEMPT1/addons/services/handlers.js

I have then used gulp to zip all of that up and drop it into the mobile directory - https://github.com/mchurchward/moodle-mod_questionnaire/tree/MB32_PART2_ATTEMPT1/mobile.

When I install that version of the plugin on my test site, and then run the mobile app locally, I still get the message "Your organisation installed a plugin that is not yet supported". What am I missing?

Again, I don't expect this version to provide the correct functionality. I'm just trying to get to the point where I impact the mobile app.

mike

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

FYI... I also have the questionnaire added directly to the app I am testing. You can see that here - https://github.com/mchurchward/moodlemobile2/tree/QUESTIONNAIRE_32/www/addons/mod/questionnaire

mike

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hi Mike,

I checked it in a local site and in my case it's not working because my site doesn't have the following WebServices:

mod_questionnaire_get_questionnaires_by_courses

mod_questionnaire_get_access_information

The function $mmaModQuestionnaire.isPluginEnabled checks if those WebServices are present in the site. If they aren't, the questionnaire is not supported in the app. Maybe the same is happening in your site?

Kind regards,

Dani

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Thanks Dani -

I have not added those services, so I will do so now. How did you determine that was the problem? Where were you able to get the report that those services were missing?

mike

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hi Mike,

I added some console.log to your remote addon to verify that the addon was downloaded and executed. The addon was downloaded and executed, but it wasn't in the list of enabledHandlers inside $mmCourseDelegate, so I checked the isPluginEnabled function and I saw that it was returning false.

You cannot check the console of the app published in Google Play or App Store, I used a development version to do so. That's why we recommend developing the addon in a local environment (preferable in browser as it is explained in here), and once everything is ready you can push it to your site. Also, this way you don't have to re-upload the addon everytime you do a change, you will only package and upload it once everything's ready.

There is a way to obtain Angular services from the console to make easier to debug the app. For example, if you execute the following code in the Javascript console it will call the isPluginEnabled of your remote addon:

var $mmaModQuestionnaire = angular.element(document.querySelector('[ng-app]')).injector().get('$mmaModQuestionnaire');

$mmaModQuestionnaire.isPluginEnabled().then(function(enabled) {

console.log('Is enabled?, enabled);

});

Kind regards,

Dani

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Thanks again Dani -

I added those services to my plugin, and tried the tests again. I am still not able to see a supported app.

You can see the added services here - https://github.com/mchurchward/moodle-mod_questionnaire/blob/MB32_PART2_ATTEMPT2/db/services.php

and here - https://github.com/mchurchward/moodle-mod_questionnaire/blob/MB32_PART2_ATTEMPT2/classes/external.php

Just to assure you, I am debugging this using a local Moodle site, and a local ionic server running the mobile2 app code. I have my browser connecting to the ionic server in place of a mobile device. And, the mobile app that ionic is connecting to contains the remote add-on code in the "www/addons/mod/questionnaire" folder. So, I believe it should be accessing it directly and not from a downloaded zip file.

I added this to the console:

var $mmaModQuestionnaire = angular.element(document.querySelector('[ng-app]')).injector().get('$mmaModQuestionnaire');

$mmaModQuestionnaire.isPluginEnabled().then(function(enabled) {

console.log('Is enabled?', enabled);

});

It came back with the error:

Uncaught Error: [$injector:unpr] Unknown provider: $mmaModQuestionnaireProvider <- $mmaModQuestionnaire
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=%24mmaModQuestionnaireProvider%20%3C-%20%24mmaModQuestionnaire
    at ionic.bundle.js:13443
    at ionic.bundle.js:17793
    at Object.getService [as get] (ionic.bundle.js:17946)
    at ionic.bundle.js:17798
    at Object.getService [as get] (ionic.bundle.js:17946)
    at <anonymous>:1:91
(anonymous) @ ionic.bundle.js:13443
(anonymous) @ ionic.bundle.js:17793
getService @ ionic.bundle.js:17946
(anonymous) @ ionic.bundle.js:17798
getService @ ionic.bundle.js:17946
(anonymous) @ VM649:1

mike

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hi Mike,

I'm not sure if you already did it, but first you should follow the steps in this guide to setup the development environment. The important section is the "Clone the app base code". Once you've done this, you should be able to run this command:

ionic serve --browser chromium 

to start the app in Chromium. You can see more details in this wiki page.

Once this is done, I suggest you to remove the remote addon from your Moodle site (leave only the Moodle plugin only) and instead add the addon to your local Moodle Mobile app, next to the rest of mod addons in the app. The local addon doesn't need the zip file or the addon.js file.

I suggest you to restart the ionic serve after this since it doesn't watch files created after starting it.

Now you should check if you're able to open the addon in the browser. If you aren't, you will have to check why. First you should check if the isPluginEnabled function is returning true now: you can execute it from the Javascript Console of the Chromium DevTools, see the code I pasted above.

If the isPluginEnabled function still returns false, maybe your Moodle site hasn't registered your functions right. They should appear in Site administration > Plugins > Web services > External services > Functions. Beware: if you use local_mobile plugin, you need to register your WebServices in that service too!

You also might want to add some console.log in $mmCourseDelegate to determine if your addon is being registered (added to contentHandlers) and if it's detected as enabled (added to enabledHandlers). You can see the output of console.log in the Javascript Console of the Chromium DevTools.

I hope this helps you determine the problem.

Cheers,

Dani

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Dani -

Just to clarify, I am doing all of that.

I have a local Moodle server that contains my new questionnaire code. It has the web services and I have removed the 'mobile' directory.

I have a local clone of the mobile app, and I have set up a development environment as per the instructions. I have loaded the questionnaire remote add-on into the mobile code at "www/addons/mod/questionnaire/*".

I run the ionic sever from the root of the mobile app code base. I then connect my browser to that server. That all works fine (see screen grab):


I have checked the Moodle site, and all of the web services have been registered:


You said, "Beware: if you use local_mobile plugin, you need to register your WebServices in that service too!". I'm not sure what you mean by that. I'm not using a Moodle local plugin. My plugin is an activity module.

I'll see if I can figure out how to add some logging in the mobile portion.

mike


 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi -

I monitored the console while starting up my app. I have my questionnaire plugin located in "[approot]/www/addons/mod/qestionnaire".

When the app starts, I can see the output for registering addons, but my plugin never appears there. All of the other directories in the "mod" directory do appear in the register output.

I'm guessing, simply being present in the "mod" directory isn't enough? Is there some action I need to take to make the app recognize my plugin?

mike

 
Average of ratings: -
Picture of Juan Leyva
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Mike,

I see in your plugin code that you have still the zip file there and mobile.php file.

You should remove the mobile.php and the plugin zip from your plugin and, as Dani said, first develop the mobile add-on for the questionnaire adding the folder in the apps code.

If you have both your code in the apps folder and the remote add-on you will get errors.

I  would  also recommend you to start fresh copying a simple add-on, lti, chat or choice are very simple add-ons.

So basically the plan I'm proposing would be:

- Remove from your Moodle plugin the mobile.php file and the zip with the remote add-on (adding this is the last step in all the process of building a remote add-on)

- Start fresh, you can copy and rename one of the existing add-ons to understand how everything works (the lti add-on is very simple, you can copy it renaming it to questionnaire)

Juan

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Juan -

I have left the mobile and zip file in the repo files, but they are not in the Moodle site I am testing with. I deliberately removed them from there.

My apps folder contains the plugin files in the www/addons/mod/questionnaire/ directory from the plugin repo's "addons" subdirectory.

As I mentioned in the previous post, I monitored the console output when I ramped up the mobile app on my local development Chrome browser, and the questionnaire did not show up in the list of plugins being registered. All other apps in the www/addons/mod/ directory did show up in the registering output.

I could start over, but it feels like I will just end up in this same place.

Can you confirm for me that presence in the 'www/addons/mod/' directory is all that the mobile app needs to try and register the plugin?

mike

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Okay... I tried another tactic.

I added the certificate plugin to my test mobile app from here - https://github.com/jleyva/moodlemobile2/tree/MOBILE-1586. I put this code into the "www/addons/mod/certificate" directory.

I then added the certificate module to my test Moodle site from here - https://github.com/jleyva/moodle-mod_certificate/tree/CONTRIB-6313. I deleted the "mobile" directory from the certificate code.

I then restarted my ionic server, accessed the mobile app, and tried to access a certificate module. Like the questionnaire, I got an "plugin is not yet supported" message.

When I looked at the console output, the certificate module, like the questionnaire module, is not showing up in the registration output:

mm.bundle.js:11528 $mmCourseDelegateProvider: Registered addon 'mmaModBook' as course content handler.
mm.bundle.js:12007 $mmCoursePrefetchDelegateProvider: Registered addon 'mmaModBook' as prefetch handler.
mm.bundle.js:10557 $mmContentLinksDelegateProvider: Registered handler 'mmaModBook' as link handler.
mm.bundle.js:11528 $mmCourseDelegateProvider: Registered addon 'mmaModChat' as course content handler.
mm.bundle.js:10557 $mmContentLinksDelegateProvider: Registered handler 'mmaModChat' as link handler.

It seems that the mobile app is not looking for new plugins?

I do see occurrences of the certificate and questionnaire modules in other console output:

ionic.bundle.js:26799 3/16/2017 5:15:02 PM $mmFilepool: Set status 'downloading' for package mmAddonManager mod_certificate_mod_certificate
ionic.bundle.js:26799 3/16/2017 5:15:02 PM $mmFilepool: Set status 'downloading' for package mmAddonManager mod_questionnaire_mod_questionnaire
ionic.bundle.js:26799 3/16/2017 5:15:03 PM $mmFilepool: Set status 'downloaded' for package mmAddonManager mod_certificate_mod_certificate
ionic.bundle.js:26799 3/16/2017 5:15:03 PM $mmFilepool: Set status 'downloaded' for package mmAddonManager mod_questionnaire_mod_questionnaire
ionic.bundle.js:26799 3/16/2017 5:15:03 PM $mmFS: Remove directory: sites/f53fa802d4b0dccf90d6a2fcfa02e5c2/filepool/remoteaddons/mod_certificate_mod_certificate
ionic.bundle.js:26799 3/16/2017 5:15:03 PM $mmFilepool: Set status 'notdownloaded' for package mmAddonManager mod_certificate_mod_certificate
ionic.bundle.js:26799 3/16/2017 5:15:03 PM $mmFilepool: Set status 'notdownloaded' for package mmAddonManager mod_questionnaire_mod_questionnaire

This makes me think that somehow there is a zip file expected? Or cached? Is there something I can do do reinitialize any cache in the mobile app?

mike

 
Average of ratings: -
Picture of Neill Magill
Re: Adding mobile support to my plugin
Group Core developersGroup Plugin developers

I think a version bump got missed when the extra web services got added in the latest commit.

i.e. Moodle will not have picked them up, unless you did a clean install of the plugin.

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Neill -

While I'm in development, I tend to leave the version alone, and instead trigger an update by setting the site back to the previous version. I do see the web services in the site listing (see below).

mike

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

(just to make it easier for others, I have bumped the version and recommitted here - https://github.com/mchurchward/moodle-mod_questionnaire/tree/MOBILE_32)

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hi Mike,

that console output about mmAddonManager is for remote addons. Maybe your site is still returning your plugin as a remote addon? Please open www/core/lib/addonmanager.js and look for the line that has tool_mobile_get_plugins_supporting_mobile. You should print the result of this WebService call to see if Moodle is still returning your remote addon:

return site.read('tool_mobile_get_plugins_supporting_mobile', {}, preSets).then(function(data) {
    console.log(data);


The app should be able to pick up your addon's code as long as it is inside the www folder, it doesn't matter if it's in the mod resource or not (we put it in there to keep the app's structure clean). The line that will make the app aware of your module is this one in main.js:

$mmCourseDelegateProvider.registerContentHandler('mmaModQuestionnaire', 'questionnaire', '$mmaModQuestionnaireHandlers.courseContent');


First of all, please open the file www/build/mm.bundle.js and check if your addon code is in there. All the Javascript code of the app is put in that file, and that file is the one that is included in the index.html (that way we don't have to include hundreds of files).

If it is, then you should make sure that the register code is executed. You should open your addon's main.js and add a console.log in the .config function:

.config(function($mmCourseDelegateProvider, $mmContentLinksDelegateProvider) {

    console.log('Questionnaire: Config function run');


If it is executed, then maybe it's not detected as enabled. Please open the Javascript Console in DevTools and run this code:

var $mmaModQuestionnaire = angular.element(document.querySelector('[ng-app]')).injector().get('$mmaModQuestionnaire');

$mmaModQuestionnaire.isPluginEnabled().then(function(enabled) {

    console.log('Is enabled?, enabled);

}).catch(function(error) {

    console.log('Error', error);

});


The output should tell you if the plugin is enabled (it detects the WebServices) or not. If it is enabled, then you will have to add some console.log in $mmCourseDelegate (www/core/components/course/services/delegate.js). You should add them in these functions:

  • registerContentHandler: This is the function that registers your addon.
  • getContentHandlerControllerFor: This is the function that retrieves your addon (when you open the course).
  • isModuleDisabledInSite: New in Moodle 3.3, to check for disabled features in Moodle.
  • updateContentHandler: This is where your addon is marked as "enabled".


Hope this helps,

Dani

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Thanks Dani.

I'll work through all of this. A couple of comments / questions:

1. As noted above (https://moodle.org/mod/forum/discuss.php?d=348597#p1409228), I am seeing the same thing using the certificate app and module code developed as the example to use. When I install it as a local add-on, it generates the same problems.

2. You mentioned that the code from my app should be in www/build/mm.bundle.js. I'm guessing then, that the app files must be writable by the ionic server? Or am I supposed to run a build process somewhere to add my app code to that file?

I'll let you know how my testing goes.

mike

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hi Dani -

Some answers:

1) You should print the result of this WebService call to see if Moodle is still returning your remote addon:

No output was generated. I also put a "console.log" statement before the "return", just to see if the function was entered. It does not appear that "downloadRemoteAddons" is called.

2) open the file www/build/mm.bundle.js and check if your addon code is in there:

No. No code exists in there for either questionnaire or certificate.

mike

 
Average of ratings: -
Picture of Juan Leyva
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Hi Mike,

before testing your code in the browser a build process is required.

The build process is done automatically by ionic serve, alternatively you can use gulp. But ionic serve should be enough (please notice that you must check the console where ionic serve is running because an error will stop the build)

Juan

 
Average of ratings: -
Picture of Mike Churchward
Re: Adding mobile support to my plugin
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup Testers

Hey! I may have gotten somewhere!

I just updated my version of the moodlemobile app with the latest code in the main repo. Now, both the questionnaire and the certificate are appearing in the app!

Not sure if it was something fixed in the new code, or the act of updating it triggered some refresh. In any case, looks like I can start to move forward!

mike

 
Average of ratings: -
Picture of Neill Magill
Re: Adding mobile support to my plugin
Group Core developersGroup Plugin developers

I'm also working on developing a remote mobile app and got it working as part of the Mobile app.

Unfortunately things started going wrong when I tried to package it as a remote app.

The first issue I encountered is that the web service that lists plugins as mobile compatible does not work on Windows correctly. I have raised a ticket with a fix for it: https://tracker.moodle.org/browse/MDL-58285

After getting the Mobile app to recognise that there was a Mobile plugin the plugin would not load, as it could not find the template file. I compiled the remote plugin using the gulp command, i.e. gulp remoteaddon -p {PATHTOADDON}

The issue seems to be that the gulp command did not convert the template path from the internal plugin form:

templateUrl: 'addons/myaddon/templates/index.html'

to the remote plugin form:

templateUrl: '$ADDONPATH$/templates/index.html'

Should this have happened automatically? Is it a bug with the process on Windows?

 
Average of ratings: -
Picture of Dani Palou
Re: Adding mobile support to my plugin
Group Core developersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developers

Hi Neill,

thank you for letting us know. The gulp task is probably failing due to the inverted paths in Windows. I opened an issue to fix this:

https://tracker.moodle.org/browse/MOBILE-2068

Kind regards,

Dani

 
Average of ratings: Useful (1)
Picture of Neill Magill
Re: Adding mobile support to my plugin
Group Core developersGroup Plugin developers

You are right if I use Linux separators it compiles and changes the path.

i.e. it does not work with 'gulp remoteaddon -p www\addons\mod\tutorialbooking', but does with 'gulp remoteaddon -p www/addons/mod/tutorialbooking'

 
Average of ratings: -