Present all course actions in Boost course dropdown action menu

Present all course actions in Boost course dropdown action menu

by Zabelle Motte -
Number of replies: 10
Picture of Particularly helpful Moodlers

Hello,

Our Moodle uses an old theme and we have to change it on the next upgrade planned this summer.
We like very much the Boost theme that fixes the admin course menu on the gears icon in the course header.
But we would like to show all options in this list (without the "More" link) or to show our selection of options (nobody customize filters in our Moodle, for example).

I had a look on the forum and in the documentation, also had a look on Boost teme files and did not find how to do.
It would be great for somebody to precise how filter "only on certain pages" works in this doc page :
https://docs.moodle.org/dev/Boost_Navigation

Thanks in advance for advices ;-*

Zabelle

Average of ratings: -
In reply to Zabelle Motte

Re: Present all course actions in Boost course dropdown action menu

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hi Zabelle wink

AFAIK, you cannot replace the "More..." link with all missing items unless you dive into the core navigation code (I would not recommend that wink).
However you have some solutions:

To remove items, you can play with role capabilities

To get a full list of course administration items, you can use the great local_boostnavigation plugin (by A. Bias and the Ulm University) which allows you to add custom nodes to the left navigation drawer, and so you can add a link to the course admin page. You can also check what is done in boost_campus theme (same authors) where they replace the cog icon behaviour. Instead of getting a short list in a dropdown menu, you toggle the full course admin menu above course content.



You can also look at Fordson theme where C. Kenniburg chose to replace the default course admin menu with a theme built modal window including custom admin nodes. 



Hope this helps
Cheers
Average of ratings: Useful (2)
In reply to Jean-Roch Meurisse

Re: Present all course actions in Boost course dropdown action menu

by Zabelle Motte -
Picture of Particularly helpful Moodlers
Hello Jean-Roch,

Thanks for this feedback.

I found the function that defines the Boost admin menu (build_action_menu_from_navigation in /theme/boost/classes/output/core_renderer.php).
It perhaps would be possible to investigate a child theme that tweaks this function.

I also had the idea to modify permission to suppress filters, restore, share and repositories menu items.

The local_boostnavigation plugin seems an interesting option to test.
I also tested the Fordson theme with its modal window but I read somewhere that the additionnal plugins would not appear in this menu.
If you did more tests with this theme, please let me know how to tweak th modal window.

But while testing these themes, I found they had a big default : you need to have 2 clicks to enable edition mode.
And the edition button does not remain in the fixed above navbar, thats always visible.

As you know, I already used the popular Adaptable theme that has an edition mode button that is always visible and, that is finally well supported on Moodle recent versions.
It is a bit complicated to config but would enable us to have a theme that gives an easy access to edition mode, with menu that behave like actual menus of our old Clean derived theme.

Thank for suggestions and hoping to continue this discussion while meeting you in Rennes shortly clin d’œil

Kisses

Zabelle
In reply to Zabelle Motte

Re: Present all course actions in Boost course dropdown action menu

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi,

There is an edition mode switch in the fordson theme navbar but I think only in course context.
As for the course and activities action menus, we borrowed functionality from boost_campus theme (see my first screenshot) 

We also added a permanent edit mode switch in the navbar in every relevant context as well as the "redballs" functionality that you know well wink

If you want I can give you a link to our git repository with our local "receptic" theme that is almost ready to be sent for approval. It just needs some more cleanup.
Among other things it allows to add hide/show courses and unenrol from the dashboard, flashboxes, hide/show blocks column and "shrinkable" nav drawer on click on the hamburger icon (reduced to icons) 

Cheers

In reply to Jean-Roch Meurisse

Re: Present all course actions in Boost course dropdown action menu

by Zabelle Motte -
Picture of Particularly helpful Moodlers
Hello Jean-Roch,

  Working with my collegue, Dominique Palumbo, we finally found a way to have a customized action menu while tweaking minimally the Moodle functions.

custom cog menu action

Here are the modifications we made on out Moodle 3.7.1.
These modifications should not be done one production Moodle without testing.

There is one file to adapt : /lib/outputrenderers.php
Here are the 2 functions tweaks ...

In  public function context_header_settings_menu(), modify the  build_action_menu_from_navigation call when if ($showcoursemenu), and set the last parameter ($onlytopleafnodes) to false.

