mirror of
https://github.com/moodle/moodle.git
synced 2025-03-20 07:30:01 +01:00
MDL-78749 Accessibility\Quiz: Previous attempt table caption missing
This commit is contained in:
parent
272fdb321a
commit
1408e3b964
@ -1082,6 +1082,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
$table->head = array();
|
||||
$table->align = array();
|
||||
$table->size = array();
|
||||
$table->caption = get_string('summaryofattempts', 'quiz');
|
||||
$table->captionhide = true;
|
||||
if ($viewobj->attemptcolumn) {
|
||||
$table->head[] = get_string('attemptnumber', 'quiz');
|
||||
$table->align[] = 'center';
|
||||
|
@ -507,4 +507,56 @@ class attempt_test extends \advanced_testcase {
|
||||
$this->expectExceptionObject(new \moodle_exception('questiondraftonly', 'mod_quiz', '', $question->name));
|
||||
quiz_start_attempt_built_on_last($quba, $newattempt, $attempt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting a new attempt and check the summary previous attempts table.
|
||||
*
|
||||
* @covers ::view_table()
|
||||
*/
|
||||
public function test_view_table(): void {
|
||||
global $PAGE;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$timenow = time();
|
||||
// Create attempt object.
|
||||
$attempt = $this->create_quiz_and_attempt_with_layout('1,1,0');
|
||||
// Finish attempt.
|
||||
$attempt->process_finish($timenow, false);
|
||||
|
||||
$quiz = $attempt->get_quiz();
|
||||
$context = $attempt->get_quizobj()->get_context();
|
||||
|
||||
// Prepare view object.
|
||||
$viewobj = new \mod_quiz_view_object();
|
||||
$viewobj->attemptcolumn = true;
|
||||
$viewobj->markcolumn = true;
|
||||
$viewobj->gradecolumn = true;
|
||||
$viewobj->canreviewmine = true;
|
||||
$viewobj->mygrade = 0.00;
|
||||
$viewobj->feedbackcolumn = false;
|
||||
$viewobj->attempts = $attempt;
|
||||
$viewobj->attemptobjs[] = new quiz_attempt($attempt->get_attempt(),
|
||||
$quiz, $attempt->get_cm(), $attempt->get_course(), false);
|
||||
$viewobj->accessmanager = new \quiz_access_manager($attempt->get_quizobj(), $timenow,
|
||||
has_capability('mod/quiz:ignoretimelimits', $context, null, false));
|
||||
|
||||
// Render summary previous attempts table.
|
||||
$renderer = $PAGE->get_renderer('mod_quiz');
|
||||
$table = $renderer->view_table($quiz, $context, $viewobj);
|
||||
$captionpattern = '/<caption\b[^>]*>' . get_string('summaryofattempts', 'quiz') . '<\/caption>/';
|
||||
|
||||
// Check caption existed.
|
||||
$this->assertMatchesRegularExpression($captionpattern, $table);
|
||||
// Check column attempt.
|
||||
$this->assertMatchesRegularExpression('/<td\b[^>]*>' . $attempt->get_attempt_number() . '<\/td>/', $table);
|
||||
// Check column state.
|
||||
$this->assertMatchesRegularExpression('/<td\b[^>]*>' . ucfirst($attempt->get_state()) . '.+?<\/td>/', $table);
|
||||
// Check column marks.
|
||||
$this->assertMatchesRegularExpression('/<td\b[^>]* c2.+?' .
|
||||
quiz_format_grade($quiz, $attempt->get_sum_marks()) .'<\/td>/', $table);
|
||||
// Check column grades.
|
||||
$this->assertMatchesRegularExpression('/<td\b[^>]* c2.+?0\.00<\/td>/', $table);
|
||||
// Check column review.
|
||||
$this->assertMatchesRegularExpression('/<td\b[^>]*>.+?Review<\/a><\/td>/', $table);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user