| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | 
							- <?php
 
- // This file is part of
 
- //
 
- // Moodle is free software: you can redistribute it and/or modify
 
- // it under the terms of the GNU General Public License as published by
 
- // the Free Software Foundation, either version 3 of the License, or
 
- // (at your option) any later version.
 
- //
 
- // Moodle is distributed in the hope that it will be useful,
 
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
- // GNU General Public License for more details.
 
- //
 
- // You should have received a copy of the GNU General Public License
 
- // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
- defined('MOODLE_INTERNAL') || die();
 
- function get_comments($cmid, $id) {
 
-     global $DB, $USER, $CFG;
 
-     $tp = $CFG->prefix; // gets moodle tables prefix, not everyone uses mdl_
 
-     $sql = "
 
-           SELECT gf.id gf_id,
 
-                 gf.grade,
 
-                 gf.comment gf_comment,
 
-                 gf.contextid gf_contextid,
 
-                 gf.fileid gf_fileid,
 
-                 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 = ?";
 
-     $records = $DB->get_records_sql($sql, array('studentid' => $USER->id));
 
-     $data = array();
 
-     if (count($records)) {
 
-         foreach ($records as $value) {
 
-             if (!array_key_exists($value->gst_name, $data)) {
 
-                 $data[$value->gst_name] = array();
 
-             }
 
-             $fileurl = buildurl($cmid, $value->gf_id, $value->gf_name);
 
-             $data[$value->gst_name][] = array($value->gs_name, $value->grade, $value->gf_comment, $fileurl);
 
-         }
 
-     }
 
-     return $data;
 
- }
 
- require_once($CFG->libdir . '/filelib.php');
 
- require_once("$CFG->libdir/csvlib.class.php");
 
- function buildurl($cmid, $fileid, $filename) {
 
-     $fileurl = new moodle_url("/mod/gradeimporter/view.php", array('id' => $cmid, 'fileid' => $fileid, 'filename' => $filename, 'action' => 1));
 
-     return "<a href=$fileurl target=_blank> $filename</a>";
 
- }
 
- function editSub($subname, $gradeimporterid, $cmid, $subid) {
 
-     $url = new moodle_url("/mod/gradeimporter/submission.php", array('id' => $gradeimporterid,
 
-                                                                     'cmid' => $cmid,
 
-                                                                     'subid' => $subid,
 
-                                                                     'update' => 1
 
-                                                                   )
 
-                            );
 
-     return $subname.'<a href='.$url.' target="_blank"><i class="icon fa fa-pencil fa-fw"  title="'
 
-                         .get_string('editSub', 'gradeimporter')
 
-                         .'" aria-label="'
 
-                         .get_string('editSub', 'gradeimporter').'"></i>';
 
- }
 
- function exportCSV($context) {
 
-     $enrolledusers = get_enrolled_users($context, 'mod/gradeimporter:student');
 
-     $header = array('id', 'name', 'email', 'grade', 'comment', 'file');
 
-     $csvexport = new csv_export_writer();
 
-     $csvexport->set_filename('config');
 
-     $csvexport->add_data($header);
 
-     foreach ($enrolledusers as $value) {
 
-         $name = $value->firstname . ' ' . $value->lastname;
 
-         $studententry = array($value->id, $name, $value->email, '', '', '');
 
-         $csvexport->add_data($studententry);
 
-     }
 
-     $csvexport->download_file();
 
-     // $dlfile = $csvexporter->download_array('config', $data);
 
- }
 
 
  |