teacher_replace_content.feature 3.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@core @core_contentbank @contenttype_h5p @_file_upload @_switch_iframe @javascript
Feature: Replace H5P file from an existing content requires special capabilities
  In order replace an H5P content from the content bank
  As a teacher
  I need to be able to replace the content only if certain capabilities are allowed

  Background:
    Given the following "users" exist:
      | username | firstname | lastname | email                |
      | teacher1 | Teacher   | 1        | teacher1@example.com |
    And the following "categories" exist:
      | name  | category | idnumber |
      | Cat 1 | 0        | CAT1     |
    And the following "courses" exist:
      | fullname | shortname | category |
      | Course 1 | C1        | CAT1     |
    And the following "course enrolments" exist:
      | user     | course | role           |
      | teacher1 | C1     | editingteacher |
    And the following "contentbank content" exist:
      | contextlevel | reference | contenttype     | user     | contentname       | filepath                              |
      | Course       | C1        | contenttype_h5p | admin    | admincontent      | /h5p/tests/fixtures/ipsums.h5p        |
      | Course       | C1        | contenttype_h5p | teacher1 | teachercontent    | /h5p/tests/fixtures/filltheblanks.h5p |
    And I log in as "teacher1"
    And I am on "Course 1" course homepage with editing mode on
    And I add the "Navigation" block if not present
    And I expand "Site pages" node
    And I click on "Content bank" "link"
    # Force the content deploy
    And I click on "admincontent" "link"
    And I click on "Content bank" "link"

  Scenario: Teacher can replace its own H5P files
    Given I click on "teachercontent" "link"
    When I open the action menu in "region-main-settings-menu" "region"
    And I choose "Replace with file" in the open action menu
    And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Upload content" filemanager
    And I click on "Save changes" "button"
    Then I switch to "h5p-player" class iframe
    And I switch to "h5p-iframe" class iframe
    And I should see "Lorum ipsum"
    And I switch to the main frame

  Scenario: Teacher cannot replace another user's H5P files
    When I click on "admincontent" "link"
46
    Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region"
47
48
49
50
51
52

  Scenario: Teacher cannot replace a content without having upload capability
    Given the following "permission overrides" exist:
      | capability                | permission | role           | contextlevel | reference |
      | moodle/contentbank:upload | Prevent    | editingteacher | Course       | C1        |
    When I click on "teachercontent" "link"
53
    Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region"
54
55
56
57
58
59

  Scenario: Teacher cannot replace a content without having the H5P upload capability
    Given the following "permission overrides" exist:
      | capability             | permission | role           | contextlevel | reference |
      | contenttype/h5p:upload | Prevent    | editingteacher | Course       | C1        |
    When I click on "teachercontent" "link"
60
    Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region"
61
62
63
64
65
66

  Scenario: Teacher cannot replace a content without having the manage own content capability
    Given the following "permission overrides" exist:
      | capability                          | permission | role           | contextlevel | reference |
      | moodle/contentbank:manageowncontent | Prevent    | editingteacher | Course       | C1        |
    When I click on "teachercontent" "link"
67
    Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region"