MDL-62944 activities: Test adding activities with no calendar capability

This commit is contained in:
Neill Magill
2018-08-31 10:19:25 +01:00
parent 2d533ee7e8
commit de198dce1b
16 changed files with 591 additions and 0 deletions
@@ -0,0 +1,58 @@
@mod @mod_assign
Feature: Assignment with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create assignments even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing an assignment
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assignment name |
| Description | Test assignment description |
| id_allowsubmissionsfromdate_enabled | 1 |
| id_allowsubmissionsfromdate_day | 1 |
| id_allowsubmissionsfromdate_month | 1 |
| id_allowsubmissionsfromdate_year | 2017 |
| id_duedate_enabled | 1 |
| id_duedate_day | 1 |
| id_duedate_month | 2 |
| id_duedate_year | 2017 |
| id_cutoffdate_enabled | 1 |
| id_cutoffdate_day | 2 |
| id_cutoffdate_month | 2 |
| id_cutoffdate_year | 2017 |
| id_gradingduedate_enabled | 1 |
| id_gradingduedate_day | 1 |
| id_gradingduedate_month | 3 |
| id_gradingduedate_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test assignment name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_allowsubmissionsfromdate_year | 2018 |
| id_duedate_year | 2018 |
| id_cutoffdate_year | 2018 |
| id_gradingduedate_year | 2018 |
And I press "Save and return to course"
Then I should see "Test assignment name"
+25
View File
@@ -1472,4 +1472,29 @@ class mod_assign_lib_testcase extends advanced_testcase {
// is changed.
$this->assertNotEmpty($moduleupdatedevents);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an assignment.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_assign');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'allowsubmissionsfromdate' => $time,
'duedate' => $time + 500,
'cutoffdate' => $time + 600,
'gradingduedate' => $time + 700,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,43 @@
@mod @mod_chat
Feature: Chat with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create chats even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a chat
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Chat" to section "1" and I fill the form with:
| Name of this chat room | Test chat name |
| Description | Test chat description |
| Repeat/publish session times | No repeats - publish the specified time only |
| id_chattime_day | 1 |
| id_chattime_month | 1 |
| id_chattime_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test chat name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_chattime_year | 2018 |
And I press "Save and return to course"
Then I should see "Test chat name"
+21
View File
@@ -163,4 +163,25 @@ class mod_chat_lib_testcase extends advanced_testcase {
return calendar_event::create($event);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an chat.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_chat');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$params = array(
'course' => $course->id,
'chattime' => time() + 500,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,50 @@
@mod @mod_choice
Feature: Choice with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create choices even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a choice
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Choice" to section "1" and I fill the form with:
| Choice name | Test choice name |
| Description | Test choice description |
| option[0] | Option 1 |
| option[1] | Option 2 |
| id_timeopen_enabled | 1 |
| id_timeopen_day | 1 |
| id_timeopen_month | 1 |
| id_timeopen_year | 2017 |
| id_timeclose_enabled | 1 |
| id_timeclose_day | 1 |
| id_timeclose_month | 2 |
| id_timeclose_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test choice name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_timeopen_year | 2018 |
| id_timeclose_year | 2018 |
And I press "Save and return to course"
Then I should see "Test choice name"
+23
View File
@@ -979,4 +979,27 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
$this->expectException('moodle_exception');
choice_user_submit_response($optionids[1], $choicewithoptions, $user2->id, $course, $cm);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an choice.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_choice');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'timeopen' => $time + 200,
'timeclose' => $time + 500,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,58 @@
@mod @mod_data
Feature: Database with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create databases even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a database
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Database" to section "1" and I fill the form with:
| Name | Test database name |
| Description | Test database description |
| id_timeavailablefrom_enabled | 1 |
| id_timeavailablefrom_day | 1 |
| id_timeavailablefrom_month | 1 |
| id_timeavailablefrom_year | 2017 |
| id_timeavailableto_enabled | 1 |
| id_timeavailableto_day | 1 |
| id_timeavailableto_month | 4 |
| id_timeavailableto_year | 2017 |
| id_timeviewfrom_enabled | 1 |
| id_timeviewfrom_day | 1 |
| id_timeviewfrom_month | 3 |
| id_timeviewfrom_year | 2017 |
| id_timeviewto_enabled | 1 |
| id_timeviewto_day | 1 |
| id_timeviewto_month | 4 |
| id_timeviewto_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test database name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_timeavailablefrom_year | 2018 |
| id_timeavailableto_year | 2018 |
| id_timeviewfrom_year | 2018 |
| id_timeviewto_year | 2018 |
And I press "Save and return to course"
Then I should see "Test database name"
+25
View File
@@ -1483,4 +1483,29 @@ class mod_data_lib_testcase extends advanced_testcase {
$this->assertEquals(mod_data_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
$this->assertEquals(mod_data_get_completion_active_rule_descriptions(new stdClass()), []);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an database.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_data');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'timeavailablefrom' => $time + 200,
'timeavailableto' => $time + 2000,
'timeviewfrom' => $time + 400,
'timeviewto' => $time + 2000,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,48 @@
@mod @mod_feedback
Feature: Feedback with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create feedbacks even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a feedback
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Feedback" to section "1" and I fill the form with:
| Name | Test feedback name |
| Description | Test feedback description |
| id_timeopen_enabled | 1 |
| id_timeopen_day | 1 |
| id_timeopen_month | 1 |
| id_timeopen_year | 2017 |
| id_timeclose_enabled | 1 |
| id_timeclose_day | 1 |
| id_timeclose_month | 2 |
| id_timeclose_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test feedback name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_timeopen_year | 2018 |
| id_timeclose_year | 2018 |
And I press "Save and return to course"
Then I should see "Test feedback name"
+23
View File
@@ -852,4 +852,27 @@ class mod_feedback_lib_testcase extends advanced_testcase {
// was successfully modified.
$this->assertNotEmpty($moduleupdatedevents);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an feedback.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_feedback');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'timeopen' => $time + 200,
'timeclose' => $time + 2000,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,48 @@
@mod @mod_lesson
Feature: Lesson with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create lessons even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a lesson
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Lesson" to section "1" and I fill the form with:
| Name | Test lesson name |
| Description | Test lesson description |
| id_available_enabled | 1 |
| id_available_day | 1 |
| id_available_month | 1 |
| id_available_year | 2017 |
| id_deadline_enabled | 1 |
| id_deadline_day | 1 |
| id_deadline_month | 2 |
| id_deadline_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test lesson name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_available_year | 2018 |
| id_deadline_year | 2018 |
And I press "Save and return to course"
Then I should see "Test lesson name"
+23
View File
@@ -441,4 +441,27 @@ class mod_lesson_lib_testcase extends advanced_testcase {
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
$this->assertEquals(mod_lesson_get_completion_active_rule_descriptions(new stdClass()), []);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create an lesson.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_lesson');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'available' => $time + 200,
'deadline' => $time + 2000,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,48 @@
@mod @mod_quiz
Feature: Quiz with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create quiz even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a quiz
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "Quiz" to section "1" and I fill the form with:
| Name | Test quiz name |
| Description | Test quiz description |
| id_timeopen_enabled | 1 |
| id_timeopen_day | 1 |
| id_timeopen_month | 1 |
| id_timeopen_year | 2017 |
| id_timeclose_enabled | 1 |
| id_timeclose_day | 1 |
| id_timeclose_month | 2 |
| id_timeclose_year | 2017 |
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test quiz name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_timeopen_year | 2018 |
| id_timeclose_year | 2018 |
And I press "Save and return to course"
Then I should see "Test quiz name"
+23
View File
@@ -736,4 +736,27 @@ class mod_quiz_lib_testcase extends advanced_testcase {
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
$this->assertEquals(mod_quiz_get_completion_active_rule_descriptions(new stdClass()), []);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create a quiz.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_quiz');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'timeopen' => $time + 200,
'timeclose' => $time + 2000,
);
$generator->create_instance($params);
}
}
@@ -0,0 +1,52 @@
@mod @mod_scorm
Feature: Scorm with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create SCORM activities even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Users > Permissions" in current page administration
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
@javascript @_file_upload @_switch_iframe
Scenario: Editing a chat
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
When I add a "SCORM package" to section "1"
And I set the following fields to these values:
| Name | Test scorm name |
| Description | Test scorm description |
| id_timeopen_enabled | 1 |
| id_timeopen_day | 1 |
| id_timeopen_month | 1 |
| id_timeopen_year | 2017 |
| id_timeclose_enabled | 1 |
| id_timeclose_day | 1 |
| id_timeclose_month | 2 |
| id_timeclose_year | 2017 |
And I upload "mod/scorm/tests/packages/singlesco_scorm12.zip" file to "Package file" filemanager
And I click on "Save and display" "button"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test scorm name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| id_timeopen_year | 2018 |
| id_timeclose_year | 2018 |
And I press "Save and return to course"
Then I should see "Test scorm name"
+23
View File
@@ -433,4 +433,27 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions($moddefaults), $activeruledescriptions);
$this->assertEquals(mod_scorm_get_completion_active_rule_descriptions(new stdClass()), []);
}
/**
* A user who does not have capabilities to add events to the calendar should be able to create a SCORM.
*/
public function test_creation_with_no_calendar_capabilities() {
$this->resetAfterTest();
$course = self::getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$user = self::getDataGenerator()->create_and_enrol($course, 'editingteacher');
$roleid = self::getDataGenerator()->create_role();
self::getDataGenerator()->role_assign($roleid, $user->id, $context->id);
assign_capability('moodle/calendar:manageentries', CAP_PROHIBIT, $roleid, $context, true);
$generator = self::getDataGenerator()->get_plugin_generator('mod_scorm');
// Create an instance as a user without the calendar capabilities.
$this->setUser($user);
$time = time();
$params = array(
'course' => $course->id,
'timeopen' => $time + 200,
'timeclose' => $time + 2000,
);
$generator->create_instance($params);
}
}