Skip to content

Commit

Permalink
MDL-43833 quiz reports: persist states settings between pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed May 15, 2014
1 parent ba05f57 commit b7acb1f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions mod/quiz/report/attemptsreport_options.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -186,16 +197,18 @@ 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);
$this->group = groups_get_activity_group($this->cm, true);
$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);
}
Expand Down

0 comments on commit b7acb1f

Please sign in to comment.