Skip to content

Commit

Permalink
Merge branch 'MDL-71912-master-v5' of git://github.com/abgreeve/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Nov 10, 2021
2 parents 0c9f92a + e5b0be3 commit d824172
Show file tree
Hide file tree
Showing 25 changed files with 145 additions and 47 deletions.
Expand Up @@ -67,7 +67,7 @@ Feature: Enable Block Completion in a course using activity completion
And I follow "More details"
And I should see "Yes" in the "Activity completion" "table_row"

@javascript @skip_interim
@javascript
Scenario: Add the block to a the course and add course completion items with passing grade
Given I am on the "Test assign name" "assign activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
Expand All @@ -78,7 +78,7 @@ Feature: Enable Block Completion in a course using activity completion
| gradepass | 50 |
And I press "Save and return to course"
And I am on the "Test assign name" "assign activity" page
And I navigate to "View all submissions" in current page administration
And I follow "View all submissions"
And I click on "Grade" "link" in the "Student" "table_row"
And I set the field "Grade out of 100" to "53"
And I set the field "Notify students" to "0"
Expand All @@ -101,7 +101,7 @@ Feature: Enable Block Completion in a course using activity completion
And I should see "Achieving grade, Achieving passing grade" in the "Activity completion" "table_row"
And I should see "Yes" in the "Activity completion" "table_row"

@javascript @skip_interim
@javascript
Scenario: Add the block to a the course and add course completion items with failing grade.
Given I am on the "Test assign name" "assign activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
Expand All @@ -112,7 +112,7 @@ Feature: Enable Block Completion in a course using activity completion
| gradepass | 50 |
And I press "Save and return to course"
And I am on the "Test assign name" "assign activity" page
And I navigate to "View all submissions" in current page administration
And I follow "View all submissions"
And I click on "Grade" "link" in the "Student" "table_row"
And I set the field "Grade out of 100" to "49"
And I set the field "Notify students" to "0"
Expand Down
4 changes: 2 additions & 2 deletions lib/form/tests/behat/modgrade_validation.feature
Expand Up @@ -150,10 +150,10 @@ Feature: Using the activity grade form element
Then I should see "You cannot change the type, as grades already exist for this item."
And the "Maximum grade" "field" should be disabled

