. require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); require_once(dirname(__FILE__) . '/lib.php'); require_once($CFG->libdir . '/filelib.php'); require_once('locallib.php'); require_once('libs/student_viewlib.php'); require_once('libs/teacher_viewlib.php'); global $DB; // Moodle variable to access data base // Get parameter passed through HTTP by Moodle $id = optional_param('id', 0, PARAM_INT); // Course_module ID. $g = optional_param('g', 0, PARAM_INT); // Gradeimporter instance ID, should be named as the first character of the module. $action = optional_param('action', 0, PARAM_INT); $fileid = optional_param('fileid', 0, PARAM_INT); // to download an specific file $filename = optional_param('filename', 'a', PARAM_TEXT); if ($id) { // is $id defined? if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) { // get object from table "coursemodule" error('Course Module ID was incorrect'); //TODO precisa internacionalizar } if (! $course = $DB->get_record('course', array('id' => $cm->course))) { // get object from table "course" error('Course is misconfigured'); //TODO precisa internacionalizar } if (! $gradeimporter = $DB->get_record('gradeimporter', array('id' => $cm->instance))) { error('Course module is incorrect'); //TODO precisa internacionalizar } } else if ($g) { if (! $gradeimporter = $DB->get_record('gradeimporter', array('id' => $g))) { error('Course module is incorrect'); //TODO precisa internacionalizar } if (! $course = $DB->get_record('course', array('id' => $gradeimporter->course))) { error('Course is misconfigured'); //TODO precisa internacionalizar } if (! $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id, $course->id)) { error('Course Module ID was incorrect'); //TODO precisa internacionalizar } } else { error('You must specify a course_module ID or an instance ID'); //TODO precisa internacionalizar } require_login($course, true, $cm); $context = context_module::instance($cm->id); if ($action == 1 && has_capability('mod/gradeimporter:view', $context)) { // Download feedback file. $fs = get_file_storage(); $file = $fs->get_file($context->id, 'mod_gradeimporter', 'gradeimporter_feedback', $fileid, '/', $filename); if ($file) { send_stored_file($file, 86400, 0, true); } } else if ($action == 2 && has_capability('mod/gradeimporter:edit', $context)) { // Download students csv with their id. exportCSV($context); } // Print the page header. $PAGE->set_cm($cm); $PAGE->set_url('/mod/gradeimporter/view.php', array('id' => $cm->id)); $PAGE->set_title(format_string($gradeimporter->name)); $PAGE->set_heading(format_string($course->fullname)); $PAGE->set_context($context); $output = $PAGE->get_renderer('mod_folder'); print $output->header(); $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name); print $output->heading($heading); // Button to add new submission. if (has_capability('mod/gradeimporter:edit', $context)) { $url = new moodle_url('/mod/gradeimporter/forms/submission/submission.php'); $newbutton = '
' . "\n"; print $newbutton; $url = new moodle_url("/mod/gradeimporter/view.php", array('id' => $id, 'cmid' => $cm->id, 'action' => 2)); $newbutton = '' . "\n"; print $newbutton; } // Table of this instance are bellow: students, grades and file require_once($CFG->libdir . '/tablelib.php'); require_once(dirname(__FILE__) . '/locallib.php'); if (has_capability('mod/gradeimporter:edit', $context)) { // Loads teacher view. // get_teacher_view($cm->id, $gradeimporter->id); $teacherview = new Teacherview($cm->id, $gradeimporter->id); $teachertable = $teacherview->make_table(); print $teachertable; } else { // Load student view // Query database to find student feedbacks $feedbacks = query_feedbacks($cm->id, $gradeimporter->id); make_feedback_table($feedbacks, $cm->id); } // Finishes the page! print $output->footer();