From ad67b7eeea4abf194eb432d5958e9a7032ee2c25 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 4 Feb 2016 16:17:40 +0800 Subject: [PATCH] MDL-52378 singleview: Using is_disabled instead of is_locked --- grade/report/singleview/classes/local/screen/screen.php | 2 +- .../report/singleview/classes/local/screen/tablelike.php | 2 +- grade/report/singleview/classes/local/ui/exclude.php | 15 +++++++-------- grade/report/singleview/tests/behat/singleview.feature | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/grade/report/singleview/classes/local/screen/screen.php b/grade/report/singleview/classes/local/screen/screen.php index 9e7ba7ca841..7c9760016f1 100644 --- a/grade/report/singleview/classes/local/screen/screen.php +++ b/grade/report/singleview/classes/local/screen/screen.php @@ -329,7 +329,7 @@ abstract class screen { continue; } - // If the user submits Exclude grade elements without the proper + // If the user submits Exclude grade elements without the proper. // permissions then we should refuse to update. if ($matches[1] === 'exclude' && !has_capability('moodle/grade:manage', $this->context)){ $warnings[] = get_string('nopermissions', 'error', get_string('grade:manage', 'role')); diff --git a/grade/report/singleview/classes/local/screen/tablelike.php b/grade/report/singleview/classes/local/screen/tablelike.php index 2d7835d24af..5e5054fbd92 100644 --- a/grade/report/singleview/classes/local/screen/tablelike.php +++ b/grade/report/singleview/classes/local/screen/tablelike.php @@ -144,7 +144,7 @@ abstract class tablelike extends screen { // Singleview users without proper permissions should be presented // disabled checkboxes for the Exclude grade attribute. if ($field == 'exclude' && !has_capability('moodle/grade:manage', $this->context)){ - $html->locked=TRUE; + $html->disabled = true; } $line[] = $html; diff --git a/grade/report/singleview/classes/local/ui/exclude.php b/grade/report/singleview/classes/local/ui/exclude.php index 73440b55d16..62f7780acb7 100644 --- a/grade/report/singleview/classes/local/ui/exclude.php +++ b/grade/report/singleview/classes/local/ui/exclude.php @@ -35,13 +35,13 @@ use grade_grade; * @copyright 2014 Moodle Pty Ltd (http://moodle.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class exclude extends grade_attribute_format implements be_checked { +class exclude extends grade_attribute_format implements be_checked, be_disabled { /** @var string $name The name of the input */ public $name = 'exclude'; - /** @var bool $locked Is the input locked? */ - public $locked = FALSE; + /** @var bool $disabled Is the checkbox disabled? */ + public $disabled = false; /** * Is it checked? @@ -53,12 +53,12 @@ class exclude extends grade_attribute_format implements be_checked { } /** - * Is it locked? + * Is it disabled? * * @return bool */ - public function is_locked() { - return $this->locked; + public function is_disabled() { + return $this->disabled; } /** @@ -71,8 +71,7 @@ class exclude extends grade_attribute_format implements be_checked { $this->get_name(), $this->get_label(), $this->is_checked(), - // Call checkbox constructor with locked attribute, expects integer. - $this->is_locked() ? 1 : 0 + $this->is_disabled() ); } diff --git a/grade/report/singleview/tests/behat/singleview.feature b/grade/report/singleview/tests/behat/singleview.feature index 8036568a660..04731db3351 100644 --- a/grade/report/singleview/tests/behat/singleview.feature +++ b/grade/report/singleview/tests/behat/singleview.feature @@ -11,6 +11,7 @@ Feature: We can use Single view And the following "users" exist: | username | firstname | lastname | email | idnumber | alternatename | | teacher1 | Teacher | 1 | teacher1@example.com | t1 | fred | + | teacher2 | No edit | 1 | teacher2@example.com | t2 | nick | | student1 | Student | 1 | student1@example.com | s1 | james | | student2 | Student | 2 | student1@example.com | s2 | holly | | student3 | Student | 3 | student1@example.com | s3 | anna | @@ -27,6 +28,7 @@ Feature: We can use Single view And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + | teacher2 | C1 | teacher | | student1 | C1 | student | | student2 | C1 | student | | student3 | C1 | student | @@ -44,6 +46,10 @@ Feature: We can use Single view And the following "grade items" exist: | itemname | course | gradetype | | Test grade item | C1 | Scale | + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | moodle/grade:edit | Allow | teacher | Course | C1 | + | gradereport/singleview:view | Allow | teacher | Course | C1 | And I log in as "teacher1" And I follow "Course 1" And I navigate to "Grades" node in "Course administration" @@ -89,6 +95,14 @@ Feature: We can use Single view And the following should exist in the "generaltable" table: | First name (Alternate name) Surname | Grade | | james (Student) 1 | Very good | + And I log out + And I log in as "teacher2" + And I follow "Course 1" + And I navigate to "Grades" node in "Course administration" + And I click on "Single view" "option" + And I click on "Student 4" "option" + And the "Exclude for Test assignment one" "checkbox" should be disabled + And the "Override for Test assignment one" "checkbox" should be enabled Scenario: Single view links work on grade report. Given I follow "Single view for Test assignment one" -- 2.11.4.GIT