From 237f76ce14ede2d43cf2e460f9031780725486c8 Mon Sep 17 00:00:00 2001 From: Zachary Durber Date: Thu, 23 Oct 2014 11:53:42 +0800 Subject: [PATCH] MDL-47838 gradebook: Singleview fix for invalid links. --- .../singleview/classes/local/screen/user.php | 13 ++++++++----- .../singleview/tests/behat/singleview.feature | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/grade/report/singleview/classes/local/screen/user.php b/grade/report/singleview/classes/local/screen/user.php index cdd56d94085..f1107a06927 100644 --- a/grade/report/singleview/classes/local/screen/user.php +++ b/grade/report/singleview/classes/local/screen/user.php @@ -179,16 +179,19 @@ class user extends tablelike implements selectable_items { if (isset($item->cmid)) { $realmodid = $item->cmid; } - $url = new moodle_url('/mod/' . $item->itemmodule . '/view.php', array('id' => $realmodid)); + $iconstring = get_string('filtergrades', 'gradereport_singleview', $item->get_name()); $grade->label = $item->get_name(); + $itemlabel = $item->get_name(); + if (!empty($realmodid)) { + $url = new moodle_url('/mod/' . $item->itemmodule . '/view.php', array('id' => $realmodid)); + $itemlabel = html_writer::link($url, $item->get_name()); + } + $line = array( $OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', $iconstring)), - $this->format_icon($item) . $lockicon, - html_writer::link($url, $item->get_name()), - $this->category($item), - (new range($item)) + $this->format_icon($item) . $lockicon, $itemlabel, $this->category($item), (new range($item)) ); return $this->format_definition($line, $grade); } diff --git a/grade/report/singleview/tests/behat/singleview.feature b/grade/report/singleview/tests/behat/singleview.feature index f8f80909e9d..8683961ecec 100644 --- a/grade/report/singleview/tests/behat/singleview.feature +++ b/grade/report/singleview/tests/behat/singleview.feature @@ -15,6 +15,9 @@ Feature: We can use Single view | student2 | Student | 2 | student1@asd.com | s2 | holly | | student3 | Student | 3 | student1@asd.com | s3 | anna | | student4 | Student | 4 | student1@asd.com | s4 | zac | + And the following "grade items" exist: + | itemname | course | + | new grade item 1 | C1 | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | @@ -36,7 +39,7 @@ Feature: We can use Single view And I follow "Course 1" And I follow "Grades" - @javascript + @javascript Scenario: I can update grades, add feedback and exclude grades. Given I click on "Single view" "option" And I click on "Student 4" "option" @@ -71,10 +74,8 @@ Feature: We can use Single view And I follow "Single view for Student 1" Then I should see "Student 1" - @javascript Scenario: Navigation works in the Single view. - Given I click on "Single view" "option" - Then I click on "Student 1" "option" + 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" @@ -86,3 +87,10 @@ Feature: We can use Single view Then I should see "Test assignment three" And I follow "Test assignment four" Then I should see "Test assignment four" + + Scenario: Activities are clickable only when + it has a valid activity page. + Given I follow "Single view for Student 1" + 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"