locallib.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace gradeimporter;
  3. class feedback {
  4. public static function get_comments() {
  5. global $DB, $USER;
  6. $sql = "
  7. SELECT gf.id,
  8. gf.grade,
  9. gf.comment,
  10. gs.name gs_name,
  11. gs.info gs_info,
  12. gst.name gst_name,
  13. gst.info gst_info,
  14. fileid
  15. FROM mdl_gradeimporter_feedback gf
  16. JOIN mdl_gradeimporter_submission gs
  17. ON gf.submissionid = gs.id
  18. JOIN mdl_gradeimporter_submissiontype gst
  19. ON gs.type = gst.id
  20. WHERE gf.studentid = ?";
  21. $comments = array();
  22. $records = $DB->get_records_sql($sql, array('studentid'=>$USER->id));
  23. $data = array();
  24. if (count($records)) {
  25. foreach ($records as $key => $value) {
  26. if (!array_key_exists($value->gst_name, $data)) $data[$value->gst_name] = array();
  27. $data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->fileid);
  28. }
  29. }
  30. return $data;
  31. }
  32. }
  33. //
  34. // INSERT INTO `mdl_gradeimporter_feedback` (`id`, `submissionid`, `studentid`, `grade`, `comment`, `fileid`, `usermodified`, `timecreated`, `timemodified`)
  35. // VALUES
  36. // (1, 10, 1, 10.00, 'ok muito bem', 100, 0, 0, 0);
  37. //