Moodle quiz with audio : How to give path to the audio file using $CFG?

327 Views Asked by At

I am a developer working on my first moodle project. I have to create a quiz with audio question. I have checked the forums for the steps and about to try. But how to refer to an audio file ? How can i use $CFG to indicate the path for audio file ?

Please help. Moodle Version 2.8

1

There are 1 best solutions below

1
On BEST ANSWER

Is it a single hard-coded audio file in the Moodle code directory? If so $CFG->wwwroot.'/path/to/file'.

If it is a file that is uploaded as the question is created, then $CFG won't help, you need to use the Moodle Files API -https://docs.moodle.org/dev/File_API this can take a bit of getting used to, but is not so bad once you've got the hang of it.