Browse files

MDL-38429: lesson report - Improve lesson statistics code.

  • Loading branch information...
1 parent 373a8e0 commit 1b5865168175e2148449f6c1fe58c7725e14e6ad @gentlecat gentlecat committed with rwijaya Mar 25, 2013
Showing with 25 additions and 25 deletions.
  1. +25 −25 mod/lesson/report.php
View
50 mod/lesson/report.php
@@ -28,7 +28,7 @@
require_once($CFG->dirroot.'/mod/lesson/locallib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
-$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
+$pageid = optional_param('pageid', null, PARAM_INT); // Lesson Page ID
$action = optional_param('action', 'reportoverview', PARAM_ALPHA); // action to take
$nothingtodisplay = false;
@@ -73,7 +73,7 @@
if ($action !== 'reportoverview') {
$url->param('action', $action);
}
-if ($pageid !== NULL) {
+if ($pageid !== null) {
$url->param('pageid', $pageid);
}
$PAGE->set_url($url);
@@ -182,7 +182,7 @@
$n = 0;
$timestart = 0;
$timeend = 0;
- $usergrade = NULL;
+ $usergrade = null;
// search for the grade record for this try. if not there, the nulls defined above will be used.
foreach($grades as $grade) {
@@ -226,10 +226,10 @@
$numofattempts = 0;
$avescore = 0;
$avetime = 0;
- $highscore = NULL;
- $lowscore = NULL;
- $hightime = NULL;
- $lowtime = NULL;
+ $highscore = null;
+ $lowscore = null;
+ $hightime = null;
+ $lowtime = null;
$table = new html_table();
@@ -262,7 +262,7 @@
}
$temp .= "<a href=\"report.php?id=$cm->id&amp;action=reportdetail&amp;userid=".$try['userid'].'&amp;try='.$try['try'].'">';
- if ($try["grade"] !== NULL) { // if NULL then not done yet
+ 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"];
@@ -277,26 +277,26 @@
// this is what the link does/looks like when the user has not completed the try
$temp .= get_string("notcompleted", "lesson");
$temp .= "&nbsp;".userdate($try["timestart"])."</a>";
- $timetotake = NULL;
+ $timetotake = null;
}
// build up the attempts array
$attempts[] = $temp;
// run these lines for the stats only if the user finnished the lesson
- if ($try["grade"] !== NULL) {
+ if ($try["grade"] !== null) {
$numofattempts++;
$avescore += $try["grade"];
$avetime += $timetotake;
- if ($try["grade"] > $highscore || $highscore === NULL) {
+ if ($try["grade"] > $highscore || $highscore === null) {
$highscore = $try["grade"];
}
- if ($try["grade"] < $lowscore || $lowscore === NULL) {
+ if ($try["grade"] < $lowscore || $lowscore === null) {
$lowscore = $try["grade"];
}
- if ($timetotake > $hightime || $hightime == NULL) {
+ if ($timetotake > $hightime || $hightime == null) {
$hightime = $timetotake;
}
- if ($timetotake < $lowtime || $lowtime == NULL) {
+ if ($timetotake < $lowtime || $lowtime == null) {
$lowtime = $timetotake;
}
}
@@ -333,26 +333,26 @@
} else {
$avescore = format_float($avescore/$numofattempts, 2);
}
- if ($avetime == NULL) {
+ if ($avetime == null) {
$avetime = get_string("notcompleted", "lesson");
} else {
$avetime = format_float($avetime/$numofattempts, 0);
$avetime = format_time($avetime);
}
- if ($hightime == NULL) {
+ if ($hightime == null) {
$hightime = get_string("notcompleted", "lesson");
} else {
$hightime = format_time($hightime);
}
- if ($lowtime == NULL) {
+ if ($lowtime == null) {
$lowtime = get_string("notcompleted", "lesson");
} else {
$lowtime = format_time($lowtime);
}
- if ($highscore === NULL) {
+ if ($highscore === null) {
$highscore = get_string("notcompleted", "lesson");
}
- if ($lowscore === NULL) {
+ if ($lowscore === null) {
$lowscore = get_string("notcompleted", "lesson");
}
@@ -402,8 +402,8 @@
$formattextdefoptions->para = false; //I'll use it widely in this page
$formattextdefoptions->overflowdiv = true;
- $userid = optional_param('userid', NULL, PARAM_INT); // if empty, then will display the general detailed view
- $try = optional_param('try', NULL, PARAM_INT);
+ $userid = optional_param('userid', null, PARAM_INT); // if empty, then will display the general detailed view
+ $try = optional_param('try', null, PARAM_INT);
$lessonpages = $lesson->load_all_pages();
foreach ($lessonpages as $lessonpage) {
@@ -456,8 +456,8 @@
$answerdata = new stdClass;
// Set some defaults for the answer data.
- $answerdata->score = NULL;
- $answerdata->response = NULL;
+ $answerdata->score = null;
+ $answerdata->response = null;
$answerdata->responseformat = FORMAT_PLAIN;
$answerpage->title = format_string($page->title);
@@ -474,7 +474,7 @@
if (empty($userid)) {
// there is no userid, so set these vars and display stats.
$answerpage->grayout = 0;
- $useranswer = NULL;
+ $useranswer = null;
} elseif ($useranswers = $DB->get_records("lesson_attempts",array("lessonid"=>$lesson->id, "userid"=>$userid, "retry"=>$try,"pageid"=>$page->id), "timeseen")) {
// get the user's answer for this page
// need to find the right one
@@ -489,7 +489,7 @@
} else {
// user did not answer this page, gray it out and set some nulls
$answerpage->grayout = 1;
- $useranswer = NULL;
+ $useranswer = null;
}
$i = 0;
$n = 0;

0 comments on commit 1b58651

Please sign in to comment.