Commit b74d0f84 authored by David Monllaó's avatar David Monllaó Committed by Eloy Lafuente (stronk7)

MDL-52378 singleview: Using is_disabled instead of is_locked

parent 71beedee
......@@ -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'));
......
......@@ -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;
......
......@@ -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()
);
}
......
......@@ -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 follow "Grades"
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment