Retrieving file for assignment submission

Retrieving file for assignment submission

by Bobby White -
Number of replies: 0

Could anybody help, not sure how to access the file for submissions, I tried something like this:


SELECT f.filename, s.id AS submissionid, s.assignment AS assignmentid, s.userid AS studentid, u.firstname, u.lastname, s.timecreated, s.timemodified, ast.onlinetext, asf.id AS fileid, asf.numfiles AS filecount, a.name AS assignmentname, c.id AS courseid, c.fullname AS coursename, u.email, u.id AS teacherid FROM mdl_assign_submission AS s LEFT JOIN mdl_assign_grades AS ag ON (s.assignment = ag.assignment AND s.userid = ag.userid) LEFT JOIN mdl_assignsubmission_onlinetext AS ast ON s.id = ast.submission LEFT JOIN mdl_assignsubmission_file AS asf ON s.id = asf.submission INNER JOIN mdl_assign AS a ON s.assignment = a.id INNER JOIN mdl_course AS c ON a.course = c.id INNER JOIN mdl_context AS ct ON c.id = ct.instanceid INNER JOIN mdl_role_assignments AS ra ON ct.id = ra.contextid INNER JOIN mdl_user AS u ON ra.userid = u.id INNER JOIN mdl_files AS f ON f.contextid = ct.id WHERE ag.id IS NULL AND s.status = 'submitted' AND ra.roleid = 3


This query works before I try to select the filename, and join mdl_files. But I need a way to retrieve the files associated with a submission.


I know you use this: $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());

To get the file using the file api, but once again I am not sure how to get the file information.

Average of ratings: -