Custom dashboard block on Mobile App

Custom dashboard block on Mobile App

by Giorgio Riva -
Number of replies: 5

Hi,

we are trying to add mobile support for a block plugin.

As specified in the Mobile support for plugins doc we defined a handler of type CoreBlockDelegate with the delegated method mobile_block_view.

Inside the delegated method definition we are not able to get the block instance Id. We need it to load instance specific settings.

How can we get the block instance id?

Thanks,
Giorgio

Average of ratings: -
In reply to Giorgio Riva

Re: Custom dashboard block on Mobile App

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 Giorgio,

the Moodle app supports 3 types of block plugins as explained in the documentation: only title, prerendered, or displayed directly. Can you please specify which type are you using?

I assume that you want to display the block directly using your template. In that case I think the app sends the contextlevel and the instanceid of the block. They should be inside the param received by your mobile_block_view function. Can you please check if you receive that data and if it's enough for you?

Cheers,
Dani
In reply to Dani Palou

Ri: Re: Custom dashboard block on Mobile App

by Giorgio Riva -
Hi Dani,

we're trying to help Kevin Wiliarty with the development of the Filtered course list block and we want to display the block in the App Dashboard. We use the third type to display directly the block.

Here's our definition code in \db\mobile.php. We do not define the displaydata option because it's optional and default values (title, blockname and type) are already what we need.
$addons = array(
    "block_filtered_course_list" => array( // Plugin identifier.
        'handlers' => array( // Different places where the plugin will display content.
            'filteredcourselist' => array( // Handler unique name (alphanumeric).
                'delegate'    => 'CoreBlockDelegate', // Delegate (where to display the link to the plugin).
                'method' => 'mobile_block_view',
            )
        ),
        'lang' => [ // Language strings that are used in all the handlers.
            ['blockname', 'block_filtered_course_list'],
            ['pluginname', 'block_filtered_course_list'],
        ],

    )
);

In the mobile_block_view method here's what we get from $args.

key: appcustomurlscheme value:moodlemobile
key: appid value:com.moodle.moodlemobile
key: appisdesktop value:0
key: appismobile value:1
key: appiswide value:0
key: applang value:it
key: appplatform value:browser
key: appversioncode value:3920
key: appversionname value:3.9.2
key: contextlevel value:user
key: instanceid value:9
key: userid value:9

We have the instanceid and the contextlevel but they are always referred to the logged-in user, not the block. This is not a problem when we have only one block but, in case of multiple blocks, we cannot identify which one we are displaying.

Maybe we are missing something in the configuration file but we cannot identify what, since there aren't many options available to set.

Thanks,
Giorgio

In reply to Giorgio Riva

Ri: Re: Custom dashboard block on Mobile App

by Giorgio Riva -
We tried to add the block in a course and now the contextlevel is course and the instanceid is the courseid.
It seems that contextlevel and instanceid are not from the block but from the context in which the block is added.

Giorgio
In reply to Giorgio Riva

Re: Ri: Re: Custom dashboard block on Mobile App

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 Giorgio,

oh, I thought the instanceid was from the block, not the context where it's added. I've opened an issue (MOBILE-3596) to send that information too, and I've added to the current sprint so it's included in the next release of the app.

Cheers,
Dani