protected function standard_attempt_fields(MoodleQuickForm $mform)
 {
     $mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'), quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'), quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'), quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz')));
     $stategroup = array($mform->createElement('advcheckbox', 'stateinprogress', '', get_string('stateinprogress', 'quiz')), $mform->createElement('advcheckbox', 'stateoverdue', '', get_string('stateoverdue', 'quiz')), $mform->createElement('advcheckbox', 'statefinished', '', get_string('statefinished', 'quiz')), $mform->createElement('advcheckbox', 'stateabandoned', '', get_string('stateabandoned', 'quiz')));
     $mform->addGroup($stategroup, 'stateoptions', get_string('reportattemptsthatare', 'quiz'), array(' '), false);
     $mform->setDefault('stateinprogress', 1);
     $mform->setDefault('stateoverdue', 1);
     $mform->setDefault('statefinished', 1);
     $mform->setDefault('stateabandoned', 1);
     $mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     $mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
     if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) {
         $gm = html_writer::tag('span', quiz_get_grading_option_name($this->_customdata['quiz']->grademethod), array('class' => 'highlight'));
         $mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'), get_string('optonlygradedattempts', 'quiz_overview', $gm));
         $mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
         $mform->disabledIf('onlygraded', 'statefinished', 'notchecked');
     }
 }
 /**
  * Check the settings, and remove any 'impossible' combinations.
  */
 public function resolve_dependencies()
 {
     if ($this->group) {
         // Default for when a group is selected.
         if ($this->attempts === null || $this->attempts == quiz_attempts_report::ALL_WITH) {
             $this->attempts = quiz_attempts_report::ENROLLED_WITH;
         }
     } else {
         if (!$this->group && $this->course->id == SITEID) {
             // Force report on front page to show all, unless a group is selected.
             $this->attempts = quiz_attempts_report::ALL_WITH;
         } else {
             if (!in_array($this->attempts, array(quiz_attempts_report::ALL_WITH, quiz_attempts_report::ENROLLED_WITH, quiz_attempts_report::ENROLLED_WITHOUT, quiz_attempts_report::ENROLLED_ALL))) {
                 $this->attempts = quiz_attempts_report::ENROLLED_WITH;
             }
         }
     }
     $cleanstates = array();
     foreach (self::$statefields as $state) {
         if (in_array($state, $this->states)) {
             $cleanstates[] = $state;
         }
     }
     $this->states = $cleanstates;
     if (count($this->states) == count(self::$statefields)) {
         // If all states have been selected, then there is no constraint
         // required in the SQL, so clear the array.
         $this->states = null;
     }
     if (!quiz_report_can_filter_only_graded($this->quiz)) {
         // A grading mode like 'average' has been selected, so we cannot do
         // the show the attempt that gave the final grade thing.
         $this->onlygraded = false;
     }
     if ($this->attempts == quiz_attempts_report::ENROLLED_WITHOUT) {
         $this->states = null;
         $this->onlygraded = false;
     }
     if ($this->onlygraded) {
         $this->states = array(quiz_attempt::FINISHED);
     }
     if ($this->pagesize < 1) {
         $this->pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE;
     }
 }