~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to mod/scorm/report/graphs/graph.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php');
29
29
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
30
30
 
31
 
$scoid = required_param('scoid', PARAM_INT);// sco ID
 
31
$scoid = required_param('scoid', PARAM_INT);// SCO ID.
32
32
 
33
 
$sco = $DB->get_record('scorm_scoes', array('id'=>$scoid), '*', MUST_EXIST);
34
 
$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm), '*', MUST_EXIST);
 
33
$sco = $DB->get_record('scorm_scoes', array('id' => $scoid), '*', MUST_EXIST);
 
34
$scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
35
35
$cm = get_coursemodule_from_instance('scorm', $scorm->id, 0, false, MUST_EXIST);
36
 
$course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST);
37
 
 
38
 
 
39
 
// Capability Checks
 
36
$course = $DB->get_record('course', array('id' => $scorm->course), '*', MUST_EXIST);
 
37
 
 
38
 
 
39
// Capability Checks.
40
40
require_login($course, false, $cm);
41
41
$contextmodule = context_module::instance($cm->id);
42
42
require_capability('mod/scorm:viewreport', $contextmodule);
43
43
 
44
 
// find out current groups mode
 
44
// Find out current groups mode.
45
45
$currentgroup = groups_get_activity_group($cm, true);
46
46
 
47
 
// Group Check
 
47
// Group Check.
48
48
if (empty($currentgroup)) {
49
49
    // All users who can attempt scoes.
50
50
    $students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id' , '', '', '', '', '', false);
95
95
                if (empty($range)) {
96
96
                    continue;
97
97
                }
98
 
                $percent = round((($score*100)/$range), 2);
99
 
                if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid]) || ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
 
98
                $percent = round((($score * 100) / $range), 2);
 
99
                if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid])
 
100
                        || ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
100
101
                    $usergrades[$attempt->userid] = $percent;
101
102
                }
102
103
                unset($percent);
103
104
            } else {
104
 
                // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO
 
105
                // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO.
105
106
                if (!isset($usergrades[$attempt->userid])) {
106
107
                    $usergrades[$attempt->userid] = '*';
107
108
                }
111
112
}
112
113
 
113
114
$bandlabels[] = get_string('invaliddata', 'scormreport_graphs');
114
 
for ($i = 1; $i <= $bands-1; $i++) {
 
115
for ($i = 1; $i <= $bands - 1; $i++) {
115
116
    $bandlabels[] = ($i - 1) * $bandwidth . ' - ' . $i * $bandwidth;
116
117
}
117
118
// Recording all users  who attempted the SCO,but resulting data was invalid.
119
120
    if ($userpercent === '*') {
120
121
        $graphdata[0]++;
121
122
    } else {
122
 
        $gradeband = floor($userpercent/10);
 
123
        $gradeband = floor($userpercent / 10);
123
124
        if ($gradeband != ($bands - 1)) {
124
125
            $gradeband++;
125
126
        }
135
136
$line->parameter['x_label_angle'] = 0;
136
137
$line->parameter['x_axis_angle'] = 60;
137
138
 
138
 
//following two lines seem to silence notice warnings from graphlib.php
 
139
// Following two lines seem to silence notice warnings from graphlib.php.
139
140
$line->y_tick_labels = null;
140
141
$line->offset_relation = null;
141
142
 
142
143
$line->parameter['bar_size'] = 1;
143
 
// don't forget to increase spacing so that graph doesn't become one big block of colour
 
144
// Don't forget to increase spacing so that graph doesn't become one big block of colour.
144
145
$line->parameter['bar_spacing'] = 10;
145
146
$line->x_data = $bandlabels;
146
147
 
155
156
$line->y_order = array('allusers');
156
157
 
157
158
$ymax = max($line->y_data['allusers']);
158
 
$line->parameter['y_min_left'] = 0;  // start at 0
 
159
$line->parameter['y_min_left'] = 0;  // Start at 0.
159
160
$line->parameter['y_max_left'] = $ymax;
160
161
$line->parameter['y_decimal_left'] = 0; // 2 decimal places for y axis.
161
162
 
162
 
//pick a sensible number of gridlines depending on max value on graph.
 
163
// Pick a sensible number of gridlines depending on max value on graph.
163
164
$gridlines = $ymax;
164
165
while ($gridlines >= 10) {
165
166
    if ($gridlines >= 50) {