MDL-41615 quiz_mod: fix heading levels for usability and accessibility

This commit is contained in:
rwijaya 2013-11-05 18:52:24 +08:00
parent d214057cad
commit c544ee92f5
23 changed files with 86 additions and 32 deletions

View file

@ -123,7 +123,7 @@ if (!$quizname = $DB->get_field($cm->modname, 'name', array('id' => $cm->instanc
print_error('invalidcoursemodule'); print_error('invalidcoursemodule');
} }
echo $OUTPUT->heading(get_string('addrandomquestiontoquiz', 'quiz', $quizname), 2, 'mdl-left'); echo $OUTPUT->heading(get_string('addrandomquestiontoquiz', 'quiz', $quizname), 2);
$mform->display(); $mform->display();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

View file

@ -50,8 +50,24 @@ add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?atte
// Print the page header. // Print the page header.
$PAGE->set_pagelayout('popup'); $PAGE->set_pagelayout('popup');
echo $OUTPUT->header(); $PAGE->set_heading($attemptobj->get_course()->fullname);
echo $OUTPUT->heading(format_string($attemptobj->get_question_name($slot))); $output = $PAGE->get_renderer('mod_quiz');
echo $output->header();
// Prepare summary information about this question attempt.
$summarydata = array();
// Quiz name.
$summarydata['quizname'] = array(
'title' => get_string('modulename', 'quiz'),
'content' => format_string($attemptobj->get_quiz_name()),
);
// Question name.
$summarydata['questionname'] = array(
'title' => get_string('question', 'quiz'),
'content' => $attemptobj->get_question_name($slot),
);
// Process any data that was submitted. // Process any data that was submitted.
if (data_submitted() && confirm_sesskey()) { if (data_submitted() && confirm_sesskey()) {
@ -59,12 +75,15 @@ if (data_submitted() && confirm_sesskey()) {
$transaction = $DB->start_delegated_transaction(); $transaction = $DB->start_delegated_transaction();
$attemptobj->process_submitted_actions(time()); $attemptobj->process_submitted_actions(time());
$transaction->allow_commit(); $transaction->allow_commit();
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess'); echo $output->notification(get_string('changessaved'), 'notifysuccess');
close_window(2, true); close_window(2, true);
die; die;
} }
} }
// Print quiz information.
echo $output->review_summary_table($summarydata, 0);
// Print the comment form. // Print the comment form.
echo '<form method="post" class="mform" id="manualgradingform" action="' . echo '<form method="post" class="mform" id="manualgradingform" action="' .
$CFG->wwwroot . '/mod/quiz/comment.php">'; $CFG->wwwroot . '/mod/quiz/comment.php">';
@ -91,4 +110,4 @@ echo '</form>';
$PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module()); $PAGE->requires->js_init_call('M.mod_quiz.init_comment_popup', null, false, quiz_get_js_module());
// End of the page. // End of the page.
echo $OUTPUT->footer(); echo $output->footer();

View file

