From 453f69263f67abbeeee0e085c17faf6e1fc2d8db Mon Sep 17 00:00:00 2001 From: Conn Date: Thu, 2 Apr 2015 23:54:03 +0100 Subject: [PATCH 1/2] MDL-49743 singleview: Prevent errors when no itemid was selected Signed-off-by: Conn --- grade/report/singleview/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grade/report/singleview/index.php b/grade/report/singleview/index.php index 47b45785c0cc7..9df746c5cc701 100644 --- a/grade/report/singleview/index.php +++ b/grade/report/singleview/index.php @@ -40,6 +40,11 @@ $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 100, PARAM_INT); +if ($itemid < 1){ + $itemid = $userid; + $itemtype = $defaulttype; +} + $courseparams = array('id' => $courseid); $PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $courseparams)); $PAGE->set_pagelayout('incourse'); From a24abd55e064e752fcd675e529603c175de418eb Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 25 Nov 2015 15:00:49 +0000 Subject: [PATCH 2/2] MDL-49743 singleview: slightly clarify logic Make it clearer what the 'unset' behaviour is because previously we've set the default for 'empty' values twice. --- grade/report/singleview/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grade/report/singleview/index.php b/grade/report/singleview/index.php index 9df746c5cc701..be9461ba13b49 100644 --- a/grade/report/singleview/index.php +++ b/grade/report/singleview/index.php @@ -35,12 +35,12 @@ $defaulttype = $userid ? 'user' : 'select'; -$itemid = optional_param('itemid', $userid, PARAM_INT); +$itemid = optional_param('itemid', null, PARAM_INT); $itemtype = optional_param('item', $defaulttype, PARAM_TEXT); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 100, PARAM_INT); -if ($itemid < 1){ +if (empty($itemid)) { $itemid = $userid; $itemtype = $defaulttype; }