diff --git a/admin/tool/recyclebin/tests/behat/backup_user_data.feature b/admin/tool/recyclebin/tests/behat/backup_user_data.feature index c5cd73951e37d..fffae0cf84518 100644 --- a/admin/tool/recyclebin/tests/behat/backup_user_data.feature +++ b/admin/tool/recyclebin/tests/behat/backup_user_data.feature @@ -43,7 +43,7 @@ Feature: Backup user data | Feedback for the response 'False'. | So you think it is false | And I log out When I am on the "Quiz 1" "quiz activity" page logged in as student1 - And I follow "Attempt quiz" + And I press "Attempt quiz" And I click on "True" "radio" in the "First question" "question" And I click on "False" "radio" in the "Second question" "question" And I press "Finish attempt" diff --git a/badges/tests/behat/criteria_activity.feature b/badges/tests/behat/criteria_activity.feature index bc7379f8b0a39..98cae5e8fb7fa 100644 --- a/badges/tests/behat/criteria_activity.feature +++ b/badges/tests/behat/criteria_activity.feature @@ -57,7 +57,7 @@ Feature: Award badges based on activity completion And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed" And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo" When I am on the "Test quiz name" "quiz activity" page - And I follow "Attempt quiz" + And I press "Re-attempt quiz" And I set the field "False" to "1" And I press "Finish attempt ..." And I press "Submit all and finish" diff --git a/lang/en/question.php b/lang/en/question.php index 7d9d054a2b7fd..c30a3db43dd86 100644 --- a/lang/en/question.php +++ b/lang/en/question.php @@ -281,6 +281,8 @@ $string['qtypeveryshort'] = 'T'; $string['questionaffected'] = 'Question "{$a->name}" ({$a->qtype}) is in this question category but is also being used in quiz "{$a->quizname}" in another course "{$a->coursename}".'; $string['questionbank'] = 'Question bank'; +$string['questionbanknavigation'] = 'Question bank tertiary navigation'; +$string['questioncategories'] = 'Question categories'; $string['questioncategory'] = 'Question category'; $string['questioncatsfor'] = 'Question categories for \'{$a}\''; $string['questiondoesnotexist'] = 'This question does not exist'; diff --git a/question/bank/bulkmove/move.php b/question/bank/bulkmove/move.php index 0c6b966ce315f..d9e79c5c848ff 100644 --- a/question/bank/bulkmove/move.php +++ b/question/bank/bulkmove/move.php @@ -60,6 +60,8 @@ $streditingquestions = get_string('movequestions', 'qbank_bulkmove'); $PAGE->set_title($streditingquestions); $PAGE->set_heading($COURSE->fullname); +$PAGE->activityheader->disable(); +$PAGE->set_secondary_active_tab("questionbank"); if ($category) { list($tocategoryid, $contextid) = explode(',', $category); diff --git a/question/bank/bulkmove/tests/behat/bulk_move.feature b/question/bank/bulkmove/tests/behat/bulk_move.feature index c901035dda9d1..6ddf0980a8883 100644 --- a/question/bank/bulkmove/tests/behat/bulk_move.feature +++ b/question/bank/bulkmove/tests/behat/bulk_move.feature @@ -23,14 +23,14 @@ Feature: Use the qbank plugin manager page for bulkmove And I should see "Bulk move questions" And I click on "Disable" "link" in the "Bulk move questions" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on "First question" "checkbox" And I click on "With selected" "button" Then I should not see question bulk action "move" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Bulk move questions" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on "First question" "checkbox" And I click on "With selected" "button" And I should see question bulk action "move" diff --git a/question/bank/comment/tests/behat/question_comment.feature b/question/bank/comment/tests/behat/question_comment.feature index 76c07957a4e8a..18e306eff1d94 100644 --- a/question/bank/comment/tests/behat/question_comment.feature +++ b/question/bank/comment/tests/behat/question_comment.feature @@ -120,7 +120,7 @@ Feature: A Teacher can comment in a question Scenario: Comments added from the quiz page are visible Given I log in as "teacher1" And I am on the "Test quiz" "quiz activity" page - When I navigate to "Edit quiz" in current page administration + When I navigate to "Questions" in current page administration And I press "Add" And I follow "from question bank" And I click on "Select" "checkbox" in the "First question" "table_row" @@ -133,7 +133,7 @@ Feature: A Teacher can comment in a question And I should see "Some new comment" And I switch to the main window And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I choose "Preview" action for "First question" in the question bank And I click on "Comments" "link" And I should see "Some new comment" @@ -141,7 +141,7 @@ Feature: A Teacher can comment in a question And I delete "Some new comment" comment from question preview And I should not see "Some new comment" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Edit quiz" in current page administration + And I navigate to "Questions" in current page administration And I click on "Preview question" "link" And I switch to "questionpreview" window And I press "Comments" diff --git a/question/bank/customfields/tests/behat/customfield_question.feature b/question/bank/customfields/tests/behat/customfield_question.feature index aeecd4c27d2e6..133c1f0169fb8 100644 --- a/question/bank/customfields/tests/behat/customfield_question.feature +++ b/question/bank/customfields/tests/behat/customfield_question.feature @@ -38,7 +38,7 @@ Feature: A teacher can edit question with custom fields | Feedback for the response 'True'. | So you think it is true | | Feedback for the response 'False'. | So you think it is false | And I am on the "Test quiz name" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration Scenario: Edit a previously created question and see the custom field in the overview table and in the question preview. When I choose "Edit question" action for "First question" in the question bank diff --git a/question/bank/customfields/tests/behat/customfield_question_visbility.feature b/question/bank/customfields/tests/behat/customfield_question_visbility.feature index eda0000a4c85a..9ca11ff967fc4 100644 --- a/question/bank/customfields/tests/behat/customfield_question_visbility.feature +++ b/question/bank/customfields/tests/behat/customfield_question_visbility.feature @@ -38,7 +38,7 @@ Feature: The visibility of question custom fields control where they are display | Feedback for the response 'True'. | So you think it is true | | Feedback for the response 'False'. | So you think it is false | And I am on the "Test quiz name" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration @javascript Scenario: Display custom question fields to teachers based on their visibility. diff --git a/question/bank/deletequestion/delete.php b/question/bank/deletequestion/delete.php index a94334da0cb9c..b41ba32bdaede 100644 --- a/question/bank/deletequestion/delete.php +++ b/question/bank/deletequestion/delete.php @@ -58,6 +58,8 @@ $streditingquestions = get_string('deletequestion', 'qbank_deletequestion'); $PAGE->set_title($streditingquestions); $PAGE->set_heading($COURSE->fullname); +$PAGE->activityheader->disable(); +$PAGE->set_secondary_active_tab("questionbank"); // Unhide a question. if (($unhide = optional_param('unhide', '', PARAM_INT)) and confirm_sesskey()) { diff --git a/question/bank/deletequestion/tests/behat/delete_question_column.feature b/question/bank/deletequestion/tests/behat/delete_question_column.feature index 70dde129068e8..cdd38b623adff 100644 --- a/question/bank/deletequestion/tests/behat/delete_question_column.feature +++ b/question/bank/deletequestion/tests/behat/delete_question_column.feature @@ -23,13 +23,13 @@ Feature: Use the qbank plugin manager page for deletequestion And I should see "Delete question" And I click on "Disable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" Then I should not see "Delete" in the "region-main" "region" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" And I should see "Delete" in the "region-main" "region" @@ -40,13 +40,13 @@ Feature: Use the qbank plugin manager page for deletequestion And I should see "Delete question" And I click on "Disable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on "With selected" "button" Then I should not see question bulk action "deleteselected" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Delete question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on "With selected" "button" And I should see question bulk action "deleteselected" @@ -54,7 +54,7 @@ Feature: Use the qbank plugin manager page for deletequestion Scenario: I should not see the deleted questions in the base view Given I log in as "admin" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on "First question" "checkbox" And I click on "First question second" "checkbox" And I click on "With selected" "button" diff --git a/question/bank/editquestion/tests/behat/qbank_editquestion.feature b/question/bank/editquestion/tests/behat/qbank_editquestion.feature index 7c70d8e73c784..b85b15cd67cc7 100644 --- a/question/bank/editquestion/tests/behat/qbank_editquestion.feature +++ b/question/bank/editquestion/tests/behat/qbank_editquestion.feature @@ -23,7 +23,7 @@ Feature: Use the qbank plugin manager page for editquestion And I should see "Edit question" And I click on "Disable" "link" in the "Edit question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration Then I should not see "Status" And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" And I should not see "Edit question" in the "region-main" "region" @@ -31,7 +31,7 @@ Feature: Use the qbank plugin manager page for editquestion And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Edit question" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" Then I should see "Status" And I click on ".dropdown-toggle" "css_element" in the "First question" "table_row" diff --git a/question/bank/exportquestions/export.php b/question/bank/exportquestions/export.php index a36a7b0914dca..ca08cc60a139f 100644 --- a/question/bank/exportquestions/export.php +++ b/question/bank/exportquestions/export.php @@ -52,7 +52,9 @@ // Print horizontal nav if needed. $renderer = $PAGE->get_renderer('core_question', 'bank'); -echo $renderer->extra_horizontal_navigation(); + +$qbankaction = new \core_question\output\qbank_action_menu($thispageurl); +echo $renderer->render($qbankaction); $exportform = new export_form($thispageurl, ['contexts' => $contexts->having_one_edit_tab_cap('export'), 'defaultcategory' => $pagevars['cat']]); diff --git a/question/bank/importquestions/import.php b/question/bank/importquestions/import.php index 959acf90eaef3..dea5b4c2a7c1b 100644 --- a/question/bank/importquestions/import.php +++ b/question/bank/importquestions/import.php @@ -79,8 +79,9 @@ // Print horizontal nav if needed. $renderer = $PAGE->get_renderer('core_question', 'bank'); -echo $renderer->extra_horizontal_navigation(); +$qbankaction = new \core_question\output\qbank_action_menu($thispageurl); +echo $renderer->render($qbankaction); // File upload form submitted. if ($form = $importform->get_data()) { diff --git a/question/bank/managecategories/category.php b/question/bank/managecategories/category.php index e501edb3014c2..4a4208b4a4df1 100644 --- a/question/bank/managecategories/category.php +++ b/question/bank/managecategories/category.php @@ -50,11 +50,13 @@ $param->cancel = optional_param('cancel', '', PARAM_ALPHA); $param->move = optional_param('move', 0, PARAM_INT); $param->moveto = optional_param('moveto', 0, PARAM_INT); -$param->edit = optional_param('edit', 0, PARAM_INT); +$param->edit = optional_param('edit', null, PARAM_INT); $url = new moodle_url($thispageurl); foreach ((array)$param as $key => $value) { - if (($key !== 'cancel' && $value !== 0) || ($key === 'cancel' && $value !== '')) { + if (($key !== 'cancel' && $key !== 'edit' && $value !== 0) || + ($key === 'cancel' && $value !== '') || + ($key === 'edit' && $value !== null)) { $url->param($key, $value); } } @@ -144,7 +146,7 @@ redirect($thispageurl); } -if ($param->edit) { +if ($param->edit !== null) { $PAGE->navbar->add(get_string('editingcategory', 'question')); } @@ -156,10 +158,12 @@ // Print horizontal nav if needed. $renderer = $PAGE->get_renderer('core_question', 'bank'); -echo $renderer->extra_horizontal_navigation(); + +$qbankaction = new \core_question\output\qbank_action_menu($url); +echo $renderer->render($qbankaction); // Display the UI. -if (!empty($param->edit)) { +if ($param->edit !== null) { $qcobject->edit_single_category($param->edit); } else if ($questionstomove) { $qcobject->display_move_form($questionstomove, $category); diff --git a/question/bank/managecategories/classes/form/question_category_edit_form.php b/question/bank/managecategories/classes/form/question_category_edit_form.php index 8bb43378f54d6..908150f2d6999 100644 --- a/question/bank/managecategories/classes/form/question_category_edit_form.php +++ b/question/bank/managecategories/classes/form/question_category_edit_form.php @@ -71,7 +71,7 @@ protected function definition() { $mform->addHelpButton('idnumber', 'idnumber', 'question'); $mform->setType('idnumber', PARAM_RAW); - $this->add_action_buttons(false, get_string('addcategory', 'question')); + $this->add_action_buttons(true, get_string('addcategory', 'question')); $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); diff --git a/question/bank/managecategories/classes/question_category_object.php b/question/bank/managecategories/classes/question_category_object.php index 4d41fedab5f4d..39e6d561cc5f4 100644 --- a/question/bank/managecategories/classes/question_category_object.php +++ b/question/bank/managecategories/classes/question_category_object.php @@ -136,7 +136,8 @@ public function initialize($page, $contexts, $currentcat, $defaultcategory, $tod foreach ($this->editlists as $key => $list) { list($paged, $count) = $this->editlists[$key]->list_from_records($paged, $count); } - $this->catform = new question_category_edit_form($this->pageurl, compact('contexts', 'currentcat')); + $this->catform = new question_category_edit_form($this->pageurl, + ['contexts' => $contexts, 'currentcat' => $currentcat ?? 0]); if (!$currentcat) { $this->catform->set_data(['parent' => $defaultcategory]); } @@ -147,15 +148,8 @@ public function initialize($page, $contexts, $currentcat, $defaultcategory, $tod * */ public function display_user_interface(): void { - // Interface for editing existing categories. $this->output_edit_lists(); - - echo \html_writer::empty_tag('br'); - // Interface for adding a new category. - $this->output_new_table(); - echo \html_writer::empty_tag('br'); - } /** @@ -174,7 +168,7 @@ public function output_new_table(): void { public function output_edit_lists(): void { global $OUTPUT; - echo $OUTPUT->heading_with_help(get_string('editcategories', 'question'), 'editcategories', 'question'); + echo $OUTPUT->heading_with_help(get_string('questioncategories', 'question'), 'editcategories', 'question'); foreach ($this->editlists as $context => $list) { $listhtml = $list->to_html(0, ['str' => $this->str]); @@ -208,26 +202,29 @@ public function get_course_ids(array $categories): array { } /** - * Edit a category. + * Edit a category, or add a new one if the id is zero. * * @param int $categoryid Category id. */ public function edit_single_category(int $categoryid): void { // Interface for adding a new category. global $DB; - // Interface for editing existing categories. - $category = $DB->get_record("question_categories", ["id" => $categoryid]); - if (empty($category)) { - throw new moodle_exception('invalidcategory', '', '', $categoryid); - } else if ($category->parent == 0) { - throw new moodle_exception('cannotedittopcat', 'question', '', $categoryid); - } else { + + if ($categoryid) { + // Editing an existing category. + $category = $DB->get_record("question_categories", ["id" => $categoryid], '*', MUST_EXIST); + if ($category->parent == 0) { + throw new moodle_exception('cannotedittopcat', 'question', '', $categoryid); + } + $category->parent = "{$category->parent},{$category->contextid}"; $category->submitbutton = get_string('savechanges'); $category->categoryheader = $this->str->edit; $this->catform->set_data($category); - $this->catform->display(); } + + // Show the form. + $this->catform->display(); } /** diff --git a/question/bank/managecategories/tests/behat/move_question_categories.feature b/question/bank/managecategories/tests/behat/move_question_categories.feature index d34e9797fd300..b548617fa4096 100644 --- a/question/bank/managecategories/tests/behat/move_question_categories.feature +++ b/question/bank/managecategories/tests/behat/move_question_categories.feature @@ -22,7 +22,9 @@ Feature: A teacher can move question categories in the question bank Scenario: A question category can be moved to another context When I follow "Test quiz" - And I navigate to "Question bank > Categories" in current page administration + And I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect + And I follow "Add category" And I set the following fields to these values: | Name | Test category | | Parent category | Top for Test quiz | @@ -32,7 +34,9 @@ Feature: A teacher can move question categories in the question bank Scenario: A question category can be moved to top level When I follow "Test quiz" - And I navigate to "Question bank > Categories" in current page administration + And I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect + And I follow "Add category" And I set the following fields to these values: | Name | Test category | | Parent category | Default for Test quiz | diff --git a/question/bank/managecategories/tests/behat/question_categories.feature b/question/bank/managecategories/tests/behat/question_categories.feature index 70b4b93645763..03cd0a762e509 100644 --- a/question/bank/managecategories/tests/behat/question_categories.feature +++ b/question/bank/managecategories/tests/behat/question_categories.feature @@ -27,7 +27,9 @@ Feature: A teacher can put questions in categories in the question bank And I am on "Course 1" course homepage Scenario: A new question category can be created - When I navigate to "Question bank > Categories" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect + And I follow "Add category" And I set the following fields to these values: | Name | New Category 1 | | Parent category | Top | @@ -39,10 +41,12 @@ Feature: A teacher can put questions in categories in the question bank And I should see "newcatidnumber" And I should see "(0)" And I should see "Created as a test" in the "New Category 1" "list_item" + And I follow "Add category" And "New Category 1 [newcatidnumber]" "option" should exist in the "Parent category" "select" Scenario: A question category can be edited - When I navigate to "Question bank > Categories" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect And I click on "Edit this category" "link" in the "Subcategory" "list_item" And the field "parent" matches value "   Default for C1" And I set the following fields to these values: @@ -53,14 +57,17 @@ Feature: A teacher can put questions in categories in the question bank And I should see "I was edited" in the "New name" "list_item" Scenario: An empty question category can be deleted - When I navigate to "Question bank > Categories" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect And I click on "Delete" "link" in the "Subcategory" "list_item" Then I should not see "Subcategory" Scenario: An non-empty question category can be deleted if you move the contents elsewhere - When I navigate to "Question bank > Categories" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect And I click on "Delete" "link" in the "Used category" "list_item" And I should see "The category 'Used category' contains 1 questions" And I press "Save in category" Then I should not see "Used category" + And I follow "Add category" And I should see "Default for C1 (1)" diff --git a/question/bank/managecategories/tests/behat/question_categories_idnumber.feature b/question/bank/managecategories/tests/behat/question_categories_idnumber.feature index 95226aa5046c9..c3199726d2c6f 100644 --- a/question/bank/managecategories/tests/behat/question_categories_idnumber.feature +++ b/question/bank/managecategories/tests/behat/question_categories_idnumber.feature @@ -23,18 +23,22 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | contextlevel | reference | questioncategory | name | idnumber | | Course | C1 | Top | top | | | Course | C1 | top | Used category | c1used | - And I navigate to "Question bank > Categories" in current page administration + And I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect + And I follow "Add category" And I set the following fields to these values: | Name | Sub used category | | Parent category | Used category | | Category info | Created as a test | | ID number | c1used | - And I press "Add category" + # Press the Add category button in category page. + And I click on "Add category" "button" in the "[id='fitem_id_submitbutton']" "css_element" # Standard warning. Then I should see "This ID number is already in use" # Correction to a unique idnumber for the context. And I set the field "ID number" to "c1unused" - And I press "Add category" + # Press the Add category button in the addcategory page. + And I click on "[id='id_submitbutton']" "css_element" Then I should see "Sub used category" And I should see "ID number" And I should see "c1unused" @@ -46,7 +50,8 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | contextlevel | reference | questioncategory | name | idnumber | | Course | C1 | Top | top | | | Course | C1 | top | Used category | c1used | - And I navigate to "Question bank > Categories" in current page administration + And I navigate to "Question bank" in current page administration + And I select "Categories" from the "questionbankactionselect" singleselect And I click on "Edit this category" "link" in the "Used category" "list_item" And I press "Save changes" Then I should not see "This ID number is already in use" diff --git a/question/bank/managecategories/tests/behat/view_manage_categories_plugin.feature b/question/bank/managecategories/tests/behat/view_manage_categories_plugin.feature index b74387bdc5357..ac121f0ef54e0 100644 --- a/question/bank/managecategories/tests/behat/view_manage_categories_plugin.feature +++ b/question/bank/managecategories/tests/behat/view_manage_categories_plugin.feature @@ -22,13 +22,12 @@ Feature: Use the qbank plugin manager page for managecategories And I should see "Manage categories" And I click on "Disable" "link" in the "Manage categories" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank" in current page administration - Then I should not see "Categories" + Then "Categories" "link" should not exist in current page administration And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Manage categories" "table_row" And I am on the "Test quiz" "quiz activity" page And I navigate to "Question bank" in current page administration - And I should see "Categories" + And I should see "Categories" in the "//div[contains(@class, 'urlselect')]//option[contains(text(), 'Categories')]" "xpath_element" Scenario: Enable/disable the tab New category when tyring to add a random question to a quiz Given I log in as "admin" @@ -36,7 +35,7 @@ Feature: Use the qbank plugin manager page for managecategories And I should see "Manage categories" And I click on "Disable" "link" in the "Manage categories" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Edit quiz" in current page administration + And I click on "Add question" "link" And I open the "last" add to quiz menu And I follow "a random question" Then I should not see "New category" @@ -44,7 +43,7 @@ Feature: Use the qbank plugin manager page for managecategories And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Manage categories" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Edit quiz" in current page administration + And I click on "Add question" "link" And I open the "last" add to quiz menu And I follow "a random question" And I should see "New category" diff --git a/question/bank/statistics/tests/behat/statistics_action.feature b/question/bank/statistics/tests/behat/statistics_action.feature index a9cc033d46065..4962d9456bce0 100644 --- a/question/bank/statistics/tests/behat/statistics_action.feature +++ b/question/bank/statistics/tests/behat/statistics_action.feature @@ -22,14 +22,14 @@ Feature: Use the qbank plugin manager page for statistics And I should see "Question statistics" And I click on "Disable" "link" in the "Question statistics" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration Then I should not see "Facility index" And I should not see "Discriminative efficiency" And I should not see "Need for revision" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Question statistics" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I should see "Facility index" And I should see "Discriminative efficiency" And I should see "Need for revision" diff --git a/question/bank/statistics/tests/behat/statistics_values.feature b/question/bank/statistics/tests/behat/statistics_values.feature index 26015d44e486c..24d301a4a343d 100644 --- a/question/bank/statistics/tests/behat/statistics_values.feature +++ b/question/bank/statistics/tests/behat/statistics_values.feature @@ -73,7 +73,7 @@ Feature: Show statistics in question bank | 1 | True | | 2 | True | When I am on the "Course 1" course page logged in as admin - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I should see "50.00%" in the "TF1" "table_row" And I should see "75.00%" in the "TF2" "table_row" And I should see "75.00%" in the "TF3" "table_row" @@ -89,7 +89,7 @@ Feature: Show statistics in question bank | 1 | True | | 2 | True | When I am on the "Course 1" course page logged in as admin - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I should see "50.00%" in the "TF1" "table_row" And I should see "75.00%" in the "TF2" "table_row" And I should see "75.00%" in the "TF3" "table_row" @@ -105,13 +105,13 @@ Feature: Show statistics in question bank | 1 | True | | 2 | True | When I am on the "Course 1" course page logged in as admin - And I navigate to "Question bank > Questions" in current page administration - And I should see "likely" in the "TF1" "table_row" - And I should see "unlikely" in the "TF2" "table_row" - And I should see "unlikely" in the "TF3" "table_row" - And I should see "likely" in the "TF4" "table_row" - And I should see "likely" in the ".alert-warning" "css_element" - And I should see "unlikely" in the ".alert-success" "css_element" + And I navigate to "Question bank" in current page administration + And I should see "Likely" in the "TF1" "table_row" + And I should see "Unlikely" in the "TF2" "table_row" + And I should see "Unlikely" in the "TF3" "table_row" + And I should see "Likely" in the "TF4" "table_row" + And I should see "Likely" in the ".alert-warning" "css_element" + And I should see "Unlikely" in the ".alert-success" "css_element" Scenario: View discrimination index in question bank, bad questions Given user "student1" has attempted "Quiz 2" with responses: @@ -127,10 +127,10 @@ Feature: Show statistics in question bank | 1 | True | | 2 | False | When I am on the "Course 1" course page logged in as admin - And I navigate to "Question bank > Questions" in current page administration - And I should see "likely" in the "TF1" "table_row" - And I should see "very likely" in the "TF2" "table_row" - And I should see "very likely" in the "TF3" "table_row" - And I should see "likely" in the "TF4" "table_row" - And I should see "very likely" in the ".alert-danger" "css_element" - And I should see "likely" in the ".alert-warning" "css_element" + And I navigate to "Question bank" in current page administration + And I should see "Likely" in the "TF1" "table_row" + And I should see "Very likely" in the "TF2" "table_row" + And I should see "Very likely" in the "TF3" "table_row" + And I should see "Likely" in the "TF4" "table_row" + And I should see "Very likely" in the ".alert-danger" "css_element" + And I should see "Likely" in the ".alert-warning" "css_element" diff --git a/question/bank/usage/tests/behat/question_usage_column.feature b/question/bank/usage/tests/behat/question_usage_column.feature index f16eb31725508..ed0f73b18fe06 100644 --- a/question/bank/usage/tests/behat/question_usage_column.feature +++ b/question/bank/usage/tests/behat/question_usage_column.feature @@ -22,19 +22,19 @@ Feature: Use the qbank plugin manager page for question usage And I should see "Question usage" When I click on "Disable" "link" in the "Question usage" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration Then I should not see "Usage" And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration And I click on "Enable" "link" in the "Question usage" "table_row" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I should see "Usage" @javascript Scenario: Question usage modal should work without any usage data Given I log in as "admin" And I am on the "Test quiz" "quiz activity" page - And I navigate to "Question bank > Questions" in current page administration + And I navigate to "Question bank" in current page administration And I set the field "Select a category" to "Test questions" And I should see "Test questions" And I should see "0" on the usage column diff --git a/question/classes/output/qbank_action_menu.php b/question/classes/output/qbank_action_menu.php new file mode 100644 index 0000000000000..12093ea6e8d4c --- /dev/null +++ b/question/classes/output/qbank_action_menu.php @@ -0,0 +1,89 @@ +. + +namespace core_question\output; + +use moodle_url; +use renderer_base; +use templatable; +use renderable; +use url_select; + +/** + * Rendered HTML elements for tertiary nav for Question bank. + * + * Provides the links for question bank tertiary navigation, below + * are the links provided for the urlselector: + * Questions, Categories, Import and Export + * Also "Add category" button is added to tertiary nav for the categories. + * The "Add category" would take the user to separate page, add category page. + * + * @package core_question + * @copyright 2021 Sujith Haridasan + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class qbank_action_menu implements templatable, renderable { + /** @var moodle_url */ + private $currenturl; + + /** + * qbank_actionbar constructor. + * + * @param moodle_url $currenturl The current URL. + */ + public function __construct(moodle_url $currenturl) { + $this->currenturl = $currenturl; + } + + /** + * Provides the data for the template. + * + * @param renderer_base $output renderer_base object. + * @return array data for the template + */ + public function export_for_template(renderer_base $output): array { + $questionslink = new moodle_url('/question/edit.php', $this->currenturl->params()); + if (\core\plugininfo\qbank::is_plugin_enabled("qbank_managecategories")) { + $categorylink = new moodle_url('/question/bank/managecategories/category.php', $this->currenturl->params()); + } + $importlink = new moodle_url('/question/bank/importquestions/import.php', $this->currenturl->params()); + $exportlink = new moodle_url('/question/bank/exportquestions/export.php', $this->currenturl->params()); + + $menu = [ + $questionslink->out(false) => get_string('questions', 'question'), + ]; + + if (\core\plugininfo\qbank::is_plugin_enabled("qbank_managecategories")) { + $menu[$categorylink->out(false)] = get_string('categories', 'question'); + } + $menu[$importlink->out(false)] = get_string('import', 'question'); + $menu[$exportlink->out(false)] = get_string('export', 'question'); + + $addcategory = null; + if (strpos($this->currenturl->get_path(), 'category.php') !== false && + $this->currenturl->param('edit') === null) { + $addcategory = $this->currenturl->out(false, ['edit' => 0]); + } + + $urlselect = new url_select($menu, $this->currenturl->out(false), null, 'questionbankaction'); + $urlselect->set_label(get_string('questionbanknavigation', 'question'), ['class' => 'accesshide']); + + return [ + 'questionbankselect' => $urlselect->export_for_template($output), + 'addcategory' => $addcategory + ]; + } +} diff --git a/question/edit.php b/question/edit.php index 2c386c29342cc..1b961845c6031 100644 --- a/question/edit.php +++ b/question/edit.php @@ -52,7 +52,10 @@ // Print horizontal nav if needed. $renderer = $PAGE->get_renderer('core_question', 'bank'); -echo $renderer->extra_horizontal_navigation(); + +// Render the selection action. +$qbankaction = new \core_question\output\qbank_action_menu($url); +echo $renderer->render($qbankaction); // Print the question area. $questionbank->display($pagevars, 'questions'); diff --git a/question/format/aiken/tests/behat/aiken_export.feature b/question/format/aiken/tests/behat/aiken_export.feature index 13bddf67deaab..9f937a7c22d3a 100644 --- a/question/format/aiken/tests/behat/aiken_export.feature +++ b/question/format/aiken/tests/behat/aiken_export.feature @@ -25,7 +25,8 @@ Feature: Test exporting questions using Aiken format. And I am on "Course 1" course homepage Scenario: Aiken export - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_aiken" to "1" When I press "Export questions to file" Then following "click here" should download between "68" and "70" bytes diff --git a/question/format/aiken/tests/behat/aiken_import.feature b/question/format/aiken/tests/behat/aiken_import.feature index 520b2ef2259cb..807e7f80f0222 100644 --- a/question/format/aiken/tests/behat/aiken_import.feature +++ b/question/format/aiken/tests/behat/aiken_import.feature @@ -19,7 +19,8 @@ Feature: Test importing questions from Aiken format. @javascript @_file_upload Scenario: import some Aiken questions - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_aiken" to "1" And I upload "question/format/aiken/tests/fixtures/questions.aiken.txt" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/format/gift/tests/behat/import_export.feature b/question/format/gift/tests/behat/import_export.feature index 48f0227321f02..e398594c95fba 100644 --- a/question/format/gift/tests/behat/import_export.feature +++ b/question/format/gift/tests/behat/import_export.feature @@ -19,7 +19,8 @@ Feature: Test importing questions from GIFT format. @javascript @_file_upload Scenario: import some GIFT questions - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_gift" to "1" And I upload "question/format/gift/tests/fixtures/questions.gift.txt" file to "Import" filemanager And I press "id_submitbutton" @@ -30,14 +31,17 @@ Feature: Test importing questions from GIFT format. Then I should see "colours" # Now export again. - And I follow "Export" + And I am on "Course 1" course homepage + And I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_gift" to "1" And I press "Export questions to file" And following "click here" should download between "1500" and "1800" bytes @javascript @_file_upload Scenario: import a GIFT file which specifies the category - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_gift" to "1" And I upload "question/format/gift/tests/fixtures/questions_in_category.gift.txt" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/format/xml/tests/behat/import_export.feature b/question/format/xml/tests/behat/import_export.feature index 0be26d71ddcf8..48e2cca5e770c 100644 --- a/question/format/xml/tests/behat/import_export.feature +++ b/question/format/xml/tests/behat/import_export.feature @@ -19,7 +19,8 @@ Feature: Test importing questions from Moodle XML format. @javascript @_file_upload Scenario: import some true/false questions from Moodle XML format - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/format/xml/tests/fixtures/truefalse.xml" file to "Import" filemanager And I press "id_submitbutton" @@ -32,7 +33,9 @@ Feature: Test importing questions from Moodle XML format. Then I should see "Moodle acronym (True)" # Now export again. - And I follow "Export" + And I am on "Course 1" course homepage + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I set the field "Export category" to "TrueFalse" And I press "Export questions to file" @@ -40,7 +43,8 @@ Feature: Test importing questions from Moodle XML format. @javascript @_file_upload Scenario: import some multiple choice questions from Moodle XML format - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/format/xml/tests/fixtures/multichoice.xml" file to "Import" filemanager And I press "id_submitbutton" @@ -52,7 +56,8 @@ Feature: Test importing questions from Moodle XML format. @javascript @_file_upload Scenario: import some multi-answer questions from Moodle XML format - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager And I press "id_submitbutton" @@ -64,7 +69,8 @@ Feature: Test importing questions from Moodle XML format. @javascript @_file_upload Scenario: import some questions with legacy-style images from Moodle XML format - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/format/xml/tests/fixtures/sample_questions_with_old_image_tag.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/templates/qbank_action_menu.mustache b/question/templates/qbank_action_menu.mustache new file mode 100644 index 0000000000000..37d0b0f5372cc --- /dev/null +++ b/question/templates/qbank_action_menu.mustache @@ -0,0 +1,70 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template core_question/qbank_action_menu + + Question bank tertiary navigtion. + + Classes required for JS: + * none + + Context variables required for this template: + * see question/classes/output/qbank_actionbar.php + + Example context (json): + { + "questionbankselect": { + "action": "http://localhost/moodle/course/jumpto.php", + "classes": "urlselect", + "formid": "questionbankaction", + "id": "url_select61a85bc543dca7", + "label": "questionbankactionselect", + "options": [{ + "name": "Questions", + "selected": true, + "value": "/question/edit.php?courseid=7" + }, + { + "name": "Categories", + "selected": false, + "value": "/question/bank/managecategories/category.php?courseid=7" + }, + { + "name": "Import", + "selected": false, + "value": "/question/bank/importquestions/import.php?courseid=7" + }, + { + "name": "Export", + "selected": false, + "value": "/question/bank/exportquestions/export.php?courseid=7" + } + ] + }, + "addcategory": "http://localhost/moodle/question/bank/managecategories/addcategory.php?cmid=71" + } +}} +
+
+ {{#questionbankselect}} + {{>core/url_select}} + {{/questionbankselect}} + {{#addcategory}} + {{#str}}addcategory, question {{/str}} + {{/addcategory}} +
+
diff --git a/question/tests/behat/delete_questions.feature b/question/tests/behat/delete_questions.feature index 428ee233493ba..b37469e0ed52f 100644 --- a/question/tests/behat/delete_questions.feature +++ b/question/tests/behat/delete_questions.feature @@ -60,7 +60,7 @@ Feature: A teacher can delete questions in the question bank And I click on "Also show old questions" "checkbox" And I should see "Test used question to be deleted" And I am on the "Test quiz" "quiz activity" page - And I click on "Preview quiz now" "button" + And I click on "Preview quiz" "button" And I should see "Write about whatever you want" @javascript diff --git a/question/type/ddimageortext/tests/behat/export.feature b/question/type/ddimageortext/tests/behat/export.feature index 61f582f1a5e5c..62265d391ab71 100644 --- a/question/type/ddimageortext/tests/behat/export.feature +++ b/question/type/ddimageortext/tests/behat/export.feature @@ -26,7 +26,8 @@ Feature: Test exporting drag and drop onto image questions @javascript Scenario: Export a drag and drop onto image question # Import sample file. - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" And following "click here" should download between "18600" and "19150" bytes diff --git a/question/type/ddimageortext/tests/behat/import.feature b/question/type/ddimageortext/tests/behat/import.feature index 65c64db824f15..d10b432d9a9ce 100644 --- a/question/type/ddimageortext/tests/behat/import.feature +++ b/question/type/ddimageortext/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing drag and drop onto image questions @javascript @_file_upload Scenario: import drag and drop onto image question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/ddimageortext/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/ddmarker/tests/behat/export.feature b/question/type/ddmarker/tests/behat/export.feature index 80928780368ca..8b19622982282 100644 --- a/question/type/ddmarker/tests/behat/export.feature +++ b/question/type/ddmarker/tests/behat/export.feature @@ -26,7 +26,8 @@ Feature: Test exporting drag and drop markers questions @javascript Scenario: Export a drag and drop markers question # Import sample file. - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" And following "click here" should download between "233700" and "233950" bytes diff --git a/question/type/ddmarker/tests/behat/import.feature b/question/type/ddmarker/tests/behat/import.feature index 38ddf880fa48c..ba32882d9d0ea 100644 --- a/question/type/ddmarker/tests/behat/import.feature +++ b/question/type/ddmarker/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing drag and drop markers questions @javascript @_file_upload Scenario: import drag and drop markers question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/ddmarker/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/ddwtos/tests/behat/export.feature b/question/type/ddwtos/tests/behat/export.feature index 03729a1c9eb69..ae6151892dbca 100644 --- a/question/type/ddwtos/tests/behat/export.feature +++ b/question/type/ddwtos/tests/behat/export.feature @@ -26,7 +26,8 @@ Feature: Test exporting drag and drop into text questions @javascript Scenario: Export a drag and drop into text question # Import sample file. - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" And following "click here" should download between "1550" and "1700" bytes diff --git a/question/type/ddwtos/tests/behat/import.feature b/question/type/ddwtos/tests/behat/import.feature index 9785350456d97..2659d869cf9ba 100644 --- a/question/type/ddwtos/tests/behat/import.feature +++ b/question/type/ddwtos/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing drag and drop into text questions @javascript @_file_upload Scenario: import drag and drop into text question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/ddwtos/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/description/tests/behat/export.feature b/question/type/description/tests/behat/export.feature index a630926060c49..91c300fda38c4 100644 --- a/question/type/description/tests/behat/export.feature +++ b/question/type/description/tests/behat/export.feature @@ -24,7 +24,8 @@ Feature: Test exporting Description questions And I am on "Course 1" course homepage Scenario: Export a Description question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "650" and "900" bytes diff --git a/question/type/description/tests/behat/import.feature b/question/type/description/tests/behat/import.feature index 53bdb1964ea15..3b7cf52f85d5c 100644 --- a/question/type/description/tests/behat/import.feature +++ b/question/type/description/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Description questions @javascript @_file_upload Scenario: import a Description question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/description/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/essay/tests/behat/export.feature b/question/type/essay/tests/behat/export.feature index deef3d77558ae..a3b7aa59188f5 100644 --- a/question/type/essay/tests/behat/export.feature +++ b/question/type/essay/tests/behat/export.feature @@ -26,7 +26,8 @@ Feature: Test exporting Essay questions And I am on "Course 1" course homepage Scenario: Export 3 Essay questions - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "3000" and "3500" bytes diff --git a/question/type/essay/tests/behat/file_type_restriction.feature b/question/type/essay/tests/behat/file_type_restriction.feature index d44c89ea98362..4e1f280c6d5fa 100644 --- a/question/type/essay/tests/behat/file_type_restriction.feature +++ b/question/type/essay/tests/behat/file_type_restriction.feature @@ -46,7 +46,7 @@ I need to limit the submittable file types And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager And I press "Save changes" And I am on the "Quiz 1" "quiz activity" page - And I press "Attempt quiz now" + And I press "Attempt quiz" And I should see "First question" And I should see "You can drag and drop files here to add them." And I click on "Add..." "button" @@ -64,7 +64,7 @@ I need to limit the submittable file types And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager And I press "Save changes" And I am on the "Quiz 1" "quiz activity" page - And I press "Attempt quiz now" + And I press "Attempt quiz" And I should see "First question" And I should see "You can drag and drop files here to add them." And I click on "Add..." "button" diff --git a/question/type/essay/tests/behat/import.feature b/question/type/essay/tests/behat/import.feature index e365569e370e5..e756b8f6eb1c7 100644 --- a/question/type/essay/tests/behat/import.feature +++ b/question/type/essay/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Essay questions @javascript @_file_upload Scenario: import Essay question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/essay/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/gapselect/tests/behat/import_test.feature b/question/type/gapselect/tests/behat/import_test.feature index a7d5018de8eb0..24cb258f7479e 100644 --- a/question/type/gapselect/tests/behat/import_test.feature +++ b/question/type/gapselect/tests/behat/import_test.feature @@ -20,7 +20,8 @@ Feature: Import and export select missing words questions @javascript @_file_upload Scenario: Import and export select missing words questions # Import sample file. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/gapselect/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" @@ -31,7 +32,9 @@ Feature: Import and export select missing words questions And I should see "Imported Select missing words 001" # Now export again. - When I follow "Export" + And I am on "Course 1" course homepage + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "1650" and "1800" bytes diff --git a/question/type/match/tests/behat/export.feature b/question/type/match/tests/behat/export.feature index 4b1b08db9aea3..0df927c1ca204 100644 --- a/question/type/match/tests/behat/export.feature +++ b/question/type/match/tests/behat/export.feature @@ -24,7 +24,8 @@ Feature: Test exporting Matching questions And I am on "Course 1" course homepage Scenario: Export a Matching question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "1600" and "1750" bytes diff --git a/question/type/match/tests/behat/import.feature b/question/type/match/tests/behat/import.feature index 99308528b2eb1..a7511298eeca7 100644 --- a/question/type/match/tests/behat/import.feature +++ b/question/type/match/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Matching questions @javascript @_file_upload Scenario: import Matching question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/match/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/multichoice/tests/behat/clearanswers.feature b/question/type/multichoice/tests/behat/clearanswers.feature index 95c7c5d27dfee..75f2f4c615222 100644 --- a/question/type/multichoice/tests/behat/clearanswers.feature +++ b/question/type/multichoice/tests/behat/clearanswers.feature @@ -40,7 +40,7 @@ Feature: Clear my answers @javascript Scenario: Attempt a quiz and reset my chosen answer. Given I am on the "Quiz 1" "quiz activity" page logged in as student1 - When I press "Attempt quiz now" + When I press "Attempt quiz" And I should see "Question One" And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question" And I should see "Clear my choice" @@ -52,7 +52,7 @@ Feature: Clear my answers @javascript Scenario: Attempt a quiz and revisit a cleared answer. Given I am on the "Quiz 1" "quiz activity" page logged in as student1 - When I press "Attempt quiz now" + When I press "Attempt quiz" And I should see "Question One" And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question" And I follow "Finish attempt ..." diff --git a/question/type/multichoice/tests/behat/export.feature b/question/type/multichoice/tests/behat/export.feature index 27fd30eb613d0..1d4c8a227638a 100644 --- a/question/type/multichoice/tests/behat/export.feature +++ b/question/type/multichoice/tests/behat/export.feature @@ -25,7 +25,8 @@ Feature: Test exporting Multiple choice questions And I am on "Course 1" course homepage Scenario: Export a Multiple choice question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "3900" and "4100" bytes diff --git a/question/type/multichoice/tests/behat/import.feature b/question/type/multichoice/tests/behat/import.feature index 53744321b2e36..79e7dc9abc7b0 100644 --- a/question/type/multichoice/tests/behat/import.feature +++ b/question/type/multichoice/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Multiple choice questions @javascript @_file_upload Scenario: import Multiple choice question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/multichoice/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/numerical/tests/behat/export.feature b/question/type/numerical/tests/behat/export.feature index 7d3f920819c3b..d77074457dade 100644 --- a/question/type/numerical/tests/behat/export.feature +++ b/question/type/numerical/tests/behat/export.feature @@ -25,7 +25,8 @@ Feature: Test exporting Numerical questions And I am on "Course 1" course homepage Scenario: Export a Numerical question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "3650" and "3750" bytes diff --git a/question/type/numerical/tests/behat/import.feature b/question/type/numerical/tests/behat/import.feature index 6995a63dc0fdc..b7026ea5748d2 100644 --- a/question/type/numerical/tests/behat/import.feature +++ b/question/type/numerical/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Numerical questions @javascript @_file_upload Scenario: import Numerical question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/numerical/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/shortanswer/tests/behat/export.feature b/question/type/shortanswer/tests/behat/export.feature index e80449a994cf5..d83243fecb142 100644 --- a/question/type/shortanswer/tests/behat/export.feature +++ b/question/type/shortanswer/tests/behat/export.feature @@ -24,7 +24,8 @@ Feature: Test exporting Short answer questions And I am on "Course 1" course homepage Scenario: Export a Short answer question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "1200" and "1450" bytes diff --git a/question/type/shortanswer/tests/behat/import.feature b/question/type/shortanswer/tests/behat/import.feature index 4890809442958..a8df6faea9174 100644 --- a/question/type/shortanswer/tests/behat/import.feature +++ b/question/type/shortanswer/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing Short answer questions @javascript @_file_upload Scenario: import Matching question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/shortanswer/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/truefalse/tests/behat/export.feature b/question/type/truefalse/tests/behat/export.feature index 1f0f4ad9c66e3..81b9de39ade9b 100644 --- a/question/type/truefalse/tests/behat/export.feature +++ b/question/type/truefalse/tests/behat/export.feature @@ -24,7 +24,8 @@ Feature: Test exporting True/False questions And I am on "Course 1" course homepage Scenario: Export a True/False question - When I navigate to "Question bank > Export" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Export" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I press "Export questions to file" Then following "click here" should download between "1000" and "1200" bytes diff --git a/question/type/truefalse/tests/behat/import.feature b/question/type/truefalse/tests/behat/import.feature index 7a3bd4c117446..4bf13dceb86d3 100644 --- a/question/type/truefalse/tests/behat/import.feature +++ b/question/type/truefalse/tests/behat/import.feature @@ -19,7 +19,8 @@ Feature: Test importing True/False questions @javascript @_file_upload Scenario: import a True/False question. - When I navigate to "Question bank > Import" in current page administration + When I navigate to "Question bank" in current page administration + And I select "Import" from the "questionbankactionselect" singleselect And I set the field "id_format_xml" to "1" And I upload "question/type/truefalse/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/theme/classic/tests/behat/behat_theme_classic_behat_navigation.php b/theme/classic/tests/behat/behat_theme_classic_behat_navigation.php index 791274e6c7d4b..af1a828ad469f 100644 --- a/theme/classic/tests/behat/behat_theme_classic_behat_navigation.php +++ b/theme/classic/tests/behat/behat_theme_classic_behat_navigation.php @@ -158,7 +158,7 @@ public function should_exist_in_current_page_administration($element, $selectort $this->find('xpath', $menuxpath, $exception); } catch (Exception $e) { // For question bank a different approach. - $menuxpath = $rootxpath . "//div[contains(@class, 'dropdown-menu')]"; + $menuxpath = $rootxpath; if ($selectortype === 'link') { $menuxpath .= "//a[contains(text(), 'Categories')]"; }