|
@@ -1,76 +1,89 @@
|
|
<?php
|
|
<?php
|
|
- require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
|
|
|
- require_once(dirname(__FILE__).'/lib.php');
|
|
|
|
- require_once($CFG->libdir.'/filelib.php');
|
|
|
|
- require_once('locallib.php');
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- global $DB;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $id = optional_param('id', 0, PARAM_INT); // course_module ID, or
|
|
|
|
- $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);
|
|
|
|
- //$cmid = optional_param('cmid', 0, PARAM_INT);
|
|
|
|
- $id = optional_param('id', 0, PARAM_INT);
|
|
|
|
- $fileid = optional_param('fileid', 0, PARAM_INT);
|
|
|
|
- $filename = optional_param('filename', 'a', PARAM_TEXT);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if ($id) {
|
|
|
|
- if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) {
|
|
|
|
- error('Course Module ID was incorrect');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
|
|
|
|
- error('Course is misconfigured');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $cm->instance) ) ) {
|
|
|
|
- error('Course module is incorrect');
|
|
|
|
- }
|
|
|
|
|
|
+// 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/>.
|
|
|
|
+
|
|
|
|
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
|
|
|
+require_once(dirname(__FILE__).'/lib.php');
|
|
|
|
+require_once($CFG->libdir.'/filelib.php');
|
|
|
|
+require_once('locallib.php');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ global $DB;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $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);
|
|
|
|
+ // $cmid = optional_param('cmid', 0, PARAM_INT);
|
|
|
|
+ $id = optional_param('id', 0, PARAM_INT);
|
|
|
|
+ $fileid = optional_param('fileid', 0, PARAM_INT);
|
|
|
|
+ $filename = optional_param('filename', 'a', PARAM_TEXT);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if ($id) {
|
|
|
|
+ if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) {
|
|
|
|
+ error('Course Module ID was incorrect');
|
|
|
|
+ }
|
|
|
|
|
|
- } else if ($g) {
|
|
|
|
- if (! $gradeimporter = $DB->get_record('gradeimporter', array('id'=> $g)) ){
|
|
|
|
- error('Course module is incorrect');
|
|
|
|
- }
|
|
|
|
- if (! $course = $DB->get_record('course', array('id'=> $gradeimporter->course)) ) {
|
|
|
|
- error('Course is misconfigured');
|
|
|
|
- }
|
|
|
|
- if (! $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id, $course->id)) {
|
|
|
|
- error('Course Module ID was incorrect');
|
|
|
|
- }
|
|
|
|
|
|
+ if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
|
|
|
|
+ error('Course is misconfigured');
|
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
|
- error('You must specify a course_module ID or an instance ID');
|
|
|
|
|
|
+ if (! $gradeimporter = $DB->get_record('gradeimporter', array('id' => $cm->instance))) {
|
|
|
|
+ error('Course module is incorrect');
|
|
|
|
+ }
|
|
|
|
+} else if ($g) {
|
|
|
|
+ if (! $gradeimporter = $DB->get_record('gradeimporter', array('id' => $g))) {
|
|
|
|
+ error('Course module is incorrect');
|
|
|
|
+ }
|
|
|
|
+ if (! $course = $DB->get_record('course', array('id' => $gradeimporter->course))) {
|
|
|
|
+ error('Course is misconfigured');
|
|
|
|
+ }
|
|
|
|
+ if (! $cm = get_coursemodule_from_instance('gradeimporter', $gradeimporter->id, $course->id)) {
|
|
|
|
+ error('Course Module ID was incorrect');
|
|
}
|
|
}
|
|
|
|
+} else {
|
|
|
|
+ error('You must specify a course_module ID or an instance ID');
|
|
|
|
+}
|
|
|
|
|
|
- require_login($course, true, $cm);
|
|
|
|
|
|
+require_login($course, true, $cm);
|
|
|
|
|
|
- $context = context_module::instance($cm->id);
|
|
|
|
|
|
+$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){
|
|
|
|
|
|
+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);
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
+} 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);
|
|
|
|
|
|
+// 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');
|
|
$output = $PAGE->get_renderer('mod_folder');
|
|
echo $output->header();
|
|
echo $output->header();
|
|
@@ -80,80 +93,86 @@ $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name);
|
|
echo $output->heading($heading);
|
|
echo $output->heading($heading);
|
|
|
|
|
|
|
|
|
|
-//button to add new submission
|
|
|
|
|
|
+// Button to add new submission.
|
|
if (has_capability('mod/gradeimporter:edit', $context)) {
|
|
if (has_capability('mod/gradeimporter:edit', $context)) {
|
|
- $url = new moodle_url('/mod/gradeimporter/submission.php');
|
|
|
|
- $newbutton = '<form action="'. $url . '">'.
|
|
|
|
|
|
+ $url = new moodle_url('/mod/gradeimporter/submission.php');
|
|
|
|
+ $newbutton = '<form action="'. $url . '">'.
|
|
'<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
|
|
'<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
|
|
'<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
|
|
'<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
|
|
'<input type="hidden" name="page" value="0" />'.
|
|
'<input type="hidden" name="page" value="0" />'.
|
|
'<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
|
|
'<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
|
|
'</form>';
|
|
'</form>';
|
|
- echo $newbutton;
|
|
|
|
|
|
+ echo $newbutton;
|
|
|
|
|
|
- $url = new moodle_url("/mod/gradeimporter/view.php", array('id'=>$id, 'cmid'=>$cm->id, 'action'=>2));
|
|
|
|
- $newbutton = '<form action="'. $url . '">'.
|
|
|
|
|
|
+ $url = new moodle_url("/mod/gradeimporter/view.php", array('id' => $id, 'cmid' => $cm->id, 'action' => 2));
|
|
|
|
+ $newbutton = '<form action="'. $url . '">'.
|
|
'<input type="hidden" name="id" value="'. $id .'" />'.
|
|
'<input type="hidden" name="id" value="'. $id .'" />'.
|
|
'<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
|
|
'<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
|
|
'<input type="hidden" name="action" value="2" />'.
|
|
'<input type="hidden" name="action" value="2" />'.
|
|
'<input type="submit" Value="'.get_string('downloadconfigcsv', 'gradeimporter').'" />'.
|
|
'<input type="submit" Value="'.get_string('downloadconfigcsv', 'gradeimporter').'" />'.
|
|
'</form>';
|
|
'</form>';
|
|
- echo $newbutton;
|
|
|
|
|
|
+ echo $newbutton;
|
|
}
|
|
}
|
|
|
|
|
|
-//tabela com as notas vem aqui
|
|
|
|
|
|
+// Tabela com as notas vem aqui.
|
|
|
|
|
|
require_once($CFG->libdir . '/tablelib.php');
|
|
require_once($CFG->libdir . '/tablelib.php');
|
|
require_once(dirname(__FILE__).'/locallib.php');
|
|
require_once(dirname(__FILE__).'/locallib.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-if (has_capability('mod/gradeimporter:edit', $context)){
|
|
|
|
- //loads teacher view
|
|
|
|
-
|
|
|
|
- $enrolledusers = get_enrolled_users ($context, 'mod/gradeimporter:view', 0, 'u.id, u.firstname, u.lastname', 'u.firstname, u.lastname');
|
|
|
|
|
|
+if (has_capability('mod/gradeimporter:edit', $context)) {
|
|
|
|
+ // Loads teacher view.
|
|
|
|
+
|
|
|
|
+ $enrolledusers = get_enrolled_users($context, 'mod/gradeimporter:view', 0, 'u.id, u.firstname, u.lastname', 'u.firstname, u.lastname');
|
|
|
|
|
|
- get_teacher_view($cm->id, $gradeimporter->id, $enrolledusers);
|
|
|
|
-
|
|
|
|
|
|
+ get_teacher_view($cm->id, $gradeimporter->id, $enrolledusers);
|
|
} else {
|
|
} else {
|
|
- $data = get_comments($cm->id, $id);
|
|
|
|
-
|
|
|
|
- //loads student view
|
|
|
|
- $table = new html_table();
|
|
|
|
- $table->attributes['class'] = 'generaltable mod_index';
|
|
|
|
- $table->head = array (get_string('type', 'gradeimporter'), get_string('submission', 'gradeimporter'), get_string('grade', 'gradeimporter'), get_string('comment', 'gradeimporter'), get_string('file', 'gradeimporter'));
|
|
|
|
- $table->align = array ('center', 'center', 'center', 'center', 'center');
|
|
|
|
-
|
|
|
|
- if (count($data)) {
|
|
|
|
- $current = "";
|
|
|
|
- foreach ($data as $tipo => $cells) {
|
|
|
|
- if ($current != "" && $current != $tipo) {
|
|
|
|
- $row = new html_table_row();
|
|
|
|
- $cell = new html_table_cell();
|
|
|
|
- $cell->colspan = 5;
|
|
|
|
- $row->cells[] = $cell;
|
|
|
|
- $table->data[] = $row;
|
|
|
|
- }
|
|
|
|
- $current = $tipo;
|
|
|
|
-
|
|
|
|
- $row = new html_table_row();
|
|
|
|
- $cell = new html_table_cell($tipo);
|
|
|
|
- $cell->rowspan = count($cells)+1;
|
|
|
|
- $row->cells[] = $cell;
|
|
|
|
- $table->data[] = $row;
|
|
|
|
- foreach ($cells as $cell) {
|
|
|
|
- $row = new html_table_row();
|
|
|
|
- foreach ($cell as $value) {
|
|
|
|
- $cell = new html_table_cell($value);
|
|
|
|
- $row->cells[] = $cell;
|
|
|
|
|
|
+ $data = get_comments($cm->id, $id);
|
|
|
|
+
|
|
|
|
+ // Loads student view.
|
|
|
|
+ $table = new html_table();
|
|
|
|
+ $table->attributes['class'] = 'generaltable mod_index';
|
|
|
|
+ $table->head = array(get_string('type', 'gradeimporter'),
|
|
|
|
+ get_string('submission', 'gradeimporter'),
|
|
|
|
+ get_string('grade', 'gradeimporter'),
|
|
|
|
+ get_string('comment', 'gradeimporter'),
|
|
|
|
+ get_string('file', 'gradeimporter'));
|
|
|
|
+ $table->align = array('center', 'center', 'center', 'center', 'center');
|
|
|
|
+
|
|
|
|
+ if (count($data)) {
|
|
|
|
+ $current = "";
|
|
|
|
+ foreach ($data as $tipo => $cells) {
|
|
|
|
+ if ($current != "" && $current != $tipo) {
|
|
|
|
+ $row = new html_table_row();
|
|
|
|
+ $cell = new html_table_cell();
|
|
|
|
+ $cell->colspan = 5;
|
|
|
|
+ $row->cells[] = $cell;
|
|
|
|
+ $table->data[] = $row;
|
|
|
|
+ }
|
|
|
|
+ $current = $tipo;
|
|
|
|
+
|
|
|
|
+ $row = new html_table_row();
|
|
|
|
+ $cell = new html_table_cell($tipo);
|
|
|
|
+ $cell->rowspan = count($cells) + 1;
|
|
|
|
+ $row->cells[] = $cell;
|
|
|
|
+ $table->data[] = $row;
|
|
|
|
+ foreach ($cells as $cell) {
|
|
|
|
+ $row = new html_table_row();
|
|
|
|
+ foreach ($cell as $value) {
|
|
|
|
+ $cell = new html_table_cell($value);
|
|
|
|
+ $row->cells[] = $cell;
|
|
|
|
+ }
|
|
|
|
+ $table->data[] = $row;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- $table->data[] = $row;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- echo html_writer::table($table);
|
|
|
|
|
|
+ echo html_writer::table($table);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+$PAGE->requires->js_call_amd('mod_gradeimporter/helloworld', 'helloworld');
|
|
|
|
+$PAGE->requires->js_call_amd('mod_gradeimporter/hello', 'informal', array('marquinho'));
|
|
|
|
+
|
|
|
|
|
|
-/// Finish the page
|
|
|
|
-echo $output->footer();
|
|
|
|
|
|
+// Finishes the page!
|
|
|
|
+echo $output->footer();
|