locallib.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace gradeimporter;
  3. class feedback {
  4. public static function get_comments() {
  5. global $DB, $USER, $CFG;
  6. $tp = $CFG->prefix; // gets moodle tables prefix, not everyone uses mdl_
  7. $sql = "
  8. SELECT gf.id,
  9. gf.grade,
  10. gf.comment,
  11. gf.contextid,
  12. gf.name gf_name,
  13. gs.name gs_name,
  14. gs.description gs_description,
  15. gst.name gst_name,
  16. gst.description gst_description,
  17. fileid
  18. FROM ".$tp."gradeimporter_feedback gf
  19. JOIN ".$tp."gradeimporter_submission gs
  20. ON gf.submissionid = gs.id
  21. JOIN ".$tp."gradeimporter_submissiontype gst
  22. ON gs.type = gst.id
  23. WHERE gf.studentid = ?";
  24. $comments = array();
  25. $records = $DB->get_records_sql($sql, array('studentid'=>$USER->id));
  26. $data = array();
  27. if (count($records)) {
  28. foreach ($records as $key => $value) {
  29. if (!array_key_exists($value->gst_name, $data)) $data[$value->gst_name] = array();
  30. //$fileurl = moodle_url::make_pluginfile_url($value->gf_contextid, 'mod_gradeimporter', 'gradeimporter_feedback', $value->gf_submissionid, '/', $value->gf_filename, false);
  31. $data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->gf_name);
  32. //$data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->fileid);
  33. }
  34. }
  35. return $data;
  36. }
  37. }
  38. //
  39. // INSERT INTO `mdl_gradeimporter_feedback` (`id`, `submissionid`, `studentid`, `grade`, `comment`, `fileid`, `usermodified`, `timecreated`, `timemodified`)
  40. // VALUES
  41. // (1, 10, 1, 10.00, 'ok muito bem', 100, 0, 0, 0);
  42. //