Skip to content

Commit

Permalink
Merge branch 'MDL-51864-master' of git://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Oct 27, 2015
2 parents d891a6d + 3dbdeb5 commit 4727a4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
12 changes: 10 additions & 2 deletions blocks/course_summary/block_course_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
*/

class block_course_summary extends block_base {

/**
* @var bool Flag to indicate whether the header should be hidden or not.
*/
private $headerhidden = true;

function init() {
$this->title = get_string('pluginname', 'block_course_summary');
}
Expand All @@ -32,8 +38,10 @@ function applicable_formats() {
}

function specialization() {
if($this->page->pagetype == PAGE_COURSE_VIEW && $this->page->course->id != SITEID) {
// Page type starts with 'course-view' and the page's course ID is not equal to the site ID.
if (strpos($this->page->pagetype, PAGE_COURSE_VIEW) === 0 && $this->page->course->id != SITEID) {
$this->title = get_string('coursesummary', 'block_course_summary');
$this->headerhidden = false;
}
}

Expand Down Expand Up @@ -71,7 +79,7 @@ function get_content() {
}

function hide_header() {
return true;
return $this->headerhidden;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ Feature: Course summary block used in a course
Scenario: Student can view course summary
When I log in as "student1"
And I follow "Course 1"
Then "Course/site summary" "block" should exist
And I should see "Proved the course summary block works!" in the "Course/site summary" "block"
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 see an edit icon when edit mode is on and follow it to the course edit page
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
Then I should see "Proved the course summary block works!" in the "Course/site summary" "block"
And I click on "Edit" "link" in the "Course/site summary" "block"
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 I click on "Edit" "link" in the "Course summary" "block"
Then I should see "Edit course settings" in the "h2" "css_element"

Scenario: Teacher can not see edit icon when edit mode is off
When I log in as "teacher1"
And I follow "Course 1"
Then I should see "Proved the course summary block works!" in the "Course/site summary" "block"
And "Edit" "link" should not exist in the "Course/site summary" "block"
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"
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ Feature: Course summary block used on the frontpage
Scenario: Guest can view site summary
When I am on site homepage
Then "Course/site summary" "block" should exist
And I should not see "Course summary" in the "Course/site summary" "block"
And I should see "Proved the summary block works!" in the "Course/site summary" "block"

Scenario: Admin can see an edit icon when edit mode is on and follow it to the front page settings
When I log in as "admin"
And I am on site homepage
And I follow "Turn editing on"
Then I should see "Proved the summary block works!" in the "Course/site summary" "block"
And I should not see "Course summary" in the "Course/site summary" "block"
And I click on "Edit" "link" in the "Course/site summary" "block"
Then I should see "Front page settings" in the "h2" "css_element"

Scenario: Admin can not see edit icon when edit mode is off
When I log in as "admin"
And I am on site homepage
Then I should see "Proved the summary block works!" in the "Course/site summary" "block"
And I should not see "Course summary" in the "Course/site summary" "block"
And "Edit" "link" should not exist in the "Course/site summary" "block"

0 comments on commit 4727a4a

Please sign in to comment.