Skip to content
Snippets Groups Projects
Commit 1dc85617 authored by Sam Boyer's avatar Sam Boyer
Browse files

Filled out the filter so it actually does something. Not optimal maybe, but it works.

Still needs UI love.
parent e76c063d
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,36 @@
class quiz_views_handler_filter_user_quiz_state extends views_handler_filter {
function options_definition() {
$options = parent::option_definition();
$options['quiz_state'] = array('default' => 'finished');
return $options;
}
function options_form(&$form, &$form_state) {
$form['quiz_state'] = array(
'#type' => 'radios',
'#description' => t('The final result set will only include quiz results in the state you select here.'),
'#title' => t('Quiz State'),
'#options' => array(
'not_started' => t('Not Started'),
'in_progress' => t('In Progress'),
'finished' => t('Finished'),
),
'#default_value' => $this->options['quiz_state'],
);
}
function query() {
$this->ensure_my_table();
if ($this->options['quiz_state'] == 'not_started') {
$this->query->add_where(0, "$this->table_alias.time_end IS NULL");
}
else {
// $field = $this->query->add_field($table_alias, "time_end");
$operator = $this->options['quiz_state'] == 'in_progress' ? '=' : '>';
// $this->query->add_where(0, "$table_alias.$field $operator 0");
$this->query->add_where(0, "$this->table_alias.time_end $operator 0");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment