Merge branch 'MDL-55611-master' of git://github.com/danpoltawski/moodle
This commit is contained in:
@@ -9,11 +9,10 @@ Feature: Highlight non-inherited permissions
|
||||
| fullname | shortname |
|
||||
| Course fullname | C_shortname |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
|
||||
@javascript
|
||||
Scenario: Override a permission
|
||||
Given I follow "Course fullname"
|
||||
Given I am on "Course fullname" course homepage
|
||||
And I navigate to "Users > Permissions" in current page administration
|
||||
And I select "Manager (0)" from the "roleid" singleselect
|
||||
And I click on "Prohibit" "radio" in the "View added and updated modules in recent activity block" "table_row"
|
||||
|
||||
@@ -133,7 +133,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
// Completion tracking.
|
||||
$temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
|
||||
new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
new lang_string('enablecompletion_help', 'completion'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
// Groups.
|
||||
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
||||
|
||||
@@ -49,9 +49,7 @@ Feature: Manage availability conditions
|
||||
|
||||
# OK, toggling works. Set the grade one to Hide and we'll go see if it actually worked.
|
||||
And I click on "Hide" "icon" in the "Restriction by grade" "table_row"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Page" to section "1"
|
||||
And I expand all fieldsets
|
||||
And I click on "Add restriction..." "button"
|
||||
|
||||
@@ -57,8 +57,7 @@ Feature: Set up contextual data for tests
|
||||
| Grouping 1 | C1 | GG1 |
|
||||
| Grouping 2 | C1 | GG2 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Users > Groups" in current page administration
|
||||
Then I should see "Group 1"
|
||||
And I should see "Group 2"
|
||||
@@ -87,8 +86,7 @@ Feature: Set up contextual data for tests
|
||||
| mod/forum:editanypost | Allow | student | Course | C1 |
|
||||
| mod/forum:replynews | Prevent | editingteacher | Course | C1 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Users > Permissions" in current page administration
|
||||
And I set the field "Advanced role override" to "Student (1)"
|
||||
Then "mod/forum:editanypost" capability has "Allow" permission
|
||||
@@ -108,7 +106,7 @@ Feature: Set up contextual data for tests
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Topic 1"
|
||||
|
||||
Scenario: Add role assigns
|
||||
@@ -144,24 +142,20 @@ Feature: Set up contextual data for tests
|
||||
Then "Edit settings" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user2"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user3"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user4"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user5"
|
||||
And I should see "You are logged in as"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "You can not enrol yourself in this course."
|
||||
|
||||
Scenario: Add modules
|
||||
@@ -199,8 +193,7 @@ Feature: Set up contextual data for tests
|
||||
| activity | name | intro | course | idnumber | grade |
|
||||
| assign | Test assignment name with scale | Test assignment description | C1 | assign1 | Test Scale 1 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Test assignment name"
|
||||
# Assignment 2.2 module type is disabled by default
|
||||
# And I should see "Test assignment22 name"
|
||||
@@ -261,8 +254,7 @@ Feature: Set up contextual data for tests
|
||||
| grouping | group |
|
||||
| GG1 | G1 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Users > Groups" in current page administration
|
||||
Then the "groups" select box should contain "Group 1 (1)"
|
||||
And the "groups" select box should contain "Group 2 (1)"
|
||||
@@ -321,7 +313,7 @@ Feature: Set up contextual data for tests
|
||||
| Grade sub category 2 | C1 | Grade category 1 |
|
||||
When I log in as "admin"
|
||||
And I am on course index
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
Then I should see "Grade category 1"
|
||||
And I should see "Grade sub category 2"
|
||||
@@ -344,8 +336,7 @@ Feature: Set up contextual data for tests
|
||||
| Test Grade Item 2 | C1 | Grade category 1 |
|
||||
| Test Grade Item 3 | C1 | Grade sub category 2 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Setup > Gradebook setup" in the course gradebook
|
||||
Then I should see "Test Grade Item 1"
|
||||
And I follow "Edit Test Grade Item 1"
|
||||
@@ -373,8 +364,7 @@ Feature: Set up contextual data for tests
|
||||
| name | scale |
|
||||
| Test Scale 1 | Disappointing, Good, Very good, Excellent |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Scales" in the course gradebook
|
||||
Then I should see "Test Scale 1"
|
||||
And I should see "Disappointing, Good, Very good, Excellent"
|
||||
@@ -395,8 +385,7 @@ Feature: Set up contextual data for tests
|
||||
And the following config values are set as admin:
|
||||
| enableoutcomes | 1 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Outcomes"
|
||||
Then I should see "Grade outcome 1" in the "#addoutcomes" "css_element"
|
||||
And I should see "Grade outcome 2" in the "#removeoutcomes" "css_element"
|
||||
@@ -424,8 +413,7 @@ Feature: Set up contextual data for tests
|
||||
And the following config values are set as admin:
|
||||
| enableoutcomes | 1 |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Setup > Gradebook setup" in the course gradebook
|
||||
Then I should see "Test Outcome Grade Item 1"
|
||||
And I follow "Edit Test Outcome Grade Item 1"
|
||||
@@ -442,6 +430,5 @@ Feature: Set up contextual data for tests
|
||||
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
|
||||
| online_users | Course | C1 | course-view-* | site-pre |
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Online users"
|
||||
|
||||
@@ -19,7 +19,7 @@ Feature: Transform date time string arguments
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment name"
|
||||
And I should see "##yesterday##l, j F Y##"
|
||||
And I log out
|
||||
|
||||
@@ -31,7 +31,7 @@ Feature: Edit capabilities
|
||||
|
||||
Scenario: Course capabilities overrides
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
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 "Student" role with:
|
||||
| mod/forum:deleteanypost | Prohibit |
|
||||
@@ -45,8 +45,7 @@ Feature: Edit capabilities
|
||||
|
||||
Scenario: Module capabilities overrides
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | I'm the name |
|
||||
| Description | I'm the introduction |
|
||||
|
||||
@@ -33,8 +33,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
| activity | course | idnumber | name | intro | firstpagetitle | wikimode | visible |
|
||||
| wiki | C1 | wiki1 | Test this one | Test this one | Test this one | collaborative | 0 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Reset" node in "Course administration"
|
||||
# Select (multi-select) - Checking "the select box should contain".
|
||||
And I expand all fieldsets
|
||||
@@ -48,9 +47,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
And the "Unenrol users" select box should not contain "President"
|
||||
And the "Unenrol users" select box should not contain "Baker"
|
||||
And the "Unenrol users" select box should not contain "President, Baker"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test this one"
|
||||
And I press "Create page"
|
||||
# Text (textarea & editor) & Select (multi-select) - Checking "I set the following fields to these values".
|
||||
@@ -100,7 +97,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
| Default format | HTML |
|
||||
| Force format | 1 |
|
||||
And I press "Cancel"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Radio - Checking "I set the field" and "the field matches value".
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Test choice name |
|
||||
@@ -115,8 +112,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
And the field "one" matches value "1"
|
||||
And the field "two" matches value ""
|
||||
# Check if field xpath set/match works.
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the field with xpath "//input[@id='id_idnumber']" to "Course id number"
|
||||
And the field with xpath "//input[@name='idnumber']" matches value "Course id number"
|
||||
@@ -129,7 +125,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
|
||||
@javascript
|
||||
Scenario: with JS enabled all form fields getters and setters works as expected
|
||||
Then I follow "Course 1"
|
||||
Then I am on "Course 1" course homepage
|
||||
And I navigate to "Users > Groups" in current page administration
|
||||
# Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
|
||||
And I set the field "groups" to "Group 2"
|
||||
@@ -141,7 +137,7 @@ Feature: Verify that all form fields values can be get and set
|
||||
And the "members" select box should contain "Student 2"
|
||||
And the "members" select box should not contain "Student 3"
|
||||
# Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Lesson" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Test lesson |
|
||||
|
||||
@@ -23,9 +23,7 @@ Feature: Forms manipulation
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Quiz" to section "1"
|
||||
When I expand all fieldsets
|
||||
Then I should see "Close the quiz"
|
||||
|
||||
@@ -120,9 +120,7 @@ Feature: Add customised file types
|
||||
| Custom description | Froggy file |
|
||||
And I press "Save changes"
|
||||
# Create a resource activity and add it to a course
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add a "File" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | An example of customised file type |
|
||||
|
||||
@@ -18,7 +18,7 @@ Feature: tool_monitor_rule
|
||||
And I navigate to "Event monitoring rules" node in "Site administration > Reports"
|
||||
And I click on "Enable" "link"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
And I press "Add a new rule"
|
||||
And I set the following fields to these values:
|
||||
@@ -45,8 +45,7 @@ Feature: tool_monitor_rule
|
||||
|
||||
Scenario: Add a rule on course level
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
When I press "Add a new rule"
|
||||
And I set the following fields to these values:
|
||||
@@ -66,7 +65,7 @@ Feature: tool_monitor_rule
|
||||
|
||||
Scenario: Delete a rule on course level
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
When I click on "Delete rule" "link"
|
||||
Then I should see "Are you sure you want to delete the rule \"New rule course level\"?"
|
||||
@@ -76,7 +75,7 @@ Feature: tool_monitor_rule
|
||||
|
||||
Scenario: Edit a rule on course level
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
When I click on "Edit rule" "link"
|
||||
And I set the following fields to these values:
|
||||
@@ -95,7 +94,7 @@ Feature: tool_monitor_rule
|
||||
|
||||
Scenario: Duplicate a rule on course level
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
When I click on "Duplicate rule" "link" in the "New rule course level" "table_row"
|
||||
Then I should see "Rule successfully duplicated"
|
||||
@@ -154,7 +153,7 @@ Feature: tool_monitor_rule
|
||||
|
||||
Scenario: Duplicate a rule on site level
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
When I click on "Duplicate rule" "link" in the "New rule site level" "table_row"
|
||||
Then I should see "Rule successfully duplicated"
|
||||
|
||||
@@ -22,8 +22,7 @@ Feature: tool_monitor_subscriptions
|
||||
And I log in as "admin"
|
||||
And I navigate to "Event monitoring rules" node in "Site administration > Reports"
|
||||
And I click on "Enable" "link"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Event monitoring rules" node in "Course administration > Reports"
|
||||
And I press "Add a new rule"
|
||||
And I set the following fields to these values:
|
||||
@@ -132,8 +131,7 @@ Feature: tool_monitor_subscriptions
|
||||
And I follow "Subscribe to rule \"New rule course level\""
|
||||
And I should see "Subscription successfully created"
|
||||
And "#toolmonitorsubs_r0" "css_element" should exist
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I trigger cron
|
||||
And I am on site homepage
|
||||
When I click on ".popover-region-notifications" "css_element"
|
||||
|
||||
@@ -23,8 +23,7 @@ Feature: Backup user data
|
||||
@javascript
|
||||
Scenario: Delete and restore a quiz with user data
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Quiz" to section "1" and I fill the form with:
|
||||
| Name | Quiz 1 |
|
||||
| Description | Test quiz description |
|
||||
@@ -44,7 +43,7 @@ Feature: Backup user data
|
||||
| Feedback for the response 'False'. | So you think it is false |
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Quiz 1"
|
||||
And I press "Attempt quiz now"
|
||||
And I click on "True" "radio" in the "First question" "question"
|
||||
@@ -55,8 +54,7 @@ Feature: Backup user data
|
||||
And I should see "5.00 out of 10.00"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I delete "Quiz 1" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
@@ -64,7 +62,7 @@ Feature: Backup user data
|
||||
And I click on "Restore" "link" in the "region-main" "region"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I navigate to "User report" in the course gradebook
|
||||
Then "Quiz 1" row "Grade" column of "user-grade" table should contain "5"
|
||||
And "Quiz 1" row "Percentage" column of "user-grade" table should contain "50"
|
||||
|
||||
@@ -25,8 +25,7 @@ Feature: Basic recycle bin functionality
|
||||
|
||||
Scenario: Restore a deleted assignment
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assign |
|
||||
| Description | Test |
|
||||
@@ -37,8 +36,7 @@ Feature: Basic recycle bin functionality
|
||||
And I click on "Restore" "link" in the "region-main" "region"
|
||||
And I should see "'Test assign' has been restored"
|
||||
And I wait to be redirected
|
||||
And I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Test assign" in the "Topic 1" "section"
|
||||
|
||||
Scenario: Restore a deleted course
|
||||
@@ -64,8 +62,7 @@ Feature: Basic recycle bin functionality
|
||||
@javascript
|
||||
Scenario: Deleting a single item from the recycle bin
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assign |
|
||||
| Description | Test |
|
||||
@@ -84,8 +81,7 @@ Feature: Basic recycle bin functionality
|
||||
@javascript
|
||||
Scenario: Deleting all the items from the recycle bin
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assign 1 |
|
||||
| Description | Test 1 |
|
||||
|
||||
@@ -33,8 +33,7 @@ Feature: Upload users
|
||||
And I should see "Tom Jones"
|
||||
And I should see "Trent Reznor"
|
||||
And I should see "reznor@example.com"
|
||||
And I am on site homepage
|
||||
And I follow "Maths"
|
||||
And I am on "Maths" course homepage
|
||||
And I navigate to "Users > Groups" in current page administration
|
||||
And I set the field "groups" to "Section 1 (1)"
|
||||
And the "members" select box should contain "Tom Jones"
|
||||
|
||||
@@ -20,7 +20,7 @@ Feature: Add a new user tour
|
||||
| Display in middle of page | Welcome | Welcome to your personal learning space. We'd like to give you a quick tour to show you some of the areas you may find helpful |
|
||||
And I add steps to the "First tour" tour:
|
||||
| targettype | targetvalue_block | Title | Content |
|
||||
| Block | Course overview | Course overview | This area shows you what's happening in some of your courses |
|
||||
| Block | My overview | My overview | This area shows you what's happening in some of your courses |
|
||||
| Block | Calendar | Calendar | This is the Calendar. All of your assignments and due dates can be found here |
|
||||
And I add steps to the "First tour" tour:
|
||||
| targettype | targetvalue_selector | Title | Content |
|
||||
|
||||
@@ -46,17 +46,14 @@ Feature: Apply tour filters to a tour
|
||||
| Display in middle of page | Welcome | Welcome to your course tour.|
|
||||
And I log out
|
||||
And I log in as "editor1"
|
||||
And I am on site homepage
|
||||
When I follow "Course 1"
|
||||
When I am on "Course 1" course homepage
|
||||
Then I should not see "Welcome to your course tour."
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Welcome to your course tour."
|
||||
And I click on "End tour" "button"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Welcome to your course tour."
|
||||
|
||||
@@ -21,9 +21,7 @@ Feature: availability_completion
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add a Page with a completion tickbox.
|
||||
And I add a "Page" to section "1" and I fill the form with:
|
||||
@@ -48,8 +46,7 @@ Feature: availability_completion
|
||||
# Log back in as student.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Page 2 should not appear yet.
|
||||
Then I should not see "Page 2" in the "region-main" "region"
|
||||
|
||||
@@ -19,7 +19,7 @@ Feature: Confirm that conditions on completion no longer cause a bug
|
||||
Scenario: Multiple completion conditions on glossary
|
||||
# Set up course.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I expand all fieldsets
|
||||
And I set the field "Enable completion tracking" to "Yes"
|
||||
|
||||
@@ -21,9 +21,7 @@ Feature: availability_date
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add a Page with a date condition that does match (from the past).
|
||||
And I add a "Page" to section "1"
|
||||
@@ -55,8 +53,7 @@ Feature: availability_date
|
||||
# Log back in as student.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Page 1 should appear, but page 2 does not.
|
||||
Then I should see "Page 1" in the "region-main" "region"
|
||||
|
||||
@@ -21,9 +21,7 @@ Feature: availability_grade
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add an assignment.
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
@@ -71,7 +69,7 @@ Feature: availability_grade
|
||||
And I click on "Edit settings" "link" in the "P3" activity
|
||||
And I expand all fieldsets
|
||||
And the field "Maximum grade percentage (exclusive)" matches value ""
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Add a Page with a grade condition for 10%.
|
||||
And I add a "Page" to section "4"
|
||||
@@ -91,8 +89,7 @@ Feature: availability_grade
|
||||
# Log in as student without a grade yet.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Do the assignment.
|
||||
And I follow "A1"
|
||||
@@ -110,8 +107,7 @@ Feature: availability_grade
|
||||
# Log back in as teacher.
|
||||
When I log out
|
||||
And I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Give the assignment 40%.
|
||||
And I follow "A1"
|
||||
@@ -126,8 +122,7 @@ Feature: availability_grade
|
||||
# Log back in as student.
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Check pages are visible.
|
||||
Then I should see "P2" in the "region-main" "region"
|
||||
|
||||
@@ -21,9 +21,7 @@ Feature: availability_group
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Start to add a Page. If there aren't any groups, there's no Group option.
|
||||
And I add a "Page" to section "1"
|
||||
@@ -39,8 +37,7 @@ Feature: availability_group
|
||||
| G2 | C1 | GI2 |
|
||||
# This step used to be 'And I follow "C1"', but Chrome thinks the breadcrumb
|
||||
# is not clickable, so we'll go via the home page instead.
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Page" to section "1"
|
||||
And I expand all fieldsets
|
||||
And I click on "Add restriction..." "button"
|
||||
@@ -85,8 +82,7 @@ Feature: availability_group
|
||||
# Log back in as student.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# No pages should appear yet.
|
||||
Then I should not see "P1" in the "region-main" "region"
|
||||
@@ -99,8 +95,7 @@ Feature: availability_group
|
||||
| student1 | GI1 |
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# P1 (any groups) and P2 should show but not P3.
|
||||
Then I should see "P1" in the "region-main" "region"
|
||||
|
||||
@@ -27,9 +27,7 @@ Feature: availability_grouping
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Start to add a Page. If there aren't any groupings, there's no Grouping option.
|
||||
And I add a "Page" to section "1"
|
||||
@@ -41,8 +39,7 @@ Feature: availability_grouping
|
||||
# Back to course page but add groups.
|
||||
# This step used to be 'And I follow "C1"', but Chrome thinks the breadcrumb
|
||||
# is not clickable, so we'll go via the home page instead.
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And the following "groupings" exist:
|
||||
| name | course | idnumber |
|
||||
| GX1 | C1 | GXI1 |
|
||||
@@ -78,7 +75,7 @@ Feature: availability_grouping
|
||||
# Log back in as student.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# No pages should appear yet.
|
||||
Then I should not see "P1" in the "region-main" "region"
|
||||
@@ -90,8 +87,7 @@ Feature: availability_grouping
|
||||
| grouping | group |
|
||||
| GXI1 | GI1 |
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# P1 should show but not B2.
|
||||
Then I should see "P1" in the "region-main" "region"
|
||||
|
||||
@@ -21,9 +21,7 @@ Feature: availability_profile
|
||||
Scenario: Test condition
|
||||
# Basic setup.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add
|
||||
And I add a "Page" to section "1"
|
||||
@@ -56,8 +54,7 @@ Feature: availability_profile
|
||||
# Log back in as student.
|
||||
When I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# I see P1 but not P2.
|
||||
Then I should see "P1" in the "region-main" "region"
|
||||
@@ -82,9 +79,7 @@ Feature: availability_profile
|
||||
And I click on "Update profile" "button"
|
||||
|
||||
# Set Page activity which has requirement on this field.
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Page" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | P1 |
|
||||
@@ -109,6 +104,5 @@ Feature: availability_profile
|
||||
# Log out and back in as student. Should be able to see activity.
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "P1" in the "region-main" "region"
|
||||
|
||||
@@ -39,9 +39,7 @@ Feature: display_availability
|
||||
Scenario: Activity availability display
|
||||
# Set up.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add a Page with 1 restriction.
|
||||
When I add a "Page" to section "1"
|
||||
@@ -102,8 +100,7 @@ Feature: display_availability
|
||||
# Change to student view.
|
||||
Given I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Page 1 display still there but should be dimmed and not a link.
|
||||
Then I should see "Page 1" in the "#section-1 .dimmed_text" "css_element"
|
||||
@@ -123,9 +120,7 @@ Feature: display_availability
|
||||
Scenario: Section availability display
|
||||
# Set up.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Add a restriction to section 1 (visible to students).
|
||||
When I edit the section "1"
|
||||
@@ -147,8 +142,7 @@ Feature: display_availability
|
||||
And I press "Save changes"
|
||||
|
||||
# This is necessary because otherwise it fails in Chrome, see MDL-44959
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Add Pages to each section.
|
||||
And I add a "Page" to section "1" and I fill the form with:
|
||||
@@ -172,8 +166,7 @@ Feature: display_availability
|
||||
# Change to student view.
|
||||
Given I log out
|
||||
And I log in as "student1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# The contents of both sections should be hidden.
|
||||
Then I should not see "Page 1" in the "region-main" "region"
|
||||
|
||||
@@ -32,9 +32,7 @@ Feature: edit_availability
|
||||
Given the following config values are set as admin:
|
||||
| enableavailability | 0 |
|
||||
When I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Page" to section "1"
|
||||
Then "Restrict access" "fieldset" should not exist
|
||||
|
||||
@@ -45,8 +43,7 @@ Feature: edit_availability
|
||||
And the following config values are set as admin:
|
||||
| enableavailability | 1 |
|
||||
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Page" to section "1"
|
||||
Then "Restrict access" "fieldset" should exist
|
||||
|
||||
@@ -58,10 +55,7 @@ Feature: edit_availability
|
||||
Scenario: Edit availability using settings in activity form
|
||||
# Set up.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
|
||||
# Add a Page and check it has None in so far.
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Page" to section "1"
|
||||
And I expand all fieldsets
|
||||
Then I should see "None" in the "Restrict access" "fieldset"
|
||||
@@ -149,9 +143,7 @@ Feature: edit_availability
|
||||
Scenario: Edit availability using settings in section form
|
||||
# Set up.
|
||||
Given I log in as "teacher1"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
# Edit a section
|
||||
When I edit the section "1"
|
||||
@@ -171,9 +163,7 @@ Feature: edit_availability
|
||||
Given the following config values are set as admin:
|
||||
| enableavailability | 0 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "1"
|
||||
When I expand all fieldsets
|
||||
Then "Add group/grouping access restriction" "button" should not exist
|
||||
@@ -185,9 +175,7 @@ Feature: edit_availability
|
||||
| name | course | idnumber |
|
||||
| GX1 | C1 | GXI1 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Forum name | MyForum |
|
||||
|
||||
@@ -15,8 +15,7 @@ Feature: Duplicate activities
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Database" to section "1" and I fill the form with:
|
||||
| Name | Test database name |
|
||||
| Description | Test database description |
|
||||
|
||||
@@ -17,8 +17,7 @@ Feature: Import course's contents into another course
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher1 | C2 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Database" to section "1" and I fill the form with:
|
||||
| Name | Test database name |
|
||||
| Description | Test database description |
|
||||
|
||||
@@ -25,7 +25,7 @@ Feature: Option to include groups and groupings when importing a course to anoth
|
||||
| Grouping 1 | C1 | GROUPING1 |
|
||||
| Grouping 2 | C1 | GROUPING2 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Include groups and groupings when importing a course to another course
|
||||
Given I import "Course 1" course into "Course 2" course using this options:
|
||||
|
||||
@@ -15,9 +15,7 @@ Feature: Restore Moodle 2 course backups
|
||||
| assign | C3 | assign1 | Test assign name | Assign description | 1 |
|
||||
| data | C3 | data1 | Test database name | Database description | 2 |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
@@ -63,7 +61,7 @@ Feature: Restore Moodle 2 course backups
|
||||
Scenario: Restore a backup into the same course removing it's contents before that
|
||||
When I backup "Course 1" course using this options:
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum post backup name |
|
||||
| Description | Test forum post backup description |
|
||||
|
||||
@@ -86,7 +86,7 @@ Feature: Award badges
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I follow "Add a new badge"
|
||||
And I set the following fields to these values:
|
||||
@@ -128,7 +128,7 @@ Feature: Award badges
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the following fields to these values:
|
||||
| Enable completion tracking | Yes |
|
||||
@@ -137,7 +137,8 @@ Feature: Award badges
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment name |
|
||||
| Description | Submit your online text |
|
||||
And I follow "Course 1"
|
||||
| id_completion | 1 |
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I follow "Add a new badge"
|
||||
And I set the following fields to these values:
|
||||
@@ -156,9 +157,8 @@ Feature: Award badges
|
||||
And I follow "Profile" in the user menu
|
||||
And I click on "Course 1" "link" in the "region-main" "region"
|
||||
Then I should not see "badges"
|
||||
And I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I click on "Not completed: Test assignment name. Select to mark as complete." "icon"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Not completed: Test assignment name" "icon"
|
||||
And I follow "Profile" in the user menu
|
||||
And I click on "Course 1" "link" in the "region-main" "region"
|
||||
Then I should see "Course Badge"
|
||||
@@ -177,7 +177,7 @@ Feature: Award badges
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the following fields to these values:
|
||||
| Enable completion tracking | Yes |
|
||||
@@ -187,12 +187,13 @@ Feature: Award badges
|
||||
| Assignment name | Test assignment name |
|
||||
| Description | Submit your online text |
|
||||
| assignsubmission_onlinetext_enabled | 1 |
|
||||
| id_completion | 1 |
|
||||
And I navigate to "Course completion" node in "Course administration"
|
||||
And I set the field "id_overall_aggregation" to "2"
|
||||
And I click on "Condition: Activity completion" "link"
|
||||
And I set the field "Assignment - Test assignment name" to "1"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I follow "Add a new badge"
|
||||
And I set the following fields to these values:
|
||||
@@ -211,9 +212,8 @@ Feature: Award badges
|
||||
And I follow "Profile" in the user menu
|
||||
And I click on "Course 1" "link" in the "region-main" "region"
|
||||
Then I should not see "badges"
|
||||
And I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I click on "Not completed: Test assignment name. Select to mark as complete." "icon"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Not completed: Test assignment name" "icon"
|
||||
And I log out
|
||||
# Completion cron won't mark the whole course completed unless the
|
||||
# individual criteria was marked completed more than a second ago. So
|
||||
@@ -242,7 +242,7 @@ Feature: Award badges
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Create course badge 1.
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I follow "Add a new badge"
|
||||
@@ -325,7 +325,7 @@ Feature: Award badges
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I follow "Add a new badge"
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -110,48 +110,47 @@ Feature: Block activity modules
|
||||
|
||||
When I log in as "admin"
|
||||
And I am on course index
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Activities" block
|
||||
And I click on "Assignments" "link" in the "Activities" "block"
|
||||
Then I should see "Test assignment name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Chats" "link" in the "Activities" "block"
|
||||
And I should see "Test chat name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Choices" "link" in the "Activities" "block"
|
||||
And I should see "Test choice name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Databases" "link" in the "Activities" "block"
|
||||
And I should see "Test database name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Feedback" "link" in the "Activities" "block"
|
||||
And I should see "Test feedback name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Forums" "link" in the "Activities" "block"
|
||||
And I should see "Test forum name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "External tools" "link" in the "Activities" "block"
|
||||
And I should see "Test lti name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Quizzes" "link" in the "Activities" "block"
|
||||
And I should see "Test quiz name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Glossaries" "link" in the "Activities" "block"
|
||||
And I should see "Test glossary name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "SCORM packages" "link" in the "Activities" "block"
|
||||
And I should see "Test scorm name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Lessons" "link" in the "Activities" "block"
|
||||
And I should see "Test lesson name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Wikis" "link" in the "Activities" "block"
|
||||
And I should see "Test wiki name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Workshop" "link" in the "Activities" "block"
|
||||
And I should see "Test workshop name"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Resources" "link" in the "Activities" "block"
|
||||
And I should see "Test book name"
|
||||
And I should see "Test page name"
|
||||
|
||||
@@ -25,30 +25,29 @@ Feature: The activity results block displays student scores
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment 1 |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment 2 |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment 3 |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Page" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Test page name |
|
||||
| Description | Test page description |
|
||||
| Page content | This is a page |
|
||||
And I press "Save and return to course"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Test page name"
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
@@ -58,7 +57,7 @@ Feature: The activity results block displays student scores
|
||||
And I give the grade "60.00" to the user "Student 4" for the grade item "Test assignment 1"
|
||||
And I give the grade "50.00" to the user "Student 5" for the grade item "Test assignment 1"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on a non-graded activity to show 3 high scores
|
||||
Given I follow "Test page name"
|
||||
@@ -84,19 +83,19 @@ Feature: The activity results block displays student scores
|
||||
And I configure the "Activity results" block
|
||||
Then the field "id_config_activitygradeitemid" matches value "Test assignment 1"
|
||||
And I press "Cancel"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 2"
|
||||
And I add the "Activity results" block
|
||||
And I configure the "Activity results" block
|
||||
And the field "id_config_activitygradeitemid" matches value "Test assignment 2"
|
||||
And I press "Cancel"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 3"
|
||||
And I add the "Activity results" block
|
||||
And I configure the "Activity results" block
|
||||
And the field "id_config_activitygradeitemid" matches value "Test assignment 3"
|
||||
And I press "Cancel"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test page name"
|
||||
And I add the "Activity results" block
|
||||
And I configure the "Activity results" block
|
||||
|
||||
@@ -15,8 +15,7 @@ Feature: The activity results block doesn't displays student scores for unconfig
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
Scenario: Add the block to a the course
|
||||
Given I add the "Activity results" block
|
||||
|
||||
@@ -15,8 +15,7 @@ Feature: The activity results block doesn't display student scores for unsupport
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
|
||||
Scenario: Try to configure the block to use an activity without grades
|
||||
Given I add a "Assignment" to section "1" and I fill the form with:
|
||||
|
||||
@@ -24,13 +24,12 @@ Feature: The activity results block can have administrator set defaults
|
||||
| config_gradeformat | 2 | block_activity_results |
|
||||
| config_nameformat | 2 | block_activity_results |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add the "Activity results" block
|
||||
When I configure the "Activity results" block
|
||||
And the following fields match these values:
|
||||
@@ -48,13 +47,12 @@ Feature: The activity results block can have administrator set defaults
|
||||
| config_showworst | 0 | block_activity_results |
|
||||
| config_showworst_locked | 1 | block_activity_results |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add the "Activity results" block
|
||||
When I configure the "Activity results" block
|
||||
And the following fields match these values:
|
||||
|
||||
@@ -25,13 +25,12 @@ Feature: The activity results block displays student high scores
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -40,7 +39,7 @@ Feature: The activity results block displays student high scores
|
||||
And I give the grade "60.00" to the user "Student 4" for the grade item "Test assignment"
|
||||
And I give the grade "50.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 0 high scores
|
||||
Given I add the "Activity results" block
|
||||
|
||||
@@ -25,22 +25,21 @@ Feature: The activity results block displays students high scores in group as sc
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Scales" in the course gradebook
|
||||
And I press "Add a new scale"
|
||||
And I set the following fields to these values:
|
||||
| Name | My Scale |
|
||||
| Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| id_grade_modgrade_type | Scale |
|
||||
| id_grade_modgrade_scale | My Scale |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -49,7 +48,7 @@ Feature: The activity results block displays students high scores in group as sc
|
||||
And I give the grade "Average" to the user "Student 4" for the grade item "Test assignment"
|
||||
And I give the grade "Not good enough" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 high score
|
||||
Given I add the "Activity results" block
|
||||
|
||||
@@ -42,15 +42,14 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Scales" in the course gradebook
|
||||
And I press "Add a new scale"
|
||||
And I set the following fields to these values:
|
||||
| Name | My Scale |
|
||||
| Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
@@ -58,7 +57,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
| id_grade_modgrade_type | Scale |
|
||||
| id_grade_modgrade_scale | My Scale |
|
||||
| Group mode | Separate groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -68,7 +67,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
And I give the grade "Good" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "Average" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Try to configure the block on the course page to show 1 high score
|
||||
Given I add the "Activity results" block
|
||||
@@ -83,7 +82,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
And I should see "Excellent!" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 1" in the "Activity results" "block"
|
||||
And I should see "Excellent!" in the "Activity results" "block"
|
||||
|
||||
@@ -104,7 +103,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student3"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 3" in the "Activity results" "block"
|
||||
And I should see "Very good" in the "Activity results" "block"
|
||||
And I should see "Student 4" in the "Activity results" "block"
|
||||
@@ -125,7 +124,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User S1" in the "Activity results" "block"
|
||||
And I should see "Excellent!" in the "Activity results" "block"
|
||||
And I should see "User S2" in the "Activity results" "block"
|
||||
@@ -146,7 +145,7 @@ Feature: The activity results block displays student in group high scores as sca
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User" in the "Activity results" "block"
|
||||
And I should see "Excellent!" in the "Activity results" "block"
|
||||
And I should see "Very good" in the "Activity results" "block"
|
||||
|
||||
@@ -42,14 +42,13 @@ Feature: The activity results block displays student in separate groups scores
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| Group mode | Separate groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -59,7 +58,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I give the grade "80.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "70.00" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 high score
|
||||
Given I add the "Activity results" block
|
||||
@@ -89,7 +88,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "95.00/100.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 1" in the "Activity results" "block"
|
||||
And I should see "100.00/100.00" in the "Activity results" "block"
|
||||
|
||||
@@ -107,7 +106,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "95.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 1" in the "Activity results" "block"
|
||||
And I should see "100.00" in the "Activity results" "block"
|
||||
|
||||
@@ -130,7 +129,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "75%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 1" in the "Activity results" "block"
|
||||
And I should see "100%" in the "Activity results" "block"
|
||||
And I should see "Student 2" in the "Activity results" "block"
|
||||
@@ -154,7 +153,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "75.00/100.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student3"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 3" in the "Activity results" "block"
|
||||
And I should see "90.00/100.00" in the "Activity results" "block"
|
||||
And I should see "Student 4" in the "Activity results" "block"
|
||||
@@ -178,7 +177,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "75.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 1" in the "Activity results" "block"
|
||||
And I should see "100.00" in the "Activity results" "block"
|
||||
And I should see "Student 2" in the "Activity results" "block"
|
||||
@@ -200,7 +199,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User S1" in the "Activity results" "block"
|
||||
And I should see "100.00%" in the "Activity results" "block"
|
||||
And I should see "User S2" in the "Activity results" "block"
|
||||
@@ -222,7 +221,7 @@ Feature: The activity results block displays student in separate groups scores
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User" in the "Activity results" "block"
|
||||
And I should see "100.00%" in the "Activity results" "block"
|
||||
And I should see "90.00%" in the "Activity results" "block"
|
||||
|
||||
@@ -42,14 +42,13 @@ Feature: The activity results block displays student in visible groups scores
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| Group mode | Visible groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -59,7 +58,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I give the grade "80.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "70.00" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 high score
|
||||
Given I add the "Activity results" block
|
||||
@@ -87,7 +86,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 1" in the "Activity results" "block"
|
||||
And I should see "95.00/100.00" in the "Activity results" "block"
|
||||
|
||||
@@ -103,7 +102,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 1" in the "Activity results" "block"
|
||||
And I should see "95.00" in the "Activity results" "block"
|
||||
|
||||
@@ -120,7 +119,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 1" in the "Activity results" "block"
|
||||
And I should see "95%" in the "Activity results" "block"
|
||||
And I should see "Group 2" in the "Activity results" "block"
|
||||
@@ -140,7 +139,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 1" in the "Activity results" "block"
|
||||
And I should see "95.00/100.00" in the "Activity results" "block"
|
||||
And I should see "Group 2" in the "Activity results" "block"
|
||||
@@ -160,7 +159,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 1" in the "Activity results" "block"
|
||||
And I should see "95.00" in the "Activity results" "block"
|
||||
And I should see "Group 2" in the "Activity results" "block"
|
||||
@@ -180,7 +179,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group" in the "Activity results" "block"
|
||||
And I should see "95.00%" in the "Activity results" "block"
|
||||
And I should see "85.00%" in the "Activity results" "block"
|
||||
@@ -198,7 +197,7 @@ Feature: The activity results block displays student in visible groups scores
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group" in the "Activity results" "block"
|
||||
And I should see "95.00%" in the "Activity results" "block"
|
||||
And I should see "85.00%" in the "Activity results" "block"
|
||||
|
||||
@@ -25,13 +25,12 @@ Feature: The activity results block displays student low scores
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -40,7 +39,7 @@ Feature: The activity results block displays student low scores
|
||||
And I give the grade "60.00" to the user "Student 4" for the grade item "Test assignment"
|
||||
And I give the grade "50.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 low score
|
||||
Given I add the "Activity results" block
|
||||
|
||||
@@ -25,22 +25,21 @@ Feature: The activity results block displays student low scores as scales
|
||||
| student4 | C1 | student |
|
||||
| student5 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Scales" in the course gradebook
|
||||
And I press "Add a new scale"
|
||||
And I set the following fields to these values:
|
||||
| Name | My Scale |
|
||||
| Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| id_grade_modgrade_type | Scale |
|
||||
| id_grade_modgrade_scale | My Scale |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -49,7 +48,7 @@ Feature: The activity results block displays student low scores as scales
|
||||
And I give the grade "Average" to the user "Student 4" for the grade item "Test assignment"
|
||||
And I give the grade "Not good enough" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 low score
|
||||
Given I add the "Activity results" block
|
||||
|
||||
@@ -42,15 +42,14 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Scales" in the course gradebook
|
||||
And I press "Add a new scale"
|
||||
And I set the following fields to these values:
|
||||
| Name | My Scale |
|
||||
| Scale | Disappointing, Not good enough, Average, Good, Very good, Excellent! |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
@@ -58,7 +57,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
| id_grade_modgrade_type | Scale |
|
||||
| id_grade_modgrade_scale | My Scale |
|
||||
| Group mode | Separate groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "Excellent!" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -68,7 +67,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
And I give the grade "Good" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "Average" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Try to configure the block on the course page to show 1 low score
|
||||
Given I add the "Activity results" block
|
||||
@@ -83,7 +82,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 6" in the "Activity results" "block"
|
||||
And I should see "Average" in the "Activity results" "block"
|
||||
|
||||
@@ -102,7 +101,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student3"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 3" in the "Activity results" "block"
|
||||
And I should see "Very good" in the "Activity results" "block"
|
||||
And I should see "Student 4" in the "Activity results" "block"
|
||||
@@ -122,7 +121,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User S5" in the "Activity results" "block"
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I should see "User S6" in the "Activity results" "block"
|
||||
@@ -142,7 +141,7 @@ Feature: The activity results block displays students in groups low scores as sc
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User" in the "Activity results" "block"
|
||||
And I should see "Good" in the "Activity results" "block"
|
||||
And I should see "Average" in the "Activity results" "block"
|
||||
|
||||
@@ -42,14 +42,13 @@ Feature: The activity results block displays students in separate groups scores
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| Group mode | Separate groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -59,7 +58,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I give the grade "80.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "70.00" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 low score
|
||||
Given I add the "Activity results" block
|
||||
@@ -89,7 +88,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00/100.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 6" in the "Activity results" "block"
|
||||
And I should see "70.00/100.00" in the "Activity results" "block"
|
||||
|
||||
@@ -107,7 +106,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 6" in the "Activity results" "block"
|
||||
And I should see "70.00" in the "Activity results" "block"
|
||||
|
||||
@@ -128,7 +127,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 6" in the "Activity results" "block"
|
||||
And I should see "70%" in the "Activity results" "block"
|
||||
And I should see "Student 5" in the "Activity results" "block"
|
||||
@@ -150,7 +149,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00/100.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student3"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 3" in the "Activity results" "block"
|
||||
And I should see "90.00/100.00" in the "Activity results" "block"
|
||||
And I should see "Student 4" in the "Activity results" "block"
|
||||
@@ -172,7 +171,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Student 5" in the "Activity results" "block"
|
||||
And I should see "80.00" in the "Activity results" "block"
|
||||
And I should see "Student 6" in the "Activity results" "block"
|
||||
@@ -193,7 +192,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User S1" in the "Activity results" "block"
|
||||
And I should see "100.00%" in the "Activity results" "block"
|
||||
And I should see "User S2" in the "Activity results" "block"
|
||||
@@ -214,7 +213,7 @@ Feature: The activity results block displays students in separate groups scores
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "User" in the "Activity results" "block"
|
||||
And I should see "100.00%" in the "Activity results" "block"
|
||||
And I should see "90.00%" in the "Activity results" "block"
|
||||
|
||||
@@ -42,14 +42,13 @@ Feature: The activity results block displays student in visible groups low score
|
||||
| student5 | G3 |
|
||||
| student6 | G3 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment |
|
||||
| Description | Offline text |
|
||||
| assignsubmission_file_enabled | 0 |
|
||||
| Group mode | Visible groups |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
And I turn editing mode on
|
||||
And I give the grade "100.00" to the user "Student 1" for the grade item "Test assignment"
|
||||
@@ -59,7 +58,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I give the grade "80.00" to the user "Student 5" for the grade item "Test assignment"
|
||||
And I give the grade "70.00" to the user "Student 6" for the grade item "Test assignment"
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Configure the block on the course page to show 1 low score
|
||||
Given I add the "Activity results" block
|
||||
@@ -87,7 +86,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 3" in the "Activity results" "block"
|
||||
And I should see "75.00/100.00" in the "Activity results" "block"
|
||||
|
||||
@@ -103,7 +102,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 3" in the "Activity results" "block"
|
||||
And I should see "75.00" in the "Activity results" "block"
|
||||
|
||||
@@ -124,7 +123,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I should see "75%" in the "Activity results" "block"
|
||||
And I log out
|
||||
And I log in as "student5"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Group 2" in the "Activity results" "block"
|
||||
And I should see "85%" in the "Activity results" "block"
|
||||
And I should see "Group 3" in the "Activity results" "block"
|
||||
@@ -142,7 +141,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 2" in the "Activity results" "block"
|
||||
And I should see "85.00/100.00" in the "Activity results" "block"
|
||||
And I should see "Group 3" in the "Activity results" "block"
|
||||
@@ -160,7 +159,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group 2" in the "Activity results" "block"
|
||||
And I should see "85.00" in the "Activity results" "block"
|
||||
And I should see "Group 3" in the "Activity results" "block"
|
||||
@@ -178,7 +177,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group" in the "Activity results" "block"
|
||||
And I should see "85.00%" in the "Activity results" "block"
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
@@ -195,7 +194,7 @@ Feature: The activity results block displays student in visible groups low score
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Group" in the "Activity results" "block"
|
||||
And I should see "85.00%" in the "Activity results" "block"
|
||||
And I should see "75.00%" in the "Activity results" "block"
|
||||
|
||||
@@ -21,14 +21,12 @@ Feature: Enable Block Badges in a course without badges
|
||||
| enablebadges | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Latest badges" block
|
||||
Then I should see "Badges are not enabled on this site." in the "Latest badges" "block"
|
||||
|
||||
Scenario: Add the block to a the course when badges are enabled
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Latest badges" block
|
||||
Then I should see "You have no badges to display" in the "Latest badges" "block"
|
||||
|
||||
@@ -15,7 +15,7 @@ Feature: Enable Block Badges in a course
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Issue badge 1 of 2
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I set the following fields to these values:
|
||||
@@ -54,16 +54,14 @@ Feature: Enable Block Badges in a course
|
||||
|
||||
Scenario: Add the recent badges block to a course.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Latest badges" block
|
||||
Then I should see "Badge 1" in the "Latest badges" "block"
|
||||
And I should see "Badge 2" in the "Latest badges" "block"
|
||||
|
||||
Scenario: Add the recent badges block to a course and limit it to only display 1 badge.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Latest badges" block
|
||||
And I configure the "Latest badges" block
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -15,7 +15,7 @@ Feature: Enable Block Badges on the dashboard and view awarded badges
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Issue badge 1 of 2
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -20,7 +20,7 @@ Feature: Enable Block Badges on the frontpage and view awarded badges
|
||||
And I add the "Latest badges" block
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Issue badge 1 of 2
|
||||
And I navigate to "Add a new badge" node in "Course administration > Badges"
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -21,8 +21,7 @@ Feature: Enable Block blog menu in a course
|
||||
| enableblogs | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "Blogging is disabled!" in the "Blog menu" "block"
|
||||
|
||||
@@ -32,8 +31,7 @@ Feature: Enable Block blog menu in a course
|
||||
| useblogassociations | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "Blog entries" in the "Blog menu" "block"
|
||||
And I should see "Add a new entry" in the "Blog menu" "block"
|
||||
@@ -47,8 +45,7 @@ Feature: Enable Block blog menu in a course
|
||||
| useblogassociations | 1 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "Blog entries" in the "Blog menu" "block"
|
||||
And I should see "Add a new entry" in the "Blog menu" "block"
|
||||
@@ -62,8 +59,7 @@ Feature: Enable Block blog menu in a course
|
||||
| enablerssfeeds | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should not see "Blog RSS feed" in the "Blog menu" "block"
|
||||
And I should see "Add a new entry" in the "Blog menu" "block"
|
||||
@@ -74,8 +70,7 @@ Feature: Enable Block blog menu in a course
|
||||
| enablerssfeeds | 1 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "Blog RSS feed" in the "Blog menu" "block"
|
||||
And I should see "Add a new entry" in the "Blog menu" "block"
|
||||
|
||||
@@ -19,8 +19,7 @@ Feature: Enable Block blog menu in an activity
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment 1 |
|
||||
| Description | Offline text |
|
||||
@@ -31,7 +30,7 @@ Feature: Enable Block blog menu in an activity
|
||||
|
||||
Scenario: Students use the blog menu block to post blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add a new entry"
|
||||
When I set the following fields to these values:
|
||||
@@ -40,8 +39,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I press "Save changes"
|
||||
Then I should see "S1 First Blog"
|
||||
And I should see "This is my awesome blog!"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Blog entries"
|
||||
And I should see "S1 First Blog"
|
||||
@@ -49,7 +47,7 @@ Feature: Enable Block blog menu in an activity
|
||||
|
||||
Scenario: Students use the blog menu block to view their blogs about the activity
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -61,7 +59,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
@@ -71,8 +69,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -82,8 +79,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
When I follow "View my entries about this Assignment"
|
||||
Then I should see "S2 First Blog"
|
||||
@@ -92,7 +88,7 @@ Feature: Enable Block blog menu in an activity
|
||||
|
||||
Scenario: Students use the blog menu block to view all blogs about the assignment
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -104,7 +100,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
@@ -114,8 +110,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -125,8 +120,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
When I follow "View all entries about this Assignment"
|
||||
Then I should see "S1 First Blog"
|
||||
@@ -135,7 +129,7 @@ Feature: Enable Block blog menu in an activity
|
||||
|
||||
Scenario: Students use the blog menu block to view all their blog entries
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -147,7 +141,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
@@ -157,8 +151,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -168,8 +161,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
When I follow "Blog entries"
|
||||
Then I should see "S2 First Blog"
|
||||
@@ -178,7 +170,7 @@ Feature: Enable Block blog menu in an activity
|
||||
|
||||
Scenario: Teacher searches for student blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -190,7 +182,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
@@ -200,8 +192,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Assignment: Test assignment 1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
And I set the following fields to these values:
|
||||
@@ -213,7 +204,7 @@ Feature: Enable Block blog menu in an activity
|
||||
And I should see "Associated Assignment: Test assignment 1"
|
||||
And I log out
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I set the field "blogsearchquery" to "First"
|
||||
And I press "Search"
|
||||
|
||||
@@ -19,14 +19,13 @@ Feature: Students can use block blog menu in a course
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Blog menu" block
|
||||
And I log out
|
||||
|
||||
Scenario: Students use the blog menu block to post blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add a new entry"
|
||||
When I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -34,15 +33,14 @@ Feature: Students can use block blog menu in a course
|
||||
And I press "Save changes"
|
||||
Then I should see "S1 First Blog"
|
||||
And I should see "This is my awesome blog!"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Blog entries"
|
||||
And I should see "S1 First Blog"
|
||||
And I should see "This is my awesome blog!"
|
||||
|
||||
Scenario: Students use the blog menu block to view their blogs about the course
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -53,7 +51,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "Associated Course: C1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 Second Blog |
|
||||
@@ -62,8 +60,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 First Blog |
|
||||
@@ -72,8 +69,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I follow "View my entries about this course"
|
||||
Then I should see "S2 First Blog"
|
||||
And I should not see "S2 Second Blog"
|
||||
@@ -81,7 +77,7 @@ Feature: Students can use block blog menu in a course
|
||||
|
||||
Scenario: Students use the blog menu block to view all blogs about the course
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -92,7 +88,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "Associated Course: C1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 Second Blog |
|
||||
@@ -101,8 +97,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 First Blog |
|
||||
@@ -111,8 +106,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I follow "View all entries for this course"
|
||||
Then I should see "S1 First Blog"
|
||||
And I should see "S2 First Blog"
|
||||
@@ -120,7 +114,7 @@ Feature: Students can use block blog menu in a course
|
||||
|
||||
Scenario: Students use the blog menu block to view all their blog entries
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -131,7 +125,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "Associated Course: C1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 Second Blog |
|
||||
@@ -140,8 +134,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 First Blog |
|
||||
@@ -150,8 +143,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 First Blog"
|
||||
And I should see "My course blog is better!"
|
||||
And I should see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I follow "Blog entries"
|
||||
Then I should see "S2 First Blog"
|
||||
And I should see "S2 Second Blog"
|
||||
@@ -159,7 +151,7 @@ Feature: Students can use block blog menu in a course
|
||||
|
||||
Scenario: Teacher searches for student blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -170,7 +162,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "Associated Course: C1"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 Second Blog |
|
||||
@@ -179,8 +171,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "S2 Second Blog"
|
||||
And I should see "My unrelated blog!"
|
||||
And I should not see "Associated Course: C1"
|
||||
And I follow "Dashboard"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
And I set the following fields to these values:
|
||||
| Entry title | S2 First Blog |
|
||||
@@ -191,7 +182,7 @@ Feature: Students can use block blog menu in a course
|
||||
And I should see "Associated Course: C1"
|
||||
And I log out
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I set the field "blogsearchquery" to "First"
|
||||
And I press "Search"
|
||||
Then I should see "S1 First Blog"
|
||||
|
||||
@@ -21,14 +21,12 @@ Feature: Feature: Users can use the recent blog entries block to view recent blo
|
||||
| enableblogs | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Recent blog entries" block
|
||||
Then I should see "Blogging is disabled!" in the "Recent blog entries" "block"
|
||||
|
||||
Scenario: Add the recent blogs block to a course when there are not any blog posts
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Recent blog entries" block
|
||||
Then I should see "No recent entries" in the "Recent blog entries" "block"
|
||||
|
||||
@@ -19,8 +19,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment 1 |
|
||||
| Description | Offline text |
|
||||
@@ -32,7 +31,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
|
||||
Scenario: Students use the recent blog entries block to view blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
When I set the following fields to these values:
|
||||
@@ -48,7 +47,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
|
||||
Scenario: Students only see a few entries in the recent blog entries block
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test assignment 1"
|
||||
And I follow "Add an entry about this Assignment"
|
||||
# Blog 1 of 5
|
||||
@@ -106,8 +105,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
And I should see "This is my awesome blog!"
|
||||
Then I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test assignment 1"
|
||||
And I configure the "Recent blog entries" block
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -17,15 +17,14 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Blog menu" block
|
||||
And I add the "Recent blog entries" block
|
||||
And I log out
|
||||
|
||||
Scenario: Students use the recent blog entries block to view blogs
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
When I set the following fields to these values:
|
||||
| Entry title | S1 First Blog |
|
||||
@@ -40,7 +39,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
|
||||
Scenario: Students only see a few entries in the recent blog entries block
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Add an entry about this course"
|
||||
# Blog 1 of 5
|
||||
And I set the following fields to these values:
|
||||
@@ -97,8 +96,7 @@ Feature: Students can use the recent blog entries block to view recent entries o
|
||||
And I should see "This is my awesome blog!"
|
||||
Then I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I configure the "Recent blog entries" block
|
||||
And I set the following fields to these values:
|
||||
| id_config_numberofrecentblogentries | 2 |
|
||||
|
||||
@@ -21,8 +21,7 @@ Feature: Adding blog tag block
|
||||
| teacher1 | c1 | editingteacher |
|
||||
| student1 | c1 | student |
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Blog tags" block
|
||||
# TODO MDL-57120 site "Blogs" link not accessible without navigation block.
|
||||
And I add the "Navigation" block if not present
|
||||
@@ -37,7 +36,7 @@ Feature: Adding blog tag block
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to course participants
|
||||
And I click on "Course blogs" "link" in the "Navigation" "block"
|
||||
And I follow "Blog about this Course"
|
||||
|
||||
@@ -79,13 +79,16 @@ class block_calendar_month extends block_base {
|
||||
list($courses, $group, $user) = calendar_set_filters($filtercourse);
|
||||
if ($issite) {
|
||||
// For the front page.
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false,
|
||||
'frontpage', $courseid, $time);
|
||||
// No filters for now.
|
||||
} else {
|
||||
// For any other course.
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false,
|
||||
'course', $courseid, $time);
|
||||
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
|
||||
$this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
|
||||
$this->content->text .= '<div class="filters calendar_filters">' .
|
||||
calendar_filter_controls($this->page->url) . '</div>';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -21,8 +21,7 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
|
||||
Scenario: Add the block to a the course
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Calendar" block
|
||||
Then I should see "Events key" in the "Calendar" "block"
|
||||
|
||||
@@ -34,8 +33,7 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
| id_name | Site Event |
|
||||
And I log out
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I hover over today in the calendar
|
||||
Then I should see "Site Event"
|
||||
@@ -48,13 +46,12 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
| id_name | Site Event |
|
||||
And I log out
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Course |
|
||||
| id_name | Course Event |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Hide global events"
|
||||
And I hover over today in the calendar
|
||||
Then I should not see "Site Event"
|
||||
@@ -63,31 +60,29 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
@javascript
|
||||
Scenario: View a course event in the calendar block
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Course |
|
||||
| id_name | Course Event |
|
||||
When I follow "Course 1"
|
||||
When I am on "Course 1" course homepage
|
||||
And I hover over today in the calendar
|
||||
Then I should see "Course Event"
|
||||
|
||||
@javascript
|
||||
Scenario: Filter course events in the calendar block
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Course |
|
||||
| id_name | Course Event |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | User |
|
||||
| id_name | User Event |
|
||||
When I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Hide course events"
|
||||
And I hover over today in the calendar
|
||||
Then I should not see "Course Event"
|
||||
@@ -96,32 +91,30 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
@javascript
|
||||
Scenario: View a user event in the calendar block
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | User |
|
||||
| id_name | User Event |
|
||||
When I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I hover over today in the calendar
|
||||
Then I should see "User Event"
|
||||
|
||||
@javascript
|
||||
Scenario: Filter user events in the calendar block
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Course |
|
||||
| id_name | Course Event |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | User |
|
||||
| id_name | User Event |
|
||||
When I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Hide user events"
|
||||
And I hover over today in the calendar
|
||||
Then I should not see "User Event"
|
||||
@@ -138,7 +131,7 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
| student1 | G1 |
|
||||
| student2 | G2 |
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the following fields to these values:
|
||||
| id_groupmode | Separate groups |
|
||||
@@ -152,12 +145,12 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
| id_name | Group Event |
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I hover over today in the calendar
|
||||
And I should see "Group Event"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I hover over today in the calendar
|
||||
And I should not see "Group Event"
|
||||
|
||||
@@ -172,7 +165,7 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
| student1 | G1 |
|
||||
| student2 | G2 |
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the following fields to these values:
|
||||
| id_groupmode | Separate groups |
|
||||
@@ -183,14 +176,14 @@ Feature: Enable the calendar block in a course and test it's functionality
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Course |
|
||||
| id_name | Course Event 1 |
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I create a calendar event with form data:
|
||||
| id_eventtype | Group |
|
||||
| id_groupid | Group 1 |
|
||||
| id_name | Group Event 1 |
|
||||
And I log out
|
||||
Then I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Hide group events"
|
||||
And I hover over today in the calendar
|
||||
And I should not see "Group Event 1"
|
||||
|
||||
@@ -21,8 +21,7 @@ Feature: Enable the calendar block in a course
|
||||
| id_name | Site Event |
|
||||
And I log out
|
||||
Then I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Calendar" block
|
||||
And I hover over today in the calendar
|
||||
And I should see "Site Event"
|
||||
|
||||
@@ -90,7 +90,7 @@ class block_calendar_upcoming extends block_base {
|
||||
if (!empty($this->instance)) {
|
||||
$link = 'view.php?view=day&course='.$courseshown.'&';
|
||||
$showcourselink = ($this->page->course->id == SITEID);
|
||||
$this->content->text = calendar_get_block_upcoming($events, $link, $showcourselink);
|
||||
$this->content->text = self::get_upcoming_content($events, $link, $showcourselink);
|
||||
}
|
||||
|
||||
if (empty($this->content->text)) {
|
||||
@@ -99,6 +99,54 @@ class block_calendar_upcoming extends block_base {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upcoming event block content.
|
||||
*
|
||||
* @param array $events list of events
|
||||
* @param \moodle_url|string $linkhref link to event referer
|
||||
* @param boolean $showcourselink whether links to courses should be shown
|
||||
* @return string|null $content html block content
|
||||
*/
|
||||
public static function get_upcoming_content($events, $linkhref = null, $showcourselink = false) {
|
||||
$content = '';
|
||||
$lines = count($events);
|
||||
|
||||
if (!$lines) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $lines; ++$i) {
|
||||
if (!isset($events[$i]->time)) {
|
||||
continue;
|
||||
}
|
||||
$events[$i] = calendar_add_event_metadata($events[$i]);
|
||||
$content .= '<div class="event"><span class="icon c0">' . $events[$i]->icon . '</span>';
|
||||
if (!empty($events[$i]->referer)) {
|
||||
// That's an activity event, so let's provide the hyperlink.
|
||||
$content .= $events[$i]->referer;
|
||||
} else {
|
||||
if (!empty($linkhref)) {
|
||||
$href = calendar_get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0,
|
||||
$events[$i]->timestart);
|
||||
$href->set_anchor('event_' . $events[$i]->id);
|
||||
$content .= \html_writer::link($href, $events[$i]->name);
|
||||
} else {
|
||||
$content .= $events[$i]->name;
|
||||
}
|
||||
}
|
||||
$events[$i]->time = str_replace('»', '<br />»', $events[$i]->time);
|
||||
if ($showcourselink && !empty($events[$i]->courselink)) {
|
||||
$content .= \html_writer::div($events[$i]->courselink, 'course');
|
||||
}
|
||||
$content .= '<div class="date">' . $events[$i]->time . '</div></div>';
|
||||
if ($i < $lines - 1) {
|
||||
$content .= '<hr />';
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,12 +17,11 @@ Feature: Add a comment to the comments block
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Comments" block
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
@javascript
|
||||
Scenario: Add a comment with Javascript enabled
|
||||
@@ -69,7 +68,7 @@ Feature: Add a comment to the comments block
|
||||
And I add "Super test comment 31" comment to comments block
|
||||
Then I should see "Super test comment 01"
|
||||
And I should see "Super test comment 31"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should not see "Super test comment 01"
|
||||
And I should not see "Super test comment 02"
|
||||
And I should not see "Super test comment 16"
|
||||
|
||||
@@ -20,15 +20,14 @@ Feature: Enable Block comments on an activity page and view comments
|
||||
| activity | course | idnumber | name | intro |
|
||||
| page | C1 | page1 | Test page name | Test page description |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test page name"
|
||||
And I add the "Comments" block
|
||||
And I follow "Show comments"
|
||||
And I add "I'm a comment from the teacher" comment to comments block
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test page name"
|
||||
And I follow "Show comments"
|
||||
Then I should see "I'm a comment from the teacher"
|
||||
|
||||
@@ -17,13 +17,12 @@ Feature: Enable Block comments on a course page and view comments
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Comments" block
|
||||
And I follow "Show comments"
|
||||
And I add "I'm a comment from the teacher" comment to comments block
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Show comments"
|
||||
Then I should see "I'm a comment from the teacher"
|
||||
|
||||
@@ -18,16 +18,15 @@ Feature: Delete comment block messages
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Comments" block
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add "Comment from student1" comment to comments block
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add "Comment from teacher1" comment to comments block
|
||||
When I delete "Comment from student1" comment from comments block
|
||||
Then I should not see "Comment from student1"
|
||||
|
||||
@@ -19,8 +19,7 @@ Feature: Enable Block Completion in a course
|
||||
|
||||
Scenario: Add the block to a the course where completion is disabled
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I navigate to "Edit settings" node in "Course administration"
|
||||
And I set the following fields to these values:
|
||||
| Enable completion tracking | No |
|
||||
@@ -30,8 +29,7 @@ Feature: Enable Block Completion in a course
|
||||
|
||||
Scenario: Add the block to a the course where completion is not set
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Course completion status" block
|
||||
Then I should see "No completion criteria set for this course" in the "Course completion status" "block"
|
||||
|
||||
@@ -40,8 +38,7 @@ Feature: Enable Block Completion in a course
|
||||
| activity | course | idnumber | name | intro |
|
||||
| page | C1 | page1 | Test page name | Test page description |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test page name"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
|
||||
+5
-8
@@ -22,8 +22,7 @@ Feature: Enable Block Completion in a course using activity completion
|
||||
|
||||
Scenario: Add the block to a the course and add course completion items
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test page name"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
@@ -38,14 +37,13 @@ Feature: Enable Block Completion in a course using activity completion
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Status: Not yet started" in the "Course completion status" "block"
|
||||
And I should see "0 of 1" in the "Activity completion" "table_row"
|
||||
|
||||
Scenario: Add the block to a the course and add course completion items
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test page name"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
@@ -60,14 +58,13 @@ Feature: Enable Block Completion in a course using activity completion
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test page name"
|
||||
And I follow "C1"
|
||||
Then I should see "Status: Pending" in the "Course completion status" "block"
|
||||
And I should see "0 of 1" in the "Activity completion" "table_row"
|
||||
And I trigger cron
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "1 of 1" in the "Activity completion" "table_row"
|
||||
And I follow "More details"
|
||||
And I should see "Yes" in the "Activity completion" "table_row"
|
||||
|
||||
@@ -21,8 +21,7 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
|
||||
Scenario: Add the block to a the course and mark a student complete.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Course completion status" block
|
||||
And I navigate to "Course completion" node in "Course administration"
|
||||
And I expand all fieldsets
|
||||
@@ -31,12 +30,12 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Status: Not yet started" in the "Course completion status" "block"
|
||||
And I should see "No" in the "Teacher" "table_row"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Course completion" node in "Course administration > Reports"
|
||||
And I follow "Click to mark user complete"
|
||||
# Running completion task just after clicking sometimes fail, as record
|
||||
@@ -46,7 +45,7 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
And I am on site homepage
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Status: Complete" in the "Course completion status" "block"
|
||||
And I should see "Yes" in the "Teacher" "table_row"
|
||||
And I follow "More details"
|
||||
@@ -54,8 +53,7 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
|
||||
Scenario: Add the block to a the course and require multiple roles to mark a student complete.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Course completion status" block
|
||||
And I navigate to "Course completion" node in "Course administration"
|
||||
And I expand all fieldsets
|
||||
@@ -66,18 +64,18 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Status: Not yet started" in the "Course completion status" "block"
|
||||
And I should see "No" in the "Teacher" "table_row"
|
||||
And I should see "No" in the "Non-editing teacher" "table_row"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Course completion" node in "Course administration > Reports"
|
||||
And I follow "Click to mark user complete"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Status: In progress" in the "Course completion status" "block"
|
||||
And I should see "Yes" in the "Teacher" "table_row"
|
||||
And I should see "No" in the "Non-editing teacher" "table_row"
|
||||
@@ -86,7 +84,7 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
And I should see "No" in the "Marked complete by Non-editing teacher" "table_row"
|
||||
And I log out
|
||||
And I log in as "teacher2"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Course completion" node in "Course administration > Reports"
|
||||
And I follow "Click to mark user complete"
|
||||
# Running completion task just after clicking sometimes fail, as record
|
||||
@@ -96,7 +94,7 @@ Feature: Enable Block Completion in a course using manual completion by others
|
||||
And I am on site homepage
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Status: Complete" in the "Course completion status" "block"
|
||||
And I should see "Yes" in the "Teacher" "table_row"
|
||||
And I should see "Yes" in the "Non-editing teacher" "table_row"
|
||||
|
||||
@@ -17,8 +17,7 @@ Feature: Enable Block Completion in a course using manual self completion
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Course completion status" block
|
||||
And I add the "Self completion" block
|
||||
And I navigate to "Course completion" node in "Course administration"
|
||||
@@ -28,7 +27,7 @@ Feature: Enable Block Completion in a course using manual self completion
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Status: Not yet started" in the "Course completion status" "block"
|
||||
And I should see "No" in the "Self completion" "table_row"
|
||||
And I follow "Complete course"
|
||||
@@ -39,8 +38,7 @@ Feature: Enable Block Completion in a course using manual self completion
|
||||
# should be created before the task runs.
|
||||
And I wait "1" seconds
|
||||
And I run the scheduled task "core\task\completion_regular_task"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Status: Complete" in the "Course completion status" "block"
|
||||
And I should see "Yes" in the "Self completion" "table_row"
|
||||
And I follow "More details"
|
||||
|
||||
@@ -58,7 +58,7 @@ Feature: Enable the course_list block on a category page and view it's contents
|
||||
And I should see "Course 2" in the "My courses" "block"
|
||||
And I should see "Course 3" in the "My courses" "block"
|
||||
And I should not see "Course 4" in the "My courses" "block"
|
||||
And I follow "Course 3"
|
||||
And I am on "Course 3" course homepage
|
||||
And I should see "Course 3"
|
||||
|
||||
Scenario: Add the course list block on category page and view as an admin
|
||||
|
||||
@@ -27,8 +27,7 @@ Feature: Enable the course_list block on a course page and view it's contents
|
||||
|
||||
Scenario: Add the course list block on course page and navigate to the course listing
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Courses" block
|
||||
Then I should see "Course 1" in the "My courses" "block"
|
||||
And I should see "Course 2" in the "My courses" "block"
|
||||
@@ -39,21 +38,18 @@ Feature: Enable the course_list block on a course page and view it's contents
|
||||
|
||||
Scenario: Add the course list block on course page and navigate to another course
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Courses" block
|
||||
Then I should see "Course 1" in the "My courses" "block"
|
||||
And I should see "Course 2" in the "My courses" "block"
|
||||
And I should see "Course 3" in the "My courses" "block"
|
||||
And I should not see "Course 4" in the "My courses" "block"
|
||||
And I follow "Course 3"
|
||||
And I am on "Course 3" course homepage
|
||||
And I should see "Course 3"
|
||||
|
||||
Scenario: Add the course list block on course page and view as an admin
|
||||
Given I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Courses" block
|
||||
Then I should see "Miscellaneous" in the "Course categories" "block"
|
||||
And I should see "Category 1" in the "Course categories" "block"
|
||||
@@ -68,8 +64,7 @@ Feature: Enable the course_list block on a course page and view it's contents
|
||||
Given the following config values are set as admin:
|
||||
| block_course_list_hideallcourseslink | 1 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Courses" block
|
||||
Then I should not see "All courses" in the "My courses" "block"
|
||||
|
||||
@@ -80,9 +75,7 @@ Feature: Enable the course_list block on a course page and view it's contents
|
||||
| user | course | role |
|
||||
| admin | C1 | editingteacher |
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
When I add the "Courses" block
|
||||
Then I should not see "Miscellaneous" in the "My courses" "block"
|
||||
And I should not see "Category 1" in the "My courses" "block"
|
||||
|
||||
@@ -44,7 +44,7 @@ Feature: Enable the course_list block on the dashboard and view it's contents
|
||||
And I should see "Course 2" in the "My courses" "block"
|
||||
And I should see "Course 3" in the "My courses" "block"
|
||||
And I should not see "Course 4" in the "My courses" "block"
|
||||
And I follow "Course 3"
|
||||
And I am on "Course 3" course homepage
|
||||
And I should see "Course 3"
|
||||
|
||||
Scenario: Add the course list block on the dashboard and view as an admin
|
||||
|
||||
@@ -52,7 +52,7 @@ Feature: Enable the course_list block on the frontpage and view it's contents
|
||||
And I should see "Course 2" in the "My courses" "block"
|
||||
And I should see "Course 3" in the "My courses" "block"
|
||||
And I should not see "Course 4" in the "My courses" "block"
|
||||
And I follow "Course 3"
|
||||
And I am on "Course 3" course homepage
|
||||
And I should see "Course 3"
|
||||
|
||||
Scenario: Add the course list block on the frontpage page and view as an admin
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Course overview block
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once($CFG->dirroot.'/blocks/course_overview/locallib.php');
|
||||
|
||||
/**
|
||||
* Course overview block
|
||||
*
|
||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class block_course_overview extends block_base {
|
||||
/**
|
||||
* If this is passed as mynumber then showallcourses, irrespective of limit by user.
|
||||
*/
|
||||
const SHOW_ALL_COURSES = -2;
|
||||
|
||||
/**
|
||||
* Block initialization
|
||||
*/
|
||||
public function init() {
|
||||
$this->title = get_string('pluginname', 'block_course_overview');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return contents of course_overview block
|
||||
*
|
||||
* @return stdClass contents of block
|
||||
*/
|
||||
public function get_content() {
|
||||
global $USER, $CFG, $DB;
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$config = get_config('block_course_overview');
|
||||
|
||||
$this->content = new stdClass();
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
$content = array();
|
||||
|
||||
$updatemynumber = optional_param('mynumber', -1, PARAM_INT);
|
||||
if ($updatemynumber >= 0) {
|
||||
block_course_overview_update_mynumber($updatemynumber);
|
||||
}
|
||||
|
||||
profile_load_custom_fields($USER);
|
||||
|
||||
$showallcourses = ($updatemynumber === self::SHOW_ALL_COURSES);
|
||||
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses($showallcourses);
|
||||
$overviews = block_course_overview_get_overviews($sitecourses);
|
||||
|
||||
$renderer = $this->page->get_renderer('block_course_overview');
|
||||
if (!empty($config->showwelcomearea)) {
|
||||
require_once($CFG->dirroot.'/message/lib.php');
|
||||
$msgcount = message_count_unread_messages();
|
||||
$this->content->text = $renderer->welcome_area($msgcount);
|
||||
}
|
||||
|
||||
// Number of sites to display.
|
||||
if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) {
|
||||
$this->content->text .= $renderer->editing_bar_head($totalcourses);
|
||||
}
|
||||
|
||||
if (empty($sortedcourses)) {
|
||||
$this->content->text .= get_string('nocourses','my');
|
||||
} else {
|
||||
// For each course, build category cache.
|
||||
$this->content->text .= $renderer->course_overview($sortedcourses, $overviews);
|
||||
$this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses));
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the block to have a configuration page
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locations where block can be displayed
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function applicable_formats() {
|
||||
return array('my' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets block header to be hidden or visible
|
||||
*
|
||||
* @return bool if true then header will be visible.
|
||||
*/
|
||||
public function hide_header() {
|
||||
// Hide header if welcome area is show.
|
||||
$config = get_config('block_course_overview');
|
||||
return !empty($config->showwelcomearea);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Lang strings for course_overview block
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['activityoverview'] = 'You have {$a}s that need attention';
|
||||
$string['alwaysshowall'] = 'Always show all';
|
||||
$string['collapseall'] = 'Collapse all course lists';
|
||||
$string['configotherexpanded'] = 'If enabled, other courses will be expanded by default unless overridden by user preferences.';
|
||||
$string['configpreservestates'] = 'If enabled, the collapsed/expanded states set by the user are stored and used on each load.';
|
||||
$string['course_overview:addinstance'] = 'Add a new course overview block';
|
||||
$string['course_overview:myaddinstance'] = 'Add a new course overview block to Dashboard';
|
||||
$string['defaultmaxcourses'] = 'Default maximum courses';
|
||||
$string['defaultmaxcoursesdesc'] = 'Maximum courses which should be displayed on course overview block, 0 will show all courses';
|
||||
$string['expandall'] = 'Expand all course lists';
|
||||
$string['forcedefaultmaxcourses'] = 'Force maximum courses';
|
||||
$string['forcedefaultmaxcoursesdesc'] = 'If set then user will not be able to change his/her personal setting';
|
||||
$string['fullpath'] = 'All categories and subcategories';
|
||||
$string['hiddencoursecount'] = 'You have {$a} hidden course';
|
||||
$string['hiddencoursecountplural'] = 'You have {$a} hidden courses';
|
||||
$string['hiddencoursecountwithshowall'] = 'You have {$a->coursecount} hidden course ({$a->showalllink})';
|
||||
$string['hiddencoursecountwithshowallplural'] = 'You have {$a->coursecount} hidden courses ({$a->showalllink})';
|
||||
$string['message'] = 'message';
|
||||
$string['messages'] = 'messages';
|
||||
$string['movecourse'] = 'Move course: {$a}';
|
||||
$string['movecoursehere'] = 'Move course here';
|
||||
$string['movetofirst'] = 'Move {$a} course to top';
|
||||
$string['moveafterhere'] = 'Move {$a->movingcoursename} course after {$a->currentcoursename}';
|
||||
$string['movingcourse'] = 'You are moving: {$a->fullname} ({$a->cancellink})';
|
||||
$string['none'] = 'None';
|
||||
$string['numtodisplay'] = 'Number of courses to display: ';
|
||||
$string['onlyparentname'] = 'Parent category only';
|
||||
$string['otherexpanded'] = 'Other courses expanded';
|
||||
$string['pluginname'] = 'Course overview';
|
||||
$string['preservestates'] = 'Preserve expanded states';
|
||||
$string['shortnameprefix'] = 'Includes {$a}';
|
||||
$string['shortnamesufixsingular'] = ' (and {$a} other)';
|
||||
$string['shortnamesufixprural'] = ' (and {$a} others)';
|
||||
$string['showcategories'] = 'Categories to show';
|
||||
$string['showcategoriesdesc'] = 'Should course categories be displayed below each course?';
|
||||
$string['showchildren'] = 'Show children';
|
||||
$string['showchildrendesc'] = 'Should child courses be listed underneath the main course title?';
|
||||
$string['showwelcomearea'] = 'Show welcome area';
|
||||
$string['showwelcomeareadesc'] = 'Show the welcome area above the course list?';
|
||||
$string['view_edit_profile'] = '(View and edit your profile.)';
|
||||
$string['welcome'] = 'Welcome {$a}';
|
||||
$string['youhavemessages'] = 'You have {$a} unread ';
|
||||
$string['youhavenomessages'] = 'You have no unread ';
|
||||
@@ -1,233 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Helper functions for course_overview block
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE', '0');
|
||||
define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_ONLY_PARENT_NAME', '1');
|
||||
define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH', '2');
|
||||
|
||||
/**
|
||||
* Display overview for courses
|
||||
*
|
||||
* @param array $courses courses for which overview needs to be shown
|
||||
* @return array html overview
|
||||
*/
|
||||
function block_course_overview_get_overviews($courses) {
|
||||
$htmlarray = array();
|
||||
if ($modules = get_plugin_list_with_function('mod', 'print_overview')) {
|
||||
// Split courses list into batches with no more than MAX_MODINFO_CACHE_SIZE courses in one batch.
|
||||
// Otherwise we exceed the cache limit in get_fast_modinfo() and rebuild it too often.
|
||||
if (defined('MAX_MODINFO_CACHE_SIZE') && MAX_MODINFO_CACHE_SIZE > 0 && count($courses) > MAX_MODINFO_CACHE_SIZE) {
|
||||
$batches = array_chunk($courses, MAX_MODINFO_CACHE_SIZE, true);
|
||||
} else {
|
||||
$batches = array($courses);
|
||||
}
|
||||
foreach ($batches as $courses) {
|
||||
foreach ($modules as $fname) {
|
||||
$fname($courses, $htmlarray);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $htmlarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user preference for maximum courses to be displayed in course_overview block
|
||||
*
|
||||
* @param int $number maximum courses which should be visible
|
||||
*/
|
||||
function block_course_overview_update_mynumber($number) {
|
||||
set_user_preference('course_overview_number_of_courses', $number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user course sorting preference in course_overview block
|
||||
*
|
||||
* @param array $sortorder list of course ids
|
||||
*/
|
||||
function block_course_overview_update_myorder($sortorder) {
|
||||
$value = implode(',', $sortorder);
|
||||
if (core_text::strlen($value) > 1333) {
|
||||
// The value won't fit into the user preference. Remove courses in the end of the list (mostly likely user won't even notice).
|
||||
$value = preg_replace('/,[\d]*$/', '', core_text::substr($value, 0, 1334));
|
||||
}
|
||||
set_user_preference('course_overview_course_sortorder', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user course sorting preference in course_overview block
|
||||
*
|
||||
* @return array list of course ids
|
||||
*/
|
||||
function block_course_overview_get_myorder() {
|
||||
if ($value = get_user_preferences('course_overview_course_sortorder')) {
|
||||
return explode(',', $value);
|
||||
}
|
||||
// If preference was not found, look in the old location and convert if found.
|
||||
$order = array();
|
||||
if ($value = get_user_preferences('course_overview_course_order')) {
|
||||
$order = unserialize_array($value);
|
||||
block_course_overview_update_myorder($order);
|
||||
unset_user_preference('course_overview_course_order');
|
||||
}
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns shortname of activities in course
|
||||
*
|
||||
* @param int $courseid id of course for which activity shortname is needed
|
||||
* @return string|bool list of child shortname
|
||||
*/
|
||||
function block_course_overview_get_child_shortnames($courseid) {
|
||||
global $DB;
|
||||
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
|
||||
$sql = "SELECT c.id, c.shortname, $ctxselect
|
||||
FROM {enrol} e
|
||||
JOIN {course} c ON (c.id = e.customint1)
|
||||
JOIN {context} ctx ON (ctx.instanceid = e.customint1)
|
||||
WHERE e.courseid = :courseid AND e.enrol = :method AND ctx.contextlevel = :contextlevel ORDER BY e.sortorder";
|
||||
$params = array('method' => 'meta', 'courseid' => $courseid, 'contextlevel' => CONTEXT_COURSE);
|
||||
|
||||
if ($results = $DB->get_records_sql($sql, $params)) {
|
||||
$shortnames = array();
|
||||
// Preload the context we will need it to format the category name shortly.
|
||||
foreach ($results as $res) {
|
||||
context_helper::preload_from_record($res);
|
||||
$context = context_course::instance($res->id);
|
||||
$shortnames[] = format_string($res->shortname, true, $context);
|
||||
}
|
||||
$total = count($shortnames);
|
||||
$suffix = '';
|
||||
if ($total > 10) {
|
||||
$shortnames = array_slice($shortnames, 0, 10);
|
||||
$diff = $total - count($shortnames);
|
||||
if ($diff > 1) {
|
||||
$suffix = get_string('shortnamesufixprural', 'block_course_overview', $diff);
|
||||
} else {
|
||||
$suffix = get_string('shortnamesufixsingular', 'block_course_overview', $diff);
|
||||
}
|
||||
}
|
||||
$shortnames = get_string('shortnameprefix', 'block_course_overview', implode('; ', $shortnames));
|
||||
$shortnames .= $suffix;
|
||||
}
|
||||
|
||||
return isset($shortnames) ? $shortnames : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns maximum number of courses which will be displayed in course_overview block
|
||||
*
|
||||
* @param bool $showallcourses if set true all courses will be visible.
|
||||
* @return int maximum number of courses
|
||||
*/
|
||||
function block_course_overview_get_max_user_courses($showallcourses = false) {
|
||||
// Get block configuration
|
||||
$config = get_config('block_course_overview');
|
||||
$limit = $config->defaultmaxcourses;
|
||||
|
||||
// If max course is not set then try get user preference
|
||||
if (empty($config->forcedefaultmaxcourses)) {
|
||||
if ($showallcourses) {
|
||||
$limit = 0;
|
||||
} else {
|
||||
$limit = get_user_preferences('course_overview_number_of_courses', $limit);
|
||||
}
|
||||
}
|
||||
return $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return sorted list of user courses
|
||||
*
|
||||
* @param bool $showallcourses if set true all courses will be visible.
|
||||
* @return array list of sorted courses and count of courses.
|
||||
*/
|
||||
function block_course_overview_get_sorted_courses($showallcourses = false) {
|
||||
global $USER;
|
||||
|
||||
$limit = block_course_overview_get_max_user_courses($showallcourses);
|
||||
|
||||
$courses = enrol_get_my_courses();
|
||||
$site = get_site();
|
||||
|
||||
if (array_key_exists($site->id,$courses)) {
|
||||
unset($courses[$site->id]);
|
||||
}
|
||||
|
||||
foreach ($courses as $c) {
|
||||
if (isset($USER->lastcourseaccess[$c->id])) {
|
||||
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
|
||||
} else {
|
||||
$courses[$c->id]->lastaccess = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get remote courses.
|
||||
$remotecourses = array();
|
||||
if (is_enabled_auth('mnet')) {
|
||||
$remotecourses = get_my_remotecourses();
|
||||
}
|
||||
// Remote courses will have -ve remoteid as key, so it can be differentiated from normal courses
|
||||
foreach ($remotecourses as $id => $val) {
|
||||
$remoteid = $val->remoteid * -1;
|
||||
$val->id = $remoteid;
|
||||
$courses[$remoteid] = $val;
|
||||
}
|
||||
|
||||
$order = block_course_overview_get_myorder();
|
||||
|
||||
$sortedcourses = array();
|
||||
$counter = 0;
|
||||
// Get courses in sort order into list.
|
||||
foreach ($order as $key => $cid) {
|
||||
if (($counter >= $limit) && ($limit != 0)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure user is still enroled.
|
||||
if (isset($courses[$cid])) {
|
||||
$sortedcourses[$cid] = $courses[$cid];
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
// Append unsorted courses if limit allows
|
||||
foreach ($courses as $c) {
|
||||
if (($limit != 0) && ($counter >= $limit)) {
|
||||
break;
|
||||
}
|
||||
if (!in_array($c->id, $order)) {
|
||||
$sortedcourses[$c->id] = $c;
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// From list extract site courses for overview
|
||||
$sitecourses = array();
|
||||
foreach ($sortedcourses as $key => $course) {
|
||||
if ($course->id > 0) {
|
||||
$sitecourses[$key] = $course;
|
||||
}
|
||||
}
|
||||
return array($sortedcourses, $sitecourses, count($courses));
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
M.block_course_overview = {}
|
||||
|
||||
M.block_course_overview.add_handles = function(Y) {
|
||||
M.block_course_overview.Y = Y;
|
||||
var MOVEICON = {
|
||||
pix: "i/move_2d",
|
||||
component: 'moodle'
|
||||
};
|
||||
|
||||
YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', 'dd-plugin', function(Y) {
|
||||
//Static Vars
|
||||
var goingUp = false, lastY = 0;
|
||||
|
||||
var list = Y.Node.all('.course_list .coursebox');
|
||||
list.each(function(v, k) {
|
||||
// Replace move link and image with move_2d image.
|
||||
var imagenode = v.one('.course_title .move a img');
|
||||
imagenode.setAttribute('src', M.util.image_url(MOVEICON.pix, MOVEICON.component));
|
||||
imagenode.addClass('cursor');
|
||||
v.one('.course_title .move a').replace(imagenode);
|
||||
|
||||
var dd = new Y.DD.Drag({
|
||||
node: v,
|
||||
target: {
|
||||
padding: '0 0 0 20'
|
||||
}
|
||||
}).plug(Y.Plugin.DDProxy, {
|
||||
moveOnEnd: false
|
||||
}).plug(Y.Plugin.DDConstrained, {
|
||||
constrain2node: '.course_list'
|
||||
});
|
||||
dd.addHandle('.course_title .move');
|
||||
});
|
||||
|
||||
Y.DD.DDM.on('drag:start', function(e) {
|
||||
//Get our drag object
|
||||
var drag = e.target;
|
||||
//Set some styles here
|
||||
drag.get('node').setStyle('opacity', '.25');
|
||||
drag.get('dragNode').addClass('block_course_overview');
|
||||
drag.get('dragNode').set('innerHTML', drag.get('node').get('innerHTML'));
|
||||
drag.get('dragNode').setStyles({
|
||||
opacity: '.5',
|
||||
borderColor: drag.get('node').getStyle('borderColor'),
|
||||
backgroundColor: drag.get('node').getStyle('backgroundColor')
|
||||
});
|
||||
});
|
||||
|
||||
Y.DD.DDM.on('drag:end', function(e) {
|
||||
var drag = e.target;
|
||||
//Put our styles back
|
||||
drag.get('node').setStyles({
|
||||
visibility: '',
|
||||
opacity: '1'
|
||||
});
|
||||
M.block_course_overview.save(Y);
|
||||
});
|
||||
|
||||
Y.DD.DDM.on('drag:drag', function(e) {
|
||||
//Get the last y point
|
||||
var y = e.target.lastXY[1];
|
||||
//is it greater than the lastY var?
|
||||
if (y < lastY) {
|
||||
//We are going up
|
||||
goingUp = true;
|
||||
} else {
|
||||
//We are going down.
|
||||
goingUp = false;
|
||||
}
|
||||
//Cache for next check
|
||||
lastY = y;
|
||||
});
|
||||
|
||||
Y.DD.DDM.on('drop:over', function(e) {
|
||||
//Get a reference to our drag and drop nodes
|
||||
var drag = e.drag.get('node'),
|
||||
drop = e.drop.get('node');
|
||||
|
||||
//Are we dropping on a li node?
|
||||
if (drop.hasClass('coursebox')) {
|
||||
//Are we not going up?
|
||||
if (!goingUp) {
|
||||
drop = drop.get('nextSibling');
|
||||
}
|
||||
//Add the node to this list
|
||||
e.drop.get('node').get('parentNode').insertBefore(drag, drop);
|
||||
//Resize this nodes shim, so we can drop on it later.
|
||||
e.drop.sizeShim();
|
||||
}
|
||||
});
|
||||
|
||||
Y.DD.DDM.on('drag:drophit', function(e) {
|
||||
var drop = e.drop.get('node'),
|
||||
drag = e.drag.get('node');
|
||||
|
||||
//if we are not on an li, we must have been dropped on a ul
|
||||
if (!drop.hasClass('coursebox')) {
|
||||
if (!drop.contains(drag)) {
|
||||
drop.appendChild(drag);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
M.block_course_overview.save = function() {
|
||||
var Y = M.block_course_overview.Y;
|
||||
var sortorder = Y.one('.course_list').get('children').getAttribute('id');
|
||||
for (var i = 0; i < sortorder.length; i++) {
|
||||
sortorder[i] = sortorder[i].substring(7);
|
||||
}
|
||||
var params = {
|
||||
sesskey : M.cfg.sesskey,
|
||||
sortorder : sortorder
|
||||
};
|
||||
Y.io(M.cfg.wwwroot+'/blocks/course_overview/save.php', {
|
||||
method: 'POST',
|
||||
data: build_querystring(params),
|
||||
context: this
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Init a collapsible region, see print_collapsible_region in weblib.php
|
||||
* @param {YUI} Y YUI3 instance with all libraries loaded
|
||||
* @param {String} id the HTML id for the div.
|
||||
* @param {String} userpref the user preference that records the state of this box. false if none.
|
||||
* @param {String} strtooltip
|
||||
*/
|
||||
M.block_course_overview.collapsible = function(Y, id, userpref, strtooltip) {
|
||||
if (userpref) {
|
||||
M.block_course_overview.userpref = true;
|
||||
}
|
||||
Y.use('anim', function(Y) {
|
||||
new M.block_course_overview.CollapsibleRegion(Y, id, userpref, strtooltip);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Object to handle a collapsible region : instantiate and forget styled object
|
||||
*
|
||||
* @class
|
||||
* @constructor
|
||||
* @param {YUI} Y YUI3 instance with all libraries loaded
|
||||
* @param {String} id The HTML id for the div.
|
||||
* @param {String} userpref The user preference that records the state of this box. false if none.
|
||||
* @param {String} strtooltip
|
||||
*/
|
||||
M.block_course_overview.CollapsibleRegion = function(Y, id, userpref, strtooltip) {
|
||||
// Record the pref name
|
||||
this.userpref = userpref;
|
||||
|
||||
// Find the divs in the document.
|
||||
this.div = Y.one('#'+id);
|
||||
|
||||
// Get the caption for the collapsible region
|
||||
var caption = this.div.one('#'+id + '_caption');
|
||||
caption.setAttribute('title', strtooltip);
|
||||
|
||||
// Create a link
|
||||
var a = Y.Node.create('<a href="#"></a>');
|
||||
// Create a local scoped lamba function to move nodes to a new link
|
||||
var movenode = function(node){
|
||||
node.remove();
|
||||
a.append(node);
|
||||
};
|
||||
// Apply the lamba function on each of the captions child nodes
|
||||
caption.get('children').each(movenode, this);
|
||||
caption.prepend(a);
|
||||
|
||||
// Get the height of the div at this point before we shrink it if required
|
||||
var height = this.div.get('offsetHeight');
|
||||
if (this.div.hasClass('collapsed')) {
|
||||
// Shrink the div as it is collapsed by default
|
||||
this.div.setStyle('height', caption.get('offsetHeight')+'px');
|
||||
}
|
||||
|
||||
// Create the animation.
|
||||
var animation = new Y.Anim({
|
||||
node: this.div,
|
||||
duration: 0.3,
|
||||
easing: Y.Easing.easeBoth,
|
||||
to: {height:caption.get('offsetHeight')},
|
||||
from: {height:height}
|
||||
});
|
||||
|
||||
// Handler for the animation finishing.
|
||||
animation.on('end', function() {
|
||||
this.div.toggleClass('collapsed');
|
||||
}, this);
|
||||
|
||||
// Hook up the event handler.
|
||||
caption.on('click', function(e, animation) {
|
||||
e.preventDefault();
|
||||
// Animate to the appropriate size.
|
||||
if (animation.get('running')) {
|
||||
animation.stop();
|
||||
}
|
||||
animation.set('reverse', this.div.hasClass('collapsed'));
|
||||
// Update the user preference.
|
||||
if (this.userpref) {
|
||||
M.util.set_user_preference(this.userpref, !this.div.hasClass('collapsed'));
|
||||
}
|
||||
animation.run();
|
||||
}, this, animation);
|
||||
};
|
||||
|
||||
M.block_course_overview.userpref = false;
|
||||
|
||||
/**
|
||||
* The user preference that stores the state of this box.
|
||||
* @property userpref
|
||||
* @type String
|
||||
*/
|
||||
M.block_course_overview.CollapsibleRegion.prototype.userpref = null;
|
||||
|
||||
/**
|
||||
* The key divs that make up this
|
||||
* @property div
|
||||
* @type Y.Node
|
||||
*/
|
||||
M.block_course_overview.CollapsibleRegion.prototype.div = null;
|
||||
|
||||
/**
|
||||
* The key divs that make up this
|
||||
* @property icon
|
||||
* @type Y.Node
|
||||
*/
|
||||
M.block_course_overview.CollapsibleRegion.prototype.icon = null;
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Move/order course functionality for course_overview block.
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once(__DIR__ . '/locallib.php');
|
||||
|
||||
require_sesskey();
|
||||
require_login();
|
||||
|
||||
$coursetomove = required_param('courseid', PARAM_INT);
|
||||
$moveto = required_param('moveto', PARAM_INT);
|
||||
|
||||
list($courses, $sitecourses, $coursecount) = block_course_overview_get_sorted_courses();
|
||||
$sortedcourses = array_keys($courses);
|
||||
|
||||
$currentcourseindex = array_search($coursetomove, $sortedcourses);
|
||||
// If coursetomove is not found or moveto < 0 or > count($sortedcourses) then throw error.
|
||||
if ($currentcourseindex === false) {
|
||||
print_error("invalidcourseid", null, null, $coursetomove);
|
||||
} else if (($moveto < 0) || ($moveto >= count($sortedcourses))) {
|
||||
print_error("invalidaction");
|
||||
}
|
||||
|
||||
// If current course index is same as destination index then don't do anything.
|
||||
if ($currentcourseindex === $moveto) {
|
||||
redirect(new moodle_url('/my/index.php'));
|
||||
}
|
||||
|
||||
// Create neworder list for courses.
|
||||
$neworder = array();
|
||||
|
||||
unset($sortedcourses[$currentcourseindex]);
|
||||
$neworder = array_slice($sortedcourses, 0, $moveto, true);
|
||||
$neworder[] = $coursetomove;
|
||||
$remaningcourses = array_slice($sortedcourses, $moveto);
|
||||
foreach ($remaningcourses as $courseid) {
|
||||
$neworder[] = $courseid;
|
||||
}
|
||||
block_course_overview_update_myorder(array_values($neworder));
|
||||
redirect(new moodle_url('/my/index.php'));
|
||||
@@ -1,348 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* course_overview block rendrer
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Course_overview block rendrer
|
||||
*
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class block_course_overview_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Construct contents of course_overview block
|
||||
*
|
||||
* @param array $courses list of courses in sorted order
|
||||
* @param array $overviews list of course overviews
|
||||
* @return string html to be displayed in course_overview block
|
||||
*/
|
||||
public function course_overview($courses, $overviews) {
|
||||
$html = '';
|
||||
$config = get_config('block_course_overview');
|
||||
if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/coursecatlib.php');
|
||||
}
|
||||
$ismovingcourse = false;
|
||||
$courseordernumber = 0;
|
||||
$maxcourses = count($courses);
|
||||
$userediting = false;
|
||||
// Intialise string/icon etc if user is editing and courses > 1
|
||||
if ($this->page->user_is_editing() && (count($courses) > 1)) {
|
||||
$userediting = true;
|
||||
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
|
||||
|
||||
// Check if course is moving
|
||||
$ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
|
||||
$movingcourseid = optional_param('courseid', 0, PARAM_INT);
|
||||
}
|
||||
|
||||
// Render first movehere icon.
|
||||
if ($ismovingcourse) {
|
||||
// Remove movecourse param from url.
|
||||
$this->page->ensure_param_not_in_url('movecourse');
|
||||
|
||||
// Show moving course notice, so user knows what is being moved.
|
||||
$html .= $this->output->box_start('notice');
|
||||
$a = new stdClass();
|
||||
$a->fullname = $courses[$movingcourseid]->fullname;
|
||||
$a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
|
||||
$html .= get_string('movingcourse', 'block_course_overview', $a);
|
||||
$html .= $this->output->box_end();
|
||||
|
||||
$moveurl = new moodle_url('/blocks/course_overview/move.php',
|
||||
array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
|
||||
// Create move icon, so it can be used.
|
||||
$name = $courses[$movingcourseid]->fullname;
|
||||
$movetofirsticon = $this->output->pix_icon('movehere', get_string('movetofirst', 'block_course_overview', $name));
|
||||
$moveurl = html_writer::link($moveurl, $movetofirsticon);
|
||||
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
|
||||
}
|
||||
|
||||
foreach ($courses as $key => $course) {
|
||||
// If moving course, then don't show course which needs to be moved.
|
||||
if ($ismovingcourse && ($course->id == $movingcourseid)) {
|
||||
continue;
|
||||
}
|
||||
$html .= $this->output->box_start('coursebox', "course-{$course->id}");
|
||||
$html .= html_writer::start_tag('div', array('class' => 'course_title'));
|
||||
// If user is editing, then add move icons.
|
||||
if ($userediting && !$ismovingcourse) {
|
||||
$moveicon = $this->output->pix_icon('t/move', get_string('movecourse', 'block_course_overview', $course->fullname));
|
||||
$moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
|
||||
$moveurl = html_writer::link($moveurl, $moveicon);
|
||||
$html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
|
||||
|
||||
}
|
||||
|
||||
// No need to pass title through s() here as it will be done automatically by html_writer.
|
||||
$attributes = array('title' => $course->fullname);
|
||||
if ($course->id > 0) {
|
||||
if (empty($course->visible)) {
|
||||
$attributes['class'] = 'dimmed';
|
||||
}
|
||||
$courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
$coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
|
||||
$link = html_writer::link($courseurl, $coursefullname, $attributes);
|
||||
$html .= $this->output->heading($link, 2, 'title');
|
||||
} else {
|
||||
$html .= $this->output->heading(html_writer::link(
|
||||
new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id='.$course->remoteid)),
|
||||
format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
|
||||
}
|
||||
$html .= $this->output->container('', 'flush');
|
||||
$html .= html_writer::end_tag('div');
|
||||
|
||||
if (!empty($config->showchildren) && ($course->id > 0)) {
|
||||
// List children here.
|
||||
if ($children = block_course_overview_get_child_shortnames($course->id)) {
|
||||
$html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
|
||||
}
|
||||
}
|
||||
|
||||
// If user is moving courses, then down't show overview.
|
||||
if (isset($overviews[$course->id]) && !$ismovingcourse) {
|
||||
$html .= $this->activity_display($course->id, $overviews[$course->id]);
|
||||
}
|
||||
|
||||
if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) {
|
||||
// List category parent or categories path here.
|
||||
$currentcategory = coursecat::get($course->category, IGNORE_MISSING);
|
||||
if ($currentcategory !== null) {
|
||||
$html .= html_writer::start_tag('div', array('class' => 'categorypath'));
|
||||
if ($config->showcategories == BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH) {
|
||||
foreach ($currentcategory->get_parents() as $categoryid) {
|
||||
$category = coursecat::get($categoryid, IGNORE_MISSING);
|
||||
if ($category !== null) {
|
||||
$html .= $category->get_formatted_name().' / ';
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= $currentcategory->get_formatted_name();
|
||||
$html .= html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
|
||||
$html .= $this->output->container('', 'flush');
|
||||
$html .= $this->output->box_end();
|
||||
$courseordernumber++;
|
||||
if ($ismovingcourse) {
|
||||
$moveurl = new moodle_url('/blocks/course_overview/move.php',
|
||||
array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid));
|
||||
$a = new stdClass();
|
||||
$a->movingcoursename = $courses[$movingcourseid]->fullname;
|
||||
$a->currentcoursename = $course->fullname;
|
||||
$movehereicon = $this->output->pix_icon('movehere', get_string('moveafterhere', 'block_course_overview', $a));
|
||||
$moveurl = html_writer::link($moveurl, $movehereicon);
|
||||
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
|
||||
}
|
||||
}
|
||||
// Wrap course list in a div and return.
|
||||
return html_writer::tag('div', $html, array('class' => 'course_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Coustuct activities overview for a course
|
||||
*
|
||||
* @param int $cid course id
|
||||
* @param array $overview overview of activities in course
|
||||
* @return string html of activities overview
|
||||
*/
|
||||
protected function activity_display($cid, $overview) {
|
||||
$output = html_writer::start_tag('div', array('class' => 'activity_info'));
|
||||
foreach (array_keys($overview) as $module) {
|
||||
$output .= html_writer::start_tag('div', array('class' => 'activity_overview'));
|
||||
$url = new moodle_url("/mod/$module/index.php", array('id' => $cid));
|
||||
$modulename = get_string('modulename', $module);
|
||||
$icontext = html_writer::link($url, $this->output->image_icon('icon', $modulename, 'mod_'.$module, array('class'=>'iconlarge')));
|
||||
if (get_string_manager()->string_exists("activityoverview", $module)) {
|
||||
$icontext .= get_string("activityoverview", $module);
|
||||
} else {
|
||||
$icontext .= get_string("activityoverview", 'block_course_overview', $modulename);
|
||||
}
|
||||
|
||||
// Add collapsible region with overview text in it.
|
||||
$output .= $this->collapsible_region($overview[$module], '', 'region_'.$cid.'_'.$module, $icontext, '', true);
|
||||
|
||||
$output .= html_writer::end_tag('div');
|
||||
}
|
||||
$output .= html_writer::end_tag('div');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs header in editing mode
|
||||
*
|
||||
* @param int $max maximum number of courses
|
||||
* @return string html of header bar.
|
||||
*/
|
||||
public function editing_bar_head($max = 0) {
|
||||
$output = $this->output->box_start('notice');
|
||||
|
||||
$options = array('0' => get_string('alwaysshowall', 'block_course_overview'));
|
||||
for ($i = 1; $i <= $max; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$url = new moodle_url('/my/index.php');
|
||||
$select = new single_select($url, 'mynumber', $options, block_course_overview_get_max_user_courses(), array());
|
||||
$select->set_label(get_string('numtodisplay', 'block_course_overview'));
|
||||
$output .= $this->output->render($select);
|
||||
|
||||
$output .= $this->output->box_end();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show hidden courses count
|
||||
*
|
||||
* @param int $total count of hidden courses
|
||||
* @return string html
|
||||
*/
|
||||
public function hidden_courses($total) {
|
||||
if ($total <= 0) {
|
||||
return;
|
||||
}
|
||||
$output = $this->output->box_start('notice');
|
||||
$plural = $total > 1 ? 'plural' : '';
|
||||
$config = get_config('block_course_overview');
|
||||
// Show view all course link to user if forcedefaultmaxcourses is not empty.
|
||||
if (!empty($config->forcedefaultmaxcourses)) {
|
||||
$output .= get_string('hiddencoursecount'.$plural, 'block_course_overview', $total);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->coursecount = $total;
|
||||
$a->showalllink = html_writer::link(new moodle_url('/my/index.php', array('mynumber' => block_course_overview::SHOW_ALL_COURSES)),
|
||||
get_string('showallcourses'));
|
||||
$output .= get_string('hiddencoursecountwithshowall'.$plural, 'block_course_overview', $a);
|
||||
}
|
||||
|
||||
$output .= $this->output->box_end();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates collapsable region
|
||||
*
|
||||
* @param string $contents existing contents
|
||||
* @param string $classes class names added to the div that is output.
|
||||
* @param string $id id added to the div that is output. Must not be blank.
|
||||
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
||||
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
||||
* (May be blank if you do not wish the state to be persisted.
|
||||
* @param bool $default Initial collapsed state to use if the user_preference it not set.
|
||||
* @return bool if true, return the HTML as a string, rather than printing it.
|
||||
*/
|
||||
protected function collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false) {
|
||||
$output = $this->collapsible_region_start($classes, $id, $caption, $userpref, $default);
|
||||
$output .= $contents;
|
||||
$output .= $this->collapsible_region_end();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print (or return) the start of a collapsible region, that has a caption that can
|
||||
* be clicked to expand or collapse the region. If JavaScript is off, then the region
|
||||
* will always be expanded.
|
||||
*
|
||||
* @param string $classes class names added to the div that is output.
|
||||
* @param string $id id added to the div that is output. Must not be blank.
|
||||
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
||||
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
||||
* (May be blank if you do not wish the state to be persisted.
|
||||
* @param bool $default Initial collapsed state to use if the user_preference it not set.
|
||||
* @return bool if true, return the HTML as a string, rather than printing it.
|
||||
*/
|
||||
protected function collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false) {
|
||||
// Work out the initial state.
|
||||
if (!empty($userpref) and is_string($userpref)) {
|
||||
user_preference_allow_ajax_update($userpref, PARAM_BOOL);
|
||||
$collapsed = get_user_preferences($userpref, $default);
|
||||
} else {
|
||||
$collapsed = $default;
|
||||
$userpref = false;
|
||||
}
|
||||
|
||||
if ($collapsed) {
|
||||
$classes .= ' collapsed';
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$output .= '<div id="' . $id . '" class="collapsibleregion ' . $classes . '">';
|
||||
$output .= '<div id="' . $id . '_sizer">';
|
||||
$output .= '<div id="' . $id . '_caption" class="collapsibleregioncaption">';
|
||||
$output .= $caption . ' ';
|
||||
$output .= '</div><div id="' . $id . '_inner" class="collapsibleregioninner">';
|
||||
$this->page->requires->js_init_call('M.block_course_overview.collapsible', array($id, $userpref, get_string('clicktohideshow')));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a region started with print_collapsible_region_start.
|
||||
*
|
||||
* @return string return the HTML as a string, rather than printing it.
|
||||
*/
|
||||
protected function collapsible_region_end() {
|
||||
$output = '</div></div></div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cretes html for welcome area
|
||||
*
|
||||
* @param int $msgcount number of messages
|
||||
* @return string html string for welcome area.
|
||||
*/
|
||||
public function welcome_area($msgcount) {
|
||||
global $CFG, $USER;
|
||||
$output = $this->output->box_start('welcome_area');
|
||||
|
||||
$picture = $this->output->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture'));
|
||||
$output .= html_writer::tag('div', $picture, array('class' => 'profilepicture'));
|
||||
|
||||
$output .= $this->output->box_start('welcome_message');
|
||||
$output .= $this->output->heading(get_string('welcome', 'block_course_overview', $USER->firstname));
|
||||
|
||||
if (!empty($CFG->messaging)) {
|
||||
$plural = 's';
|
||||
if ($msgcount > 0) {
|
||||
$output .= get_string('youhavemessages', 'block_course_overview', $msgcount);
|
||||
if ($msgcount == 1) {
|
||||
$plural = '';
|
||||
}
|
||||
} else {
|
||||
$output .= get_string('youhavenomessages', 'block_course_overview');
|
||||
}
|
||||
$output .= html_writer::link(new moodle_url('/message/index.php'),
|
||||
get_string('message'.$plural, 'block_course_overview'));
|
||||
}
|
||||
$output .= $this->output->box_end();
|
||||
$output .= $this->output->container('', 'flush');
|
||||
$output .= $this->output->box_end();
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* course_overview block settings
|
||||
*
|
||||
* @package block_course_overview
|
||||
* @copyright 2012 Adam Olley <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configtext('block_course_overview/defaultmaxcourses', new lang_string('defaultmaxcourses', 'block_course_overview'),
|
||||
new lang_string('defaultmaxcoursesdesc', 'block_course_overview'), 10, PARAM_INT));
|
||||
$settings->add(new admin_setting_configcheckbox('block_course_overview/forcedefaultmaxcourses', new lang_string('forcedefaultmaxcourses', 'block_course_overview'),
|
||||
new lang_string('forcedefaultmaxcoursesdesc', 'block_course_overview'), 1, PARAM_INT));
|
||||
$settings->add(new admin_setting_configcheckbox('block_course_overview/showchildren', new lang_string('showchildren', 'block_course_overview'),
|
||||
new lang_string('showchildrendesc', 'block_course_overview'), 1, PARAM_INT));
|
||||
$settings->add(new admin_setting_configcheckbox('block_course_overview/showwelcomearea', new lang_string('showwelcomearea', 'block_course_overview'),
|
||||
new lang_string('showwelcomeareadesc', 'block_course_overview'), 1, PARAM_INT));
|
||||
$showcategories = array(
|
||||
BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE => new lang_string('none', 'block_course_overview'),
|
||||
BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_ONLY_PARENT_NAME => new lang_string('onlyparentname', 'block_course_overview'),
|
||||
BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH => new lang_string('fullpath', 'block_course_overview')
|
||||
);
|
||||
$settings->add(new admin_setting_configselect('block_course_overview/showcategories', new lang_string('showcategories', 'block_course_overview'),
|
||||
new lang_string('showcategoriesdesc', 'block_course_overview'), BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE, $showcategories));
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
.block_course_overview .coursechildren {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.block_course_overview .categorypath {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.block_course_overview .content {
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
.block_course_overview .content .notice {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.block_course_overview .coursebox {
|
||||
padding: 15px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.block_course_overview .profilepicture {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.block_course_overview .welcome_area {
|
||||
width: 100%;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.block_course_overview .welcome_message {
|
||||
float: left;
|
||||
padding: 10px;
|
||||
border-collapse: separate;
|
||||
clear: none;
|
||||
}
|
||||
|
||||
.block_course_overview .content h2.title {
|
||||
float: left;
|
||||
margin: 0 0 .5em 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.block_course_overview .course_title {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.editing .block_course_overview .coursebox .cursor {
|
||||
cursor: move;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.editing .block_course_overview .move {
|
||||
float: left;
|
||||
padding: 2px 10px 0 0;
|
||||
}
|
||||
|
||||
.block_course_overview .course_list {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.block_course_overview div.flush {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.block_course_overview .activity_info {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.block_course_overview .activity_overview {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.block_course_overview .activity_overview img.iconlarge {
|
||||
vertical-align: text-bottom;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.block_course_overview .singleselect {
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.block_course_overview .content .course_list .movehere {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
@block @block_course_overview
|
||||
Feature: View the course overview block on the dashboard and test it's functionality
|
||||
In order to view the course overview block on the dashboard
|
||||
As an admin
|
||||
I can configure the course overview block
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email | idnumber |
|
||||
| student1 | Student | 1 | student1@example.com | S1 |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
|
||||
And the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| Category 1 | 0 | CAT1 |
|
||||
| Category 2 | CAT1 | CAT2 |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
| Course 2 | C2 | CAT1 |
|
||||
| Course 3 | C3 | CAT2 |
|
||||
|
||||
Scenario: View the block by a user without any enrolments
|
||||
Given I log in as "student1"
|
||||
Then I should see "No course information to show" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with several enrolments
|
||||
Given the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
When I log in as "student1"
|
||||
Then I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "Course 2" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with several enrolments and limit the number of courses.
|
||||
Given the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
| student1 | C3 | student |
|
||||
When I log in as "student1"
|
||||
And I press "Customise this page"
|
||||
And I select "1" from the "Number of courses to display:" singleselect
|
||||
Then I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "You have 2 hidden courses"
|
||||
And I should not see "Course 2" in the "Course overview" "block"
|
||||
And I should not see "Course 3" in the "Course overview" "block"
|
||||
And I follow "Show all courses"
|
||||
And I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "Course 2" in the "Course overview" "block"
|
||||
And I should see "Course 3" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with several enrolments and an admin set default max courses.
|
||||
Given the following config values are set as admin:
|
||||
| defaultmaxcourses | 2 | block_course_overview |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
| student1 | C3 | student |
|
||||
When I log in as "student1"
|
||||
Then I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "Course 2" in the "Course overview" "block"
|
||||
And I should see "You have 1 hidden course"
|
||||
And I press "Customise this page"
|
||||
And I select "Always show all" from the "Number of courses to display:" singleselect
|
||||
And I should see "Course 3" in the "Course overview" "block"
|
||||
And I should not see "You have 1 hidden course"
|
||||
|
||||
Scenario: View the block by a user with several enrolments and an admin enforced maximum displayed courses.
|
||||
Given the following config values are set as admin:
|
||||
| defaultmaxcourses | 2 | block_course_overview |
|
||||
| forcedefaultmaxcourses | 1 | block_course_overview |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
| student1 | C3 | student |
|
||||
When I log in as "student1"
|
||||
Then I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "Course 2" in the "Course overview" "block"
|
||||
And I should see "You have 1 hidden course"
|
||||
And I press "Customise this page"
|
||||
And I should not see "Always show all"
|
||||
|
||||
Scenario: View the block by a user with the welcome area enabled and messaging disabled.
|
||||
Given the following config values are set as admin:
|
||||
| showwelcomearea | 1 | block_course_overview |
|
||||
| messaging | 0 | |
|
||||
When I log in as "student1"
|
||||
Then I should see "Welcome Student" in the "Course overview" "block"
|
||||
And I should not see "messages" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with both the welcome area and messaging enabled.
|
||||
Given the following config values are set as admin:
|
||||
| showwelcomearea | 1 | block_course_overview |
|
||||
When I log in as "student1"
|
||||
Then I should see "Welcome Student" in the "Course overview" "block"
|
||||
And I should see "You have no unread messages" in the "Course overview" "block"
|
||||
And I follow "messages"
|
||||
And I should see "No messages"
|
||||
|
||||
@javascript
|
||||
Scenario: View the block by a user with the welcome area and the user having messages.
|
||||
Given the following config values are set as admin:
|
||||
| showwelcomearea | 1 | block_course_overview |
|
||||
And I log in as "student1"
|
||||
And I should see "Welcome Student" in the "Course overview" "block"
|
||||
And I should see "You have no unread messages" in the "Course overview" "block"
|
||||
And I follow "messages"
|
||||
And I send "This is message 1" message to "Teacher 1" user
|
||||
And I send "This is message 2" message to "Teacher 1" user
|
||||
When I log out
|
||||
And I log in as "teacher1"
|
||||
Then I should see "Welcome Teacher" in the "Course overview" "block"
|
||||
And I should see "You have 2 unread messages" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with the parent categories displayed.
|
||||
Given the following config values are set as admin:
|
||||
| showcategories | Parent category only | block_course_overview |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
| student1 | C3 | student |
|
||||
When I log in as "student1"
|
||||
Then I should see "Miscellaneous" in the "Course overview" "block"
|
||||
And I should see "Category 1" in the "Course overview" "block"
|
||||
And I should see "Category 2" in the "Course overview" "block"
|
||||
And I should not see "Category 1 / Category 1" in the "Course overview" "block"
|
||||
|
||||
Scenario: View the block by a user with the full categories displayed.
|
||||
Given the following config values are set as admin:
|
||||
| showcategories | 2 | block_course_overview |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student1 | C2 | student |
|
||||
| student1 | C3 | student |
|
||||
When I log in as "student1"
|
||||
Then I should see "Miscellaneous" in the "Course overview" "block"
|
||||
And I should see "Category 1 / Category 2" in the "Course overview" "block"
|
||||
|
||||
@javascript
|
||||
Scenario: View the block by a user with the show children option enabled.
|
||||
Given the following config values are set as admin:
|
||||
| showchildren | 1 | block_course_overview |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Manage enrol plugins" node in "Site administration > Plugins > Enrolments"
|
||||
And I click on "Enable" "link" in the "Course meta link" "table_row"
|
||||
And I am on site homepage
|
||||
And I follow "Course 2"
|
||||
And I add "Course meta link" enrolment method with:
|
||||
| Link course | C1 |
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
Then I should see "Course 1" in the "Course overview" "block"
|
||||
And I should see "Course 2" in the "Course overview" "block"
|
||||
And I should see "Includes C1" in the "Course overview" "block"
|
||||
@@ -1,93 +0,0 @@
|
||||
@block @block_course_overview @mod_quiz
|
||||
Feature: View the quiz being due
|
||||
In order to know what quizzes are due
|
||||
As a student
|
||||
I can visit my dashboard
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 2 | student2@example.com |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
| Course 2 | C2 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C2 | student |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher1 | C2 | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | name | timeclose |
|
||||
| quiz | C1 | Q1A | Quiz 1A No deadline | 0 |
|
||||
| quiz | C1 | Q1B | Quiz 1B Past deadline | 1337 |
|
||||
| quiz | C1 | Q1C | Quiz 1C Future deadline | 9000000000 |
|
||||
| quiz | C1 | Q1D | Quiz 1D Future deadline | 9000000000 |
|
||||
| quiz | C1 | Q1E | Quiz 1E Future deadline | 9000000000 |
|
||||
| quiz | C2 | Q2A | Quiz 2A Future deadline | 9000000000 |
|
||||
And the following "question categories" exist:
|
||||
| contextlevel | reference | name |
|
||||
| Course | C1 | Test questions |
|
||||
And the following "questions" exist:
|
||||
| qtype | name | questiontext | questioncategory |
|
||||
| truefalse | First question | Answer the first question | Test questions |
|
||||
And quiz "Quiz 1A No deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
And quiz "Quiz 1B Past deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
And quiz "Quiz 1C Future deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
And quiz "Quiz 1D Future deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
And quiz "Quiz 1E Future deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
And quiz "Quiz 2A Future deadline" contains the following questions:
|
||||
| question | page |
|
||||
| First question | 1 |
|
||||
|
||||
Scenario: View my quizzes that are due
|
||||
Given I log in as "student1"
|
||||
When I am on homepage
|
||||
Then I should see "You have quizzes that are due" in the "Course overview" "block"
|
||||
And I should see "Quiz 1C Future deadline" in the "Course overview" "block"
|
||||
And I should see "Quiz 1D Future deadline" in the "Course overview" "block"
|
||||
And I should see "Quiz 1E Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1A No deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1B Past deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 2A Future deadline" in the "Course overview" "block"
|
||||
And I log out
|
||||
And I log in as "student2"
|
||||
And I should see "You have quizzes that are due" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1C Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1D Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1E Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1A No deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1B Past deadline" in the "Course overview" "block"
|
||||
And I should see "Quiz 2A Future deadline" in the "Course overview" "block"
|
||||
|
||||
Scenario: View my quizzes that are due and never finished
|
||||
Given I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Quiz 1D Future deadline"
|
||||
And I press "Attempt quiz now"
|
||||
And I follow "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I follow "Course 1"
|
||||
And I follow "Quiz 1E Future deadline"
|
||||
And I press "Attempt quiz now"
|
||||
When I am on homepage
|
||||
Then I should see "You have quizzes that are due" in the "Course overview" "block"
|
||||
And I should see "Quiz 1C Future deadline" in the "Course overview" "block"
|
||||
And I should see "Quiz 1E Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1A No deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1B Past deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 1D Future deadline" in the "Course overview" "block"
|
||||
And I should not see "Quiz 2A Future deadline" in the "Course overview" "block"
|
||||
@@ -17,21 +17,20 @@ Feature: Course summary block used in a course
|
||||
| student1 | C101 | student |
|
||||
| teacher1 | C101 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Course/site summary" block
|
||||
And I log out
|
||||
|
||||
Scenario: Student can view course summary
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then "Course summary" "block" should exist
|
||||
And I should see "Course summary" in the "Course summary" "block"
|
||||
And I should see "Proved the course summary block works!" in the "Course summary" "block"
|
||||
|
||||
Scenario: Teacher can not see edit icon when edit mode is off
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Proved the course summary block works!" in the "Course summary" "block"
|
||||
And I should see "Course summary" in the "Course summary" "block"
|
||||
And "Edit" "link" should not exist in the "Course summary" "block"
|
||||
|
||||
@@ -19,13 +19,12 @@ Feature: Random glossary entry block is used in a course
|
||||
|
||||
Scenario: Student can not see the block if it is not configured
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
Then I should see "Please configure this block using the edit icon" in the "block_glossary_random" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And "block_glossary_random" "block" should not exist
|
||||
And I log out
|
||||
|
||||
@@ -34,8 +33,7 @@ Feature: Random glossary entry block is used in a course
|
||||
| activity | name | intro | course | idnumber | defaultapproval |
|
||||
| glossary | GlossaryAuto | Test glossary description | C1 | glossary1 | 1 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I configure the "block_glossary_random" block
|
||||
And I set the following fields to these values:
|
||||
@@ -45,14 +43,14 @@ Feature: Random glossary entry block is used in a course
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "There are no entries yet in the chosen glossary" in the "AutoGlossaryblock" "block"
|
||||
And I click on "Add a new entry" "link" in the "AutoGlossaryblock" "block"
|
||||
And I set the following fields to these values:
|
||||
| Concept | Concept1 |
|
||||
| Definition | Definition1 |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Concept1" in the "AutoGlossaryblock" "block"
|
||||
And I should see "Definition1" in the "AutoGlossaryblock" "block"
|
||||
And I should not see "There are no entries yet in the chosen glossary" in the "AutoGlossaryblock" "block"
|
||||
@@ -61,7 +59,7 @@ Feature: Random glossary entry block is used in a course
|
||||
| Concept | Concept2 |
|
||||
| Definition | Definition2 |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
# Only the last entry appears in the block
|
||||
And I should not see "Concept1" in the "AutoGlossaryblock" "block"
|
||||
And I should not see "Definition1" in the "AutoGlossaryblock" "block"
|
||||
@@ -78,8 +76,7 @@ Feature: Random glossary entry block is used in a course
|
||||
| activity | name | intro | course | idnumber | defaultapproval |
|
||||
| glossary | GlossaryManual | Test glossary description | C1 | glossary2 | 0 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I configure the "block_glossary_random" block
|
||||
And I set the following fields to these values:
|
||||
@@ -89,18 +86,18 @@ Feature: Random glossary entry block is used in a course
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block"
|
||||
And I click on "Add a new entry" "link" in the "ManualGlossaryblock" "block"
|
||||
And I set the following fields to these values:
|
||||
| Concept | Concept1 |
|
||||
| Definition | Definition1 |
|
||||
And I press "Save changes"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block"
|
||||
And I follow "GlossaryManual"
|
||||
And I follow "Waiting approval"
|
||||
|
||||
@@ -23,8 +23,7 @@ Feature: Random glossary entry block linking to global glossary
|
||||
|
||||
Scenario: View random (last) entry in the global glossary
|
||||
When I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 2"
|
||||
And I am on "Course 2" course homepage
|
||||
And I follow "Tips and Tricks"
|
||||
And I press "Add a new entry"
|
||||
And I set the following fields to these values:
|
||||
@@ -34,8 +33,7 @@ Feature: Random glossary entry block linking to global glossary
|
||||
And I log out
|
||||
# As a teacher add a block to the course page linking to the global glossary.
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I configure the "block_glossary_random" block
|
||||
And I set the following fields to these values:
|
||||
@@ -49,7 +47,7 @@ Feature: Random glossary entry block linking to global glossary
|
||||
And I log out
|
||||
# Student who can't see the module is still able to view entries in this block (because the glossary was marked as global)
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Never come late" in the "Tip of the day" "block"
|
||||
And I should not see "Add a new entry" in the "Tip of the day" "block"
|
||||
And I should see "View all entries" in the "Tip of the day" "block"
|
||||
@@ -57,8 +55,7 @@ Feature: Random glossary entry block linking to global glossary
|
||||
|
||||
Scenario: Removing the global glossary that is used in random glossary block
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I configure the "block_glossary_random" block
|
||||
And I set the following fields to these values:
|
||||
@@ -68,17 +65,15 @@ Feature: Random glossary entry block linking to global glossary
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I follow "Course 2"
|
||||
And I am on "Course 2" course homepage
|
||||
And I follow "Tips and Tricks"
|
||||
And I follow "Edit settings"
|
||||
And I set the field "globalglossary" to "0"
|
||||
And I press "Save and return to course"
|
||||
And I am on site homepage
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Please configure this block using the edit icon." in the "Tip of the day" "block"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Tip of the day" "block" should not exist
|
||||
And I log out
|
||||
|
||||
@@ -17,8 +17,7 @@ Feature: HTML blocks in a course
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
When I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "HTML" block
|
||||
And I configure the "(new HTML block)" block
|
||||
And I set the field "Content" to "First block content"
|
||||
@@ -31,6 +30,6 @@ Feature: HTML blocks in a course
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "First block content" in the "First block header" "block"
|
||||
And I should see "Second block content" in the "Second block header" "block"
|
||||
@@ -21,15 +21,13 @@ Feature: The messages block allows users to list new messages an a course
|
||||
Given the following config values are set as admin:
|
||||
| messaging | 0 |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Messages" block
|
||||
Then I should see "Messaging is disabled on this site" in the "Messages" "block"
|
||||
|
||||
Scenario: View the block by a user who does not have any messages.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Messages" block
|
||||
Then I should see "No messages" in the "Messages" "block"
|
||||
|
||||
@@ -41,20 +39,18 @@ Feature: The messages block allows users to list new messages an a course
|
||||
And I send "This is message 2" message to "Teacher 1" user
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Messages" block
|
||||
Then I should see "Student 1" in the "Messages" "block"
|
||||
|
||||
@javascript
|
||||
Scenario: Use the block to send a message to a user.
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Messages" block
|
||||
And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
|
||||
And I send "This is message 1" message to "Student 1" user
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Teacher 1" in the "Messages" "block"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
define(["jquery","core/ajax","core/notification"],function(a,b,c){var d=20,e=function(a){a.hasOwnProperty("limit")||(a.limit=d),a.limitnum=a.limit,delete a.limit,a.hasOwnProperty("starttime")&&(a.timesortfrom=a.starttime,delete a.starttime),a.hasOwnProperty("endtime")&&(a.timesortto=a.endtime,delete a.endtime);var e={methodname:"core_calendar_get_action_events_by_course",args:a},f=b.call([e])[0];return f.fail(c.exception),f},f=function(a){a.hasOwnProperty("limit")||(a.limit=10),a.limitnum=a.limit,delete a.limit,a.hasOwnProperty("starttime")&&(a.timesortfrom=a.starttime,delete a.starttime),a.hasOwnProperty("endtime")&&(a.timesortto=a.endtime,delete a.endtime);var d={methodname:"core_calendar_get_action_events_by_courses",args:a},e=b.call([d])[0];return e.fail(c.exception),e},g=function(a){a.hasOwnProperty("limit")||(a.limit=d),a.limitnum=a.limit,delete a.limit,a.hasOwnProperty("starttime")&&(a.timesortfrom=a.starttime,delete a.starttime),a.hasOwnProperty("endtime")&&(a.timesortto=a.endtime,delete a.endtime);var e={methodname:"core_calendar_get_action_events_by_timesort",args:a},f=b.call([e])[0];return f.fail(c.exception),f};return{queryByTime:g,queryByCourse:e,queryByCourses:f}});
|
||||
@@ -0,0 +1 @@
|
||||
define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b){var c=Math.floor((new Date).setHours(0,0,0,0)/1e3),d=+b.attr("data-start-day")*f,e=+b.attr("data-end-day")*f,g=s(c,a);return""===b.attr("data-end-day")?d<=g:d<=g&&g<e},u=function(b){return function(c){return t(c,a(b))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(b){var f=c.filter(u(b));return f.length?(d+=f.length,r(a(b),f,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var f,g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=new Date;if(n.setDate(n.getDate()-14),n.setHours(0,0,0,0),f=Math.floor(n/1e3),m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var o={starttime:f,limit:g};j&&(o.aftereventid=j),h?(o.courseid=h,d=e.queryByCourse(o)):d=e.queryByTime(o)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<g)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});
|
||||
@@ -0,0 +1 @@
|
||||
define(["jquery","block_myoverview/event_list","block_myoverview/calendar_events_repository"],function(a,b,c){var d={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]'},e=function(e){var f=e.find(d.EVENTS_BY_COURSE_CONTAINER);if(f.length){var g=new Date;g.setDate(g.getDate()-14),g.setHours(0,0,0,0);var h=Math.floor(g/1e3),i=f.attr("data-limit"),j=f.map(function(){return a(this).attr("data-course-id")}).get(),k=c.queryByCourses({courseids:j,starttime:h,limit:i});f.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();k.done(function(a){var b=[],c=a.groupedbycourse.filter(function(a){return a.courseid==e});c.length&&(b=c[0].events),g.resolve({events:b})}).fail(function(a){g.reject(a)}),b.load(f,g)})}};return{init:function(b){b=a(b),e(b)}}});
|
||||
@@ -0,0 +1 @@
|
||||
define(["jquery","core/custom_interaction_events"],function(a,b){var c={ROOT:'[data-region="paging-bar"]',PAGE_ITEM:'[data-region="page-item"]',ACTIVE_PAGE_ITEM:'[data-region="page-item"].active'},d={PAGE_SELECTED:"block_myoverview-paging-bar-page-selected"},e=function(a,b){return a.find(c.PAGE_ITEM+'[data-page-number="'+b+'"]')},f=function(a,b){var c=b.attr("data-page-number");return"first"==c?c=1:"last"==c&&(c=a.attr("data-page-count")),c},g=function(g){g=a(g),b.define(g,[b.events.activate]),g.on(b.events.activate,c.PAGE_ITEM,function(b,h){var i=a(b.target).closest(c.PAGE_ITEM),j=g.find(c.ACTIVE_PAGE_ITEM),k=f(g,i),l=k==f(g,j);l||(g.find(c.PAGE_ITEM).removeClass("active"),e(g,k).addClass("active")),g.trigger(d.PAGE_SELECTED,[{pageNumber:k,isSamePage:l}]),h.originalEvent.preventDefault()})};return{registerEventListeners:g,events:d,rootSelector:c.ROOT}});
|
||||
@@ -0,0 +1 @@
|
||||
define(["jquery","core/templates","block_myoverview/paging_bar"],function(a,b,c){var d={ROOT:'[data-region="paging-content"]',PAGE_REGION:'[data-region="paging-content-item"]'},e=function(b,c){this.root=a(b),this.pagingBar=a(c)};return e.rootSelector=d.ROOT,e.prototype.createPage=function(a){return this.loadContent(a).then(function(a,c){b.appendNodeContents(this.root,a,c)}.bind(this)).then(function(){return this.findPage(a)}.bind(this))},e.prototype.findPage=function(a){return this.root.find('[data-page="'+a+'"]')},e.prototype.showPage=function(a){var b=this.findPage(a);this.root.find(d.PAGE_REGION).addClass("hidden"),b.length?b.removeClass("hidden"):this.createPage(a).done(function(a){a.removeClass("hidden")})},e.prototype.registerEventListeners=function(){this.pagingBar.on(c.events.PAGE_SELECTED,function(a,b){b.isSamePage||this.showPage(b.pageNumber)}.bind(this))},e});
|
||||
@@ -0,0 +1,168 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* A javascript module to retrieve calendar events from the server.
|
||||
*
|
||||
* @module block_myoverview/calendar_events_repository
|
||||
* @class repository
|
||||
* @package block_myoverview
|
||||
* @copyright 2016 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {
|
||||
|
||||
var DEFAULT_LIMIT = 20;
|
||||
|
||||
/**
|
||||
* Retrieve a list of calendar events for the logged in user for the
|
||||
* given course.
|
||||
*
|
||||
* Valid args are:
|
||||
* int courseid Only get events for this course
|
||||
* int starttime Only get events after this time
|
||||
* int endtime Only get events before this time
|
||||
* int limit Limit the number of results returned
|
||||
* int aftereventid Offset the result set from the given id
|
||||
*
|
||||
* @method queryByCourse
|
||||
* @param {object} args The request arguments
|
||||
* @return {promise} Resolved with an array of the calendar events
|
||||
*/
|
||||
var queryByCourse = function(args) {
|
||||
if (!args.hasOwnProperty('limit')) {
|
||||
args.limit = DEFAULT_LIMIT;
|
||||
}
|
||||
|
||||
args.limitnum = args.limit;
|
||||
delete args.limit;
|
||||
|
||||
if (args.hasOwnProperty('starttime')) {
|
||||
args.timesortfrom = args.starttime;
|
||||
delete args.starttime;
|
||||
}
|
||||
|
||||
if (args.hasOwnProperty('endtime')) {
|
||||
args.timesortto = args.endtime;
|
||||
delete args.endtime;
|
||||
}
|
||||
|
||||
var request = {
|
||||
methodname: 'core_calendar_get_action_events_by_course',
|
||||
args: args
|
||||
};
|
||||
|
||||
var promise = Ajax.call([request])[0];
|
||||
|
||||
promise.fail(Notification.exception);
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve a list of calendar events for the given courses for the
|
||||
* logged in user.
|
||||
*
|
||||
* Valid args are:
|
||||
* array courseids Get events for these courses
|
||||
* int starttime Only get events after this time
|
||||
* int endtime Only get events before this time
|
||||
* int limit Limit the number of results returned
|
||||
*
|
||||
* @method queryByCourses
|
||||
* @param {object} args The request arguments
|
||||
* @return {promise} Resolved with an array of the calendar events
|
||||
*/
|
||||
var queryByCourses = function(args) {
|
||||
if (!args.hasOwnProperty('limit')) {
|
||||
// This is intentionally smaller than the default limit.
|
||||
args.limit = 10;
|
||||
}
|
||||
|
||||
args.limitnum = args.limit;
|
||||
delete args.limit;
|
||||
|
||||
if (args.hasOwnProperty('starttime')) {
|
||||
args.timesortfrom = args.starttime;
|
||||
delete args.starttime;
|
||||
}
|
||||
|
||||
if (args.hasOwnProperty('endtime')) {
|
||||
args.timesortto = args.endtime;
|
||||
delete args.endtime;
|
||||
}
|
||||
|
||||
var request = {
|
||||
methodname: 'core_calendar_get_action_events_by_courses',
|
||||
args: args
|
||||
};
|
||||
|
||||
var promise = Ajax.call([request])[0];
|
||||
|
||||
promise.fail(Notification.exception);
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve a list of calendar events for the logged in user after the given
|
||||
* time.
|
||||
*
|
||||
* Valid args are:
|
||||
* int starttime Only get events after this time
|
||||
* int endtime Only get events before this time
|
||||
* int limit Limit the number of results returned
|
||||
* int aftereventid Offset the result set from the given id
|
||||
*
|
||||
* @method queryByTime
|
||||
* @param {object} args The request arguments
|
||||
* @return {promise} Resolved with an array of the calendar events
|
||||
*/
|
||||
var queryByTime = function(args) {
|
||||
if (!args.hasOwnProperty('limit')) {
|
||||
args.limit = DEFAULT_LIMIT;
|
||||
}
|
||||
|
||||
args.limitnum = args.limit;
|
||||
delete args.limit;
|
||||
|
||||
if (args.hasOwnProperty('starttime')) {
|
||||
args.timesortfrom = args.starttime;
|
||||
delete args.starttime;
|
||||
}
|
||||
|
||||
if (args.hasOwnProperty('endtime')) {
|
||||
args.timesortto = args.endtime;
|
||||
delete args.endtime;
|
||||
}
|
||||
|
||||
var request = {
|
||||
methodname: 'core_calendar_get_action_events_by_timesort',
|
||||
args: args
|
||||
};
|
||||
|
||||
var promise = Ajax.call([request])[0];
|
||||
|
||||
promise.fail(Notification.exception);
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
return {
|
||||
queryByTime: queryByTime,
|
||||
queryByCourse: queryByCourse,
|
||||
queryByCourses: queryByCourses,
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,413 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Javascript to load and render the list of calendar events for a
|
||||
* given day range.
|
||||
*
|
||||
* @module block_myoverview/event_list
|
||||
* @package block_myoverview
|
||||
* @copyright 2016 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/notification', 'core/templates',
|
||||
'core/custom_interaction_events',
|
||||
'block_myoverview/calendar_events_repository'],
|
||||
function($, Notification, Templates, CustomEvents, CalendarEventsRepository) {
|
||||
|
||||
var SECONDS_IN_DAY = 60 * 60 * 24;
|
||||
|
||||
var SELECTORS = {
|
||||
EMPTY_MESSAGE: '[data-region="empty-message"]',
|
||||
ROOT: '[data-region="event-list-container"]',
|
||||
EVENT_LIST: '[data-region="event-list"]',
|
||||
EVENT_LIST_CONTENT: '[data-region="event-list-content"]',
|
||||
EVENT_LIST_GROUP_CONTAINER: '[data-region="event-list-group-container"]',
|
||||
LOADING_ICON_CONTAINER: '[data-region="loading-icon-container"]',
|
||||
VIEW_MORE_BUTTON: '[data-action="view-more"]'
|
||||
};
|
||||
|
||||
var TEMPLATES = {
|
||||
EVENT_LIST_ITEMS: 'block_myoverview/event-list-items',
|
||||
COURSE_EVENT_LIST_ITEMS: 'block_myoverview/course-event-list-items'
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a flag on the element to indicate that it has completed
|
||||
* loading all event data.
|
||||
*
|
||||
* @method setLoadedAll
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
*/
|
||||
var setLoadedAll = function(root) {
|
||||
root.attr('data-loaded-all', true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if all event data has finished loading.
|
||||
*
|
||||
* @method hasLoadedAll
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
* @return {bool} if the element has completed all loading
|
||||
*/
|
||||
var hasLoadedAll = function(root) {
|
||||
return !!root.attr('data-loaded-all');
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the element state to loading.
|
||||
*
|
||||
* @method startLoading
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
*/
|
||||
var startLoading = function(root) {
|
||||
var loadingIcon = root.find(SELECTORS.LOADING_ICON_CONTAINER),
|
||||
viewMoreButton = root.find(SELECTORS.VIEW_MORE_BUTTON);
|
||||
|
||||
root.addClass('loading');
|
||||
loadingIcon.removeClass('hidden');
|
||||
viewMoreButton.prop('disabled', true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the loading state from the element.
|
||||
*
|
||||
* @method stopLoading
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
*/
|
||||
var stopLoading = function(root) {
|
||||
var loadingIcon = root.find(SELECTORS.LOADING_ICON_CONTAINER),
|
||||
viewMoreButton = root.find(SELECTORS.VIEW_MORE_BUTTON);
|
||||
|
||||
root.removeClass('loading');
|
||||
loadingIcon.addClass('hidden');
|
||||
|
||||
if (!hasLoadedAll(root)) {
|
||||
// Only enable the button if we've got more events to load.
|
||||
viewMoreButton.prop('disabled', false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the element is currently loading some event data.
|
||||
*
|
||||
* @method isLoading
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
var isLoading = function(root) {
|
||||
return root.hasClass('loading');
|
||||
};
|
||||
|
||||
/**
|
||||
* Flag the root element to remember that it contains events.
|
||||
*
|
||||
* @method setHasContent
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
*/
|
||||
var setHasContent = function(root) {
|
||||
root.attr('data-has-events', true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the root element has had events loaded.
|
||||
*
|
||||
* @method hasContent
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
* @return {bool}
|
||||
*/
|
||||
var hasContent = function(root) {
|
||||
return root.attr('data-has-events') ? true : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the visibility of the content area. The content area
|
||||
* is hidden if we have no events.
|
||||
*
|
||||
* @method updateContentVisibility
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
* @param {int} eventCount A count of the events we just received.
|
||||
*/
|
||||
var updateContentVisibility = function(root, eventCount) {
|
||||
if (eventCount) {
|
||||
// We've rendered some events, let's remember that.
|
||||
setHasContent(root);
|
||||
} else {
|
||||
// If this is the first time trying to load events and
|
||||
// we don't have any then there isn't any so let's show
|
||||
// the empty message.
|
||||
if (!hasContent(root)) {
|
||||
hideContent(root);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the content area and display the empty content message.
|
||||
*
|
||||
* @method hideContent
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
*/
|
||||
var hideContent = function(root) {
|
||||
root.find(SELECTORS.EVENT_LIST_CONTENT).addClass('hidden');
|
||||
root.find(SELECTORS.EMPTY_MESSAGE).removeClass('hidden');
|
||||
};
|
||||
|
||||
/**
|
||||
* Render a group of calendar events and add them to the event
|
||||
* list.
|
||||
*
|
||||
* @method renderGroup
|
||||
* @private
|
||||
* @param {object} group The group container element
|
||||
* @param {array} calendarEvents The list of calendar events
|
||||
* @param {string} templateName The template name
|
||||
* @return {promise} Resolved when the elements are attached to the DOM
|
||||
*/
|
||||
var renderGroup = function(group, calendarEvents, templateName) {
|
||||
|
||||
group.removeClass('hidden');
|
||||
|
||||
return Templates.render(
|
||||
templateName,
|
||||
{events: calendarEvents}
|
||||
).done(function(html, js) {
|
||||
Templates.appendNodeContents(group.find(SELECTORS.EVENT_LIST), html, js);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine the time (in seconds) from the given timestamp until the calendar
|
||||
* event will need actioning.
|
||||
*
|
||||
* @method timeUntilEvent
|
||||
* @private
|
||||
* @param {int} timestamp The time to compare with
|
||||
* @param {object} event The calendar event
|
||||
* @return {int}
|
||||
*/
|
||||
var timeUntilEvent = function(timestamp, event) {
|
||||
var orderTime = event.timesort || 0;
|
||||
return orderTime - timestamp;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given calendar event should be added to the given event
|
||||
* list group container. The event list group container will specify a
|
||||
* day range for the time boundary it is interested in.
|
||||
*
|
||||
* If only a start day is specified for the container then it will be treated
|
||||
* as an open catchment for all events that begin after that time.
|
||||
*
|
||||
* @method eventBelongsInContainer
|
||||
* @private
|
||||
* @param {object} event The calendar event
|
||||
* @param {object} container The group event list container
|
||||
* @return {bool}
|
||||
*/
|
||||
var eventBelongsInContainer = function(event, container) {
|
||||
var todayTime = Math.floor(new Date().setHours(0, 0, 0, 0) / 1000),
|
||||
timeUntilContainerStart = +container.attr('data-start-day') * SECONDS_IN_DAY,
|
||||
timeUntilContainerEnd = +container.attr('data-end-day') * SECONDS_IN_DAY,
|
||||
timeUntilEventNeedsAction = timeUntilEvent(todayTime, event);
|
||||
|
||||
if (container.attr('data-end-day') === '') {
|
||||
return timeUntilContainerStart <= timeUntilEventNeedsAction;
|
||||
} else {
|
||||
return timeUntilContainerStart <= timeUntilEventNeedsAction &&
|
||||
timeUntilEventNeedsAction < timeUntilContainerEnd;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a function that can be used to filter a list of events based on the day
|
||||
* range specified on the given event list group container.
|
||||
*
|
||||
* @method getFilterCallbackForContainer
|
||||
* @private
|
||||
* @param {object} container Event list group container
|
||||
* @return {function}
|
||||
*/
|
||||
var getFilterCallbackForContainer = function(container) {
|
||||
return function(event) {
|
||||
return eventBelongsInContainer(event, $(container));
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the given calendar events in the container element. The container
|
||||
* elements must have a day range defined using data attributes that will be
|
||||
* used to group the calendar events according to their order time.
|
||||
*
|
||||
* @method render
|
||||
* @private
|
||||
* @param {object} root The container element
|
||||
* @param {array} calendarEvents A list of calendar events
|
||||
* @return {promise} Resolved with a count of the number of rendered events
|
||||
*/
|
||||
var render = function(root, calendarEvents) {
|
||||
var renderCount = 0;
|
||||
var templateName = TEMPLATES.EVENT_LIST_ITEMS;
|
||||
|
||||
if (root.attr('data-course-id')) {
|
||||
templateName = TEMPLATES.COURSE_EVENT_LIST_ITEMS;
|
||||
}
|
||||
|
||||
// Loop over each of the element list groups and find the set of calendar events
|
||||
// that belong to that group (as defined by the group's day range). The matching
|
||||
// list of calendar events are rendered and added to the DOM within that group.
|
||||
return $.when.apply($, $.map(root.find(SELECTORS.EVENT_LIST_GROUP_CONTAINER), function(container) {
|
||||
var events = calendarEvents.filter(getFilterCallbackForContainer(container));
|
||||
|
||||
if (events.length) {
|
||||
renderCount += events.length;
|
||||
return renderGroup($(container), events, templateName);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})).then(function() {
|
||||
return renderCount;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve a list of calendar events, render and append them to the end of the
|
||||
* existing list. The events will be loaded based on the set of data attributes
|
||||
* on the root element.
|
||||
*
|
||||
* This function can be provided with a jQuery promise. If it is then it won't
|
||||
* attempt to load data by itself, instead it will use the given promise.
|
||||
*
|
||||
* The provided promise must resolve with an an object that has an events key
|
||||
* and value is an array of calendar events.
|
||||
* E.g.
|
||||
* { events: ['event 1', 'event 2'] }
|
||||
*
|
||||
* @method load
|
||||
* @param {object} root The root element of the event list
|
||||
* @param {object} promise A jQuery promise resolved with events
|
||||
* @return {promise} A jquery promise
|
||||
*/
|
||||
var load = function(root, promise) {
|
||||
root = $(root);
|
||||
var limit = +root.attr('data-limit'),
|
||||
courseId = +root.attr('data-course-id'),
|
||||
lastId = root.attr('data-last-id'),
|
||||
date = new Date(),
|
||||
startTime;
|
||||
|
||||
date.setDate(date.getDate() - 14);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
startTime = Math.floor(date / 1000);
|
||||
|
||||
// Don't load twice.
|
||||
if (isLoading(root)) {
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
|
||||
startLoading(root);
|
||||
|
||||
// If we haven't been provided a promise to resolve the
|
||||
// data then we will load our own.
|
||||
if (typeof promise == 'undefined') {
|
||||
var args = {
|
||||
starttime: startTime,
|
||||
limit: limit,
|
||||
};
|
||||
|
||||
if (lastId) {
|
||||
args.aftereventid = lastId;
|
||||
}
|
||||
|
||||
// If we have a course id then we only want events from that course.
|
||||
if (courseId) {
|
||||
args.courseid = courseId;
|
||||
promise = CalendarEventsRepository.queryByCourse(args);
|
||||
} else {
|
||||
// Otherwise we want events from any course.
|
||||
promise = CalendarEventsRepository.queryByTime(args);
|
||||
}
|
||||
}
|
||||
|
||||
// Request data from the server.
|
||||
return promise.then(function(result) {
|
||||
return result.events;
|
||||
}).then(function(calendarEvents) {
|
||||
if (!calendarEvents.length || (calendarEvents.length < limit)) {
|
||||
// We have no more events so mark the list as done.
|
||||
setLoadedAll(root);
|
||||
}
|
||||
|
||||
if (calendarEvents.length) {
|
||||
// Remember the last id we've seen.
|
||||
root.attr('data-last-id', calendarEvents[calendarEvents.length - 1].id);
|
||||
|
||||
// Render the events.
|
||||
return render(root, calendarEvents).then(function(renderCount) {
|
||||
updateContentVisibility(root, calendarEvents.length);
|
||||
|
||||
if (renderCount < calendarEvents.length) {
|
||||
// if the number of events that was rendered is less than
|
||||
// the number we sent for rendering we can assume that there
|
||||
// are no groups to add them in. Since the ordering of the
|
||||
// events is guaranteed it means that any future requests will
|
||||
// also yield events that can't be rendered, so let's not bother
|
||||
// sending any more requests.
|
||||
setLoadedAll(root);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
updateContentVisibility(root, calendarEvents.length);
|
||||
}
|
||||
}).fail(
|
||||
Notification.exception
|
||||
).always(function() {
|
||||
stopLoading(root);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Register the event listeners for the container element.
|
||||
*
|
||||
* @method registerEventListeners
|
||||
* @param {object} root The root element of the event list
|
||||
*/
|
||||
var registerEventListeners = function(root) {
|
||||
CustomEvents.define(root, [CustomEvents.events.activate]);
|
||||
root.on(CustomEvents.events.activate, SELECTORS.VIEW_MORE_BUTTON, function() {
|
||||
load(root);
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
init: function(root) {
|
||||
root = $(root);
|
||||
load(root);
|
||||
registerEventListeners(root);
|
||||
},
|
||||
registerEventListeners: registerEventListeners,
|
||||
load: load,
|
||||
rootSelector: SELECTORS.ROOT,
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Javascript to load and render the list of calendar events grouping by course.
|
||||
*
|
||||
* @module block_myoverview/events_by_course_list
|
||||
* @package block_myoverview
|
||||
* @copyright 2016 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'block_myoverview/event_list',
|
||||
'block_myoverview/calendar_events_repository'
|
||||
],
|
||||
function($, EventList, EventsRepository) {
|
||||
|
||||
var SELECTORS = {
|
||||
EVENTS_BY_COURSE_CONTAINER: '[data-region="course-events-container"]',
|
||||
};
|
||||
|
||||
/**
|
||||
* Loop through course events containers and load calendar events for that course.
|
||||
*
|
||||
* @method load
|
||||
* @param {Object} root The root element of sort by course list.
|
||||
*/
|
||||
var load = function(root) {
|
||||
var courseBlocks = root.find(SELECTORS.EVENTS_BY_COURSE_CONTAINER);
|
||||
|
||||
if (!courseBlocks.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 14);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
var startTime = Math.floor(date / 1000);
|
||||
var limit = courseBlocks.attr('data-limit');
|
||||
var courseIds = courseBlocks.map(function() {
|
||||
return $(this).attr('data-course-id');
|
||||
}).get();
|
||||
|
||||
// Load the first set of events for each course in a single request.
|
||||
// We want to avoid sending an individual request for each course because
|
||||
// there could be lots of them.
|
||||
var coursesPromise = EventsRepository.queryByCourses({
|
||||
courseids: courseIds,
|
||||
starttime: startTime,
|
||||
limit: limit
|
||||
});
|
||||
|
||||
// Load the events into each course block.
|
||||
courseBlocks.each(function(index, container) {
|
||||
container = $(container);
|
||||
var courseId = container.attr('data-course-id');
|
||||
var eventListContainer = container.find(EventList.rootSelector);
|
||||
var promise = $.Deferred();
|
||||
|
||||
// Once all of the course events have been loaded then we need
|
||||
// to extract just the ones relevant to this course block and
|
||||
// hand them to the event list to render.
|
||||
coursesPromise.done(function(result) {
|
||||
var events = [];
|
||||
// Get this course block's events from the collection returned
|
||||
// from the server.
|
||||
var courseGroup = result.groupedbycourse.filter(function(group) {
|
||||
return group.courseid == courseId;
|
||||
});
|
||||
|
||||
if (courseGroup.length) {
|
||||
events = courseGroup[0].events;
|
||||
}
|
||||
|
||||
promise.resolve({events: events});
|
||||
}).fail(function(e) {
|
||||
promise.reject(e);
|
||||
});
|
||||
|
||||
// Provide the event list with a promise that will be resolved
|
||||
// when we have received the events from the server.
|
||||
EventList.load(eventListContainer, promise);
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
init: function(root) {
|
||||
root = $(root);
|
||||
load(root);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Javascript to load and render the paging bar.
|
||||
*
|
||||
* @module block_myoverview/paging_bar
|
||||
* @package block_myoverview
|
||||
* @copyright 2016 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/custom_interaction_events'],
|
||||
function($, CustomEvents) {
|
||||
|
||||
var SELECTORS = {
|
||||
ROOT: '[data-region="paging-bar"]',
|
||||
PAGE_ITEM: '[data-region="page-item"]',
|
||||
ACTIVE_PAGE_ITEM: '[data-region="page-item"].active'
|
||||
};
|
||||
|
||||
var EVENTS = {
|
||||
PAGE_SELECTED: 'block_myoverview-paging-bar-page-selected',
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the page element by number.
|
||||
*
|
||||
* @param {object} root The root element.
|
||||
* @param {Number} pageNumber The page number.
|
||||
* @returns {*}
|
||||
*/
|
||||
var getPageByNumber = function(root, pageNumber) {
|
||||
return root.find(SELECTORS.PAGE_ITEM + '[data-page-number="' + pageNumber + '"]');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the page number.
|
||||
*
|
||||
* @param {object} root The root element.
|
||||
* @param {object} page The page.
|
||||
* @returns {*} the page number
|
||||
*/
|
||||
var getPageNumber = function(root, page) {
|
||||
var pageNumber = page.attr('data-page-number');
|
||||
|
||||
if (pageNumber == 'first') {
|
||||
pageNumber = 1;
|
||||
} else if (pageNumber == 'last') {
|
||||
pageNumber = root.attr('data-page-count');
|
||||
}
|
||||
|
||||
return pageNumber;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register event listeners for the module.
|
||||
* @param {object} root The root element.
|
||||
*/
|
||||
var registerEventListeners = function(root) {
|
||||
root = $(root);
|
||||
CustomEvents.define(root, [
|
||||
CustomEvents.events.activate
|
||||
]);
|
||||
|
||||
root.on(CustomEvents.events.activate, SELECTORS.PAGE_ITEM, function(e, data) {
|
||||
var page = $(e.target).closest(SELECTORS.PAGE_ITEM);
|
||||
var activePage = root.find(SELECTORS.ACTIVE_PAGE_ITEM);
|
||||
var pageNumber = getPageNumber(root, page);
|
||||
var isSamePage = pageNumber == getPageNumber(root, activePage);
|
||||
|
||||
if (!isSamePage) {
|
||||
root.find(SELECTORS.PAGE_ITEM).removeClass('active');
|
||||
getPageByNumber(root, pageNumber).addClass('active');
|
||||
}
|
||||
|
||||
root.trigger(EVENTS.PAGE_SELECTED, [{
|
||||
pageNumber: pageNumber,
|
||||
isSamePage: isSamePage,
|
||||
}]);
|
||||
|
||||
data.originalEvent.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
registerEventListeners: registerEventListeners,
|
||||
events: EVENTS,
|
||||
rootSelector: SELECTORS.ROOT,
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Paging content module.
|
||||
*
|
||||
* @module block_myoverview/paging_content
|
||||
* @package block_myoverview
|
||||
* @copyright 2016 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/templates', 'block_myoverview/paging_bar'],
|
||||
function($, Templates, PagingBar) {
|
||||
|
||||
var SELECTORS = {
|
||||
ROOT: '[data-region="paging-content"]',
|
||||
PAGE_REGION: '[data-region="paging-content-item"]'
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor of the paging content module.
|
||||
*
|
||||
* @param {object} root
|
||||
* @param {object} pagingBarElement
|
||||
* @constructor
|
||||
*/
|
||||
var PagingContent = function(root, pagingBarElement) {
|
||||
this.root = $(root);
|
||||
this.pagingBar = $(pagingBarElement);
|
||||
|
||||
};
|
||||
|
||||
PagingContent.rootSelector = SELECTORS.ROOT;
|
||||
|
||||
/**
|
||||
* Load content and create page.
|
||||
*
|
||||
* @param {Number} pageNumber
|
||||
* @returns {*|Promise}
|
||||
*/
|
||||
PagingContent.prototype.createPage = function(pageNumber) {
|
||||
|
||||
return this.loadContent(pageNumber).then(function(html, js) {
|
||||
Templates.appendNodeContents(this.root, html, js);
|
||||
}.bind(this)).then(function() {
|
||||
return this.findPage(pageNumber);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a page by the number.
|
||||
*
|
||||
* @param {Number} pageNumber The number of the page to be found.
|
||||
* @returns {*} Page root
|
||||
*/
|
||||
PagingContent.prototype.findPage = function(pageNumber) {
|
||||
return this.root.find('[data-page="' + pageNumber + '"]');
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a page visible.
|
||||
*
|
||||
* @param {Number} pageNumber The number of the page to be visible.
|
||||
*/
|
||||
PagingContent.prototype.showPage = function(pageNumber) {
|
||||
|
||||
var existingPage = this.findPage(pageNumber);
|
||||
this.root.find(SELECTORS.PAGE_REGION).addClass('hidden');
|
||||
|
||||
if (existingPage.length) {
|
||||
existingPage.removeClass('hidden');
|
||||
} else {
|
||||
this.createPage(pageNumber).done(function(newPage) {
|
||||
newPage.removeClass('hidden');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listeners.
|
||||
*/
|
||||
PagingContent.prototype.registerEventListeners = function() {
|
||||
|
||||
this.pagingBar.on(PagingBar.events.PAGE_SELECTED, function(e, data) {
|
||||
if (!data.isSamePage) {
|
||||
this.showPage(data.pageNumber);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
return PagingContent;
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Contains the class for the My overview block.
|
||||
*
|
||||
* @package block_myoverview
|
||||
* @copyright Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* My overview block class.
|
||||
*
|
||||
* @package block_myoverview
|
||||
* @copyright Mark Nelson <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class block_myoverview extends block_base {
|
||||
|
||||
/**
|
||||
* Init.
|
||||
*/
|
||||
public function init() {
|
||||
$this->title = get_string('pluginname', 'block_myoverview');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents.
|
||||
*
|
||||
* @return stdClass contents of block
|
||||
*/
|
||||
public function get_content() {
|
||||
if (isset($this->content)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$renderable = new \block_myoverview\output\main();
|
||||
$renderer = $this->page->get_renderer('block_myoverview');
|
||||
|
||||
$this->content = new stdClass();
|
||||
$this->content->text = $renderer->render($renderable);
|
||||
$this->content->footer = '';
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locations where block can be displayed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function applicable_formats() {
|
||||
return array('my' => true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for my overview block.
|
||||
*
|
||||
* @package block_myoverview
|
||||
* @copyright 2017 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace block_myoverview\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_course\external\course_summary_exporter;
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use templatable;
|
||||
/**
|
||||
* Class containing data for my overview block.
|
||||
*
|
||||
* @copyright 2017 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_summary implements renderable, templatable {
|
||||
|
||||
/** @var array $courses List of courses the user is enrolled in. */
|
||||
protected $courses = [];
|
||||
|
||||
/** @var array $coursesprogress List of progress percentage for each course. */
|
||||
protected $coursesprogress = [];
|
||||
|
||||
/**
|
||||
* The course_summary constructor.
|
||||
*
|
||||
* @param array $courses list of courses.
|
||||
* @param array $coursesprogress list of courses progress.
|
||||
*/
|
||||
public function __construct($courses, $coursesprogress) {
|
||||
$this->courses = $courses;
|
||||
$this->coursesprogress = $coursesprogress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param \renderer_base $output
|
||||
* @return array
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
|
||||
$data = [];
|
||||
foreach ($this->courses as $courseid => $course) {
|
||||
$context = \context_course::instance($courseid);
|
||||
// Convert summary to plain text.
|
||||
$course->summary = content_to_text($course->summary, false);
|
||||
$exporter = new course_summary_exporter($course, array('context' => $context));
|
||||
$exportedcourse = $exporter->export($output);
|
||||
|
||||
if (isset($this->coursesprogress[$courseid])) {
|
||||
$courseprogress = $this->coursesprogress[$courseid];
|
||||
$exportedcourse->hasprogress = !is_null($courseprogress);
|
||||
$exportedcourse->progress = $courseprogress;
|
||||
}
|
||||
|
||||
$data[] = $exportedcourse;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Class containing data for courses view in the myoverview block.
|
||||
*
|
||||
* @package block_myoverview
|
||||
* @copyright 2017 Ryan Wyllie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace block_myoverview\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use templatable;
|
||||
use core_course\external\course_summary_exporter;
|
||||
|
||||
/**
|
||||
* Class containing data for courses view in the myoverview block.
|
||||
*
|
||||
* @copyright 2017 Simey Lameze <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class courses_view implements renderable, templatable {
|
||||
/** Quantity of courses per page. */
|
||||
const COURSES_PER_PAGE = 6;
|
||||
|
||||
/** @var array $courses List of courses the user is enrolled in. */
|
||||
protected $courses = [];
|
||||
|
||||
/** @var array $coursesprogress List of progress percentage for each course. */
|
||||
protected $coursesprogress = [];
|
||||
|
||||
/**
|
||||
* The courses_view constructor.
|
||||
*
|
||||
* @param array $courses list of courses.
|
||||
* @param array $coursesprogress list of courses progress.
|
||||
*/
|
||||
public function __construct($courses, $coursesprogress) {
|
||||
$this->courses = $courses;
|
||||
$this->coursesprogress = $coursesprogress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template.
|
||||
*
|
||||
* @param \renderer_base $output
|
||||
* @return array
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$today = time();
|
||||
|
||||
// Build courses view data structure.
|
||||
$coursesview = [
|
||||
'hascourses' => !empty($this->courses)
|
||||
];
|
||||
|
||||
// How many courses we have per status?
|
||||
$coursesbystatus = ['past' => 0, 'inprogress' => 0, 'future' => 0];
|
||||
foreach ($this->courses as $course) {
|
||||
$startdate = $course->startdate;
|
||||
$enddate = $course->enddate;
|
||||
$courseid = $course->id;
|
||||
$context = \context_course::instance($courseid);
|
||||
// Convert summary to plain text.
|
||||
$course->summary = content_to_text($course->summary, false);
|
||||
$exporter = new course_summary_exporter($course, [
|
||||
'context' => $context
|
||||
]);
|
||||
$exportedcourse = $exporter->export($output);
|
||||
|
||||
if (isset($this->coursesprogress[$courseid])) {
|
||||
$courseprogress = $this->coursesprogress[$courseid];
|
||||
$exportedcourse->hasprogress = !is_null($courseprogress);
|
||||
$exportedcourse->progress = $courseprogress;
|
||||
}
|
||||
|
||||
if ($startdate > $today) {
|
||||
// Courses that have not started yet.
|
||||
$futurepages = floor($coursesbystatus['future'] / $this::COURSES_PER_PAGE);
|
||||
|
||||
$coursesview['future']['pages'][$futurepages]['courses'][] = $exportedcourse;
|
||||
$coursesview['future']['pages'][$futurepages]['active'] = ($futurepages == 0 ? true : false);
|
||||
$coursesview['future']['pages'][$futurepages]['page'] = $futurepages + 1;
|
||||
$coursesbystatus['future']++;
|
||||
|
||||
} else if (!empty($enddate) && $enddate < $today) {
|
||||
// Courses that have already ended.
|
||||
$pastpages = floor($coursesbystatus['past'] / $this::COURSES_PER_PAGE);
|
||||
|
||||
$coursesview['past']['pages'][$pastpages]['courses'][] = $exportedcourse;
|
||||
$coursesview['past']['pages'][$pastpages]['active'] = ($pastpages == 0 ? true : false);
|
||||
$coursesview['past']['pages'][$pastpages]['page'] = $pastpages + 1;
|
||||
$coursesbystatus['past']++;
|
||||
|
||||
} else {
|
||||
// Courses still in progress. Either their end date is not set, or the end date is not yet past the current date.
|
||||
$inprogresspages = floor($coursesbystatus['inprogress'] / $this::COURSES_PER_PAGE);
|
||||
|
||||
$coursesview['inprogress']['pages'][$inprogresspages]['courses'][] = $exportedcourse;
|
||||
$coursesview['inprogress']['pages'][$inprogresspages]['active'] = ($inprogresspages == 0 ? true : false);
|
||||
$coursesview['inprogress']['pages'][$inprogresspages]['page'] = $inprogresspages + 1;
|
||||
$coursesbystatus['inprogress']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Build courses view paging bar structure.
|
||||
foreach ($coursesbystatus as $status => $total) {
|
||||
$quantpages = ceil($total / $this::COURSES_PER_PAGE);
|
||||
|
||||
if ($quantpages) {
|
||||
$coursesview[$status]['pagingbar']['disabled'] = ($quantpages <= 1);
|
||||
$coursesview[$status]['pagingbar']['pagecount'] = $quantpages;
|
||||
$coursesview[$status]['pagingbar']['first'] = ['page' => '«', 'url' => '#'];
|
||||
$coursesview[$status]['pagingbar']['last'] = ['page' => '»', 'url' => '#'];
|
||||
for ($page = 0; $page < $quantpages; $page++) {
|
||||
$coursesview[$status]['pagingbar']['pages'][$page] = [
|
||||
'number' => $page + 1,
|
||||
'page' => $page + 1,
|
||||
'url' => '#',
|
||||
'active' => ($page == 0 ? true : false)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $coursesview;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user