Moodle mobile app customization

Moodle mobile app customization

by priscillah balirwa -
Number of replies: 6

Hello

Iam trying to create a custom moodle mobile app using V 3.2.1 code. Would like to prefix the username and password so that the app just displays the content on initialization. Does anyone have an idea on how i can prefix these? Thanks

Average of ratings: -
In reply to priscillah balirwa

Re: Moodle mobile app customization

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hello Priscillah,

there is no "easy" way to do that. We allow using fixed URLs so your app can only connect to a certain site. Also, we have "demo_sites" that allow the user to connect to a certain site with a certain user by only typing a certain word instead of a URL. But there is no built-in support for fixed users and URL right after accessing the app.

To achieve this, you would have to modify the function $mmLoginHelper#goToAddSite. In there, you should perform all the authentication code that is done in mmLoginSiteCtrl and mmLoginCredentialsCtrl.

Kind regards,

Dani

In reply to Dani Palou

Re: Moodle mobile app customization

by priscillah balirwa -

Thank you Dani... I have successfully been able to prefix the username and now my app launches with the username. I did that in www/core/main.js as shown in the screenshot below. 


Tried to do the same for the password but can't seem to find a place to prefix that. So I added password below username and defined it like in the screenshot below but it didn't work.


I'm also just learning how to code smile . Could I be missing out something?

In reply to priscillah balirwa

Re: Moodle mobile app customization

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Priscillah,

it worked for the username because the app is programmed to accept a fixed username (for Custom URL Schemes), but it isn't implemented for passwords. That's why it isn't working.

If you want to do the same for password, you need to modify this code and put it like this:

    $scope.credentials = {

        username: $stateParams.username,

        password:  $stateParams.password

    };

I think that should be enough smile

Cheers,

Dani

In reply to Dani Palou

Re: Moodle mobile app customization

by priscillah balirwa -

Hello Dani

Wow... Thanks a million!!! It worked. One last question smile

How do I make it log in directly without displaying the login button?  This way it just displays the home page on initialization.

Cheers... smile

In reply to priscillah balirwa

Re: Moodle mobile app customization

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Priscillah,

the easiest way is to call $scope.login() automatically inside mmLoginCredentialsCtrl. You should do it at the end of checkSite, after checkmodal.dismiss(). This means that the user will see that screen, but the login will be automatic.

The best way to do this would be to authenticate the user before reaching that view. As I said in a previous post, you would have to modify the function $mmLoginHelper#goToAddSite. In there, you should perform all the authentication code that is done in mmLoginSiteCtrl and mmLoginCredentialsCtrl.

Kind regards,

Dani

In reply to Dani Palou

Re: Moodle mobile app customization

by priscillah balirwa -
Thank you so much Dani!!!

I used the first approach and it worked. I'm now almost done with my customization thanks to you..

God bless... smile