. function query_feedbacks($cmid, $gradeimporterid) { global $DB, $USER, $CFG; // Get moodle table prefix, usually 'mdl_' $tp = $CFG->prefix; // Build database query to fetch feedbacks for the student $query = " SELECT /* gst.name as typename, gst.id as typeid, gst.description as typedescription, */ gf.id as id, gs.name as submissionname, gs.id as submissionid, gf.grade as grade, gf.comment as comment, gf.name as filename, gs.description as submissiondescription, gs.position as position FROM {$tp}gradeimporter_feedback as gf JOIN {$tp}gradeimporter_submission as gs ON gf.submissionid = gs.id /* JOIN {$tp}gradeimporter_submissiontype as gst ON gs.type = gst.id */ WHERE gs.gradeimporterid = {$gradeimporterid} AND gf.studentid = {$USER->id} AND gs.visibility = 1 "; // Query database to find students feedbacks $records = $DB->get_records_sql($query); // Return query result return $records; } function make_feedback_table ($feedbacks, $cmid) { $table = new html_table(); $table->head = array(get_string('type', 'gradeimporter'), get_string('submission', 'gradeimporter'), get_string('grade', 'gradeimporter'), get_string('comment', 'gradeimporter'), get_string('file', 'gradeimporter') ); $table->aling = array('center', 'center', 'center', 'center', 'center'); if (count($feedbacks)) { // If feedbacks is not an empty list foreach ($feedbacks as $type => $feedback) { $rowvalues = array('type_name', $feedback->submissionname, $feedback->grade, $feedback->comment, get_file($feedback, $cmid) ); $row = new html_table_row($rowvalues); $table->data[] = $row; } } echo html_writer::table($table); } function get_file ($feedback, $cmid) { global $CFG; $fs = get_file_storage(); $context = context_module::instance($cmid); $url = moodle_url::make_pluginfile_url($context->id, 'mod_gradeimporter', 'submissionfiles', 0, "/", $feedback->filename, true ); // Return pluginfile url, will use function mod_gradeimporter_pluginfile at lib.php to serve the file return "$feedback->filename"; }