Skip to content

Commit

Permalink
MDL-51709 gradebook: Name display in single view.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Aug 31, 2020
1 parent 38abfb6 commit b36ea08
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 57 deletions.
6 changes: 3 additions & 3 deletions grade/report/singleview/classes/local/screen/grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function init($selfitemisempty = false) {
public function original_headers() {
return array(
'', // For filter icon.
get_string('firstname') . ' (' . get_string('alternatename') . ') ' . get_string('lastname'),
get_string('fullnameuser', 'core'),
get_string('range', 'grades'),
get_string('grade', 'grades'),
get_string('feedback', 'grades'),
Expand Down Expand Up @@ -198,8 +198,8 @@ public function format_line($item) {
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked') . ' ';
}

if (!empty($item->alternatename)) {
$fullname = $lockicon . $item->alternatename . ' (' . $item->firstname . ') ' . $item->lastname;
if (has_capability('moodle/site:viewfullnames', \context_course::instance($this->courseid))) {
$fullname = $lockicon . fullname($item, true);
} else {
$fullname = $lockicon . fullname($item);
}
Expand Down
8 changes: 4 additions & 4 deletions grade/report/singleview/classes/local/ui/finalgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ public function set($value) {
}

if ($errorstr) {
$user = $DB->get_record('user', array('id' => $userid), 'id, firstname, alternatename, lastname');
$user = get_complete_user_data('id', $userid);
$gradestr = new stdClass;
if (!empty($user->alternatename)) {
$gradestr->username = $user->alternatename . ' (' . $user->firstname . ') ' . $user->lastname;
if (has_capability('moodle/site:viewfullnames', \context_course::instance($gradeitem->courseid))) {
$gradestr->username = fullname($user, true);
} else {
$gradestr->username = $user->firstname . ' ' . $user->lastname;
$gradestr->username = fullname($user);
}
$gradestr->itemname = $this->grade->grade_item->get_name();
$errorstr = get_string($errorstr, 'grades', $gradestr);
Expand Down
44 changes: 22 additions & 22 deletions grade/report/singleview/tests/behat/bulk_insert_grades.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,33 @@ Feature: We can bulk insert grades for students in a course
And I am on "Course 1" course homepage
And I navigate to "View > Grader report" in the course gradebook
And I follow "Single view for Test assignment one"
Then the field "Grade for james (Student) 1" matches value "50.00"
And the field "Override for james (Student) 1" matches value "0"
Then the field "Grade for Student 1" matches value "50.00"
And the field "Override for Student 1" matches value "0"
And I set the field "Perform bulk insert" to "1"
And I set the field "Insert value" to "1.0"
And I press "Save"
And I press "Continue"
And the field "Grade for james (Student) 1" matches value "50.00"
And the field "Override for james (Student) 1" matches value "0"
And the field "Grade for holly (Student) 2" matches value "1.00"
And the field "Override for holly (Student) 2" matches value "1"
And the field "Grade for anna (Student) 3" matches value "1.00"
And the field "Override for anna (Student) 3" matches value "1"
And the field "Grade for zac (Student) 4" matches value "1.00"
And the field "Override for zac (Student) 4" matches value "1"
And the field "Grade for Student 1" matches value "50.00"
And the field "Override for Student 1" matches value "0"
And the field "Grade for Student 2" matches value "1.00"
And the field "Override for Student 2" matches value "1"
And the field "Grade for Student 3" matches value "1.00"
And the field "Override for Student 3" matches value "1"
And the field "Grade for Student 4" matches value "1.00"
And the field "Override for Student 4" matches value "1"
And I set the field "For" to "All grades"
And I set the field "Perform bulk insert" to "1"
And I set the field "Insert value" to "2.0"
And I press "Save"
And I press "Continue"
And the field "Grade for james (Student) 1" matches value "2.00"
And the field "Override for james (Student) 1" matches value "1"
And the field "Grade for holly (Student) 2" matches value "2.00"
And the field "Override for holly (Student) 2" matches value "1"
And the field "Grade for anna (Student) 3" matches value "2.00"
And the field "Override for anna (Student) 3" matches value "1"
And the field "Grade for zac (Student) 4" matches value "2.00"
And the field "Override for zac (Student) 4" matches value "1"
And the field "Grade for Student 1" matches value "2.00"
And the field "Override for Student 1" matches value "1"
And the field "Grade for Student 2" matches value "2.00"
And the field "Override for Student 2" matches value "1"
And the field "Grade for Student 3" matches value "2.00"
And the field "Override for Student 3" matches value "1"
And the field "Grade for Student 4" matches value "2.00"
And the field "Override for Student 4" matches value "1"

Scenario: I can bulk insert grades and check their override flags for user view.
Given I log in as "teacher1"
Expand Down Expand Up @@ -110,8 +110,8 @@ Feature: We can bulk insert grades for students in a course
And I set the field "Perform bulk insert" to "1"
When I set the field "Insert value" to "-1"
And I press "Save"
Then I should see "The grade entered for Test assignment one for james (Student) 1 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for holly (Student) 2 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for anna (Student) 3 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for zac (Student) 4 is less than the minimum allowed"
Then I should see "The grade entered for Test assignment one for Student 1 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for Student 2 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for Student 3 is less than the minimum allowed"
And I should see "The grade entered for Test assignment one for Student 4 is less than the minimum allowed"
And I should see "Grades were set for 0 items"
59 changes: 31 additions & 28 deletions grade/report/singleview/tests/behat/singleview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Feature: We can use Single view
| fullname | shortname | category |
| Course 1 | C1 | 0 |
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 |
| student4 | Student | 4 | student1@example.com | s4 | zac |
| username | firstname | lastname | email | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic |
| teacher1 | Teacher | 1 | teacher1@example.com | t1 | | fred | | |
| teacher2 | No edit | 1 | teacher2@example.com | t2 | | nick | | |
| student1 | Grainne | Beauchamp | student1@example.com | s1 | Ann | Jill | Gronya | Beecham |
| student2 | Niamh | Cholmondely | student2@example.com | s2 | Jane | Nina | Nee | Chumlee |
| student3 | Siobhan | Desforges | student3@example.com | s3 | Sarah | Sev | Shevon | De-forjay |
| student4 | Student | 4 | student4@example.com | s4 | | zac | | |
And the following "scales" exist:
| name | scale |
| Test Scale | Disappointing, Good, Very good, Excellent |
Expand Down Expand Up @@ -50,14 +50,17 @@ Feature: We can use Single view
| capability | permission | role | contextlevel | reference |
| moodle/grade:edit | Allow | teacher | Course | C1 |
| gradereport/singleview:view | Allow | teacher | Course | C1 |
And the following config values are set as admin:
| fullnamedisplay | firstnamephonetic,lastnamephonetic |
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
And I log in as "teacher1"
And I am on "Course 1" course homepage
Given I navigate to "View > Grader report" in the course gradebook

@javascript
Scenario: I can update grades, add feedback and exclude grades.
Given I navigate to "View > Single view" in the course gradebook
And I select "Student 4" from the "Select user..." singleselect
And I select "Student" from the "Select user..." singleselect
And I set the field "Override for Test assignment one" to "1"
When I set the following fields to these values:
| Grade for Test assignment one | 10.00 |
Expand All @@ -76,55 +79,55 @@ Feature: We can use Single view
And the field "Grade for Test grade item" matches value "45.00"
And the field "Grade for Course total" matches value "55.00"
And I click on "Show grades for Test assignment three" "link"
And I click on "Override for james (Student) 1" "checkbox"
And I click on "Override for Ann, Jill, Grainne, Beauchamp" "checkbox"
And I set the following fields to these values:
| Grade for james (Student) 1 | 12.05 |
| Feedback for james (Student) 1 | test data2 |
And I set the field "Exclude for holly (Student) 2" to "1"
| Grade for Ann, Jill, Grainne, Beauchamp | 12.05 |
| Feedback for Ann, Jill, Grainne, Beauchamp | test data2 |
And I set the field "Exclude for Jane, Nina, Niamh, Cholmondely" to "1"
And I press "Save"
Then I should see "Grades were set for 2 items"
And I press "Continue"
And the field "Grade for james (Student) 1" matches value "12.05"
And the field "Exclude for holly (Student) 2" matches value "1"
And the field "Grade for Ann, Jill, Grainne, Beauchamp" matches value "12.05"
And the field "Exclude for Jane, Nina, Niamh, Cholmondely" matches value "1"
And I select "new grade item 1" from the "Select grade item..." singleselect
And I set the field "Grade for james (Student) 1" to "Very good"
And I set the field "Grade for Ann, Jill, Grainne, Beauchamp" to "Very good"
And I press "Save"
Then I should see "Grades were set for 1 items"
And I press "Continue"
And the following should exist in the "generaltable" table:
| First name (Alternate name) Surname | Grade |
| james (Student) 1 | Very good |
| Ann, Jill, Grainne, Beauchamp | Very good |
And I log out
And I log in as "teacher2"
And I am on "Course 1" course homepage
Given I navigate to "View > Single view" in the course gradebook
And I select "Student 4" from the "Select user..." singleselect
And I select "Student" from the "Select user..." singleselect
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"
Then I should see "Test assignment one"
Then I navigate to "View > Grader report" in the course gradebook
And I follow "Single view for Student 1"
Then I should see "Student 1"
And I follow "Single view for Ann, Jill, Grainne, Beauchamp"
Then I should see "Gronya,Beecham"

Scenario: I can bulk update grades.
Given I follow "Single view for Student 1"
Then I should see "Student 1"
Given I follow "Single view for Ann, Jill, Grainne, Beauchamp"
Then I should see "Gronya,Beecham"
When I set the field "For" to "All grades"
And I set the field "Insert value" to "1.0"
And I set the field "Perform bulk insert" to "1"
And I press "Save"
Then I should see "Grades were set for 6 items"

Scenario: Navigation works in the Single view.
Given I follow "Single view for Student 1"
Then I should see "Student 1"
And I follow "Student 2"
Then I should see "Student 2"
And I follow "Student 1"
Then I should see "Student 1"
Given I follow "Single view for Ann, Jill, Grainne, Beauchamp"
Then I should see "Gronya,Beecham"
And I follow "Nee,Chumlee"
Then I should see "Nee,Chumlee"
And I follow "Gronya,Beecham"
Then I should see "Gronya,Beecham"
And I click on "Show grades for Test assignment four" "link"
Then I should see "Test assignment four"
And I follow "Test assignment three"
Expand All @@ -134,7 +137,7 @@ Feature: We can use Single view

Scenario: Activities are clickable only when
it has a valid activity page.
Given I follow "Single view for Student 1"
Given I follow "Single view for Ann, Jill, Grainne, Beauchamp"
And "new grade item 1" "link" should not exist in the "//tbody//tr[position()=1]//td[position()=2]" "xpath_element"
Then "Category total" "link" should not exist in the "//tbody//tr[position()=2]//td[position()=2]" "xpath_element"
And "Course total" "link" should not exist in the "//tbody//tr[position()=last()]//td[position()=2]" "xpath_element"

0 comments on commit b36ea08

Please sign in to comment.