From 7d5564d959d33b1b00d585513200496bbc68b63f Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 24 Jan 2017 11:03:42 +0100 Subject: [PATCH] MDL-57754 mod_lesson: Move overview report code to function Move the table and statistics generation to a new function --- mod/lesson/locallib.php | 335 +++++++++++++++++++++++++++++++++++++++++++++ mod/lesson/report.php | 350 ++++-------------------------------------------- 2 files changed, 362 insertions(+), 323 deletions(-) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 1bfaf096c10..1a1f6e630ae 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -675,6 +675,341 @@ function lesson_process_group_deleted_in_course($courseid, $groupid = null) { } /** + * Return the overview report table and data. + * + * @param lesson $lesson lesson instance + * @param mixed $currentgroup false if not group used, 0 for all groups, group id (int) to filter by that groups + * @return mixed false if there is no information otherwise html_table and stdClass with the table and data + * @since Moodle 3.3 + */ +function lesson_get_overview_report_table_and_data(lesson $lesson, $currentgroup) { + global $DB; + + $context = $lesson->context; + $cm = $lesson->cm; + // Count the number of branch and question pages in this lesson. + $branchcount = $DB->count_records('lesson_pages', array('lessonid' => $lesson->id, 'qtype' => LESSON_PAGE_BRANCHTABLE)); + $questioncount = ($DB->count_records('lesson_pages', array('lessonid' => $lesson->id)) - $branchcount); + + // Only load students if there attempts for this lesson. + $attempts = $DB->record_exists('lesson_attempts', array('lessonid' => $lesson->id)); + $branches = $DB->record_exists('lesson_branch', array('lessonid' => $lesson->id)); + $timer = $DB->record_exists('lesson_timer', array('lessonid' => $lesson->id)); + if ($attempts or $branches or $timer) { + list($esql, $params) = get_enrolled_sql($context, '', $currentgroup, true); + list($sort, $sortparams) = users_order_by_sql('u'); + + $params['a1lessonid'] = $lesson->id; + $params['b1lessonid'] = $lesson->id; + $params['c1lessonid'] = $lesson->id; + $ufields = user_picture::fields('u'); + $sql = "SELECT DISTINCT $ufields + FROM {user} u + JOIN ( + SELECT userid, lessonid FROM {lesson_attempts} a1 + WHERE a1.lessonid = :a1lessonid + UNION + SELECT userid, lessonid FROM {lesson_branch} b1 + WHERE b1.lessonid = :b1lessonid + UNION + SELECT userid, lessonid FROM {lesson_timer} c1 + WHERE c1.lessonid = :c1lessonid + ) a ON u.id = a.userid + JOIN ($esql) ue ON ue.id = a.userid + ORDER BY $sort"; + + $students = $DB->get_recordset_sql($sql, $params); + if (!$students->valid()) { + $students->close(); + return array(false, false); + } + } else { + return array(false, false); + } + + if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) { + $grades = array(); + } + + if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) { + $times = array(); + } + + // Build an array for output. + $studentdata = array(); + + $attempts = $DB->get_recordset('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen'); + foreach ($attempts as $attempt) { + // if the user is not in the array or if the retry number is not in the sub array, add the data for that try. + if (empty($studentdata[$attempt->userid]) || empty($studentdata[$attempt->userid][$attempt->retry])) { + // restore/setup defaults + $n = 0; + $timestart = 0; + $timeend = 0; + $usergrade = null; + $eol = false; + + // search for the grade record for this try. if not there, the nulls defined above will be used. + foreach($grades as $grade) { + // check to see if the grade matches the correct user + if ($grade->userid == $attempt->userid) { + // see if n is = to the retry + if ($n == $attempt->retry) { + // get grade info + $usergrade = round($grade->grade, 2); // round it here so we only have to do it once + break; + } + $n++; // if not equal, then increment n + } + } + $n = 0; + // search for the time record for this try. if not there, the nulls defined above will be used. + foreach($times as $time) { + // check to see if the grade matches the correct user + if ($time->userid == $attempt->userid) { + // see if n is = to the retry + if ($n == $attempt->retry) { + // get grade info + $timeend = $time->lessontime; + $timestart = $time->starttime; + $eol = $time->completed; + break; + } + $n++; // if not equal, then increment n + } + } + + // build up the array. + // this array represents each student and all of their tries at the lesson + $studentdata[$attempt->userid][$attempt->retry] = array( "timestart" => $timestart, + "timeend" => $timeend, + "grade" => $usergrade, + "end" => $eol, + "try" => $attempt->retry, + "userid" => $attempt->userid); + } + } + $attempts->close(); + + $branches = $DB->get_recordset('lesson_branch', array('lessonid' => $lesson->id), 'timeseen'); + foreach ($branches as $branch) { + // If the user is not in the array or if the retry number is not in the sub array, add the data for that try. + if (empty($studentdata[$branch->userid]) || empty($studentdata[$branch->userid][$branch->retry])) { + // Restore/setup defaults. + $n = 0; + $timestart = 0; + $timeend = 0; + $usergrade = null; + $eol = false; + // Search for the time record for this try. if not there, the nulls defined above will be used. + foreach ($times as $time) { + // Check to see if the grade matches the correct user. + if ($time->userid == $branch->userid) { + // See if n is = to the retry. + if ($n == $branch->retry) { + // Get grade info. + $timeend = $time->lessontime; + $timestart = $time->starttime; + $eol = $time->completed; + break; + } + $n++; // If not equal, then increment n. + } + } + + // Build up the array. + // This array represents each student and all of their tries at the lesson. + $studentdata[$branch->userid][$branch->retry] = array( "timestart" => $timestart, + "timeend" => $timeend, + "grade" => $usergrade, + "end" => $eol, + "try" => $branch->retry, + "userid" => $branch->userid); + } + } + $branches->close(); + + // Need the same thing for timed entries that were not completed. + foreach ($times as $time) { + $endoflesson = $time->completed; + // If the time start is the same with another record then we shouldn't be adding another item to this array. + if (isset($studentdata[$time->userid])) { + $foundmatch = false; + $n = 0; + foreach ($studentdata[$time->userid] as $key => $value) { + if ($value['timestart'] == $time->starttime) { + // Don't add this to the array. + $foundmatch = true; + break; + } + } + $n = count($studentdata[$time->userid]) + 1; + if (!$foundmatch) { + // Add a record. + $studentdata[$time->userid][] = array( + "timestart" => $time->starttime, + "timeend" => $time->lessontime, + "grade" => null, + "end" => $endoflesson, + "try" => $n, + "userid" => $time->userid + ); + } + } else { + $studentdata[$time->userid][] = array( + "timestart" => $time->starttime, + "timeend" => $time->lessontime, + "grade" => null, + "end" => $endoflesson, + "try" => 0, + "userid" => $time->userid + ); + } + } + + // To store all the data to be returned by the function. + $data = new stdClass(); + + // Determine if lesson should have a score. + if ($branchcount > 0 AND $questioncount == 0) { + // This lesson only contains content pages and is not graded. + $data->lessonscored = false; + } else { + // This lesson is graded. + $data->lessonscored = true; + } + // set all the stats variables + $data->numofattempts = 0; + $data->avescore = 0; + $data->avetime = 0; + $data->highscore = null; + $data->lowscore = null; + $data->hightime = null; + $data->lowtime = null; + $data->students = array(); + + $table = new html_table(); + + // Set up the table object. + if ($data->lessonscored) { + $table->head = array(get_string('name'), get_string('attempts', 'lesson'), get_string('highscore', 'lesson')); + } else { + $table->head = array(get_string('name'), get_string('attempts', 'lesson')); + } + $table->align = array('center', 'left', 'left'); + $table->wrap = array('nowrap', 'nowrap', 'nowrap'); + $table->attributes['class'] = 'standardtable generaltable'; + $table->size = array(null, '70%', null); + + // print out the $studentdata array + // going through each student that has attempted the lesson, so, each student should have something to be displayed + foreach ($students as $student) { + // check to see if the student has attempts to print out + if (array_key_exists($student->id, $studentdata)) { + // set/reset some variables + $attempts = array(); + $dataforstudent = new stdClass; + $dataforstudent->attempts = array(); + // gather the data for each user attempt + $bestgrade = 0; + $bestgradefound = false; + // $tries holds all the tries/retries a student has done + $tries = $studentdata[$student->id]; + $studentname = fullname($student, true); + + foreach ($tries as $try) { + $dataforstudent->attempts[] = $try; + + // Start to build up the checkbox and link. + if (has_capability('mod/lesson:edit', $context)) { + $temp = ' '; + } else { + $temp = ''; + } + + $temp .= "id&action=reportdetail&userid=".$try['userid'] + .'&try='.$try['try'].'" class="lesson-attempt-link">'; + if ($try["grade"] !== null) { // if null then not done yet + // this is what the link does when the user has completed the try + $timetotake = $try["timeend"] - $try["timestart"]; + + $temp .= $try["grade"]."%"; + $bestgradefound = true; + if ($try["grade"] > $bestgrade) { + $bestgrade = $try["grade"]; + } + $temp .= " ".userdate($try["timestart"]); + $temp .= ", (".format_time($timetotake).")"; + } else { + if ($try["end"]) { + // User finished the lesson but has no grade. (Happens when there are only content pages). + $temp .= " ".userdate($try["timestart"]); + $timetotake = $try["timeend"] - $try["timestart"]; + $temp .= ", (".format_time($timetotake).")"; + } else { + // This is what the link does/looks like when the user has not completed the attempt. + $temp .= get_string("notcompleted", "lesson"); + if ($try['timestart'] !== 0) { + // Teacher previews do not track time spent. + $temp .= " ".userdate($try["timestart"]); + } + $temp .= ""; + $timetotake = null; + } + } + // build up the attempts array + $attempts[] = $temp; + + // Run these lines for the stats only if the user finnished the lesson. + if ($try["end"]) { + // User has completed the lesson. + $data->numofattempts++; + $data->avetime += $timetotake; + if ($timetotake > $data->hightime || $data->hightime == null) { + $data->hightime = $timetotake; + } + if ($timetotake < $data->lowtime || $data->lowtime == null) { + $data->lowtime = $timetotake; + } + if ($try["grade"] !== null) { + // The lesson was scored. + $data->avescore += $try["grade"]; + if ($try["grade"] > $data->highscore || $data->highscore === null) { + $data->highscore = $try["grade"]; + } + if ($try["grade"] < $data->lowscore || $data->lowscore === null) { + $data->lowscore = $try["grade"]; + } + + } + } + } + // get line breaks in after each attempt + $attempts = implode("
\n", $attempts); + + if ($data->lessonscored) { + // Add the grade if the lesson is graded. + $table->data[] = array($studentname, $attempts, $bestgrade . "%"); + } else { + // This lesson does not have a grade. + $table->data[] = array($studentname, $attempts); + } + // Add the student data. + $dataforstudent->id = $student->id; + $dataforstudent->fullname = $studentname; + $dataforstudent->bestgrade = $bestgrade; + $data->students[] = $dataforstudent; + } + } + $students->close(); + if ($data->numofattempts > 0) { + $data->avescore = $data->avescore / $data->numofattempts; + } + + return array($table, $data); +} + +/** * Abstract class that page type's MUST inherit from. * * This is the abstract class that ALL add page type forms must extend. diff --git a/mod/lesson/report.php b/mod/lesson/report.php index df158a58ffc..1aa2258beac 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -114,47 +114,10 @@ if ($action === 'delete') { this action is for default view and overview view **************************************************************************/ - // Count the number of branch and question pages in this lesson. - $branchcount = $DB->count_records('lesson_pages', array('lessonid' => $lesson->id, 'qtype' => LESSON_PAGE_BRANCHTABLE)); - $questioncount = ($DB->count_records('lesson_pages', array('lessonid' => $lesson->id)) - $branchcount); - - // Only load students if there attempts for this lesson. - $attempts = $DB->record_exists('lesson_attempts', array('lessonid' => $lesson->id)); - $branches = $DB->record_exists('lesson_branch', array('lessonid' => $lesson->id)); - $timer = $DB->record_exists('lesson_timer', array('lessonid' => $lesson->id)); - if ($attempts or $branches or $timer) { - list($esql, $params) = get_enrolled_sql($context, '', $currentgroup, true); - list($sort, $sortparams) = users_order_by_sql('u'); - - $params['a1lessonid'] = $lesson->id; - $params['b1lessonid'] = $lesson->id; - $params['c1lessonid'] = $lesson->id; - $ufields = user_picture::fields('u'); - $sql = "SELECT DISTINCT $ufields - FROM {user} u - JOIN ( - SELECT userid, lessonid FROM {lesson_attempts} a1 - WHERE a1.lessonid = :a1lessonid - UNION - SELECT userid, lessonid FROM {lesson_branch} b1 - WHERE b1.lessonid = :b1lessonid - UNION - SELECT userid, lessonid FROM {lesson_timer} c1 - WHERE c1.lessonid = :c1lessonid - ) a ON u.id = a.userid - JOIN ($esql) ue ON ue.id = a.userid - ORDER BY $sort"; - - $students = $DB->get_recordset_sql($sql, $params); - if (!$students->valid()) { - $students->close(); - $nothingtodisplay = true; - } - } else { - $nothingtodisplay = true; - } + // Get the table and data for build statistics. + list($table, $data) = lesson_get_overview_report_table_and_data($lesson, $currentgroup); - if ($nothingtodisplay) { + if ($table === false) { echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('nolessonattempts', 'lesson')); if (!empty($currentgroup)) { $groupname = groups_get_group_name($currentgroup); @@ -167,14 +130,6 @@ if ($action === 'delete') { exit(); } - if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) { - $grades = array(); - } - - if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) { - $times = array(); - } - echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('overview', 'lesson')); groups_print_activity_menu($cm, $url); @@ -185,266 +140,15 @@ if ($action === 'delete') { echo $OUTPUT->box($seeallgradeslink, 'allcoursegrades'); } - // Build an array for output. - $studentdata = array(); - - $attempts = $DB->get_recordset('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen'); - foreach ($attempts as $attempt) { - // if the user is not in the array or if the retry number is not in the sub array, add the data for that try. - if (empty($studentdata[$attempt->userid]) || empty($studentdata[$attempt->userid][$attempt->retry])) { - // restore/setup defaults - $n = 0; - $timestart = 0; - $timeend = 0; - $usergrade = null; - $eol = false; - - // search for the grade record for this try. if not there, the nulls defined above will be used. - foreach($grades as $grade) { - // check to see if the grade matches the correct user - if ($grade->userid == $attempt->userid) { - // see if n is = to the retry - if ($n == $attempt->retry) { - // get grade info - $usergrade = round($grade->grade, 2); // round it here so we only have to do it once - break; - } - $n++; // if not equal, then increment n - } - } - $n = 0; - // search for the time record for this try. if not there, the nulls defined above will be used. - foreach($times as $time) { - // check to see if the grade matches the correct user - if ($time->userid == $attempt->userid) { - // see if n is = to the retry - if ($n == $attempt->retry) { - // get grade info - $timeend = $time->lessontime; - $timestart = $time->starttime; - $eol = $time->completed; - break; - } - $n++; // if not equal, then increment n - } - } - - // build up the array. - // this array represents each student and all of their tries at the lesson - $studentdata[$attempt->userid][$attempt->retry] = array( "timestart" => $timestart, - "timeend" => $timeend, - "grade" => $usergrade, - "end" => $eol, - "try" => $attempt->retry, - "userid" => $attempt->userid); - } - } - $attempts->close(); - - $branches = $DB->get_recordset('lesson_branch', array('lessonid' => $lesson->id), 'timeseen'); - foreach ($branches as $branch) { - // If the user is not in the array or if the retry number is not in the sub array, add the data for that try. - if (empty($studentdata[$branch->userid]) || empty($studentdata[$branch->userid][$branch->retry])) { - // Restore/setup defaults. - $n = 0; - $timestart = 0; - $timeend = 0; - $usergrade = null; - $eol = false; - // Search for the time record for this try. if not there, the nulls defined above will be used. - foreach ($times as $time) { - // Check to see if the grade matches the correct user. - if ($time->userid == $branch->userid) { - // See if n is = to the retry. - if ($n == $branch->retry) { - // Get grade info. - $timeend = $time->lessontime; - $timestart = $time->starttime; - $eol = $time->completed; - break; - } - $n++; // If not equal, then increment n. - } - } - - // Build up the array. - // This array represents each student and all of their tries at the lesson. - $studentdata[$branch->userid][$branch->retry] = array( "timestart" => $timestart, - "timeend" => $timeend, - "grade" => $usergrade, - "end" => $eol, - "try" => $branch->retry, - "userid" => $branch->userid); - } - } - $branches->close(); - - // Need the same thing for timed entries that were not completed. - foreach ($times as $time) { - $endoflesson = $time->completed; - // If the time start is the same with another record then we shouldn't be adding another item to this array. - if (isset($studentdata[$time->userid])) { - $foundmatch = false; - $n = 0; - foreach ($studentdata[$time->userid] as $key => $value) { - if ($value['timestart'] == $time->starttime) { - // Don't add this to the array. - $foundmatch = true; - break; - } - } - $n = count($studentdata[$time->userid]) + 1; - if (!$foundmatch) { - // Add a record. - $studentdata[$time->userid][] = array( - "timestart" => $time->starttime, - "timeend" => $time->lessontime, - "grade" => null, - "end" => $endoflesson, - "try" => $n, - "userid" => $time->userid - ); - } - } else { - $studentdata[$time->userid][] = array( - "timestart" => $time->starttime, - "timeend" => $time->lessontime, - "grade" => null, - "end" => $endoflesson, - "try" => 0, - "userid" => $time->userid - ); - } - } - // Determine if lesson should have a score. - if ($branchcount > 0 AND $questioncount == 0) { - // This lesson only contains content pages and is not graded. - $lessonscored = false; - } else { - // This lesson is graded. - $lessonscored = true; - } - // set all the stats variables - $numofattempts = 0; - $avescore = 0; - $avetime = 0; - $highscore = null; - $lowscore = null; - $hightime = null; - $lowtime = null; - - $table = new html_table(); - - // Set up the table object. - if ($lessonscored) { - $table->head = array(get_string('name'), get_string('attempts', 'lesson'), get_string('highscore', 'lesson')); - } else { - $table->head = array(get_string('name'), get_string('attempts', 'lesson')); - } - $table->align = array('center', 'left', 'left'); - $table->wrap = array('nowrap', 'nowrap', 'nowrap'); - $table->attributes['class'] = 'standardtable generaltable'; - $table->size = array(null, '70%', null); - - // print out the $studentdata array - // going through each student that has attempted the lesson, so, each student should have something to be displayed - foreach ($students as $student) { - // check to see if the student has attempts to print out - if (array_key_exists($student->id, $studentdata)) { - // set/reset some variables - $attempts = array(); - // gather the data for each user attempt - $bestgrade = 0; - $bestgradefound = false; - // $tries holds all the tries/retries a student has done - $tries = $studentdata[$student->id]; - $studentname = fullname($student, true); - foreach ($tries as $try) { - // start to build up the checkbox and link - if (has_capability('mod/lesson:edit', $context)) { - $temp = ' '; - } else { - $temp = ''; - } - - $temp .= "id&action=reportdetail&userid=".$try['userid'] - .'&try='.$try['try'].'" class="lesson-attempt-link">'; - if ($try["grade"] !== null) { // if null then not done yet - // this is what the link does when the user has completed the try - $timetotake = $try["timeend"] - $try["timestart"]; - - $temp .= $try["grade"]."%"; - $bestgradefound = true; - if ($try["grade"] > $bestgrade) { - $bestgrade = $try["grade"]; - } - $temp .= " ".userdate($try["timestart"]); - $temp .= ", (".format_time($timetotake).")"; - } else { - if ($try["end"]) { - // User finished the lesson but has no grade. (Happens when there are only content pages). - $temp .= " ".userdate($try["timestart"]); - $timetotake = $try["timeend"] - $try["timestart"]; - $temp .= ", (".format_time($timetotake).")"; - } else { - // This is what the link does/looks like when the user has not completed the attempt. - $temp .= get_string("notcompleted", "lesson"); - if ($try['timestart'] !== 0) { - // Teacher previews do not track time spent. - $temp .= " ".userdate($try["timestart"]); - } - $temp .= ""; - $timetotake = null; - } - } - // build up the attempts array - $attempts[] = $temp; - - // Run these lines for the stats only if the user finnished the lesson. - if ($try["end"]) { - // User has completed the lesson. - $numofattempts++; - $avetime += $timetotake; - if ($timetotake > $hightime || $hightime == null) { - $hightime = $timetotake; - } - if ($timetotake < $lowtime || $lowtime == null) { - $lowtime = $timetotake; - } - if ($try["grade"] !== null) { - // The lesson was scored. - $avescore += $try["grade"]; - if ($try["grade"] > $highscore || $highscore === null) { - $highscore = $try["grade"]; - } - if ($try["grade"] < $lowscore || $lowscore === null) { - $lowscore = $try["grade"]; - } - - } - } - } - // get line breaks in after each attempt - $attempts = implode("
\n", $attempts); - - if ($lessonscored) { - // Add the grade if the lesson is graded. - $bestgrade = $bestgrade."%"; - $table->data[] = array($studentname, $attempts, $bestgrade); - } else { - // This lesson does not have a grade. - $table->data[] = array($studentname, $attempts); - } - } - } - $students->close(); // Print it all out! if (has_capability('mod/lesson:edit', $context)) { echo "
\n \n id\" />\n"; } + echo html_writer::table($table); + if (has_capability('mod/lesson:edit', $context)) { $checklinks = ''.get_string('selectall').' / '; $checklinks .= ''.get_string('deselectall').''; @@ -471,38 +175,38 @@ if ($action === 'delete') { } // Calculate the Statistics. - if ($avetime == null) { - $avetime = get_string("notcompleted", "lesson"); + if ($data->avetime == null) { + $data->avetime = get_string("notcompleted", "lesson"); } else { - $avetime = format_float($avetime/$numofattempts, 0); - $avetime = format_time($avetime); + $data->avetime = format_float($data->avetime / $data->numofattempts, 0); + $data->avetime = format_time($data->avetime); } - if ($hightime == null) { - $hightime = get_string("notcompleted", "lesson"); + if ($data->hightime == null) { + $data->hightime = get_string("notcompleted", "lesson"); } else { - $hightime = format_time($hightime); + $data->hightime = format_time($data->hightime); } - if ($lowtime == null) { - $lowtime = get_string("notcompleted", "lesson"); + if ($data->lowtime == null) { + $data->lowtime = get_string("notcompleted", "lesson"); } else { - $lowtime = format_time($lowtime); + $data->lowtime = format_time($data->lowtime); } - if ($lessonscored) { - if ($numofattempts == 0) { - $avescore = get_string("notcompleted", "lesson"); + if ($data->lessonscored) { + if ($data->numofattempts == 0) { + $data->avescore = get_string("notcompleted", "lesson"); } else { - $avescore = format_float($avescore / $numofattempts, 2) . '%'; + $data->avescore = format_float($data->avescore, 2) . '%'; } - if ($highscore === null) { - $highscore = get_string("notcompleted", "lesson"); + if ($data->highscore === null) { + $data->highscore = get_string("notcompleted", "lesson"); } else { - $highscore .= '%'; + $data->highscore .= '%'; } - if ($lowscore === null) { - $lowscore = get_string("notcompleted", "lesson"); + if ($data->lowscore === null) { + $data->lowscore = get_string("notcompleted", "lesson"); } else { - $lowscore .= '%'; + $data->lowscore .= '%'; } // Display the full stats for the lesson. @@ -514,7 +218,7 @@ if ($action === 'delete') { $stattable->align = array('center', 'center', 'center', 'center', 'center', 'center'); $stattable->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); $stattable->attributes['class'] = 'standardtable generaltable'; - $stattable->data[] = array($avescore, $avetime, $highscore, $lowscore, $hightime, $lowtime); + $stattable->data[] = array($data->avescore, $data->avetime, $data->highscore, $data->lowscore, $data->hightime, $data->lowtime); } else { // Display simple stats for the lesson. @@ -525,7 +229,7 @@ if ($action === 'delete') { $stattable->align = array('center', 'center', 'center'); $stattable->wrap = array('nowrap', 'nowrap', 'nowrap'); $stattable->attributes['class'] = 'standardtable generaltable'; - $stattable->data[] = array($avetime, $hightime, $lowtime); + $stattable->data[] = array($data->avetime, $data->hightime, $data->lowtime); } echo html_writer::table($stattable); -- 2.11.4.GIT