From b7acb1f0e80e511b435b8b22d63e3e520f94e3ee Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 9 May 2014 16:18:18 +0100 Subject: [PATCH] MDL-43833 quiz reports: persist states settings between pages. --- mod/quiz/report/attemptsreport_options.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mod/quiz/report/attemptsreport_options.php b/mod/quiz/report/attemptsreport_options.php index c37bfe35bdb77..06fd29c08240c 100644 --- a/mod/quiz/report/attemptsreport_options.php +++ b/mod/quiz/report/attemptsreport_options.php @@ -119,6 +119,11 @@ protected function get_url_params() { 'attempts' => $this->attempts, 'onlygraded' => $this->onlygraded, ); + + if ($this->states) { + $params['states'] = implode('-', $this->states); + } + if (groups_get_activity_groupmode($this->cm, $this->course)) { $params['group'] = $this->group; } @@ -164,6 +169,12 @@ public function get_initial_form_data() { $toform->onlygraded = $this->onlygraded; $toform->pagesize = $this->pagesize; + if ($this->states) { + foreach (self::$statefields as $field => $state) { + $toform->$field = in_array($state, $this->states); + } + } + return $toform; } @@ -186,7 +197,7 @@ public function setup_from_form_data($fromform) { } /** - * Set the fields of this object from the user's preferences. + * Set the fields of this object from the URL parameters. */ public function setup_from_params() { $this->attempts = optional_param('attempts', $this->attempts, PARAM_ALPHAEXT); @@ -194,8 +205,10 @@ public function setup_from_params() { $this->onlygraded = optional_param('onlygraded', $this->onlygraded, PARAM_BOOL); $this->pagesize = optional_param('pagesize', $this->pagesize, PARAM_INT); - $this->states = explode('-', optional_param('states', - implode('-', $this->states), PARAM_ALPHAEXT)); + $states = optional_param('states', '', PARAM_ALPHAEXT); + if (!empty($states)) { + $this->states = explode('-', $states); + } $this->download = optional_param('download', $this->download, PARAM_ALPHA); }