moodle/mod/feedback/print.php
Michael Milette cba011942c MDL-42462 - Feedback - Fix for WCAG 2.0 issue with Informational and Error Content Displayed in red
1) The same code used in other Moodle forms is now used in Feedback to display the "There are required fields in this form marked (*/Required field)" message at the top of the screen and each of the asterisks next to required fields.

2) Feedback specific styles (missingrequire, feeback_required_mark), which were used to highlight required and error fields, have been eliminated. These colours are now controlled by the common Moodle styles (mform1, mform, fdescription, required, req and error) that are used throughout the rest of Moodle for a more uniform appearance.

3) Field level error reporting now displays a message instead of just highlighting the field in a similar way that other Moodle forms do.

Affected files:

- /mod/feedback/styles.css
- /mod/feedback/complete.php
- /mod/feedback/complete_guest.php
- /mod/feedback/edit.php
- /mod/feedback/print.php
- /mod/feedback/item/captcha/lib.php
- /mod/feedback/item/info/lib.php
- /mod/feedback/item/multichoice/lib.php
- /mod/feedback/item/multichoicerated/lib.php
- /mod/feedback/item/numeric/lib.php
- /mod/feedback/item/textarea/lib.php
- /mod/feedback/item/textfield/lib.php
- /mod/feedback/lang/en/feedback.php

Signed-off-by: Michael Milette <michael.milette@instruxmedia.com>
2014-04-03 09:25:37 -04:00

123 lines
4.4 KiB
PHP

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* print a printview of feedback-items
*
* @author Andreas Grabs
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
require_once("../../config.php");
require_once("lib.php");
$id = required_param('id', PARAM_INT);
$PAGE->set_url('/mod/feedback/print.php', array('id'=>$id));
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
print_error('coursemisconf');
}
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
print_error('invalidcoursemodule');
}
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/feedback:view', $context);
$PAGE->set_pagelayout('embedded');
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$feedback_url = new moodle_url('/mod/feedback/index.php', array('id'=>$course->id));
$PAGE->navbar->add($strfeedbacks, $feedback_url);
$PAGE->navbar->add(format_string($feedback->name));
$PAGE->set_title($feedback->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo $OUTPUT->heading(format_text($feedback->name));
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->continue_button('view.php?id='.$id);
if (is_array($feedbackitems)) {
$itemnr = 0;
$align = right_to_left() ? 'right' : 'left';
echo $OUTPUT->box_start('feedback_items printview');
//check, if there exists required-elements
$params = array('feedback'=>$feedback->id, 'required'=>1);
$countreq = $DB->count_records('feedback_item', $params);
if ($countreq > 0) {
echo '<div class="fdescription required">';
echo get_string('somefieldsrequired', 'form', '<img alt="'.get_string('requiredelement', 'form').
'" src="'.$OUTPUT->pix_url('req') .'" class="req" />');
echo '</div>';
}
//print the inserted items
$itempos = 0;
foreach ($feedbackitems as $feedbackitem) {
echo $OUTPUT->box_start('feedback_item_box_'.$align);
$itempos++;
//Items without value only are labels
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
$itemnr++;
echo $OUTPUT->box_start('feedback_item_number_'.$align);
echo $itemnr;
echo $OUTPUT->box_end();
}
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
if ($feedbackitem->typ != 'pagebreak') {
feedback_print_item_complete($feedbackitem, false, false);
} else {
echo $OUTPUT->box_start('feedback_pagebreak');
echo '<hr class="feedback_pagebreak" />';
echo $OUTPUT->box_end();
}
echo $OUTPUT->box_end();
echo $OUTPUT->box_end();
}
echo $OUTPUT->box_end();
} else {
echo $OUTPUT->box(get_string('no_items_available_yet', 'feedback'),
'generalbox boxaligncenter boxwidthwide');
}
echo $OUTPUT->continue_button('view.php?id='.$id);
echo $OUTPUT->box_end();
/// Finish the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo $OUTPUT->footer();