Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-39296 scorm reports: Fix undefined variables in graphs report

  • Loading branch information...
commit 2c2544877d3b272be7c9f185eb7d11ecacad88e4 1 parent d298661
@ankitagarwal ankitagarwal authored
Showing with 12 additions and 21 deletions.
  1. +12 −21 mod/scorm/report/graphs/graph.php
View
33 mod/scorm/report/graphs/graph.php
@@ -46,26 +46,16 @@
// Group Check
if (empty($currentgroup)) {
- // all users who can attempt scoes
- if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', '', '', false)) {
- $nostudents = true;
- $allowedlist = '';
- } else {
- $allowedlist = array_keys($students);
- }
+ // All users who can attempt scoes.
+ $students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id' , '', '', '', '', '', false);
+ $allowedlist = empty($students) ? array() : array_keys($students);
} else {
- // all users who can attempt scoes and who are in the currently selected group
- if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', '', '', '', '', $currentgroup, '', false)) {
- $nostudents = true;
- $groupstudents = array();
- }
- $allowedlist = array_keys($groupstudents);
+ // All users who can attempt scoes and who are in the currently selected group.
+ $groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false);
+ $allowedlist = empty($students) ? array() : array_keys($groupstudents);
}
$params = array();
-list($usql, $params) = $DB->get_in_or_equal($allowedlist);
-$params[] = $scoid;
-
$bands = 11;
$bandwidth = 10;
@@ -76,10 +66,11 @@
$graphdata[$i] = 0;
}
-
-// Do this only if we have students to report
-if(!$nostudents) {
- // Construct the SQL
+// Do this only if we have students to report.
+if (!empty($allowedlist)) {
+ list($usql, $params) = $DB->get_in_or_equal($allowedlist);
+ $params[] = $scoid;
+ // Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('st.userid', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.userid AS userid, st.scormid AS scormid, st.attempt AS attempt, st.scoid AS scoid ';
$from = 'FROM {scorm_scoes_track} st ';
@@ -88,7 +79,7 @@
foreach ($attempts as $attempt) {
if ($trackdata = scorm_get_tracks($scoid, $attempt->userid, $attempt->attempt)) {
- if (isset($trackdata->$scorekey)) {
+ if (isset($trackdata->score_raw)) {
$score = $trackdata->score_raw;
if (empty($trackdata->score_min)) {
$minmark = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.