Merge branch 'MDL-42604-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
@@ -28,23 +28,23 @@ require_once($CFG->libdir . '/graphlib.php');
|
||||
require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php');
|
||||
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
||||
|
||||
$scoid = required_param('scoid', PARAM_INT);// sco ID
|
||||
$scoid = required_param('scoid', PARAM_INT);// SCO ID.
|
||||
|
||||
$sco = $DB->get_record('scorm_scoes', array('id'=>$scoid), '*', MUST_EXIST);
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$sco->scorm), '*', MUST_EXIST);
|
||||
$sco = $DB->get_record('scorm_scoes', array('id' => $scoid), '*', MUST_EXIST);
|
||||
$scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('scorm', $scorm->id, 0, false, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $scorm->course), '*', MUST_EXIST);
|
||||
|
||||
|
||||
// Capability Checks
|
||||
// Capability Checks.
|
||||
require_login($course, false, $cm);
|
||||
$contextmodule = context_module::instance($cm->id);
|
||||
require_capability('mod/scorm:viewreport', $contextmodule);
|
||||
|
||||
// find out current groups mode
|
||||
// Find out current groups mode.
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
|
||||
// Group Check
|
||||
// Group Check.
|
||||
if (empty($currentgroup)) {
|
||||
// All users who can attempt scoes.
|
||||
$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id' , '', '', '', '', '', false);
|
||||
@@ -95,13 +95,14 @@ if (!empty($allowedlist)) {
|
||||
if (empty($range)) {
|
||||
continue;
|
||||
}
|
||||
$percent = round((($score*100)/$range), 2);
|
||||
if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid]) || ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
|
||||
$percent = round((($score * 100) / $range), 2);
|
||||
if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid])
|
||||
|| ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
|
||||
$usergrades[$attempt->userid] = $percent;
|
||||
}
|
||||
unset($percent);
|
||||
} else {
|
||||
// User has made an attempt but either SCO was not able to record the score or something else is broken in SCO
|
||||
// User has made an attempt but either SCO was not able to record the score or something else is broken in SCO.
|
||||
if (!isset($usergrades[$attempt->userid])) {
|
||||
$usergrades[$attempt->userid] = '*';
|
||||
}
|
||||
@@ -111,7 +112,7 @@ if (!empty($allowedlist)) {
|
||||
}
|
||||
|
||||
$bandlabels[] = get_string('invaliddata', 'scormreport_graphs');
|
||||
for ($i = 1; $i <= $bands-1; $i++) {
|
||||
for ($i = 1; $i <= $bands - 1; $i++) {
|
||||
$bandlabels[] = ($i - 1) * $bandwidth . ' - ' . $i * $bandwidth;
|
||||
}
|
||||
// Recording all users who attempted the SCO,but resulting data was invalid.
|
||||
@@ -119,7 +120,7 @@ foreach ($usergrades as $userpercent) {
|
||||
if ($userpercent === '*') {
|
||||
$graphdata[0]++;
|
||||
} else {
|
||||
$gradeband = floor($userpercent/10);
|
||||
$gradeband = floor($userpercent / 10);
|
||||
if ($gradeband != ($bands - 1)) {
|
||||
$gradeband++;
|
||||
}
|
||||
@@ -135,12 +136,12 @@ $line->parameter['y_label_angle'] = 90;
|
||||
$line->parameter['x_label_angle'] = 0;
|
||||
$line->parameter['x_axis_angle'] = 60;
|
||||
|
||||
//following two lines seem to silence notice warnings from graphlib.php
|
||||
// Following two lines seem to silence notice warnings from graphlib.php.
|
||||
$line->y_tick_labels = null;
|
||||
$line->offset_relation = null;
|
||||
|
||||
$line->parameter['bar_size'] = 1;
|
||||
// don't forget to increase spacing so that graph doesn't become one big block of colour
|
||||
// Don't forget to increase spacing so that graph doesn't become one big block of colour.
|
||||
$line->parameter['bar_spacing'] = 10;
|
||||
$line->x_data = $bandlabels;
|
||||
|
||||
@@ -155,11 +156,11 @@ $line->y_data['allusers'] = $graphdata;
|
||||
$line->y_order = array('allusers');
|
||||
|
||||
$ymax = max($line->y_data['allusers']);
|
||||
$line->parameter['y_min_left'] = 0; // start at 0
|
||||
$line->parameter['y_min_left'] = 0; // Start at 0.
|
||||
$line->parameter['y_max_left'] = $ymax;
|
||||
$line->parameter['y_decimal_left'] = 0; // 2 decimal places for y axis.
|
||||
|
||||
//pick a sensible number of gridlines depending on max value on graph.
|
||||
// Pick a sensible number of gridlines depending on max value on graph.
|
||||
$gridlines = $ymax;
|
||||
while ($gridlines >= 10) {
|
||||
if ($gridlines >= 50) {
|
||||
@@ -168,7 +169,7 @@ while ($gridlines >= 10) {
|
||||
$gridlines /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
$line->parameter['y_axis_gridlines'] = $gridlines + 1;
|
||||
$gridlines = max(2, ($gridlines + 1)); // We need a minimum of two lines.
|
||||
$line->parameter['y_axis_gridlines'] = $gridlines;
|
||||
|
||||
$line->draw();
|
||||
|
||||
Reference in New Issue
Block a user