index.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * This is a one-line short description of the file
  4. *
  5. * You can have a rather longer description of the file as well,
  6. * if you like, and it can span multiple lines.
  7. *
  8. * @author Leônidas O. Brandão
  9. * @version v 0.1 2019/03/04
  10. * @package mod_nasatlx
  11. * @copyright 2014 LInE
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  13. */
  14. /// Replace nasatlx with the name of your module and remove this line
  15. require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
  16. require_once(dirname(__FILE__).'/lib.php');
  17. $id = required_param('id', PARAM_INT); // course
  18. $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
  19. require_course_login($course);
  20. add_to_log($course->id, 'nasatlx', 'view all', 'index.php?id='.$course->id, '');
  21. $coursecontext = context_course::instance($course->id);
  22. $PAGE->set_url('/mod/nasatlx/index.php', array('id' => $id));
  23. $PAGE->set_title(format_string($course->fullname));
  24. $PAGE->set_heading(format_string($course->fullname));
  25. $PAGE->set_context($coursecontext);
  26. echo $OUTPUT->header();
  27. if (! $nasatlxs = get_all_instances_in_course('nasatlx', $course)) {
  28. notice(get_string('nonasatlxs', 'nasatlx'), new moodle_url('/course/view.php', array('id' => $course->id)));
  29. }
  30. $table = new html_table();
  31. if ($course->format == 'weeks') {
  32. $table->head = array(get_string('week'), get_string('name'));
  33. $table->align = array('center', 'left');
  34. } else if ($course->format == 'topics') {
  35. $table->head = array(get_string('topic'), get_string('name'));
  36. $table->align = array('center', 'left', 'left', 'left');
  37. } else {
  38. $table->head = array(get_string('name'));
  39. $table->align = array('left', 'left', 'left');
  40. }
  41. foreach ($nasatlxs as $nasatlx) {
  42. if (!$nasatlx->visible) {
  43. $link = html_writer::link(
  44. new moodle_url('/mod/nasatlx.php', array('id' => $nasatlx->coursemodule)),
  45. format_string($nasatlx->name, true),
  46. array('class' => 'dimmed'));
  47. } else {
  48. $link = html_writer::link(
  49. new moodle_url('/mod/nasatlx.php', array('id' => $nasatlx->coursemodule)),
  50. format_string($nasatlx->name, true));
  51. }
  52. if ($course->format == 'weeks' or $course->format == 'topics') {
  53. $table->data[] = array($nasatlx->section, $link);
  54. } else {
  55. $table->data[] = array($link);
  56. }
  57. }
  58. echo $OUTPUT->heading(get_string('modulenameplural', 'nasatlx'), 2);
  59. echo html_writer::table($table);
  60. echo $OUTPUT->footer();