index.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Form to display activities iAssign.
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leônidas O. Brandão
  7. * @version v 1.0 2012/10/14
  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. /**
  16. * Moodle core defines constant MOODLE_INTERNAL which shall be used to make sure that the script is included and not called directly.
  17. */
  18. if(!defined('MOODLE_INTERNAL')) {
  19. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  20. }
  21. require_once("../../config.php");
  22. require_once("lib.php");
  23. require_once($CFG->libdir . '/gradelib.php');
  24. $id = required_param('id', PARAM_INT); // course
  25. if(!$course = $DB->get_record('course', array('id' => $id))) {
  26. print_error('invalidcourseid');
  27. }
  28. require_course_login($course);
  29. $PAGE->set_pagelayout('incourse');
  30. add_to_log($course->id, "iassign", "view all", "index.php?id=$course->id", "");
  31. /// Get all required stringsia
  32. $striassigns = get_string("modulenameplural", "iassign");
  33. $striassign = get_string("modulename", "iassign");
  34. $PAGE->set_url('/mod/iassign/index.php', array('id' => $course->id));
  35. $PAGE->navbar->add($striassigns);
  36. $PAGE->set_title($striassign);
  37. $PAGE->set_heading($course->fullname);
  38. echo $OUTPUT->header();
  39. /// Get all the appropriate data
  40. if(!$ias = get_all_instances_in_course("iassign", $course)) {
  41. notice(get_string('thereareno', 'moodle', $striassigns), "../../course/view.php?id=$course->id");
  42. //notice("There are no ias", "../../course/view.php?id=$course->id");
  43. die;
  44. }
  45. /// Print the list of instances (your module will probably extend this)
  46. $timenow = time();
  47. $strname = get_string("name");
  48. $strweek = get_string("week");
  49. $strtopic = get_string("topic");
  50. $table = new html_table();
  51. if($course->format == "weeks") {
  52. $table->head = array($strweek, $strname);
  53. $table->align = array("center", "left");
  54. } else if($course->format == "topics") {
  55. $table->head = array($strtopic, $strname);
  56. $table->align = array("center", "left", "left", "left");
  57. } else {
  58. $table->head = array($strname);
  59. $table->align = array("left", "left", "left");
  60. }
  61. foreach ($ias as $iassign) {
  62. if(!$iassign->visible) {
  63. //Show dimmed if the mod is hidden
  64. $link = "<a class=\"dimmed\" href=\"view.php?id=$iassign->coursemodule\">$iassign->name</a>";
  65. } else {
  66. //Show normal if the mod is visible
  67. $link = "<a href=\"view.php?id=$iassign->coursemodule\">$iassign->name</a>";
  68. }
  69. if($course->format == "weeks" or $course->format == "topics") {
  70. $table->data[] = array($iassign->section, $link);
  71. } else {
  72. $table->data[] = array($link);
  73. }
  74. }
  75. echo "<br />";
  76. echo html_writer::table($table);
  77. /// Finish the page
  78. echo $OUTPUT->footer();