File: report.php

package info (click to toggle)
moodle 1.4.4.dfsg.1-3sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 57,876 kB
  • ctags: 29,496
  • sloc: php: 271,617; sql: 5,084; xml: 702; perl: 638; sh: 403; java: 283; makefile: 42; pascal: 21
file content (107 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?PHP  // $Id: report.php,v 1.25.2.1 2004/09/29 07:01:33 moodler Exp $

// This script uses installed report plugins to print quiz reports

    require_once("../../config.php");
    require_once("lib.php");

    optional_variable($id);    // Course Module ID, or
    optional_variable($q);     // quiz ID

    optional_variable($mode, "overview");        // Report mode

    if ($id) {
        if (! $cm = get_record("course_modules", "id", $id)) {
            error("Course Module ID was incorrect");
        }
    
        if (! $course = get_record("course", "id", $cm->course)) {
            error("Course is misconfigured");
        }
    
        if (! $quiz = get_record("quiz", "id", $cm->instance)) {
            error("Course module is incorrect");
        }

    } else {
        if (! $quiz = get_record("quiz", "id", $q)) {
            error("Course module is incorrect");
        }
        if (! $course = get_record("course", "id", $quiz->course)) {
            error("Course is misconfigured");
        }
        if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
            error("Course Module ID was incorrect");
        }
    }

    require_login($course->id);

    if (!isteacher($course->id)) {
        error("You are not allowed to use this script");
    }

    add_to_log($course->id, "quiz", "report", "report.php?id=$cm->id", "$quiz->id", "$cm->id");

/// Print the page header
    if (empty($noheader)) {
    
        $strquizzes = get_string("modulenameplural", "quiz");
        $strquiz  = get_string("modulename", "quiz");
        $strreport  = get_string("report", "quiz");
    
        print_header_simple("$quiz->name", "",
                     "<A HREF=index.php?id=$course->id>$strquizzes</A> 
                      -> <a href=\"view.php?id=$cm->id\">$quiz->name</a> -> $strreport", 
                     "", "", true, update_module_button($cm->id, $course->id, $strquiz), navmenu($course, $cm));
    
        print_heading($quiz->name);
    

    /// Print list of available quiz reports
    
        $allreports = get_list_of_plugins("mod/quiz/report");
        $reportlist = array ("overview", "regrade");   // Standard reports we want to show first

        foreach ($allreports as $report) {
            if (!in_array($report, $reportlist)) {
                $reportlist[] = $report;
            }
        }

        echo "<table cellpadding=10 align=center><tr>";
        foreach ($reportlist as $report) {
            $strreport = get_string("report$report", "quiz");
            if ($report == $mode) {
                echo "<td><u>$strreport</u></td>";
            } else {
                echo "<td><a href=\"report.php?id=$cm->id&mode=$report\">$strreport</a></td>";
            }
        }
        echo "</tr></table><hr size=\"1\" noshade=\"noshade\" />";
    }


/// Open the selected quiz report and display it

    $mode = clean_filename($mode);

    if (! is_readable("report/$mode/report.php")) {
        error("Report not known (".clean_text($mode).")");
    }

    include("report/default.php");  // Parent class
    include("report/$mode/report.php");

    $report = new quiz_report();

    if (! $report->display($quiz, $cm, $course)) {             // Run the report!
        error("Error occurred during pre-processing!");
    }

    if (empty($noheader)) {
        print_footer($course);
    }


?>