Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19  * Sets up the tabs used by the lesson pages for teachers.
  20  *
  21  * This file was adapted from the mod/quiz/tabs.php
  22  *
  23   * @package mod_lesson
  24   * @copyright  1999 onwards Martin Dougiamas  {@link http://moodle.com}
  25   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
  26  */
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /// This file to be included so we can assume config.php has already been included.
  31  global $DB;
  32  if (empty($lesson)) {
  33      print_error('cannotcallscript');
  34  }
  35  if (!isset($currenttab)) {
  36      $currenttab = '';
  37  }
  38  if (!isset($cm)) {
  39      $cm = get_coursemodule_from_instance('lesson', $lesson->id);
  40      $context = context_module::instance($cm->id);
  41  }
  42  if (!isset($course)) {
  43      $course = $DB->get_record('course', array('id' => $lesson->course));
  44  }
  45  
  46  $tabs = $row = $inactive = $activated = array();
  47  
  48  /// user attempt count for reports link hover (completed attempts - much faster)
  49  $attemptscount = $DB->count_records('lesson_grades', array('lessonid'=>$lesson->id));
  50  
  51  $row[] = new tabobject('view', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)));
  52  $row[] = new tabobject('edit', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('edit', 'lesson'), get_string('edita', 'moodle', format_string($lesson->name)));
  53  if (has_capability('mod/lesson:viewreports', $context)) {
  54      $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'),
  55              get_string('viewreports2', 'lesson', $attemptscount));
  56  }
  57  if (has_capability('mod/lesson:grade', $context)) {
  58      $row[] = new tabobject('essay', "$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('manualgrading', 'lesson'));
  59  }
  60  
  61  $tabs[] = $row;
  62  
  63  
  64  switch ($currenttab) {
  65      case 'reportoverview':
  66      case 'reportdetail':
  67      /// sub tabs for reports (overview and detail)
  68          $inactive[] = 'reports';
  69          $activated[] = 'reports';
  70  
  71          $row    = array();
  72          $row[]  = new tabobject('reportoverview', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=reportoverview", get_string('overview', 'lesson'));
  73          $row[]  = new tabobject('reportdetail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=reportdetail", get_string('detailedstats', 'lesson'));
  74          $tabs[] = $row;
  75          break;
  76      case 'collapsed':
  77      case 'full':
  78      case 'single':
  79      /// sub tabs for edit view (collapsed and expanded aka full)
  80          $inactive[] = 'edit';
  81          $activated[] = 'edit';
  82  
  83          $row    = array();
  84          $row[]  = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&amp;mode=collapsed", get_string('collapsed', 'lesson'));
  85          $row[]  = new tabobject('full', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&amp;mode=full", get_string('full', 'lesson'));
  86          $tabs[] = $row;
  87          break;
  88  }
  89  
  90  print_tabs($tabs, $currenttab, $inactive, $activated);