Merge branch 'MDL-71785_master' of https://github.com/StudiUM/moodle

This commit is contained in:
Andrew Nicols 2021-10-19 11:19:06 +08:00
commit da98ed6ea2
4 changed files with 29 additions and 7 deletions

View File

@ -2756,8 +2756,12 @@ abstract class quiz_nav_panel_base {
public function get_question_buttons() {
$buttons = array();
foreach ($this->attemptobj->get_slots() as $slot) {
if ($heading = $this->attemptobj->get_heading_before_slot($slot)) {
$buttons[] = new quiz_nav_section_heading(format_string($heading));
$heading = $this->attemptobj->get_heading_before_slot($slot);
if (!is_null($heading)) {
$sections = $this->attemptobj->get_quizobj()->get_sections();
if (!(empty($heading) && count($sections) == 1)) {
$buttons[] = new quiz_nav_section_heading(format_string($heading));
}
}
$qa = $this->attemptobj->get_question_attempt($slot);

View File

@ -892,6 +892,7 @@ $string['scores'] = 'Scores';
$string['search:activity'] = 'Quiz - activity information';
$string['sectionheadingedit'] = 'Edit heading \'{$a}\'';
$string['sectionheadingremove'] = 'Remove heading \'{$a}\'';
$string['sectionnoname'] = '(Untitled section)';
$string['seequestions'] = '(See questions)';
$string['select'] = 'Select';
$string['selectall'] = 'Select all';

View File

@ -395,7 +395,14 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @return string HTML fragment.
*/
protected function render_quiz_nav_section_heading(quiz_nav_section_heading $heading) {
return $this->heading($heading->heading, 3, 'mod_quiz-section-heading');
if (empty($heading->heading)) {
$headingtext = get_string('sectionnoname', 'quiz');
$class = ' dimmed_text';
} else {
$headingtext = $heading->heading;
$class = '';
}
return $this->heading($headingtext, 3, 'mod_quiz-section-heading' . $class);
}
/**
@ -671,7 +678,16 @@ class mod_quiz_renderer extends plugin_renderer_base {
// Add a section headings if we need one here.
$heading = $attemptobj->get_heading_before_slot($slot);
if ($heading) {
$cell = new html_table_cell(format_string($heading));
$heading = format_string($heading);
}
$sections = $attemptobj->get_quizobj()->get_sections();
if (!is_null($heading) && empty($heading) && count($sections) > 1) {
$heading = get_string('sectionnoname', 'quiz');
$heading = \html_writer::span($heading, 'dimmed_text');
}
if ($heading) {
$cell = new html_table_cell($heading);
$cell->header = true;
$cell->colspan = $tablewidth;
$table->data[] = array($cell);

View File

@ -79,7 +79,7 @@ Feature: Attempt a quiz
And I should see question "1" in section "Section 1" in the quiz navigation
And I should see question "2" in section "Section 1" in the quiz navigation
And I should see question "3" in section "Section 2" in the quiz navigation
And I should see question "4" in section "Section 2" in the quiz navigation
And I should see question "4" in section "(Untitled section)" in the quiz navigation
And I should see question "5" in section "Section 3" in the quiz navigation
And I should see question "6" in section "Section 3" in the quiz navigation
@ -87,11 +87,12 @@ Feature: Attempt a quiz
And I should see question "1" in section "Section 1" in the quiz navigation
And I should see question "2" in section "Section 1" in the quiz navigation
And I should see question "3" in section "Section 2" in the quiz navigation
And I should see question "4" in section "Section 2" in the quiz navigation
And I should see question "4" in section "(Untitled section)" in the quiz navigation
And I should see question "5" in section "Section 3" in the quiz navigation
And I should see question "6" in section "Section 3" in the quiz navigation
And I should see "Section 1" in the "quizsummaryofattempt" "table"
And I should see "Section 2" in the "quizsummaryofattempt" "table"
And I should see "(Untitled section)" in the "quizsummaryofattempt" "table"
And I should see "Section 3" in the "quizsummaryofattempt" "table"
And I press "Submit all and finish"
@ -99,7 +100,7 @@ Feature: Attempt a quiz
And I should see question "1" in section "Section 1" in the quiz navigation
And I should see question "2" in section "Section 1" in the quiz navigation
And I should see question "3" in section "Section 2" in the quiz navigation
And I should see question "4" in section "Section 2" in the quiz navigation
And I should see question "4" in section "(Untitled section)" in the quiz navigation
And I should see question "5" in section "Section 3" in the quiz navigation
And I should see question "6" in section "Section 3" in the quiz navigation