MDL-37516 Translate fieldnames on output only.
[moodle.git] / mod / lesson / tabs.php
blob548ad18e0544ee4b09b2b1b0eee0f22d6cf145f8
1 <?php
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.
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/>.
18 /**
19 * Sets up the tabs used by the lesson pages for teachers.
21 * This file was adapted from the mod/quiz/tabs.php
23 * @package mod
24 * @subpackage lesson
25 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
29 defined('MOODLE_INTERNAL') || die();
31 /// This file to be included so we can assume config.php has already been included.
32 global $DB;
33 if (empty($lesson)) {
34 print_error('cannotcallscript');
36 if (!isset($currenttab)) {
37 $currenttab = '';
39 if (!isset($cm)) {
40 $cm = get_coursemodule_from_instance('lesson', $lesson->id);
41 $context = context_module::instance($cm->id);
43 if (!isset($course)) {
44 $course = $DB->get_record('course', array('id' => $lesson->course));
47 $tabs = $row = $inactive = $activated = array();
49 /// user attempt count for reports link hover (completed attempts - much faster)
50 $attemptscount = $DB->count_records('lesson_grades', array('lessonid'=>$lesson->id));
52 $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)));
53 $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)));
54 $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports2', 'lesson', $attemptscount));
55 if (has_capability('mod/lesson:edit', $context)) {
56 $row[] = new tabobject('essay', "$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('manualgrading', 'lesson'));
58 if ($lesson->highscores) {
59 $row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id", get_string('highscores', 'lesson'));
62 $tabs[] = $row;
65 switch ($currenttab) {
66 case 'reportoverview':
67 case 'reportdetail':
68 /// sub tabs for reports (overview and detail)
69 $inactive[] = 'reports';
70 $activated[] = 'reports';
72 $row = array();
73 $row[] = new tabobject('reportoverview', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=reportoverview", get_string('overview', 'lesson'));
74 $row[] = new tabobject('reportdetail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=reportdetail", get_string('detailedstats', 'lesson'));
75 $tabs[] = $row;
76 break;
77 case 'collapsed':
78 case 'full':
79 case 'single':
80 /// sub tabs for edit view (collapsed and expanded aka full)
81 $inactive[] = 'edit';
82 $activated[] = 'edit';
84 $row = array();
85 $row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&amp;mode=collapsed", get_string('collapsed', 'lesson'));
86 $row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&amp;mode=full", get_string('full', 'lesson'));
87 $tabs[] = $row;
88 break;
91 print_tabs($tabs, $currenttab, $inactive, $activated);