From 0aa17f2631c70d47867510f60092cccfdb635a8a Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 15 Oct 2019 20:22:12 +0800 Subject: [PATCH] MDL-66553 question: Behat fixes 1. Fix sortable key for the qname/idnumber/tags column 2. Fix the default sort 3. Fix Behat test for sorting by idnumber. Added ID numbers for both question A and question C in order for us to get consistent sorting across DBs. --- .../bank/question_name_idnumber_tags_column.php | 2 +- question/classes/bank/view.php | 5 ++++- question/tests/behat/sort_questions.feature | 14 ++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/question/classes/bank/question_name_idnumber_tags_column.php b/question/classes/bank/question_name_idnumber_tags_column.php index b9dc3f8a499..872e1d82fe2 100644 --- a/question/classes/bank/question_name_idnumber_tags_column.php +++ b/question/classes/bank/question_name_idnumber_tags_column.php @@ -78,7 +78,7 @@ class question_name_idnumber_tags_column extends question_name_column { public function is_sortable() { return [ 'name' => ['field' => 'q.name', 'title' => get_string('questionname', 'question')], - 'lastname' => ['field' => 'q.idnumber', 'title' => get_string('idnumber', 'question')], + 'idnumber' => ['field' => 'q.idnumber', 'title' => get_string('idnumber', 'question')], ]; } diff --git a/question/classes/bank/view.php b/question/classes/bank/view.php index 850ce2b55ad..5bfe5d3ef22 100644 --- a/question/classes/bank/view.php +++ b/question/classes/bank/view.php @@ -347,7 +347,10 @@ class view { } protected function default_sort() { - return array('core_question\bank\question_type_column' => 1, 'core_question\bank\question_name_column' => 1); + return array( + 'core_question\bank\question_type_column' => 1, + 'core_question\bank\question_name_idnumber_tags_column-name' => 1 + ); } /** diff --git a/question/tests/behat/sort_questions.feature b/question/tests/behat/sort_questions.feature index 7a5c84d1bd9..25a103ec49c 100644 --- a/question/tests/behat/sort_questions.feature +++ b/question/tests/behat/sort_questions.feature @@ -18,10 +18,10 @@ Feature: The questions in the question bank can be sorted in various ways | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: - | questioncategory | qtype | name | user | questiontext | idnumber | - | Test questions | essay | A question 1 name | admin | Question 1 text | | - | Test questions | essay | B question 2 name | teacher1 | Question 2 text | | - | Test questions | numerical | C question 3 name | teacher1 | Question 3 text | numidnum | + | questioncategory | qtype | name | user | questiontext | idnumber | + | Test questions | essay | A question 1 name | admin | Question 1 text | numidnuma | + | Test questions | essay | B question 2 name | teacher1 | Question 2 text | | + | Test questions | numerical | C question 3 name | teacher1 | Question 3 text | numidnumc | And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Question bank > Questions" in current page administration @@ -33,8 +33,10 @@ Feature: The questions in the question bank can be sorted in various ways @javascript Scenario: The questions can be sorted by idnumber When I follow "Sort by ID number ascending" - Then "C question 3 name" "checkbox" should appear before "A question 1 name" "checkbox" - And I should see "numidnum" in the "C question 3 name" "table_row" + Then "C question 3 name" "checkbox" should appear after "A question 1 name" "checkbox" + And I should see "numidnumc" in the "C question 3 name" "table_row" + And I follow "Sort by ID number descending" + And "C question 3 name" "checkbox" should appear before "A question 1 name" "checkbox" @javascript Scenario: The questions can be sorted in reverse order by type -- 2.43.0