id); return has_capability('moodle/course:update', $usercontext); } public static function get_comments() { global $DB, $USER, $CFG; $tp = $CFG->prefix; // gets moodle tables prefix, not everyone uses mdl_ $sql = " SELECT gf.id, gf.grade, gf.comment, gf.contextid, gf.name gf_name, gs.name gs_name, gs.description gs_description, gst.name gst_name, gst.description gst_description, fileid FROM ".$tp."gradeimporter_feedback gf JOIN ".$tp."gradeimporter_submission gs ON gf.submissionid = gs.id JOIN ".$tp."gradeimporter_submissiontype gst ON gs.type = gst.id WHERE gf.studentid = ?"; $comments = array(); $records = $DB->get_records_sql($sql, array('studentid'=>$USER->id)); $data = array(); if (count($records)) { foreach ($records as $key => $value) { if (!array_key_exists($value->gst_name, $data)) $data[$value->gst_name] = array(); //$fileurl = moodle_url::make_pluginfile_url($value->gf_contextid, 'mod_gradeimporter', 'gradeimporter_feedback', $value->gf_submissionid, '/', $value->gf_filename, false); $data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->gf_name); //$data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->fileid); } } return $data; } } // // INSERT INTO `mdl_gradeimporter_feedback` (`id`, `submissionid`, `studentid`, `grade`, `comment`, `fileid`, `usermodified`, `timecreated`, `timemodified`) // VALUES // (1, 10, 1, 10.00, 'ok muito bem', 100, 0, 0, 0); //