From 1a6b714fd1b7c7e1173440c9c398fe965687b88c Mon Sep 17 00:00:00 2001 From: hieuvu Date: Mon, 26 Aug 2024 10:15:23 +0700 Subject: [PATCH] StudentQuiz: Implement Fast filter UI redesign --- classes/condition/studentquiz_condition.php | 95 ++++++++------- .../question/bank/question_bank_filter.php | 31 +++-- .../question/bank/studentquiz_bank_view.php | 113 ++++++++++-------- lang/en/studentquiz.php | 7 +- tests/behat/filter.feature | 43 ++++++- tests/behat/startpageview.feature | 1 - tests/behat/state_visibility.feature | 85 ------------- 7 files changed, 187 insertions(+), 188 deletions(-) diff --git a/classes/condition/studentquiz_condition.php b/classes/condition/studentquiz_condition.php index d5cea258..55f2df26 100755 --- a/classes/condition/studentquiz_condition.php +++ b/classes/condition/studentquiz_condition.php @@ -123,56 +123,59 @@ protected function init() { $this->tests = array(); $this->customparams = array(); - foreach ($this->filterform->get_fields() as $field) { - - // Validate input. - $data = $field->check_data($adddata); - - // If input is valid, at least one filter was activated. - if ($data === false) { - continue; - } else { - $this->isfilteractive = true; - } + foreach ($this->filterform->get_fields() as $fieldgroup) { + $conditionsgroup = []; + foreach ($fieldgroup as $field) { + // Validate input. + $data = $field->check_data($adddata); + + // If input is valid, at least one filter was activated. + if ($data === false) { + continue; + } else { + $this->isfilteractive = true; + } - $sqldata = $field->get_sql_filter($data); + $sqldata = $field->get_sql_filter($data); - // Disable filtering by firstname if anonymized. - if ($field->_name == 'firstname' && !(mod_studentquiz_check_created_permission($this->cm->id) || - !$this->report->is_anonymized())) { - continue; - } + // Disable filtering by firstname if anonymized. + if ($field->_name == 'firstname' && !(mod_studentquiz_check_created_permission($this->cm->id) || + !$this->report->is_anonymized())) { + continue; + } - // Disable filtering by firstname if anonymized. - if ($field->_name == 'lastname' && !(mod_studentquiz_check_created_permission($this->cm->id) || - !$this->report->is_anonymized())) { - continue; - } + // Disable filtering by firstname if anonymized. + if ($field->_name == 'lastname' && !(mod_studentquiz_check_created_permission($this->cm->id) || + !$this->report->is_anonymized())) { + continue; + } - // Respect leading and ending ',' for the tagarray as provided by tag_column.php. - if ($field->_name == 'tagarray') { - foreach ($sqldata[1] as $key => $value) { - if (!empty($value)) { - $sqldata[1][$key] = "%,$value,%"; - } else { - $sqldata[0] = "$field->_name IS NULL"; + // Respect leading and ending ',' for the tagarray as provided by tag_column.php. + if ($field->_name == 'tagarray') { + foreach ($sqldata[1] as $key => $value) { + if (!empty($value)) { + $sqldata[1][$key] = "%,$value,%"; + } else { + $sqldata[0] = "$field->_name IS NULL"; + } } } - } - // TODO: cleanup that buggy filter function to remove this! - // The user_filter_checkbox class has a buggy get_sql_filter function. - if ($field->_name == 'createdby') { - $sqldata = array($field->_name . ' = ' . intval($data['value']), array()); - } + // TODO: cleanup that buggy filter function to remove this! + // The user_filter_checkbox class has a buggy get_sql_filter function. + if ($field->_name == 'createdby') { + $sqldata = [$field->_name . ' = ' . intval($data['value']), []]; + } - if (is_array($sqldata)) { - $sqldata[0] = str_replace($field->_name, $this->get_sql_field($field->_name) - , $sqldata[0]); - $sqldata[0] = $this->get_special_sql($sqldata[0], $field->_name); - $this->tests[] = '((' . $sqldata[0] . '))'; - $this->customparams = array_merge($this->customparams, $sqldata[1]); + if (is_array($sqldata)) { + $sqldata[0] = str_replace($field->_name, $this->get_sql_field($field->_name) + , $sqldata[0]); + $sqldata[0] = $this->get_special_sql($sqldata[0], $field->_name); + $conditionsgroup[] = $sqldata[0]; + $this->customparams = array_merge($this->customparams, $sqldata[1]); + } } + $this->tests[] = $conditionsgroup; } } } @@ -191,7 +194,7 @@ private function get_special_sql($sqldata, $name) { ELSE 0 END)', $sqldata); } - if ($name == "onlynew") { + if ($name == 'onlynew' || $name == 'onlyanswered') { return str_replace('myattempts', 'sp.attempts', $sqldata); } return $sqldata; @@ -256,7 +259,13 @@ private function get_sql_table_prefix($name) { * @return string SQL fragment. Must use named parameters. */ public function where() { - return implode(' AND ', $this->tests); + $conditions = []; + foreach ($this->tests as $groupconditions) { + if (!empty($groupconditions)) { + $conditions[] = '(' . implode(' OR ', $groupconditions) . ')'; + } + } + return implode(' AND ', $conditions); } /** diff --git a/classes/question/bank/question_bank_filter.php b/classes/question/bank/question_bank_filter.php index 839a2c51..403be240 100644 --- a/classes/question/bank/question_bank_filter.php +++ b/classes/question/bank/question_bank_filter.php @@ -81,17 +81,27 @@ public function definition() { $mform->addElement('header', 'filtertab', get_string('filter', 'studentquiz')); $mform->setExpanded('filtertab', true); - $fastfilters = array(); - foreach ($this->fields as $field) { - if ($field instanceof toggle_filter_checkbox) { - $field->setup_form_in_group($mform, $fastfilters); + $grouplabel = [ + get_string('state_column_name', 'studentquiz'), + get_string('filter_label_owner', 'studentquiz'), + get_string('filter_label_difficulty_level', 'studentquiz'), + get_string('filter_label_rates', 'studentquiz') + ]; + $i = 0; + foreach ($this->fields as $fieldgroup) { + $fasterfiltergroup = []; + foreach ($fieldgroup as $f) { + if ($f instanceof toggle_filter_checkbox) { + $f->setup_form_in_group($mform, $fasterfiltergroup); + } else { + $f->setupForm($mform); + } } - } - $mform->addGroup($fastfilters, 'fastfilters', get_string('filter_label_fast_filters', 'studentquiz'), ' ', false); - foreach ($this->fields as $field) { - if (!$field instanceof toggle_filter_checkbox) { - $field->setupForm($mform); + if ($fasterfiltergroup) { + $mform->addGroup($fasterfiltergroup, 'fastfiltersgroup' . $i, + $grouplabel[$i], '', false); } + $i++; } $group = array(); $group[] = $mform->createElement('submit', 'submitbutton', get_string('filter')); @@ -377,6 +387,9 @@ public function get_sql_filter($data) { case 2: $res = "$this->field = $this->value"; break; + case 3: + $res = "$this->field <> $this->value"; + break; default: $res = ''; } diff --git a/classes/question/bank/studentquiz_bank_view.php b/classes/question/bank/studentquiz_bank_view.php index 7a34ce18..28de1285 100755 --- a/classes/question/bank/studentquiz_bank_view.php +++ b/classes/question/bank/studentquiz_bank_view.php @@ -418,99 +418,118 @@ private function set_filter_form_fields($anonymize = true) { $this->fields = array(); // Fast filters. - $this->fields[] = new \toggle_filter_checkbox('onlynew', + $stategroup = []; + $stategroup[] = new \toggle_filter_checkbox('only_new_state', + get_string('state_newplural', 'studentquiz'), false, 'sqq.state', + ['approved'], 2, studentquiz_helper::STATE_NEW); + $stategroup[] = new \toggle_filter_checkbox('only_changed_state', + get_string('state_changedplural', 'studentquiz'), false, 'sqq.state', // Fast filters. + + ['approved'], 2, studentquiz_helper::STATE_CHANGED); + $stategroup[] = new \toggle_filter_checkbox('only_reviewable_state', + get_string('state_reviewableplural', 'studentquiz'), false, 'sqq.state', + ['approved'], 2, studentquiz_helper::STATE_REVIEWABLE); + $stategroup[] = new \toggle_filter_checkbox('only_approved_state', + get_string('state_approvedplural', 'studentquiz'), false, 'sqq.state', + ['approved'], 2, studentquiz_helper::STATE_APPROVED); + $stategroup[] = new \toggle_filter_checkbox('only_disapproved_state', + get_string('state_disapprovedplural', 'studentquiz'), false, 'sqq.state', + ['approved'], 2, studentquiz_helper::STATE_DISAPPROVED); + $stategroup[] = new \toggle_filter_checkbox('onlynew', get_string('filter_label_onlynew', 'studentquiz'), - false, 'myattempts', array('myattempts', 'myattempts_op'), 0, 0, + false, 'myattempts', ['myattempts', 'myattempts_op'], 0, 0, get_string('filter_label_onlynew_help', 'studentquiz')); + $stategroup[] = new \toggle_filter_checkbox('onlyanswered', + get_string('filter_label_answered', 'studentquiz'), + false, 'myattempts', ['myattempts', 'myattempts_op'], 1, 1, + get_string('filter_label_onlynew_help', 'studentquiz')); + $this->fields[] = $stategroup; - $this->fields[] = new \toggle_filter_checkbox('only_new_state', - get_string('state_newplural', 'studentquiz'), false, 'sqq.state', - ['approved'], 2, studentquiz_helper::STATE_NEW); - $this->fields[] = new \toggle_filter_checkbox('only_approved_state', - get_string('state_approvedplural', 'studentquiz'), false, 'sqq.state', - ['approved'], 2, studentquiz_helper::STATE_APPROVED); - $this->fields[] = new \toggle_filter_checkbox('only_disapproved_state', - get_string('state_disapprovedplural', 'studentquiz'), false, 'sqq.state', - ['approved'], 2, studentquiz_helper::STATE_DISAPPROVED); - $this->fields[] = new \toggle_filter_checkbox('only_changed_state', - get_string('state_changedplural', 'studentquiz'), false, 'sqq.state', - ['approved'], 2, studentquiz_helper::STATE_CHANGED); - $this->fields[] = new \toggle_filter_checkbox('only_reviewable_state', - get_string('state_reviewableplural', 'studentquiz'), false, 'sqq.state', - ['approved'], 2, studentquiz_helper::STATE_REVIEWABLE); - - $this->fields[] = new \toggle_filter_checkbox('onlygood', - get_string('filter_label_onlygood', 'studentquiz'), - false, 'vo.rate', array('rate', 'rate_op'), 1, 4, - get_string('filter_label_onlygood_help', 'studentquiz', '4')); - - $this->fields[] = new \toggle_filter_checkbox('onlymine', + $ownergroup = []; + $ownergroup[] = new \toggle_filter_checkbox('onlymine', get_string('filter_label_onlymine', 'studentquiz'), - false, 'q.createdby', array('createdby'), 2, $this->userid, + false, 'q.createdby', ['createdby'], 2, $this->userid, get_string('filter_label_onlymine_help', 'studentquiz')); - $this->fields[] = new \toggle_filter_checkbox('onlydifficultforme', + $ownergroup[] = new \toggle_filter_checkbox('notmine', + get_string('filter_label_notmine', 'studentquiz'), + false, 'q.createdby', ['createdby'], 3, $this->userid, + get_string('filter_label_notmine_help', 'studentquiz')); + $this->fields[]= $ownergroup; + + $difficultygroup = []; + $difficultygroup[] = new \toggle_filter_checkbox('onlydifficultforme', get_string('filter_label_onlydifficultforme', 'studentquiz'), - false, 'mydifficulty', array('mydifficulty', 'mydifficulty_op'), 1, 0.60, + false, 'mydifficulty', ['mydifficulty', 'mydifficulty_op'], 1, 0.60, get_string('filter_label_onlydifficultforme_help', 'studentquiz', '60')); - $this->fields[] = new \toggle_filter_checkbox('onlydifficult', + $difficultygroup[] = new \toggle_filter_checkbox('onlydifficult', get_string('filter_label_onlydifficult', 'studentquiz'), - false, 'dl.difficultylevel', array('difficultylevel', 'difficultylevel_op'), 1, 0.60, + false, 'dl.difficultylevel', ['difficultylevel', 'difficultylevel_op'], 1, 0.60, get_string('filter_label_onlydifficult_help', 'studentquiz', '60')); + $this->fields[] = $difficultygroup; + $ratinggroup = []; + $ratinggroup[] = new \toggle_filter_checkbox('onlygood', + get_string('filter_label_onlygood', 'studentquiz'), + false, 'vo.rate', ['rate', 'rate_op'], 1, 4, + get_string('filter_label_onlygood_help', 'studentquiz', '4')); + $this->fields[] = $ratinggroup; + // Advanced filters. - $this->fields[] = new \studentquiz_user_filter_text('tagarray', get_string('filter_label_tags', 'studentquiz'), + $advancedgroups = []; + $advancedgroups[] = new \studentquiz_user_filter_text('tagarray', get_string('filter_label_tags', 'studentquiz'), true, 'tagarray'); - $states = array(); + $states = []; foreach (studentquiz_helper::$statename as $num => $name) { if ($num == studentquiz_helper::STATE_DELETE || $num == studentquiz_helper::STATE_HIDE) { continue; } $states[$num] = get_string('state_'.$name, 'studentquiz'); } - $this->fields[] = new \user_filter_simpleselect('state', get_string('state_column_name', 'studentquiz'), + $advancedgroups[] = new \user_filter_simpleselect('state', get_string('state_column_name', 'studentquiz'), true, 'state', $states); - $this->fields[] = new \user_filter_number('rate', get_string('filter_label_rates', 'studentquiz'), + $advancedgroups[] = new \user_filter_number('rate', get_string('filter_label_rates', 'studentquiz'), true, 'rate'); - $this->fields[] = new \user_filter_percent('difficultylevel', get_string('filter_label_difficulty_level', 'studentquiz'), + $advancedgroups[] = new \user_filter_percent('difficultylevel', get_string('filter_label_difficulty_level', 'studentquiz'), true, 'difficultylevel'); - $this->fields[] = new \user_filter_number('publiccomment', get_string('filter_label_comment', 'studentquiz'), + $advancedgroups[] = new \user_filter_number('publiccomment', get_string('filter_label_comment', 'studentquiz'), true, 'publiccomment'); - $this->fields[] = new \studentquiz_user_filter_text('name', get_string('filter_label_question', 'studentquiz'), + $advancedgroups[] = new \studentquiz_user_filter_text('name', get_string('filter_label_question', 'studentquiz'), true, 'name'); - $this->fields[] = new \studentquiz_user_filter_text('questiontext', get_string('filter_label_questiontext', 'studentquiz'), + $advancedgroups[] = new \studentquiz_user_filter_text('questiontext', get_string('filter_label_questiontext', 'studentquiz'), true, 'questiontext'); if ($anonymize) { - $this->fields[] = new \user_filter_checkbox('createdby', get_string('filter_label_show_mine', 'studentquiz'), + $advancedgroups[] = new \user_filter_checkbox('createdby', get_string('filter_label_show_mine', 'studentquiz'), true, 'createdby'); } else { - $this->fields[] = new \studentquiz_user_filter_text('firstname', get_string('firstname'), true, 'firstname'); - $this->fields[] = new \studentquiz_user_filter_text('lastname', get_string('lastname'), true, 'lastname'); + $advancedgroups[] = new \studentquiz_user_filter_text('firstname', get_string('firstname'), true, 'firstname'); + $advancedgroups[] = new \studentquiz_user_filter_text('lastname', get_string('lastname'), true, 'lastname'); } - $this->fields[] = new \studentquiz_user_filter_date('timecreated', get_string('filter_label_createdate', 'studentquiz'), + $advancedgroups[] = new \studentquiz_user_filter_date('timecreated', get_string('filter_label_createdate', 'studentquiz'), true, 'timecreated'); - $this->fields[] = new \user_filter_simpleselect('lastanswercorrect', + $advancedgroups[] = new \user_filter_simpleselect('lastanswercorrect', get_string('filter_label_mylastattempt', 'studentquiz'), - true, 'lastanswercorrect', array( + true, 'lastanswercorrect', [ '1' => get_string('lastattempt_right', 'studentquiz'), '0' => get_string('lastattempt_wrong', 'studentquiz') - )); + ]); - $this->fields[] = new \user_filter_number('myattempts', get_string('filter_label_myattempts', 'studentquiz'), + $advancedgroups[] = new \user_filter_number('myattempts', get_string('filter_label_myattempts', 'studentquiz'), true, 'myattempts'); - $this->fields[] = new \user_filter_number('mydifficulty', get_string('filter_label_mydifficulty', 'studentquiz'), + $advancedgroups[] = new \user_filter_number('mydifficulty', get_string('filter_label_mydifficulty', 'studentquiz'), true, 'mydifficulty'); - $this->fields[] = new \user_filter_number('myrate', get_string('filter_label_myrate', 'studentquiz'), + $advancedgroups[] = new \user_filter_number('myrate', get_string('filter_label_myrate', 'studentquiz'), true, 'myrate'); + $this->fields[] = $advancedgroups; } /** diff --git a/lang/en/studentquiz.php b/lang/en/studentquiz.php index 061ddaff..7ed6810d 100644 --- a/lang/en/studentquiz.php +++ b/lang/en/studentquiz.php @@ -161,7 +161,7 @@ $string['error_permission'] = 'Sorry, but you need to be part of a group to see this page.'; $string['expandcomment'] = 'Expand comment'; $string['expandall'] = 'Expand all comments'; -$string['filter'] = 'Filter'; +$string['filter'] = 'Fast Filter'; $string['filter_advanced_element'] = '{$a} (Advanced element)'; $string['filter_comment_label_forename'] = 'Forename'; $string['filter_comment_label_surname'] = 'Surname'; @@ -170,11 +170,11 @@ $string['filter_comment_label_sort_toggle'] = 'Sort by {$a->field} {$a->type}'; $string['filter_ishigher'] = 'Is higher'; $string['filter_islower'] = 'Is lower'; +$string['filter_label_answered'] = 'Answered'; $string['filter_label_approved'] = 'Approved questions'; $string['filter_label_comment'] = 'Comments'; $string['filter_label_createdate'] = 'Creation'; $string['filter_label_difficulty_level'] = 'Difficulty'; -$string['filter_label_fast_filters'] = 'Fast filter for questions'; $string['filter_label_myattempts'] = 'My attempts'; $string['filter_label_mydifficulty'] = 'My difficulty'; $string['filter_label_mylastattempt'] = 'My latest attempt'; @@ -188,7 +188,9 @@ $string['filter_label_onlygood'] = 'Good'; $string['filter_label_onlygood_help'] = 'Question with an average rating of at at least {$a} stars'; $string['filter_label_onlymine'] = 'Mine'; +$string['filter_label_notmine'] = 'Not mine'; $string['filter_label_onlymine_help'] = 'Questions you created.'; +$string['filter_label_notmine_help'] = 'Questions not created by you'; $string['filter_label_onlynew'] = 'Unanswered'; $string['filter_label_onlynew_help'] = 'Questions you have never answered before'; $string['filter_label_question'] = 'Question title'; @@ -196,6 +198,7 @@ $string['filter_label_question_creation_item'] = '{$a->creationtext} {$a->rowtext} {$a->inputtext}'; $string['filter_label_question_creation_item_inputtext'] = '{$a->inputtext} {$a->inputtype}'; $string['filter_label_rates'] = 'Rating'; +$string['filter_label_owner'] = 'Owner'; $string['filter_label_show_mine'] = 'My questions'; $string['filter_label_tags'] = 'Tag'; $string['finish_button'] = 'Finish'; diff --git a/tests/behat/filter.feature b/tests/behat/filter.feature index b1e78131..0ad8b8a2 100644 --- a/tests/behat/filter.feature +++ b/tests/behat/filter.feature @@ -21,9 +21,11 @@ Feature: Filtering in Studentquiz view. | questioncategory | qtype | name | questiontext | | Default for StudentQuiz Test 1 | truefalse | Test question 1 | Answer the question 1 | | Default for StudentQuiz Test 1 | truefalse | Test question 2 | Answer the question 2 | + | Default for StudentQuiz Test 1 | truefalse | Test question 3 | Answer the question 3 | + | Default for StudentQuiz Test 1 | truefalse | Test question 4 | Answer the question 4 | @javascript @_switch_window - Scenario: Check validation client in the advance filter. + Scenario: Check validation numeric in the advance filter. When I am on the "StudentQuiz Test 1" "mod_studentquiz > View" page logged in as "admin" And I click on "Show more..." "link" Then I set the field "Rating value" to "TF 01" @@ -82,3 +84,42 @@ Feature: Filtering in Studentquiz view. And I click on "Sort by Question ascending" "link" Then I should see "Test question 1" And I should see "Test question 2" + + @javascript @_switch_window + Scenario: Test filter for StudentQuiz + When I am on the "StudentQuiz Test 1" "mod_studentquiz > View" page logged in as "admin" + And I choose "Preview" action for "Test question 1" in the question bank + And I switch to "questionpreview" window + And I set the field "statetype" to "Disapproved" + And I click on "Change state" "button" + And I switch to the main window + And I choose "Preview" action for "Test question 2" in the question bank + And I switch to "questionpreview" window + And I set the field "statetype" to "Approved" + And I click on "Change state" "button" + And I switch to the main window + And I choose "Preview" action for "Test question 3" in the question bank + And I switch to "questionpreview" window + And I set the field "statetype" to "Changed" + And I click on "Change state" "button" + And I switch to the main window + + And I click on "Disapproved" "link" + And I press "id_submitbutton" + Then I should see "Test question 1" + And I should not see "Test question 2" + And I should not see "Test question 3" + And I should not see "Test question 4" + + And I click on "Approved" "link" + And I press "id_submitbutton" + And I should see "Test question 1" + And I should see "Test question 2" + And I should not see "Test question 3" + And I should not see "Test question 4" + + And I expand all fieldsets + And I set the field "id_name" to "Test question 1" + And I press "id_submitbutton" + And I should see "Test question 1" + And I should not see "Test question 2" diff --git a/tests/behat/startpageview.feature b/tests/behat/startpageview.feature index 84ee3260..9be4c2a9 100644 --- a/tests/behat/startpageview.feature +++ b/tests/behat/startpageview.feature @@ -65,7 +65,6 @@ Feature: View comprehensive information about this studentquiz activity # Check the Fast filter. Then "Filter" "fieldset" should be visible - And I should see "Fast filter for questions" And I click on "Unanswered" "link" And I press "id_submitbutton" And I should see "Question 1" diff --git a/tests/behat/state_visibility.feature b/tests/behat/state_visibility.feature index 7736bb89..3687e67b 100644 --- a/tests/behat/state_visibility.feature +++ b/tests/behat/state_visibility.feature @@ -52,91 +52,6 @@ Feature: Question states and visibility And I am on the "StudentQuiz Test 2" "mod_studentquiz > View" page And I should see "TF 01" - @javascript @_switch_window - Scenario: Test filter - When I am on the "StudentQuiz Test 2" "mod_studentquiz > View" page logged in as "student1" - - And I click on "Create new question" "button" - And I set the field "item_qtype_truefalse" to "1" - And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - And I set the field "Question name" to "TF 01" - And I set the field "Question text" to "The correct answer is false" - And I press "id_submitbutton" - - And I click on "Create new question" "button" - And I set the field "item_qtype_truefalse" to "1" - And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - And I set the field "Question name" to "TF 02" - And I set the field "Question text" to "The correct answer is false" - And I press "id_submitbutton" - - And I click on "Create new question" "button" - And I set the field "item_qtype_truefalse" to "1" - And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - And I set the field "Question name" to "TF 03" - And I set the field "Question text" to "The correct answer is false" - And I press "id_submitbutton" - - And I click on "Create new question" "button" - And I set the field "item_qtype_truefalse" to "1" - And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - And I set the field "Question name" to "TF 04" - And I set the field "Question text" to "The correct answer is false" - And I press "id_submitbutton" - - And I log out - And I am on the "StudentQuiz Test 2" "mod_studentquiz > View" page logged in as "admin" - - And I choose "Preview" action for "TF 01" in the question bank - And I switch to "questionpreview" window - And I set the field "statetype" to "Disapproved" - And I click on "Change state" "button" - And I switch to the main window - - And I choose "Preview" action for "TF 02" in the question bank - And I switch to "questionpreview" window - And I set the field "statetype" to "Approved" - And I click on "Change state" "button" - And I switch to the main window - - And I choose "Preview" action for "TF 03" in the question bank - And I switch to "questionpreview" window - And I set the field "statetype" to "Changed" - And I click on "Change state" "button" - And I switch to the main window - - And I click on "//a[text() = 'New']" "xpath_element" - And I press "id_submitbutton" - Then I should see "TF 04" - And I should not see "TF 01" - And I should not see "TF 02" - And I should not see "TF 03" - And I click on "Reset" "button" - - And I click on "//a[text() = 'Approved']" "xpath_element" - And I press "id_submitbutton" - And I should see "TF 02" - And I should not see "TF 01" - And I should not see "TF 03" - And I should not see "TF 04" - And I click on "Reset" "button" - - And I click on "//a[text() = 'Disapproved']" "xpath_element" - And I press "id_submitbutton" - And I should see "TF 01" - And I should not see "TF 02" - And I should not see "TF 03" - And I should not see "TF 04" - And I click on "Reset" "button" - - And I click on "//a[text() = 'Changed']" "xpath_element" - And I press "id_submitbutton" - And I should see "TF 03" - And I should not see "TF 01" - And I should not see "TF 02" - And I should not see "TF 04" - And I click on "Reset" "button" - @javascript Scenario: Hide question When I am on the "StudentQuiz Test 1" "mod_studentquiz > View" page logged in as "admin"