Explorar o código

lib com as consultas

Felipe-cavalieri %!s(int64=5) %!d(string=hai) anos
pai
achega
f25bd4181a
Modificáronse 1 ficheiros con 45 adicións e 0 borrados
  1. 45 0
      locallib.php

+ 45 - 0
locallib.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace gradeimporter;
+
+class feedback {
+    public static function get_comments() {
+        global $DB, $USER;
+
+        $sql = "
+        SELECT gf.id,
+               gf.grade,
+               gf.comment,
+               gs.name gs_name,
+               gs.info gs_info,
+               gst.name gst_name,
+               gst.info gst_info,
+               fileid
+          FROM mdl_gradeimporter_feedback gf
+          JOIN mdl_gradeimporter_submission gs
+            ON gf.submissionid = gs.id
+          JOIN mdl_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();
+
+              $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);
+//