I'm working on a script that will create courses automatically based on a cron job, pulling data from our local database. The courses are pretty standard, and each has the following elements:
- A news forum
- An "Introduce Yourself" forum
- A class participation forum
- An open chat
The script works fine when I'm logged in as a site administrator in one tab of my browser and run the script in another. However, when the script runs on its own, I get the following error message:
Sorry, but you do not currently have permissions to update calendar event
during the chat creation function. Does this mean that the chat_add_instance() function accesses the calendar API at some point?
At any rate, I have two ideas for how to fix this:
- Rewrite the chat_add_instance() function so that it does not call the calendar API;
- Somehow log the script in as an admin user while it is running. This strikes me as pretty dangerous, though.
Would either of these options work? How would I go about implementing them?
We are currently using Moodle 2.3.2. This script worked fine in Moodle 1.9.3.