has_capability Create Course ???

has_capability Create Course ???

by Chris Kenniburg -
Number of replies: 2
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hopefully a coding guru can help me out!

I have a function in a new theme and I want to make sure the user can create a course before displaying this icon:

https://github.com/kennibc/moodle-theme_fordson/blob/master/classes/output/core_renderer.php#L819

How would I go about getting this icon from the code to only show up if the user can create a course?

My main reason for asking is I want to add in an entirely new button that will appear if a user can create a course and it will take them to the course creation form.  

But for ease of hopefully getting an answer, just getting the existing button to only show if the user can create a course would be ideal.

Anyone care to take a look and share a bit of code so I can make this happen?

Thank you,

Chris

Average of ratings: -
In reply to Chris Kenniburg

Re: has_capability Create Course ???

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Actually nevermind.  $context = $this->page->context;  seems to allow me to make this work along with adding has_capability('moodle/course:create', $context).

My goal is to have a button appear that allows course creators to get right into creating a course from the homepage and only have it appear if that user has the capability to create a course.  Our users login via LDAP and any users in our teacher group are automatically added as course creators.

Average of ratings: Useful (1)
In reply to Chris Kenniburg

Re: has_capability Create Course ???

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Here is a video of the new button in action on a waiting to be approved theme - Fordson.


Scroll ahead to the 4 minute mark when I am talking about the Frontpage Icon Navigation bar.