Hi Paul,
Its not working very well. When I turn debug on, it shows the following:
Warning: copy(): The second argument to copy() function cannot be a directory in /var/www/dev/lib/filestorage/stored_file.php on line 479
Here is a bit of my code where I'm trying to copy the file:
$fs = get_file_storage();
$files = $fs->get_area_files($modulecontext->id, 'mod_peerassessment', 'attachment', $peerassessment_file->itemid, 'sortorder DESC, id ASC', false);
foreach ($files as $file) {
if (!file_exists($CFG->dataroot . '/peerassessments/' . $peerassessment->id . '/' . $student->id)) {
mkdir($CFG->dataroot . '/peerassessments/' . $peerassessment->id . '/' . $student->id);
}
if (($file->copy_content_to($CFG->dataroot . '/peerassessments/' . $peerassessment->id . '/' .$student->id))
) {
$path = '/' . $modulecontext->id . '/mod_peerassessment/attachment/' . $peerassessment_file->itemid . '/' . $filename;
$fullurl = moodle_url::make_file_url('/pluginfile.php', $path);
echo html_writer::link($fullurl, $filename, array('class' => 'studentfile'));