@javascript @skip_interim
@javascript
Scenario: Attempting to change the maximum grade when no rescaling option has been chosen
Given I am on the "Test assignment name" "assign activity" page logged in as teacher1
And I navigate to "View all submissions" in current page administration
And I follow "View all submissions"
And I click on "Grade" "link" in the "Student 1" "table_row"
And I set the field "Grade out of 100" to "50"
And I press "Save changes"
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/classes/output/user_submission_actionmenu.php
Expand Up @@ -76,7 +76,7 @@ public function __construct(int $cmid, bool $showsubmit, bool $showedit, stdClas
* @return string The status of the submission.
*/
protected function get_current_status(): string {
if (!is_null($this->teamsubmission)) {
if (!is_null($this->teamsubmission) && isset($this->teamsubmission->status)) {
return $this->teamsubmission->status;
} else if (!empty((array)$this->submission)) {
return $this->submission->status;
Expand Down
3 changes: 2 additions & 1 deletion mod/assign/tests/behat/assign_course_reset.feature
Expand Up @@ -56,10 +56,11 @@ Feature: Assign reset
And I follow "View all submissions"
Then I should not see "Submitted for grading"

@javascript @skip_interim
@javascript
Scenario: Use course reset to remove user overrides.
And I am on the "Test assignment name" Activity page logged in as teacher1
And I navigate to "Overrides" in current page administration
And I select "User overrides" from the "jump" singleselect
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student1 |
Expand Down
3 changes: 2 additions & 1 deletion mod/assign/tests/behat/assign_group_override.feature
Expand Up @@ -140,7 +140,7 @@ Feature: Assign group override
And I am on the "Test assignment name" Activity page logged in as student1
And I should not see "Tuesday, 1 January 2030, 8:00"

@javascript @skip_interim
@javascript
Scenario: Add both a user and group override and verify that both are applied correctly
Given I am on the "Test assignment name" Activity page logged in as teacher1
When I navigate to "Settings" in current page administration
Expand All @@ -160,6 +160,7 @@ Feature: Assign group override
And I should see "Tuesday, 1 January 2030, 8:00"
And I am on the "Test assignment name" Activity page
And I navigate to "Overrides" in current page administration
And I select "User overrides" from the "jump" singleselect
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student1 |
Expand Down
6 changes: 4 additions & 2 deletions mod/assign/tests/behat/assign_user_override.feature
Expand Up @@ -144,7 +144,6 @@ Feature: Assign user override
Then I should see "No groups you can access."
And the "Add user override" "button" should be disabled

@skip_interim
Scenario: A teacher without accessallgroups permission should only be able to add user override for users that he/she shares groups with,
when the activity's group mode is "separate groups"
Given the following "permission overrides" exist:
Expand All @@ -164,11 +163,12 @@ Feature: Assign user override
| student2 | G2 |
And I am on the "Assignment 2" Activity page logged in as teacher1
When I navigate to "Overrides" in current page administration
And I select "User overrides" from the "jump" singleselect
And I press "Add user override"
Then the "Override user" select box should contain "Sam1 Student1, student1@example.com"
And the "Override user" select box should not contain "Sam2 Student2, student2@example.com"

@javascript @skip_interim
@javascript
Scenario: A teacher without accessallgroups permission should only be able to see the user override for users that he/she shares groups with,
when the activity's group mode is "separate groups"
Given the following "permission overrides" exist:
Expand All @@ -188,6 +188,7 @@ Feature: Assign user override
| student2 | G2 |
And I am on the "Assignment 2" Activity page logged in as admin
And I navigate to "Overrides" in current page administration
And I select "User overrides" from the "jump" singleselect
And I press "Add user override"
And I set the following fields to these values:
| Override user | Student1 |
Expand All @@ -201,6 +202,7 @@ Feature: Assign user override

And I am on the "Assignment 2" Activity page logged in as teacher1
When I navigate to "Overrides" in current page administration
And I select "User overrides" from the "jump" singleselect
Then I should see "Student1" in the ".generaltable" "css_element"
But I should not see "Student2" in the ".generaltable" "css_element"

Expand Down
1 change: 0 additions & 1 deletion mod/assign/tests/behat/outcome_grading.feature
Expand Up @@ -68,7 +68,6 @@ Feature: Outcome grading
Then I should see "Outcome Test: Excellent" in the "Student 0" "table_row"
And I should not see "Outcome Test: Excellent" in the "Student 1" "table_row"

@skip_interim
Scenario: Giving an outcome to a group submission
Given the following "users" exist:
| username | firstname | lastname | email |
Expand Down
8 changes: 4 additions & 4 deletions mod/assign/tests/behat/remove_submission.feature
Expand Up @@ -31,7 +31,7 @@ Feature: Remove a submission
| student1 | G1 |
| student2 | G1 |

@javascript @skip_chrome_zerosize @skip_interim
@javascript @skip_chrome_zerosize
Scenario: Remove a submission should remove the data that was submitted
Given the following "activity" exists:
| activity | assign |
Expand All @@ -56,7 +56,7 @@ Feature: Remove a submission

And I am on the "Test assignment name" Activity page logged in as student1
And I should not see "I'm the student submission"
And I should see "No attempt" in the "Submission status" "table_row"
And I should see "No submissions have been made yet" in the "Submission status" "table_row"

@javascript @skip_chrome_zerosize
Scenario: Remove a group submission should remove the data from all group members
Expand Down Expand Up @@ -86,7 +86,7 @@ Feature: Remove a submission
And I should not see "I'm the student submission"
And I should see "Nothing has been submitted for this assignment" in the "Submission status" "table_row"

@javascript @skip_chrome_zerosize @skip_interim
@javascript @skip_chrome_zerosize
Scenario: A student can remove their own submission
Given the following "activity" exists:
| activity | assign |
Expand All @@ -113,4 +113,4 @@ Feature: Remove a submission

And I am on the "Test assignment name" Activity page logged in as student1
And I should not see "I'm the student submission"
And I should see "No attempt" in the "Submission status" "table_row"
And I should see "No submissions have been made yet" in the "Submission status" "table_row"
2 changes: 1 addition & 1 deletion mod/assign/tests/behat/submit_without_group.feature
Expand Up @@ -3,7 +3,7 @@ Feature: Submit assignment without group
As a teacher
I should be able to prevent students submitting team assignments as members of the default group

@javascript @skip_interim
@javascript
Scenario: Switch between group modes
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
Expand Down
20 changes: 20 additions & 0 deletions mod/book/lib.php
Expand Up @@ -335,6 +335,26 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
$firstkey = null;
}

$params = $PAGE->url->params();

if ($PAGE->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
and has_capability('mod/book:edit', $PAGE->cm->context)) {
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
$edit = '0';
} else {
$string = get_string("turneditingon");
$edit = '1';
}
$url = new moodle_url('/mod/book/view.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid'], 'edit'=>$edit, 'sesskey'=>sesskey()));
$editnode = navigation_node::create($string, $url, navigation_node::TYPE_SETTING);
$editnode->set_show_in_secondary_navigation(false);
$booknode->add_node($editnode, $firstkey);
if (!$PAGE->theme->haseditswitch) {
$PAGE->set_button($OUTPUT->single_button($url, $string));
}
}

