We would like to get information from the Moodle database (coursename, students enroled in specific courses, etc.) for our Room-Access-Control System.
What do we have to be aware of? Can we use the functions in $CFG/lib or even those in $CFG/course.
Does a dummy-php-file exist, where the needed function e.g. has_capability and other
musts for integrating already are listed? Or something like the Moodle-Programming course?
Hope someone can answer my questions!
If you don't get a response to this here then you might do better asking in the developer forum.
You are trying to go through Moodle to the database.
Why not just query the database directly?
Set up a user for the database that can access but not update the database, then use that account to access the information straight from the database.
Much less programming needed and gets rid of the moodle processing overhead.
I think it's easier for customizing to use Moodle functions instead of going directly on the database.
An example of a risk that springs to my mind are that if you execute an update query in the wrong way then you risk the integrity of the data stored in your databse. For example, deleting a user directly from the user table, or changing their ID without updating it in other related tables.
Always test, test and test some more! Never on your production server.
I just want to read tables and print some informations (categories,courses, students) out on a website! The user should select the category and course and just get the list of students in that course.
I wrote some php's using Moodle libraries, but e.g. can I use other Moodle functions as well? And is the has_capability function the only one I need to check out if the user has the permissions to read the tables? Sure just an admin is allowed to do so!
Thanks for answering!
Failing that, create a new script and just 'require' Moodle's config.php. That drags in all the standard libraries and APIs.
You can look at lib/dmllib.php for the database access functions or just have a sift through other code.
I posted my questions to the General developer forum as well.
A great mix of answers!
Could someone gather both of my "forum-answerlists" to the General developer forum?