index.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @package mod_nasatlx
  9. * @copyright 2014 LInE
  10. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  11. */
  12. /// Replace nasatlx with the name of your module and remove this line
  13. require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
  14. require_once(dirname(__FILE__).'/lib.php');
  15. $id = required_param('id', PARAM_INT); // course
  16. $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
  17. require_course_login($course);
  18. add_to_log($course->id, 'nasatlx', 'view all', 'index.php?id='.$course->id, '');
  19. $coursecontext = context_course::instance($course->id);
  20. $PAGE->set_url('/mod/nasatlx/index.php', array('id' => $id));
  21. $PAGE->set_title(format_string($course->fullname));
  22. $PAGE->set_heading(format_string($course->fullname));
  23. $PAGE->set_context($coursecontext);
  24. echo $OUTPUT->header();
  25. if (! $nasatlxs = get_all_instances_in_course('nasatlx', $course)) {
  26. notice(get_string('nonasatlxs', 'nasatlx'), new moodle_url('/course/view.php', array('id' => $course->id)));
  27. }
  28. $table = new html_table();
  29. if ($course->format == 'weeks') {
  30. $table->head = array(get_string('week'), get_string('name'));
  31. $table->align = array('center', 'left');
  32. } else if ($course->format == 'topics') {
  33. $table->head = array(get_string('topic'), get_string('name'));
  34. $table->align = array('center', 'left', 'left', 'left');
  35. } else {
  36. $table->head = array(get_string('name'));
  37. $table->align = array('left', 'left', 'left');
  38. }
  39. foreach ($nasatlxs as $nasatlx) {
  40. if (!$nasatlx->visible) {
  41. $link = html_writer::link(
  42. new moodle_url('/mod/nasatlx.php', array('id' => $nasatlx->coursemodule)),
  43. format_string($nasatlx->name, true),
  44. array('class' => 'dimmed'));
  45. } else {
  46. $link = html_writer::link(
  47. new moodle_url('/mod/nasatlx.php', array('id' => $nasatlx->coursemodule)),
  48. format_string($nasatlx->name, true));
  49. }
  50. if ($course->format == 'weeks' or $course->format == 'topics') {
  51. $table->data[] = array($nasatlx->section, $link);
  52. } else {
  53. $table->data[] = array($link);
  54. }
  55. }
  56. echo $OUTPUT->heading(get_string('modulenameplural', 'nasatlx'), 2);
  57. echo html_writer::table($table);
  58. echo $OUTPUT->footer();