File: tabs.php

package info (click to toggle)
moodle 1.6.3-2%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,172 kB
  • ctags: 51,688
  • sloc: php: 231,916; sql: 5,631; xml: 2,688; sh: 1,185; perl: 638; makefile: 48; pascal: 36
file content (80 lines) | stat: -rw-r--r-- 3,469 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php  // $Id: tabs.php,v 1.1 2006/03/25 21:38:57 mark-nielsen Exp $
/**
* Sets up the tabs used by the lesson pages for teachers.
*
* This file was adapted from the mod/quiz/tabs.php
*
* @version $Id: tabs.php,v 1.1 2006/03/25 21:38:57 mark-nielsen Exp $
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
*/

/// This file to be included so we can assume config.php has already been included.

    if (empty($lesson)) {
        error('You cannot call this script in that way');
    }
    if (!isset($currenttab)) {
        $currenttab = '';
    }
    if (!isset($cm)) {
        $cm = get_coursemodule_from_instance('lesson', $lesson->id);
    }
    if (!isset($course)) {
        $course = get_record('course', 'id', $lesson->course);
    }

    $tabs     = array();
    $row      = array();
    $inactive = array();


/// user attempt count for reports link hover (completed attempts - much faster)
    $counts           = new stdClass;
    $counts->attempts = count_records('lesson_grades', 'lessonid', $lesson->id);
    $counts->student  = $course->student;

    $row[] = new tabobject('teacherview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('edit'), get_string('editlesson', 'lesson', format_string($lesson->name)));
    $row[] = new tabobject('navigation', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp;action=navigation", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)));
    $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports', 'lesson', $counts));
    if (isteacheredit($course->id)) {
        $row[] = new tabobject('essayview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp;action=essayview", get_string('manualgrading', 'lesson')); 
    }
    if ($lesson->highscores) {
        $row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp;action=highscores", get_string('highscores', 'lesson'));
    }

    $tabs[] = $row;

/// sub tabs for reports (overview and detail)
    if ($currenttab == 'reports' and isset($mode)) {
        $inactive[] = 'reports';
        $currenttab = $mode;
        
        $row    = array();
        $row[]  = new tabobject('view', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=view", get_string('overview', 'lesson'));
        $row[]  = new tabobject('detail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&amp;action=detail", get_string('detailedstats', 'lesson'));
        $tabs[] = $row;
    }
    
/// sub tabs for teacher view (collapsed and expanded aka full)
    if ($currenttab == 'teacherview') {
        // use user preferences to remember which edit mode the user has selected
        if (empty($mode)) {
            $mode = get_user_preferences('lesson_view', 'collapsed');
        } else {
            set_user_preference('lesson_view', $mode);
        }
        
        $inactive[] = 'teacherview';
        $currenttab = $mode;
        
        $row    = array();
        $row[]  = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp;action=teacherview&amp;mode=collapsed", get_string('collapsed', 'lesson'));
        $row[]  = new tabobject('full', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&amp=teacherview&amp;mode=full", get_string('full', 'lesson'));
        $tabs[] = $row;
    }

    print_tabs($tabs, $currenttab, $inactive);

?>