$plugins = core_component::get_plugin_list('booktool');
foreach ($plugins as $plugin => $dir) {
if (file_exists("$dir/lib.php")) {
Expand Down
1 change: 0 additions & 1 deletion mod/book/tests/behat/create_chapters.feature
Expand Up @@ -61,7 +61,6 @@ Feature: In a book, create chapters and sub chapters
And I should see "1. Dummy first chapter" in the ".book_content" "css_element"
And I should see "1. Dummy first chapter" in the "strong" "css_element"

@skip_interim
Scenario: Change editing mode for an individual chapter
Given I am on the "Test book" Activity page
And I should see "Add new chapter"
Expand Down
2 changes: 1 addition & 1 deletion mod/book/tests/behat/edit_tags.feature
@@ -1,4 +1,4 @@
@mod @mod_book @core_tag @javascript @skip_interim
@mod @mod_book @core_tag @javascript
Feature: Edited book chapters handle tags correctly
In order to get book chapters properly labelled
As a user
Expand Down
77 changes: 77 additions & 0 deletions mod/lesson/tests/behat/behat_mod_lesson_behat.php
@@ -0,0 +1,77 @@
<?php
// 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 <http://www.gnu.org/licenses/>.

// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
// For that reason, we can't even rely on $CFG->admin being available here.

require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');

use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
use Behat\Mink\Exception\ExpectationException as ExpectationException;

/**
* Step definitions related mod_lesson.
*
* @package mod_lesson
* @category test
* @copyright 2021 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_mod_lesson_behat extends behat_base {

/**
* Select the lesson edit type [Collapsed|Expanded]
*
* @Given i select edit type :edittype
*
* @param string $edittype The edit type of either Collapsed or Expanded
*/
public function i_select_edit_type(string $edittype): void {

$typestring = ($edittype == 'Collapsed') ? get_string('collapsed', 'mod_lesson') : get_string('full', 'mod_lesson');
try {
$this->execute("behat_forms::i_select_from_the_singleselect", [$typestring, 'jump']);
} catch (ElementNotFoundException $e) {
$this->execute("behat_general::click_link", [$typestring]);
}
}

/**
* Go to the lesson essay grading page.
*
* @Given i grade lesson essays
*/
public function i_grade_lesson_essays(): void {
try {
$this->execute("behat_general::i_click_on", [get_string('manualgrading', 'mod_lesson'), 'button']);
} catch (ElementNotFoundException $e) {
$this->execute("behat_general::click_link", [get_string('manualgrading', 'mod_lesson')]);
}
}

/**
* Go to the lesson edit page.
*
* @Given i edit the lesson
*/
public function i_edit_the_lesson(): void {
try {
$this->execute("behat_general::click_link", [get_string('edit', 'mod_lesson')]);
} catch (ElementNotFoundException $e) {
$this->execute("behat_general::i_click_on", [get_string('edit', 'mod_lesson'), 'button']);
}
}
}
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_delete_answers.feature
@@ -1,4 +1,4 @@
@mod @mod_lesson @skip_interim
@mod @mod_lesson
Feature: In a lesson activity, teacher can delete question answers and
branch table contents
In order to modify an existing lesson
Expand Down Expand Up @@ -47,7 +47,7 @@ branch table contents
| id_jumpto_1 | First page name |
| id_score_1 | 0 |
And I press "Save page"
And I select "Expanded" from the "jump" singleselect
And I select edit type "Expanded"

Scenario: Edit lesson content page
Given I click on "//th[normalize-space(.)='First page name']/descendant::a[3]" "xpath_element"
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_edit_cluster.feature
@@ -1,4 +1,4 @@
@mod @mod_lesson @skip_interim
@mod @mod_lesson
Feature: In a lesson activity, teacher can edit a cluster page
In order to modify an existing lesson and change navigation
As a teacher
Expand Down Expand Up @@ -29,7 +29,7 @@ Feature: In a lesson activity, teacher can edit a cluster page
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I select "Expanded" from the "jump" singleselect
And I select edit type "Expanded"
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
And I set the field "Select a question type" to "Multichoice"
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_edit_pages.feature
@@ -1,4 +1,4 @@
@mod @mod_lesson @skip_interim
@mod @mod_lesson
Feature: In a lesson activity, teacher can edit lesson's pages
In order to modify an existing lesson
As a teacher
Expand Down Expand Up @@ -38,7 +38,7 @@ Feature: In a lesson activity, teacher can edit lesson's pages
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
And I select "Expanded" from the "jump" singleselect
And I select edit type "Expanded"
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
And I set the field "Select a question type" to "Numerical"
And I press "Add a question page"
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_essay_question.feature
@@ -1,4 +1,4 @@
@mod @mod_lesson @_file_upload @skip_interim
@mod @mod_lesson @_file_upload
Feature: In a lesson activity, teacher can add an essay question
As a teacher
I need to add an essay question in a lesson and grade student attempts
Expand Down Expand Up @@ -47,7 +47,7 @@ Feature: In a lesson activity, teacher can add an essay question
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test lesson name"
And I click on "Grade essays" "button"
And I grade lesson essays
And I should see "Student 1"
And I should see "Essay question"
And I follow "Essay question"
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_exit_enter_clusters.feature
@@ -1,4 +1,4 @@
@mod @mod_lesson @skip_interim
@mod @mod_lesson
Feature: In a lesson activity, students can exit and re-enter the activity when it consists only of cluster pages
As a student
I need to exit and re-enter a lesson out and into clusters.
Expand Down Expand Up @@ -28,7 +28,7 @@ Feature: In a lesson activity, students can exit and re-enter the activity when
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I select "Expanded" from the "jump" singleselect
And I select edit type "Expanded"
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
And I follow "Update page: Cluster"
And I set the following fields to these values:
Expand Down
3 changes: 1 addition & 2 deletions mod/lesson/tests/behat/lesson_navigation.feature
Expand Up @@ -18,7 +18,6 @@ Feature: In a lesson activity, students can navigate through a series of pages i
| student1 | C1 | student |
And I log in as "teacher1"

@skip_interim
Scenario: Student navigation with pages and questions
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
Expand All @@ -41,7 +40,7 @@ Feature: In a lesson activity, students can navigate through a series of pages i
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
And I select "Expanded" from the "jump" singleselect
And I select edit type "Expanded"
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
And I set the field "Select a question type" to "Numerical"
And I press "Add a question page"
Expand Down

0 comments on commit d824172

Please sign in to comment.