@ -56,6 +56,7 @@ $PAGE->set_title($strquizzes);
$PAGE->set_button($streditquestions); $PAGE->set_button($streditquestions);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($strquizzes, 2);
// Get all the appropriate data. // Get all the appropriate data.
if (!$quizzes = get_all_instances_in_course("quiz", $course)) { if (!$quizzes = get_all_instances_in_course("quiz", $course)) {

View file

@ -80,6 +80,7 @@ $PAGE->set_title($title);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
if ($override->groupid) { if ($override->groupid) {
$group = $DB->get_record('groups', array('id' => $override->groupid), 'id, name'); $group = $DB->get_record('groups', array('id' => $override->groupid), 'id, name');

View file

@ -194,7 +194,7 @@ $PAGE->set_pagelayout('admin');
$PAGE->set_title($pagetitle); $PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading($pagetitle); echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
$mform->display(); $mform->display();

View file

@ -72,6 +72,7 @@ $PAGE->set_pagelayout('admin');
$PAGE->set_title(get_string('overrides', 'quiz')); $PAGE->set_title(get_string('overrides', 'quiz'));
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
// Delete orphaned group overrides. // Delete orphaned group overrides.
$sql = 'SELECT o.id $sql = 'SELECT o.id

View file

@ -99,6 +99,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
public function review_question_not_allowed($message) { public function review_question_not_allowed($message) {
$output = ''; $output = '';
$output .= $this->header(); $output .= $this->header();
$output .= $this->heading(format_string($attemptobj->get_quiz_name(), true,
array("context" => $attemptobj->get_quizobj()->get_context())));
$output .= $this->notification($message); $output .= $this->notification($message);
$output .= $this->close_window_button(); $output .= $this->close_window_button();
$output .= $this->footer(); $output .= $this->footer();
@ -392,6 +394,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
public function start_attempt_page(quiz $quizobj, mod_quiz_preflight_check_form $mform) { public function start_attempt_page(quiz $quizobj, mod_quiz_preflight_check_form $mform) {
$output = ''; $output = '';
$output .= $this->header(); $output .= $this->header();
$output .= $this->heading(format_string($quizobj->get_quiz_name(), true,
array("context" => $quizobj->get_context())));
$output .= $this->quiz_intro($quizobj->get_quiz(), $quizobj->get_cm()); $output .= $this->quiz_intro($quizobj->get_quiz(), $quizobj->get_cm());
ob_start(); ob_start();
$mform->display(); $mform->display();
@ -879,7 +883,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
* Generates the table heading. * Generates the table heading.
*/ */
public function view_table_heading() { public function view_table_heading() {
return $this->heading(get_string('summaryofattempts', 'quiz')); return $this->heading(get_string('summaryofattempts', 'quiz'), 3);
} }
/** /**
@ -1052,14 +1056,13 @@ class mod_quiz_renderer extends plugin_renderer_base {
$a->method = quiz_get_grading_option_name($quiz->grademethod); $a->method = quiz_get_grading_option_name($quiz->grademethod);
$a->mygrade = quiz_format_grade($quiz, $viewobj->mygrade); $a->mygrade = quiz_format_grade($quiz, $viewobj->mygrade);
$a->quizgrade = quiz_format_grade($quiz, $quiz->grade); $a->quizgrade = quiz_format_grade($quiz, $quiz->grade);
$resultinfo .= $this->heading(get_string('gradesofar', 'quiz', $a), 2, 'main'); $resultinfo .= $this->heading(get_string('gradesofar', 'quiz', $a), 3);
} else { } else {
$a = new stdClass(); $a = new stdClass();
$a->grade = quiz_format_grade($quiz, $viewobj->mygrade); $a->grade = quiz_format_grade($quiz, $viewobj->mygrade);
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade); $a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
$a = get_string('outofshort', 'quiz', $a); $a = get_string('outofshort', 'quiz', $a);
$resultinfo .= $this->heading(get_string('yourfinalgradeis', 'quiz', $a), 2, $resultinfo .= $this->heading(get_string('yourfinalgradeis', 'quiz', $a), 3);
'main');
} }
} }
@ -1069,11 +1072,11 @@ class mod_quiz_renderer extends plugin_renderer_base {
array('class' => 'overriddennotice'))."\n"; array('class' => 'overriddennotice'))."\n";
} }
if ($viewobj->gradebookfeedback) { if ($viewobj->gradebookfeedback) {
$resultinfo .= $this->heading(get_string('comment', 'quiz'), 3, 'main'); $resultinfo .= $this->heading(get_string('comment', 'quiz'), 3);
$resultinfo .= html_writer::div($viewobj->gradebookfeedback, 'quizteacherfeedback') . "\n"; $resultinfo .= html_writer::div($viewobj->gradebookfeedback, 'quizteacherfeedback') . "\n";
} }
if ($viewobj->feedbackcolumn) { if ($viewobj->feedbackcolumn) {
$resultinfo .= $this->heading(get_string('overallfeedback', 'quiz'), 3, 'main'); $resultinfo .= $this->heading(get_string('overallfeedback', 'quiz'), 3);
$resultinfo .= html_writer::div( $resultinfo .= html_writer::div(
quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context), quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context),
'quizgradefeedback') . "\n"; 'quizgradefeedback') . "\n";
@ -1157,7 +1160,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
$graph = html_writer::empty_tag('img', array('src' => $url, 'alt' => $title)); $graph = html_writer::empty_tag('img', array('src' => $url, 'alt' => $title));
return $this->heading($title) . html_writer::tag('div', $graph, array('class' => 'graph')); return $this->heading($title, 3) . html_writer::tag('div', $graph, array('class' => 'graph'));
} }
} }

View file

@ -67,6 +67,8 @@ abstract class quiz_default_report {
$PAGE->set_title(format_string($quiz->name)); $PAGE->set_title(format_string($quiz->name));
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
echo $OUTPUT->header(); echo $OUTPUT->header();
$context = context_module::instance($cm->id);
echo $OUTPUT->heading(format_string($quiz->name, true, array('context' => $context)));
} }
/** /**

View file

@ -276,7 +276,7 @@ class quiz_grading_report extends quiz_default_report {
groups_print_activity_menu($this->cm, $this->list_questions_url()); groups_print_activity_menu($this->cm, $this->list_questions_url());
} }
echo $OUTPUT->heading(get_string('questionsthatneedgrading', 'quiz_grading')); echo $OUTPUT->heading(get_string('questionsthatneedgrading', 'quiz_grading'), 3);
if ($includeauto) { if ($includeauto) {
$linktext = get_string('hideautomaticallygraded', 'quiz_grading'); $linktext = get_string('hideautomaticallygraded', 'quiz_grading');
} else { } else {
@ -316,7 +316,7 @@ class quiz_grading_report extends quiz_default_report {
} }
if (empty($data)) { if (empty($data)) {
echo $OUTPUT->heading(get_string('nothingfound', 'quiz_grading')); echo $OUTPUT->notification(get_string('nothingfound', 'quiz_grading'));
return; return;
} }
@ -375,7 +375,7 @@ class quiz_grading_report extends quiz_default_report {
$a = new stdClass(); $a = new stdClass();
$a->number = $this->questions[$slot]->number; $a->number = $this->questions[$slot]->number;
$a->questionname = format_string($counts->name); $a->questionname = format_string($counts->name);
echo $OUTPUT->heading(get_string('gradingquestionx', 'quiz_grading', $a)); echo $OUTPUT->heading(get_string('gradingquestionx', 'quiz_grading', $a), 3);
echo html_writer::tag('p', html_writer::link($this->list_questions_url(), echo html_writer::tag('p', html_writer::link($this->list_questions_url(),
get_string('backtothelistofquestions', 'quiz_grading')), get_string('backtothelistofquestions', 'quiz_grading')),
array('class' => 'mdl-align')); array('class' => 'mdl-align'));

View file

@ -310,7 +310,7 @@ class quiz_overview_report extends quiz_attempts_report {
*/ */
protected function finish_regrade($nexturl) { protected function finish_regrade($nexturl) {
global $OUTPUT, $PAGE; global $OUTPUT, $PAGE;
echo $OUTPUT->heading(get_string('regradecomplete', 'quiz_overview')); echo $OUTPUT->heading(get_string('regradecomplete', 'quiz_overview'), 3);
echo $OUTPUT->continue_button($nexturl); echo $OUTPUT->continue_button($nexturl);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
die(); die();

View file

@ -233,13 +233,13 @@ class quiz_statistics_report extends quiz_default_report {
} else { } else {
// On-screen display of overview report. // On-screen display of overview report.
echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics')); echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 3);
echo $this->output_caching_info($quizstats, $quiz->id, $groupstudents, $whichattempts, $reporturl); echo $this->output_caching_info($quizstats, $quiz->id, $groupstudents, $whichattempts, $reporturl);
echo $this->everything_download_options(); echo $this->everything_download_options();
$quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz); $quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
echo $this->output_quiz_info_table($quizinfo); echo $this->output_quiz_info_table($quizinfo);
if ($quizstats->s()) { if ($quizstats->s()) {
echo $OUTPUT->heading(get_string('quizstructureanalysis', 'quiz_statistics')); echo $OUTPUT->heading(get_string('quizstructureanalysis', 'quiz_statistics'), 3);
$this->output_quiz_structure_analysis_table($quizstats->s(), $questionstats, $subquestionstats); $this->output_quiz_structure_analysis_table($quizstats->s(), $questionstats, $subquestionstats);
$this->output_statistics_graph($quiz->id, $currentgroup, $whichattempts); $this->output_statistics_graph($quiz->id, $currentgroup, $whichattempts);
} }
@ -305,10 +305,10 @@ class quiz_statistics_report extends quiz_default_report {
} }
// Display the various bits. // Display the various bits.
echo $OUTPUT->heading(get_string('questioninformation', 'quiz_statistics')); echo $OUTPUT->heading(get_string('questioninformation', 'quiz_statistics'), 3);
echo html_writer::table($questioninfotable); echo html_writer::table($questioninfotable);
echo $this->render_question_text($questionstat->question); echo $this->render_question_text($questionstat->question);
echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics')); echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics'), 3);
echo html_writer::table($questionstatstable); echo html_writer::table($questionstatstable);
} }
@ -347,7 +347,7 @@ class quiz_statistics_report extends quiz_default_report {
$qtable->export_class_instance($exportclass); $qtable->export_class_instance($exportclass);
if (!$this->table->is_downloading()) { if (!$this->table->is_downloading()) {
// Output an appropriate title. // Output an appropriate title.
echo $OUTPUT->heading(get_string('analysisofresponses', 'quiz_statistics')); echo $OUTPUT->heading(get_string('analysisofresponses', 'quiz_statistics'), 3);
} else { } else {
// Work out an appropriate title. // Work out an appropriate title.
@ -447,7 +447,7 @@ class quiz_statistics_report extends quiz_default_report {
// XHTML download is a special case. // XHTML download is a special case.
if ($this->table->is_downloading() == 'xhtml') { if ($this->table->is_downloading() == 'xhtml') {
echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics')); echo $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 3);
echo $this->output_quiz_info_table($quizinfo); echo $this->output_quiz_info_table($quizinfo);
return; return;
} }

View file

@ -1,7 +1,13 @@
This files describes API changes for quiz report plugins. This files describes API changes for quiz report plugins.
Overview of this plugin type at http://docs.moodle.org/dev/Quiz_reports Overview of this plugin type at http://docs.moodle.org/dev/Quiz_reports
=== 2.6 ===
* Improving the display page and heading levels to have a proper nesting.
We are reducing the amount of white spaces for the top report by making
'separate group' options and attempts to be displayed inline.
In grading report, we are changing 'no questions' from using heading to
notification message. (MDL-41615)
=== 2.3 === === 2.3 ===

View file

@ -50,6 +50,7 @@ $accessmanager = $attemptobj->get_access_manager(time());
$options = $attemptobj->get_display_options(true); $options = $attemptobj->get_display_options(true);
$PAGE->set_pagelayout('popup'); $PAGE->set_pagelayout('popup');
$PAGE->set_heading($attemptobj->get_course()->fullname);
$output = $PAGE->get_renderer('mod_quiz'); $output = $PAGE->get_renderer('mod_quiz');
// Check permissions. // Check permissions.

View file

@ -48,6 +48,7 @@ $PAGE->set_url($quizobj->view_url());
// Check login and sesskey. // Check login and sesskey.
require_login($quizobj->get_course(), false, $quizobj->get_cm()); require_login($quizobj->get_course(), false, $quizobj->get_cm());
require_sesskey(); require_sesskey();
$PAGE->set_heading($quizobj->get_course()->fullname);
// If no questions have been set up yet redirect to edit.php or display an error. // If no questions have been set up yet redirect to edit.php or display an error.
if (!$quizobj->has_questions()) { if (!$quizobj->has_questions()) {

View file

@ -333,8 +333,19 @@ table.quizattemptsummary .noreviewmessage {
.quizattemptcounts { .quizattemptcounts {
clear: left; clear: left;
text-align: center; text-align: center;
display:inline;
margin-left:20%;
}
.dir-rtl .quizattemptcounts {
margin-left:0;
margin-right: 20%;
}
#page-mod-quiz-view .quizattemptcounts,
.dir-rtl #page-mod-quiz-view .quizattemptcounts {
display: block;
margin-left: 0;
margin-right: 0;
} }
/** Mod quiz summary **/ /** Mod quiz summary **/
#page-mod-quiz-summary #content { #page-mod-quiz-summary #content {
text-align: center; text-align: center;

View file

@ -2,6 +2,8 @@ This files describes API changes in the quiz code.
=== 2.6 === === 2.6 ===
* As part of improving the page usability and accessibility, we updated the
heading levels for quiz module so it has a proper nesting. (MDL-41615)
* mod_quiz_renderer::view_best_score has been removed. (It did not do what the * mod_quiz_renderer::view_best_score has been removed. (It did not do what the
name suggested anyway.) name suggested anyway.)

View file

@ -138,7 +138,7 @@ class core_question_renderer extends plugin_renderer_base {
if (!$numbertext) { if (!$numbertext) {
return ''; return '';
} }
return html_writer::tag('h2', $numbertext, array('class' => 'no')); return html_writer::tag('h3', $numbertext, array('class' => 'no'));
} }
/** /**
@ -150,7 +150,7 @@ class core_question_renderer extends plugin_renderer_base {
*/ */
protected function add_part_heading($heading, $content) { protected function add_part_heading($heading, $content) {
if ($content) { if ($content) {
$content = html_writer::tag('h3', $heading, array('class' => 'accesshide')) . $content; $content = html_writer::tag('h4', $heading, array('class' => 'accesshide')) . $content;
} }
return $content; return $content;
} }
@ -456,7 +456,7 @@ class core_question_renderer extends plugin_renderer_base {
$table->data[] = $row; $table->data[] = $row;
} }
return html_writer::tag('h3', get_string('responsehistory', 'question'), return html_writer::tag('h4', get_string('responsehistory', 'question'),
array('class' => 'responsehistoryheader')) . html_writer::tag('div', array('class' => 'responsehistoryheader')) . html_writer::tag('div',
html_writer::table($table, true), array('class' => 'responsehistoryheader')); html_writer::table($table, true), array('class' => 'responsehistoryheader'));
} }

View file

@ -10,6 +10,9 @@ question_engine::is_manual_grade_in_range.
($qa, $options) to ($qa, $behaviouroutput, $options). If you have overridden ($qa, $options) to ($qa, $behaviouroutput, $options). If you have overridden
that method you will need to update your code. that method you will need to update your code.
3) Heading level for number(), add_part_heading() and respond_history()
has been lowered by one level. These changes are part of improving the page
accessibility and making heading to have proper nesting. (MDL-41615)
=== Earlier changes === === Earlier changes ===

View file

@ -368,7 +368,7 @@ input#id_externalurl {direction:ltr;}
.groupmanagementtable #addselect_wrapper label {font-weight: normal;} .groupmanagementtable #addselect_wrapper label {font-weight: normal;}
.dir-rtl .groupmanagementtable p {text-align: right;} .dir-rtl .groupmanagementtable p {text-align: right;}
#group-usersummary {width: 14em;} #group-usersummary {width: 14em;}
.groupselector {margin-top: 3px;margin-bottom: 3px;} .groupselector {margin-top: 3px;margin-bottom: 3px;display: inline-block;}
/** /**
* Login * Login

View file

@ -51,7 +51,7 @@ body.path-question-type .fitem_fgroup .accesshide {font: inherit;left: 0;positio
.dir-rtl .que {text-align: right;} .dir-rtl .que {text-align: right;}
.que .info {float: left;width: 7em;padding:0.5em;margin-bottom: 1.8em;background: #eee;} .que .info {float: left;width: 7em;padding:0.5em;margin-bottom: 1.8em;background: #eee;}
.que h2.no {margin: 0;font-size: 0.8em;line-height: 1;} .que h3.no {margin: 0;font-size: 0.8em;line-height: 1;}
.que span.qno {font-size: 1.5em;font-weight:bold;} .que span.qno {font-size: 1.5em;font-weight:bold;}
.que .info > div {font-size: 0.8em;margin-top: 0.7em;} .que .info > div {font-size: 0.8em;margin-top: 0.7em;}
.que .info .questionflag.editable {cursor:pointer;} .que .info .questionflag.editable {cursor:pointer;}

View file

@ -434,8 +434,11 @@ a.skip:active {
.groupselector { .groupselector {
margin-top: 3px; margin-top: 3px;
margin-bottom: 3px; margin-bottom: 3px;
display: inline-block;
}
.groupselector label {
display: inline-block;
} }
// Login // Login
.loginbox { .loginbox {
margin: 15px; margin: 15px;

View file

@ -165,7 +165,7 @@ body.path-question-type .fitem_fgroup .accesshide {
border: 1px solid darken(spin(@grayLighter, -10), 7%); border: 1px solid darken(spin(@grayLighter, -10), 7%);
.border-radius(2px); .border-radius(2px);
} }
.que h2.no { .que h3.no {
margin: 0; margin: 0;
font-size: 0.8em; font-size: 0.8em;
line-height: 1; line-height: 1;

File diff suppressed because one or more lines are too long