diff --git a/mod/lesson/tests/behat/link_to_gradebook.feature b/mod/lesson/tests/behat/link_to_gradebook.feature index 9c66d7e4fea..00c1d29e75a 100644 --- a/mod/lesson/tests/behat/link_to_gradebook.feature +++ b/mod/lesson/tests/behat/link_to_gradebook.feature @@ -19,10 +19,6 @@ Feature: link to gradebook on the end of lesson page And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I click on "Edit settings" "link" in the "Administration" "block" - And I set the following fields to these values: - | Show gradebook to students | No | - And I press "Save changes" And I add a "Lesson" to section "1" and I fill the form with: | Name | Test lesson | | Description | Test lesson description | @@ -53,6 +49,9 @@ Feature: link to gradebook on the end of lesson page And I press "Next page" Then I should see "Congratulations - end of lesson reached" And I should see "View grades" + And I follow "View grades" + And I should see "User report - Student 1" + And I should see "Test lesson" @javascript Scenario: No link to gradebook for non graded lesson @@ -86,6 +85,22 @@ Feature: link to gradebook on the end of lesson page Then I should see "Congratulations - end of lesson reached" And I should not see "View grades" + @javascript + Scenario: No link if Show gradebook to student disabled + Given I follow "Course 1" + And I click on "Edit settings" "link" in the "Administration" "block" + And I set the following fields to these values: + | Show gradebook to students | No | + And I press "Save changes" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson" + And I press "Next page" + And I press "Next page" + Then I should see "Congratulations - end of lesson reached" + And I should not see "View grades" + @javascript Scenario: No link to gradebook if no gradereport/user:view capability Given I log out @@ -100,4 +115,4 @@ Feature: link to gradebook on the end of lesson page And I press "Next page" And I press "Next page" Then I should see "Congratulations - end of lesson reached" - And I should not see "View grades" \ No newline at end of file + And I should not see "View grades" diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 046dbc99080..08896810c2f 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -569,7 +569,7 @@ if ($pageid != LESSON_EOL) { $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)), array('class'=>'centerpadded lessonbutton standardbutton')); if (has_capability('gradereport/user:view', context_course::instance($course->id)) - && $lesson->grade != 0 && !$lesson->practice) { + && $course->showgrades && $lesson->grade != 0 && !$lesson->practice) { $url = new moodle_url('/grade/index.php', array('id' => $course->id)); $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), array('class' => 'centerpadded lessonbutton standardbutton'));