Skip to content

Commit

Permalink
Merge branch 'MDL-59392-master' of git://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Sep 11, 2017
2 parents 52516f2 + 7aaca08 commit 4d4c599
Show file tree
Hide file tree
Showing 39 changed files with 1,236 additions and 277 deletions.
31 changes: 14 additions & 17 deletions blocks/calendar_month/block_calendar_month.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,26 @@ public function get_content() {
if ($issite) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = calendar_get_default_courses();
$course = get_site();
$courses = calendar_get_default_courses();
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseid => $this->page->course);
$course = $this->page->course;
$courses = [$course->id => $course];
}

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);
// 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 .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
$this->content->text .= '<div class="filters calendar_filters">' .
calendar_filter_controls($this->page->url) . '</div>';
$renderer = $this->page->get_renderer('core_calendar');

$calendar = new calendar_information(0, 0, 0, $time);
$calendar->prepare_for_view($course, $courses);

list($data, $template) = calendar_get_view($calendar, 'mini');
$this->content->text .= $renderer->render_from_template($template, $data);

if (!$issite) {
$this->content->text .= $renderer->event_filter();
}

return $this->content;
}
}


18 changes: 14 additions & 4 deletions blocks/calendar_month/tests/behat/block_calendar_month.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: Enable the calendar block in a course and test it's functionality
Given I log in as "teacher1"
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"
Then "Calendar" "block" should exist

@javascript
Scenario: View a global event in the calendar block
Expand Down Expand Up @@ -136,9 +136,14 @@ Feature: Enable the calendar block in a course and test it's functionality
And I press "Save and display"
And I turn editing mode on
And I add the "Calendar" block
And I create a calendar event with form data:
And I click on "This month" "link"
And I click on "New event" "button"
And I set the following fields to these values:
| id_eventtype | Group |
| id_name | Group Event |
And I set the following fields to these values:
| Group | Group 1 |
And I press "Save"
And I log out
Then I log in as "student1"
And I am on "Course 1" course homepage
Expand All @@ -150,7 +155,7 @@ Feature: Enable the calendar block in a course and test it's functionality
And I hover over today in the calendar
And I should not see "Group Event"

@javascript
@javascript @arn
Scenario: Filter group events in the calendar block
Given the following "groups" exist:
| name | course | idnumber |
Expand All @@ -173,9 +178,14 @@ Feature: Enable the calendar block in a course and test it's functionality
| id_eventtype | Course |
| id_name | Course Event 1 |
And I am on "Course 1" course homepage
And I create a calendar event with form data:
And I click on "This month" "link"
And I click on "New event" "button"
And I set the following fields to these values:
| id_eventtype | Group |
| id_name | Group Event 1 |
And I set the following fields to these values:
| Group | Group 1 |
And I press "Save"
And I log out
Then I log in as "student1"
And I am on "Course 1" course homepage
Expand Down
2 changes: 1 addition & 1 deletion calendar/amd/build/calendar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions calendar/amd/build/calendar_filter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions calendar/amd/build/calendar_mini.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion calendar/amd/build/events.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions calendar/amd/build/selectors.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion calendar/amd/build/view_manager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions calendar/amd/src/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ define([
/**
* Register event listeners for the module.
*/
var registerEventListeners = function() {
var root = $(SELECTORS.ROOT);

var registerEventListeners = function(root) {
// Bind click events to event links.
root.on('click', SELECTORS.EVENT_ITEM, function(e) {
e.preventDefault();
Expand Down Expand Up @@ -350,9 +348,11 @@ define([
};

return {
init: function() {
CalendarViewManager.init();
registerEventListeners();
init: function(root) {
root = $(root);

CalendarViewManager.init(root);
registerEventListeners(root);
}
};
});
Loading

0 comments on commit 4d4c599

Please sign in to comment.