Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3a19de6dd2
Fetching contributors…

Cannot retrieve contributors at this time

executable file 169 lines (157 sloc) 7.869 kb
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
<?php // $Id$

// 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($b); // SCO ID
    optional_variable($user); // User ID

    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 (! $scorm = get_record("scorm", "id", $cm->instance)) {
            error("Course module is incorrect");
        }
    } else if (isset($b)) {
        if (! $sco = get_record("scorm_scoes", "id", $b)) {
            error("Scorm activity is incorrect");
        }
        if (! $scorm = get_record("scorm", "id", $sco->scorm)) {
            error("Course module is incorrect");
        }
        if (! $course = get_record("course", "id", $scorm->course)) {
            error("Course is misconfigured");
        }
        if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
            error("Course Module ID was incorrect");
        }
    }

    require_login($course->id, false, $cm);

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

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

/// Print the page header
    if (empty($noheader)) {
        if ($course->category) {
            $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
} else {
$navigation = '';
}

$strscorms = get_string("modulenameplural", "scorm");
$strscorm = get_string("modulename", "scorm");
$strreport = get_string("report", "scorm");
$strname = get_string('name');
if (!empty($id)) {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
"", "", true);
} else {
print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
"$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
                      -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
              -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
"", "", true);
}
print_heading(format_string($scorm->name));
}

$scormpixdir = $CFG->modpixpath."/scorm/pix/";

if (!empty($id)) {
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) {
$table->head = array('&nbsp;', $strname);
$table->align = array('center', 'left');
$table->wrap = array('nowrap', 'nowrap');
$table->width = '100%';
$table->size = array(10, '*');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$table->head[]=scorm_string_round($sco->title);
$table->align[] = 'center';
$table->wrap[] = 'nowrap';
$table->size[] = '*';
}
}

foreach ($scousers as $scouser) {
if ($userdata = scorm_get_user_data($scouser->userid)) {
$row = '';
$row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true);
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a>";
foreach ($scoes as $sco) {
if ($sco->launch!='') {
$anchorstart = '';
$anchorend = '';
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
if ($trackdata->score_raw != '') {
$scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
} else {
$anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.
get_string('details','scorm').'">';
$anchorend = '</a>';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
$row[] = $anchorstart.'<img src="'.$scormpixdir.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
}
}
$table->data[] = $row;
}
}
print_table($table);
} else {
notice('No users to report');
}
}
} else {
if (!empty($user)) {
if ($userdata = scorm_get_user_data($user)) {
print_simple_box_start('center');
print_heading(format_string($sco->title));
echo '<div align="center">'."\n";
print_user_picture($user, $course->id, $userdata->picture, false, false);
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
"$userdata->firstname $userdata->lastname</a><br />";
$scoreview = '';
if ($trackdata = scorm_get_tracks($sco->id,$user)) {
if ($trackdata->score_raw != '') {
$scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
}
if ($trackdata->status == '') {
$trackdata->status = 'notattempted';
}
} else {
$trackdata->status = 'notattempted';
$trackdata->total_time = '';
}
$strstatus = get_string($trackdata->status,'scorm');
echo '<img src="'.$scormpixdir.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
$strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
echo '</div>'."\n";
foreach($trackdata as $element => $value) {
if (substr($element,0,3) == 'cmi') {
echo $element.' => '.$value.'<br />';
}
}
print_simple_box_end();
}
} else {
error('Missing script parameter');
}
}
if (empty($noheader)) {
print_footer($course);
}
?>
Something went wrong with that request. Please try again.