3 * Sets up the tabs used by the lesson pages for teachers.
5 * This file was adapted from the mod/quiz/tabs.php
8 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 /// This file to be included so we can assume config.php has already been included.
15 error('You cannot call this script in that way');
17 if (!isset($currenttab)) {
21 $cm = get_coursemodule_from_instance('lesson', $lesson->id
);
22 $context = get_context_instance(CONTEXT_MODULE
, $cm->id
);
24 if (!isset($course)) {
25 $course = get_record('course', 'id', $lesson->course
);
28 $tabs = $row = $inactive = $activated = array();
30 /// user attempt count for reports link hover (completed attempts - much faster)
31 $counts = new stdClass
;
32 $counts->attempts
= count_records('lesson_grades', 'lessonid', $lesson->id
);
33 $counts->student
= $course->student
;
35 $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
)));
36 $row[] = new tabobject('edit', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('edit', 'lesson'), get_string('edit', 'moodle', format_string($lesson->name
)));
37 $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports', 'lesson', $counts));
38 if (has_capability('mod/lesson:edit', $context)) {
39 $row[] = new tabobject('essay', "$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id", get_string('manualgrading', 'lesson'));
41 if ($lesson->highscores
) {
42 $row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id", get_string('highscores', 'lesson'));
48 switch ($currenttab) {
49 case 'reportoverview':
51 /// sub tabs for reports (overview and detail)
52 $inactive[] = 'reports';
53 $activated[] = 'reports';
56 $row[] = new tabobject('reportoverview', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&action=reportoverview", get_string('overview', 'lesson'));
57 $row[] = new tabobject('reportdetail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&action=reportdetail", get_string('detailedstats', 'lesson'));
63 /// sub tabs for edit view (collapsed and expanded aka full)
65 $activated[] = 'edit';
68 $row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=collapsed", get_string('collapsed', 'lesson'));
69 $row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=full", get_string('full', 'lesson'));
74 print_tabs($tabs, $currenttab, $inactive, $activated);