outputrendrers1

This will generate an action menu with all options of the administration menu.

In protected function build_action_menu_from_navigation, add a specific class for each item of this menu (to then enable us to hide some of them through css) :

outputrenderes2

Here are the 2 lines to add :

$myclass = parse_url($menuitem->action, PHP_URL_PATH);
$link->add_class(ltrim(str_replace('.php','',str_replace('/', '-', $myclass)),'-'));
This generates a class from the Moodle url.
For example, the link "http://my-moodle/course/completion.php?id=86" will be associated with class "course-completion".

Then it is possible to tweak the elements to show in the cog menu trough css.

Here is the customized css to apply to Boost Theme :

/* hide elements from cog action menu */
/* suppose to have modifications in  moodle/lib/outputrenderers.php */
/* we suppress the vertical padding to the .dropdown block and apply an equivalent margin to the a tag used to integrate menu links */
/* this is necessary to have no space when hiding one menu element beacuse the custon class is weared by the a tag. */
.path-course #page-header .dropdown-item,
.path-mod #page-header .dropdown-item
{
padding: 0 1.5rem 0 1.5rem; /* default is padding:0.25rem 1.5rem; */
}
.path-course #page-header .dropdown-item a,
.path-mod #page-header .dropdown-item a
{
margin:0.25rem 0 0.25rem 0 ; /* default is none */
}
/* we also hide top leafes that are not link */
.path-course #page-header .dropdown-item span,
.path-mod #page-header .dropdown-item span
{
display:none;
}
/* we hide menu elements we want  */
.path-course #page-header .dropdown-item .course-view,
.path-course #page-header .dropdown-item .course-completion, 
.path-course #page-header .dropdown-item .enrol-editinstance, 
.path-course #page-header .dropdown-item .admin-roles-permissions, 
.path-course #page-header .dropdown-item .admin-roles-check, 
.path-course #page-header .dropdown-item .enrol-manual-unenrolself, 
.path-course #page-header .dropdown-item .enrol-self-unenrolself, 
.path-course #page-header .dropdown-item .enrol-otherusers, 
.path-course #page-header .dropdown-item .filter-manage, 
.path-course #page-header .dropdown-item .report-competency-index, 
.path-course #page-header .dropdown-item .report-editdates-index, 
.path-course #page-header .dropdown-item .report-log-index, 
.path-course #page-header .dropdown-item .report-loglive-index, 
.path-course #page-header .dropdown-item .report-outline-index, 
.path-course #page-header .dropdown-item .report-participation-index, 
.path-course #page-header .dropdown-item .report-writeup-index, 
.path-course #page-header .dropdown-item .badges-newbadge, 
.path-course #page-header .dropdown-item .backup-backup, 
.path-course #page-header .dropdown-item .backup-restorefile, 
.path-course #page-header .dropdown-item .question-category, 
.path-course #page-header .dropdown-item .question-import, 
.path-course #page-header .dropdown-item .question-export, 
.path-course #page-header .dropdown-item .local-purgequestioncategory-category
{
display:none !important;
}
/* the question bank link is dubbled and this is the trick to hide the second one */
.path-course #page-header .dropdown-menu .ml-4
{
margin-left:0 !important;
}
.path-course #page-header .dropdown-menu a.ml-4.question-edit
{
display:none !important;
}

/* we also hide some elements of the cog menu when on a specific ressource or activity */
.path-mod #page-header .dropdown-item .admin-roles-assign,
.path-mod #page-header .dropdown-item .admin-roles-permissions,
.path-mod #page-header .dropdown-item .admin-roles-check,
.path-mod #page-header .dropdown-item .filter-manage,
.path-mod #page-header .dropdown-item .report-competency-index,
.path-mod #page-header .dropdown-item .report-log-index,
.path-mod #page-header .dropdown-item .backup-backup,
.path-mod #page-header .dropdown-item .backup-restorefile,
.path-mod #page-header .dropdown-item .local-purgequestioncategory-category
{
display:none !important;
}

