File PHP in moodledata, is it correct?

Re: File PHP in moodledata, is it correct?

by Davo Smith -
Number of replies: 2
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Gerard,

Moodledata is the location for all data files used by Moodle (e.g. uploaded files, temporary caches, downloaded translations, etc.).

Any PHP files that need to be executed should be located within the Moodle code directory, or one of the subdirectories (i.e. the same place you find config.php and the mod/, lib/, admin/, etc. subdirectories).

If you explain a bit more about what you are trying to do, then it might be possible to suggest the best place to put the file within the subdirectories there (there are a range of different plugin types - report plugins would probably be the first one to look at).

In reply to Davo Smith

Re: File PHP in moodledata, is it correct?

by Chetan Sharma -

Hi Davo,

I have built a quiz in php which stores result in a database. Can i upload that to moodle as a course resource. Will php work in this case?

In reply to Chetan Sharma

Re: File PHP in moodledata, is it correct?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Chetan - no. PHP files uploaded to a Moodle course (via the front end interface) are not allowed to execute on the server - this would be a major security risk otherwise (as executing PHP would allow a user to bypass any security restrictions at all).

You either need to convert this into a full Moodle plugin, or look at adjusting your quiz to follow the LTI standard, then use the LTI consumer plugin (standard in Moodle since 2.2) to connect to your quiz.