1
0

view.php0 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. $mood_url = new moodle_url('/mod/iassign/view.php');
  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. $cm = get_coursemodule_from_id('iassign', $id);
  26. if (!$cm) { // Moodle function 'get_coursemodule_from_id(...)' returns the object from table '*_iassign_statement'
  27. print_error('invalidcoursemodule');
  28. }
  29. $iassign = $DB->get_record("iassign", array("id" => $cm->instance));
  30. if (!$iassign) { // 'course_modules.instance = iassign.id'
  31. print_error('invalidid', 'iassign');
  32. }
  33. $course = $DB->get_record("course", array("id" => $iassign->course));
  34. if (!$course) {
  35. print_error('coursemisconf', 'iassign');
  36. }
  37. $mood_url->param('id', $id);
  38. }
  39. else {
  40. $iassign = $DB->get_record("iassign", array("id" => $a));
  41. if (!$iassign) {
  42. print_error('invalidid', 'iassign');
  43. }
  44. $course = $DB->get_record("course", array("id" => $iassign->course));
  45. if (!$course) {
  46. print_error('coursemisconf', 'iassign');
  47. }
  48. $cm = get_coursemodule_from_instance("iassign", $iassign->id, $course->id);
  49. if (!$cm) {
  50. print_error('invalidcoursemodule');
  51. }
  52. $mood_url->param('a', $a);
  53. }
  54. $PAGE->set_url($mood_url);
  55. require_login($course, true, $cm);
  56. $PAGE->set_title(format_string($iassign->name));
  57. $PAGE->set_heading($course->fullname);
  58. // Mark viewed by user (if required)
  59. $completion = new completion_info($course);
  60. $completion->set_module_viewed($cm);
  61. // About each object
  62. // - $iassing :: object from table '*_iassign_statement'
  63. // - $cm :: object from table '*_course_modules'
  64. // - $course :: object from table '*_course_modules_completion'
  65. $write_solution = 1;
  66. //$iassigninstance = new iassign($iassign, $cm, $course, array('write_solution' => 1)); // locallib.php : class iassign : function __construct ($iassign, $cm, $course)
  67. $iassigninstance = new iassign($iassign, $cm, $course); // locallib.php : class iassign : function __construct ($iassign, $cm, $course)
  68. $iassigninstance->view(); // ./mod/iassign/locallib.php : actually who display the iAssign whose id is '$id'! (this function ignores parameters)