Merge branch 'MDL-72896-master' of git://github.com/HuongNV13/moodle

This commit is contained in:
Jun Pataleta 2021-11-09 10:45:08 +08:00
commit 76db9b294f
7 changed files with 18 additions and 6 deletions

View File

@ -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) {

View File

@ -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'));
}

View File

@ -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
*/

View File

@ -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 = <<<EOF

View File

@ -116,6 +116,9 @@ completely removed from Moodle core too.
- core_grades_external::get_grades
- core_grades_external::get_grade_item
* \core\session\manager::init_empty_session() has a new optional parameter $newsid to indicate whether this is a new user session
* New html_table attribute "$responsive" which defaults to true. When set to true, tables created via html_writer::table() will be enclosed
in a .table-responsive div container which will allow the table to be scrolled horizontally with ease, especially when the table is rendered in smaller viewports.
Set to false to prevent the table from being enclosed in the responsive container.
=== 3.11.4 ===
* A new option dontforcesvgdownload has been added to the $options parameter of the send_file() function.

View File

@ -253,7 +253,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
$pageid = $page->nextpageid;
}
return html_writer::div(html_writer::table($table), 'table-responsive');
return html_writer::table($table);
}
/**

View File

@ -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');