diff --git a/mod/quiz/classes/output/attempt_summary_information.php b/mod/quiz/classes/output/attempt_summary_information.php
index bea6737229f..7944d9f77c8 100644
--- a/mod/quiz/classes/output/attempt_summary_information.php
+++ b/mod/quiz/classes/output/attempt_summary_information.php
@@ -47,6 +47,9 @@ class attempt_summary_information implements renderable, named_templatable {
/** @var array[] The rows of summary data. {@see add_item()} should make the structure clear. */
protected array $summarydata = [];
+ /** @var string The caption for attempt summary table. */
+ protected string $caption = '';
+
/**
* Add an item to the summary.
*
@@ -61,6 +64,15 @@ class attempt_summary_information implements renderable, named_templatable {
];
}
+ /**
+ * Set the caption for the summary table.
+ *
+ * @param string $caption
+ */
+ public function set_caption(string $caption): void {
+ $this->caption = $caption;
+ }
+
/**
* Add an item to the summary just before the given item.
*
@@ -209,6 +221,9 @@ class attempt_summary_information implements renderable, named_templatable {
}
}
+ // Caption.
+ $summary->set_caption(get_string('summaryofattemptscaption', 'quiz', $attemptobj->get_attempt_number()));
+
// Attempt state.
$summary->add_item('state', get_string('attemptstate', 'quiz'),
quiz_attempt::state_name($attemptobj->get_attempt()->state));
@@ -321,6 +336,7 @@ class attempt_summary_information implements renderable, named_templatable {
$templatecontext = [
'hasitems' => !empty($this->summarydata),
'items' => [],
+ 'caption' => $this->caption,
];
foreach ($this->summarydata as $item) {
if ($item['title'] instanceof renderable) {
diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php
index 37ef4d9a62d..8c6e9872560 100644
--- a/mod/quiz/comment.php
+++ b/mod/quiz/comment.php
@@ -58,7 +58,8 @@ echo $output->header();
// Prepare summary information about this question attempt.
$summary = new attempt_summary_information();
-
+// Set the caption.
+$summary->set_caption(get_string('summaryofattempt', 'quiz'));
// Student name.
$userpicture = new user_picture($student);
$userpicture->courseid = $attemptobj->get_courseid();
diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php
index 4855af58382..5837b272abb 100644
--- a/mod/quiz/lang/en/quiz.php
+++ b/mod/quiz/lang/en/quiz.php
@@ -1108,6 +1108,7 @@ $string['subplugintype_quizaccess_plural'] = 'Access rules';
$string['substitutedby'] = 'will be substituted by';
$string['summaryofattempt'] = 'Summary of attempt';
$string['summaryofattempts'] = 'Your attempts';
+$string['summaryofattemptscaption'] = 'Attempt {$a} summary';
$string['temporaryblocked'] = 'You are temporarily not allowed to re-attempt the quiz.
You will be able to take another attempt on:';
$string['theattempt'] = 'The attempt';
$string['theattempt_help'] = 'Whether the student can review the attempt at all.';
diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php
index 54f1519c7aa..d82a4703925 100644
--- a/mod/quiz/reviewquestion.php
+++ b/mod/quiz/reviewquestion.php
@@ -77,6 +77,8 @@ if ($attemptobj->is_own_attempt()) {
// Prepare summary informat about this question attempt.
$summary = new attempt_summary_information();
+// Set the caption.
+$summary->set_caption(get_string('summaryofattempt', 'quiz'));
// Student name.
$userpicture = new user_picture($student);
diff --git a/mod/quiz/templates/attempt_summary_information.mustache b/mod/quiz/templates/attempt_summary_information.mustache
index 1f3a84157bf..de574ca2b97 100644
--- a/mod/quiz/templates/attempt_summary_information.mustache
+++ b/mod/quiz/templates/attempt_summary_information.mustache
@@ -29,11 +29,15 @@
{"title": "Completed", "content": "Thursday, 23 November 2023, 9:32 AM"},
{"title": "Duration", "content": "3 minutes"},
{"title": "Grade", "content": "Not yet graded"}
- ]
+ ],
+ "caption": "Summary of attempt"
}
}}
{{#hasitems}}