diff --git a/question/engine/renderer.php b/question/engine/renderer.php index 6f5570b4521..4202c85b4b5 100644 --- a/question/engine/renderer.php +++ b/question/engine/renderer.php @@ -77,16 +77,16 @@ class core_question_renderer extends plugin_renderer_base { $output .= html_writer::start_tag('div', array('class' => 'content')); $output .= html_writer::tag('div', - $this->add_part_heading(get_string('questiontext', 'question'), - $this->formulation($qa, $behaviouroutput, $qtoutput, $options)), + $this->add_part_heading($qtoutput->formulation_heading(), + $this->formulation($qa, $behaviouroutput, $qtoutput, $options)), array('class' => 'formulation')); $output .= html_writer::nonempty_tag('div', $this->add_part_heading(get_string('feedback', 'question'), - $this->outcome($qa, $behaviouroutput, $qtoutput, $options)), + $this->outcome($qa, $behaviouroutput, $qtoutput, $options)), array('class' => 'outcome')); $output .= html_writer::nonempty_tag('div', $this->add_part_heading(get_string('comments', 'question'), - $this->manual_comment($qa, $behaviouroutput, $qtoutput, $options)), + $this->manual_comment($qa, $behaviouroutput, $qtoutput, $options)), array('class' => 'comment')); $output .= html_writer::nonempty_tag('div', $this->response_history($qa, $behaviouroutput, $qtoutput, $options), diff --git a/question/type/description/lang/en/qtype_description.php b/question/type/description/lang/en/qtype_description.php index 54f6f5848b7..b06b700bdc7 100644 --- a/question/type/description/lang/en/qtype_description.php +++ b/question/type/description/lang/en/qtype_description.php @@ -30,3 +30,4 @@ $string['description_help'] = 'A description is not really a question type. It s The question text is displayed both during the attempt and on the review page. Any general feedback is displayed on the review page only.'; $string['descriptionsummary'] = 'This is not actually a question. Instead it is a way to add some instructions, rubric or other content to the activity. This is similar to the way that labels can be used to add content to the course page.'; $string['editingdescription'] = 'Editing a Description'; +$string['informationtext'] = 'Information text'; diff --git a/question/type/description/renderer.php b/question/type/description/renderer.php index 11a0d96bb64..bf5cbc2c3be 100644 --- a/question/type/description/renderer.php +++ b/question/type/description/renderer.php @@ -40,4 +40,8 @@ class qtype_description_renderer extends qtype_renderer { return html_writer::tag('div', $qa->get_question()->format_questiontext($qa), array('class' => 'qtext')); } + + public function formulation_heading() { + return get_string('informationtext', 'qtype_description'); + } } diff --git a/question/type/description/simpletest/testwalkthrough.php b/question/type/description/simpletest/testwalkthrough.php new file mode 100644 index 00000000000..ea415d434bf --- /dev/null +++ b/question/type/description/simpletest/testwalkthrough.php @@ -0,0 +1,52 @@ +. + +/** + * This file contains tests that walks a description question through its interaction model. + * + * @package qtype + * @subpackage description + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->libdir . '/questionlib.php'); +require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php'); + + +class qtype_description_walkthrough_test extends qbehaviour_walkthrough_test_base { + + public function test_informationitem_feedback_description() { + + // Create a description question. + $description = test_question_maker::make_question('description'); + $this->start_attempt_at_question($description, 'deferredfeedback'); + + // Check the initial state. + $this->assertEqual('informationitem', + $this->quba->get_question_attempt($this->slot)->get_behaviour_name()); + + $this->check_current_output( + new ContainsTagWithContents('h3', get_string('informationtext', 'qtype_description')) + ); + + // Further tests of the description qtype are in + // question/behaviour/informationitem/simpletest/testwalkthrough.php. + } +} diff --git a/question/type/rendererbase.php b/question/type/rendererbase.php index 6edc70e07c4..25e470cae84 100644 --- a/question/type/rendererbase.php +++ b/question/type/rendererbase.php @@ -49,6 +49,16 @@ abstract class qtype_renderer extends plugin_renderer_base { return $qa->get_question()->format_questiontext($qa); } + /** + * In the question output there are some class="accesshide" headers to help + * screen-readers. This method returns the text to use for the heading above + * the formulation_and_controls section. + * @return string to use as the heading. + */ + public function formulation_heading() { + return get_string('questiontext', 'question'); + } + /** * Output hidden form fields to clear any wrong parts of the student's response. * diff --git a/question/type/truefalse/simpletest/testwalkthrough.php b/question/type/truefalse/simpletest/testwalkthrough.php index 2b54f3033e5..ccb90b3a0c0 100644 --- a/question/type/truefalse/simpletest/testwalkthrough.php +++ b/question/type/truefalse/simpletest/testwalkthrough.php @@ -48,7 +48,9 @@ class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base $this->check_current_mark(null); $this->check_current_output( $this->get_contains_question_text_expectation($tf), - $this->get_does_not_contain_feedback_expectation()); + $this->get_does_not_contain_feedback_expectation(), + new ContainsTagWithContents('h3', + get_string('questiontext', 'question'))); $this->assertEqual(get_string('false', 'qtype_truefalse'), $this->quba->get_right_answer_summary($this->slot)); $this->assertPattern('/' . preg_quote($tf->questiontext) . '/',