You are here

function quiz_views_handler_filter_user_quiz_state::query in Quiz 7

Same name and namespace in other branches
  1. 8.4 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  2. 6.6 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  3. 6.3 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  4. 6.4 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  5. 6.5 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  6. 7.6 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()
  7. 7.4 includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc \quiz_views_handler_filter_user_quiz_state::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter::query

File

includes/views/handlers/quiz_views_handler_filter_user_quiz_state.inc, line 59

Class

quiz_views_handler_filter_user_quiz_state

Code

function query() {
  $val = is_array($this->value) ? $this->value['quiz_state'] : $this->value;
  if (empty($val) || $val == 'any') {
    return;
  }
  $this
    ->ensure_my_table();
  if ($val == 'not_started') {
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.time_end", NULL, "IS NULL");
  }
  else {
    $operator = $val == 'in_progress' ? '=' : '>';
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.time_end", 0, $operator);
  }
}