diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 6d6d0da151a..a05fe1fffce 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -1278,6 +1278,8 @@ class grade_report_grader extends grade_report { $fulltable->id = 'user-grades'; $fulltable->caption = get_string('summarygrader', 'gradereport_grader'); $fulltable->captionhide = true; + // We don't want the table to be enclosed within in a .table-responsive div as it is heavily customised. + $fulltable->responsive = false; // Extract rows from each side (left and right) and collate them into one row each foreach ($leftrows as $key => $row) { diff --git a/group/tests/behat/behat_groups.php b/group/tests/behat/behat_groups.php index 86be91b6e9b..a39c0684300 100644 --- a/group/tests/behat/behat_groups.php +++ b/group/tests/behat/behat_groups.php @@ -77,8 +77,8 @@ class behat_groups extends behat_base { foreach ($groups as $groupname) { // Find the table after the H3 containing the grouping name, then look for the group name in the first column. - $xpath = "//h3[normalize-space(.) = '{$grouping}']/following-sibling::table//tr//". - "td[contains(concat(' ', normalize-space(@class), ' '), ' c0 ')][normalize-space(.) = '{$groupname}' ]"; + $xpath = "//h3[normalize-space(.) = '{$grouping}']/following-sibling::div[contains(@class, 'table-responsive')]" . + "/table//tr//td[contains(concat(' ', normalize-space(@class), ' '), ' c0 ')][normalize-space(.) = '{$groupname}' ]"; $this->execute('behat_general::should_exist', array($xpath, 'xpath_element')); } diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 5d08843f9b2..28c3464ceb1 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -2321,6 +2321,10 @@ class html_writer { } $output .= html_writer::end_tag('table') . "\n"; + if ($table->responsive) { + return self::div($output, 'table-responsive'); + } + return $output; } @@ -2772,6 +2776,9 @@ class html_table { */ public $captionhide = false; + /** @var bool Whether to make the table to be scrolled horizontally with ease. Make table responsive across all viewports. */ + public $responsive = true; + /** * Constructor */ diff --git a/lib/tests/html_writer_test.php b/lib/tests/html_writer_test.php index 7e70965982a..c2431b85566 100644 --- a/lib/tests/html_writer_test.php +++ b/lib/tests/html_writer_test.php @@ -193,6 +193,7 @@ class core_html_writer_testcase extends basic_testcase { $row->cells[] = $cell; $table = new html_table(); + $table->responsive = false; // The attribute will get overwritten by the ID. $table->id = 'Jeffrey'; $table->attributes['id'] = 'will get overwritten'; @@ -230,6 +231,7 @@ EOF; ); $table->caption = "Who even knows?"; $table->captionhide = true; + $table->responsive = false; $output = html_writer::table($table); $expected = <<nextpageid; } - return html_writer::div(html_writer::table($table), 'table-responsive'); + return html_writer::table($table); } /** diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 28d942202a0..6c2991ac180 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -140,7 +140,7 @@ if ($action === 'delete') { } // The attempts table. - $attemptstable = html_writer::div(html_writer::table($table), 'table-responsive'); + $attemptstable = html_writer::table($table); // The HTML that we will be displaying which includes the attempts table and bulk actions menu, if necessary. $attemptshtml = $attemptstable; @@ -352,9 +352,7 @@ if ($action === 'delete') { } else { $table->data[] = array(get_string('didnotanswerquestion', 'lesson'), " "); } - echo html_writer::start_tag('div', ['class' => 'no-overflow table-responsive']); echo html_writer::table($table); - echo html_writer::end_tag('div'); } } else { print_error('unknowaction');