grade.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * This script contains all the stuff to display evaluate.
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leônidas O. Brandão
  7. * @version v 1.0 2010/12/21
  8. * @package mod_iassign
  9. * @since 2010/09/27
  10. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  11. *
  12. * <b>License</b>
  13. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  14. */
  15. require_once("../../config.php");
  16. // Recovery th ID of active user.
  17. $id = required_param('id', PARAM_INT); // Course module ID
  18. // Constrain the url for redirect user.
  19. $url = new moodle_url('/mod/iassign/view.php'); // novo
  20. if ($id) {
  21. if (!$cm = get_coursemodule_from_id('iassign', $id)) {
  22. print_error('invalidcoursemodule');
  23. }
  24. if (!$iassign = $DB->get_record("iassign", array("id" => $cm->instance))) {
  25. print_error('invalidid', 'iassign');
  26. }
  27. if (!$course = $DB->get_record("course", array("id" => $iassign->course))) {
  28. print_error('coursemisconf', 'iassign');
  29. }
  30. $url->param('id', $id);
  31. }
  32. else {
  33. if (!$iassign = $DB->get_record("iassign", array("id" => $a))) {
  34. print_error('invalidid', 'iassign');
  35. }
  36. if (!$course = $DB->get_record("course", array("id" => $iassign->course))) {
  37. print_error('coursemisconf', 'iassign');
  38. }
  39. if (!$cm = get_coursemodule_from_instance("iassign", $iassign->id, $course->id)) {
  40. print_error('invalidcoursemodule');
  41. }
  42. $url->param('a', $a);
  43. }
  44. $PAGE->set_url($url);
  45. require_login($course, true, $cm);
  46. $PAGE->set_title(format_string($iassign->name));
  47. $PAGE->set_heading($course->fullname);
  48. require_once ("$CFG->dirroot/mod/iassign/locallib.php");
  49. /// Get an instance of iassign.
  50. $iassigninstance = new iassign($iassign, $cm, $course);
  51. if (has_capability('mod/iassign:viewreport', context_module::instance($cm->id))) {
  52. $iassigninstance->action = 'report';
  53. $iassigninstance->stats();
  54. }
  55. elseif (has_capability('mod/iassign:submitiassign', context_module::instance($cm->id)))
  56. $iassigninstance->stats_students();
  57. else
  58. $iassigninstance->view();