Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37675

Re: API call or this-> function to find the current course section?

$
0
0
by Darko Miletić.  

This really depends where you are. If you are on the course main page you will have section parameter (or not) indicating you where you are:

$sectionno = optional_param('section', 0, PARAM_INT);

If you are in some activity you should get course_module data and read the value of section field.

$cm = get_coursemodule_from_id('<moduletype>', $id);

$sectionno = $cm->section;

and how to know where you are? check the current page URL.

global $ME;

// activity

stripos('/mod/', $ME) > 0;

// course

stripos('/course/view.php', $ME) > 0;

 etc.


Viewing all articles
Browse latest Browse all 37675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>