view.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * This php script contains all the stuff to display iAssign.
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leo^nidas O. Branda~o
  7. * @version v 1.0 2012/10/16
  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. require_once("lib.php");
  17. require_once($CFG->libdir . '/completionlib.php');
  18. require_once($CFG->libdir . '/plagiarismlib.php');
  19. //Parameters GET e POST (parâmetros GET e POST)
  20. $id = optional_param('id', 0, PARAM_INT); // Course Module ID
  21. $a = optional_param('a', 0, PARAM_INT); // iAssign instance id (from table 'iassign')
  22. $url = new moodle_url('/mod/iassign/view.php'); // novo
  23. if ($id) {
  24. // ./lib/datalib.php : function get_coursemodule_from_id($modulename, $cmid, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING): returns 'course_modules.*' and 'modules.name'
  25. if (!$cm = get_coursemodule_from_id('iassign', $id)) { // Moodle function 'get_coursemodule_from_id(...)' returns the object from table '
  26. print_error('invalidcoursemodule');
  27. }
  28. if (!$iassign = $DB->get_record("iassign", array("id" => $cm->instance))) { // 'course_modules.instance = iassign.id'
  29. print_error('invalidid', 'iassign');
  30. }
  31. if (!$course = $DB->get_record("course", array("id" => $iassign->course))) {
  32. print_error('coursemisconf', 'iassign');
  33. }
  34. $url->param('id', $id);
  35. } else {
  36. if (!$iassign = $DB->get_record("iassign", array("id" => $a))) {
  37. print_error('invalidid', 'iassign');
  38. }
  39. if (!$course = $DB->get_record("course", array("id" => $iassign->course))) {
  40. print_error('coursemisconf', 'iassign');
  41. }
  42. if (!$cm = get_coursemodule_from_instance("iassign", $iassign->id, $course->id)) {
  43. print_error('invalidcoursemodule');
  44. }
  45. $url->param('a', $a);
  46. }
  47. //print_r($url);
  48. $PAGE->set_url($url);
  49. require_login($course, true, $cm);
  50. $PAGE->set_title(format_string($iassign->name));
  51. $PAGE->set_heading($course->fullname);
  52. // Mark viewed by user (if required)
  53. $completion = new completion_info($course);
  54. $completion->set_module_viewed($cm);
  55. $write_solution = 1;
  56. $iassigninstance = new iassign($iassign, $cm, $course, array('write_solution' => 1));
  57. $iassigninstance->view(); // ./mod/iassign/locallib.php : actually who display the iAssign whose id is '$id'! (this function ignores parameters)