format.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Competence Graph
  18. *
  19. * Competence graph format allows the visualization of courses with competencies in a graph.
  20. * In the course structure, teacher associates activities to competencies. Each course module
  21. * can have restrictions between them, so a module is opened only when the student accomplish
  22. * its requirements. In student visualization, the structure of the course is presented as a
  23. * graph. In such graph, each node is a resource available to the student that can be handled.
  24. * Subgraphs in the main graph represent competences. As students can have different paths in
  25. * the course, the plugin registers all the steps that a student produces.
  26. *
  27. * @package course/format
  28. * @subpackage competencegraph
  29. * @version 0.1
  30. * @author Laboratório de Informática na Educação <http://www.usp.br/line>
  31. * @link http://www.usp.br/line/competencegraph
  32. * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  33. */
  34. defined('MOODLE_INTERNAL') || die();
  35. require_once($CFG->libdir . '/filelib.php');
  36. require_once($CFG->libdir . '/completionlib.php');
  37. if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
  38. $course->marker = $marker;
  39. course_set_marker($course->id, $marker);
  40. }
  41. $context = context_course::instance($course->id);
  42. // Retrieve course format option fields and add them to the $course object.
  43. $courseformat = course_get_format($course);
  44. $course = $courseformat->get_course();
  45. if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
  46. $course->marker = $marker;
  47. course_set_marker($course->id, $marker);
  48. }
  49. // Make sure all sections are created
  50. //course_create_sections_if_missing($course, range(0, $course->numsections));
  51. $renderer = $PAGE->get_renderer('format_competencegraph');
  52. $devicetype = core_useragent::get_device_type(); // In /lib/classes/useragent.php.
  53. if ($devicetype == "mobile") {
  54. $portable = 1;
  55. } else if ($devicetype == "tablet") {
  56. $portable = 2;
  57. } else {
  58. $portable = 0;
  59. }
  60. $renderer->set_portable($portable);
  61. if (!empty($displaysection)) {
  62. $renderer->print_single_section_page($course, null, null, null, null, $displaysection);
  63. } else {
  64. $tcsettings = $courseformat->get_settings();
  65. // Dynamically changing widths with language.
  66. /*if ($PAGE->user_is_editing()) {
  67. echo 'IS EDITING...';
  68. } else {
  69. echo 'NOT EDITING';
  70. }*/
  71. // If user is teacher or sup, display tabs:
  72. if (has_capability('moodle/course:update', $context)) {
  73. }
  74. $course->coursedisplay = null;
  75. if (optional_param('format', NULL, PARAM_TEXT)) {
  76. if (optional_param('format', NULL, PARAM_TEXT) == 'list') {
  77. $renderer->print_multiple_section_page($course, null, null, null, null);
  78. $SESSION->format = 'list';
  79. } elseif (optional_param('format', NULL, PARAM_TEXT) == 'graph') {
  80. $renderer->print_graph_teacher_view($course, null, null, null, null);
  81. $SESSION->format = 'graph';
  82. }
  83. } elseif (isset($SESSION->format)) {
  84. if ($SESSION->format == 'list') {
  85. $renderer->print_multiple_section_page($course, null, null, null, null);
  86. } elseif ($SESSION->format == 'graph') {
  87. $renderer->print_graph_teacher_view($course, null, null, null, null);
  88. }
  89. } else {
  90. $renderer->print_graph_teacher_view($course, null, null, null, null);
  91. }
  92. }
  93. $PAGE->requires->js('/course/format/competencegraph/format.js');