/* to make it elegant, we add icons to all shown elements of the cog menu */
/* for coherent presentation this icon is also used in the adminstration menu if more explicit */
.dropdown-item a.enrol-instances i::before,
{
    content: "\f090"; /* sign-in replaced by f2f6 (sign-in-alt) in  version 5 of Font Awesome */
    font-family: FontAwesome;
}
.path-course #page-header .dropdown-item a.badges-index i::before
{
    content: "\f0a3"; 
    font-family: FontAwesome;
}
/* .path-course #page-header plus joli partout */
.dropdown-item a.question-edit i::before
{
    content: "\f187"; 
    font-family: FontAwesome;
}
.path-course #page-header .dropdown-item a.report-roster-index i::before
{
    content: "\f030"; 
    font-family: FontAwesome;
}
.path-course #page-header .dropdown-item a.report-progress-index i::before
{
    content: "\f14a"; 
    font-family: FontAwesome;
}
.path-course #page-header .dropdown-item a.grade-edit-tree-index i::before
{
    content: "\f0ce"; 
    font-family: FontAwesome;
}

And here come the miracle !

Note we also also tested the tweak on adaptable theme.
Same modifications have to be done in the moodle/theme/adaptable/renderers.php file.
And the css is almost the same, except that the class ".path-course" has to be replaced by ".pagelayout-course" and "#page-header" has to be replaced by "#main-navbar".

Now I search a way to apply these changes without tweaking the core functions while developping a local plugin.
I submitted the adding of the class in the Moodle core :
https://tracker.moodle.org/browse/MDL-66494

I think it is a good way to open the possibility of building a plugin for cog menu customization trough interface.
There should be a checkbox to enable cog menu customization and a field to list the classes associated to blocks to hide.
It would be great for a first version ...

Thanks in advance for feedback ;-*

Zabelle



Average of ratings: Useful (1)
In reply to Zabelle Motte

Re: Present all course actions in Boost course dropdown action menu

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hi,

As far as I know, the only place you can place your changes outside core is by overriding function in your theme's core_renderer file.
Here, the cog menu is not very popular, that is why we borrowed the "settingsincoursepage" feature of boost_campus theme where users are presented with a much clearer tabbed admin menu.
In reply to Jean-Roch Meurisse

Re: Present all course actions in Boost course dropdown action menu

by Zabelle Motte -
Picture of Particularly helpful Moodlers
So you mean the best way to proceed would be to derive a child theme of Adaptable or Boost that overrides the render functions ?
I find it would be great fot the cog menu to have de mostly used actions.
And I think removing some permissions do not solve the problem because in some cases, teachers need this advanced settings but not often.
I understand your position using the Fordson presentation but it would be great for this menu of the theme to support the additionnal plugin actions ...

Thanks for your advises ;-*

Zabelle
In reply to Zabelle Motte

Re: Present all course actions in Boost course dropdown action menu

by Jean-Roch Meurisse -
Picture of Core developers Picture of Plugin developers Picture of Testers
Yes you should implement that in your theme since renderer methods can only be overridden in themes (as far as I know)
As for the admin menu, we do not use Fordson's which I think is designed sowewhat manually, we use Boost Campus one which supports additional plugins natively (look at my first screenshot in my first reply to this post and you will see that Cobra is in the menu wink
Cheers
In reply to Jean-Roch Meurisse

Re: Present all course actions in Boost course dropdown action menu

by Zabelle Motte -
Picture of Particularly helpful Moodlers

I tested Boost Campus yesterday and didnot see the parameter showsettingsincourse in Course Layout Settings tab.
That is an interresting approach that presents the whole admin menu in the gear icon.
It is a bit suprising to have the tab height that changes depending on the content, but that is efficient.

Great thanks JR for this suggestion ;-*

Zabelle

In reply to Zabelle Motte

Re: Present all course actions in Boost course dropdown action menu

by Terry Aulenbach -
This is great! I've been working with it for 3.8 (a little bit of tweaking). Do you know how to add the "More" option back in though? Since we are limiting which options show up, we really need people to be able to access the other options. I'm also trying to figure out how to hide some of the Quiz menu options while having others show up. That was really why I looked at this in the first place.

Thanks!

Terry
In reply to Terry Aulenbach

Re: Present all course actions in Boost course dropdown action menu

by Terry Aulenbach -
Well, I got stubborn and figured it out. There's an if statement that makes "More..." only show if you aren't displaying the full list. I just took it out of the if. I also figured out the Quiz bit. This has been really helpful, Zabelle. Thanks again

Terry