-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to hide activity block if user is not enrolled in sub-course #89
Comments
I am not a moodle dev (I am a php dev though), but I did work out that I could solve the issue by adding the below to lib.php
|
Hey @JomacInc - best way would be to fire through a pull request with the change - we'd need a setting somewhere to allow it to be enabled/disabled (some sites will want all courses to show.) - but that could be a site wide setting in the settings.php file rather than needing to set it inside each subcourse. Also we'd need that dynamic function to do some better caching - it's called in a bunch of places and so doing a db call (get_field) on each run is probably not ideal - take a look at some of the exisitng cm_info_dynamic functions in other modules and see if you can do the work without needing to run a db call to get teh $refcourse. - maybe even just getting the courseid from the cm_info might be better. |
Thanks @danmarsden - as mentioned, Moodle dev is above my paygrade at the moment - I just don't have the time/capacity to learn the in's and out's of mod creation. I was worried about caching because I assumed needing the current user would cause issues (or is caching user specific?). I'm hoping it can be a feature request to be added in properly by someone who knows how to do it. |
thanks @JomacInc - the code you've added above is pretty close Someone might notice this in the tracker and think "I need this too" and use your example and our discussion here to send through a PR. thanks again! |
Thanks @danmarsden , I adjust the subcourse_get_coursemodule_info function as below to include the refcourse id into customdata so I don't need to do a db call and updated my function to use it.
The only question now is, do I have to worry about my changes being wiped out by an update without my knowledge? |
Is there a way we can have the block only shown if the current user is actually enrolled in the sub-course?
We have a range of sub-courses under a master course, but students will be enrolled in some of them (user specific electives).
The text was updated successfully, but these errors were encountered: