Explorar el Código

Update 'view.php'

Fixed redirect after inserted new GradeImport (Zip file).
Indentation adjusts
leo hace 2 años
padre
commit
9c979d2583
Se han modificado 1 ficheros con 69 adiciones y 66 borrados
  1. 69 66
      view.php

+ 69 - 66
view.php

@@ -1,5 +1,7 @@
 <?php
-// This file is part of
+// This file is part of LInE contributions to Free Education, Private Data
+// LInE (Laboratory of Informatics in Education)
+// www.usp.br/line
 //
 // Moodle is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -21,40 +23,40 @@ require_once('locallib.php');
 require_once('libs/student_viewlib.php');
 require_once('libs/teacher_viewlib.php');
 
-  global $DB;
+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);
-  $fileid     = optional_param('fileid', 0, PARAM_INT);
-  $filename   = optional_param('filename', 'a', PARAM_TEXT);
+$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);
+$filename   = optional_param('filename', 'a', PARAM_TEXT);
 
 
 
 if ($id) {
-    if (! $cm = get_coursemodule_from_id('gradeimporter', $id)) {
-        error('Course Module ID was incorrect');
-    }
+  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 (! $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');
-    }
+  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');
-    }
+  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');
+  error('You must specify a course_module ID or an instance ID');
 }
 
 require_login($course, true, $cm);
@@ -64,15 +66,15 @@ $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);
-    }
+  // 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);
+  // Download students csv with their id.
+  exportCSV($context);
 }
 
 
@@ -84,32 +86,32 @@ $PAGE->set_heading(format_string($course->fullname));
 $PAGE->set_context($context);
 
 $output = $PAGE->get_renderer('mod_folder');
-echo $output->header();
+print $output->header();
 
 $heading = get_string('displayingview', 'gradeimporter', $gradeimporter->name);
 
-echo $output->heading($heading);
+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 = '<form action="'. $url . '">'.
-          '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
-          '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
-          '<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
-          '</form>';
-    echo $newbutton;
-
-    $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="cmid" value="'.$cm->id.'" />'.
-        '<input type="hidden" name="action" value="2" />'.
-        '<input type="submit" Value="'.get_string('downloadconfigcsv', 'gradeimporter').'" />'.
-        '</form>';
-    echo $newbutton;
-}
+  $url = new moodle_url('/mod/gradeimporter/forms/submission/submission.php');
+  $newbutton = '<form action="'. $url . '">' . "\n" .
+    '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />' . "\n" .
+    '<input type="hidden" name="cmid" value="'.$cm->id.'" />' . "\n" .
+    '<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />' . "\n" .
+    '</form>' . "\n";
+  print $newbutton;
+
+  $url = new moodle_url("/mod/gradeimporter/view.php", array('id' => $id, 'cmid' => $cm->id, 'action' => 2));
+  $newbutton = '<form action="'. $url . '">'. "\n" .
+    '<input type="hidden" name="id" value="'. $id .'" />' . "\n" .
+    '<input type="hidden" name="cmid" value="'.$cm->id.'" />' . "\n" .
+    '<input type="hidden" name="action" value="2" />' . "\n" .
+    '<input type="submit" Value="' . get_string('downloadconfigcsv', 'gradeimporter') . '" />' . "\n" .
+    '</form>' . "\n";
+  print $newbutton;
+  }
 
 // Tabela com as notas vem aqui.
 
@@ -117,18 +119,19 @@ 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();
-    echo $teachertable;
-} else {
-    // Load student view
-
-    // Query database to find student feedbacks
-    $feedbacks = query_feedbacks($cm->id, $gradeimporter->id);
-    make_feedback_table($feedbacks, $cm->id);
-}
+  // 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!
-echo $output->footer();
+print $output->footer();