Skip to content

Commit

Permalink
Merge branch 'MDL-49666' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Mar 31, 2015
2 parents f0fb1ed + 063cbe9 commit f5c493f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
14 changes: 6 additions & 8 deletions question/behaviour/informationitem/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@
/**
* Defines the renderer the information item behaviour.
*
* @package qbehaviour
* @subpackage informationitem
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package qbehaviour_informationitem
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


defined('MOODLE_INTERNAL') || die();


/**
* Renderer for outputting parts of a question belonging to the information
* item behaviour.
*
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qbehaviour_informationitem_renderer extends qbehaviour_renderer {
public function controls(question_attempt $qa, question_display_options $options) {
if ($qa->get_state() != question_state::$todo) {
if ($options->readonly || $qa->get_state() != question_state::$todo) {
return '';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @copyright 2015 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qbehaviour_informationitem_type_test extends basic_testcase {
class qbehaviour_informationitem_type_testcase extends basic_testcase {

/** @var qbehaviour_informationitem_type */
protected $behaviourtype;
Expand Down
26 changes: 16 additions & 10 deletions question/behaviour/informationitem/tests/walkthrough_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
* This file contains tests that walks a question through the information item
* behaviour.
*
* @package qbehaviour
* @subpackage informationitem
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package qbehaviour_informationitem
* @category test
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


defined('MOODLE_INTERNAL') || die();

global $CFG;
Expand All @@ -35,10 +34,10 @@
/**
* Unit tests for the information item behaviour.
*
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough_test_base {
class qbehaviour_informationitem_walkthrough_testcase extends qbehaviour_walkthrough_test_base {
public function test_informationitem_feedback_description() {

// Create a true-false question with correct answer true.
Expand All @@ -49,10 +48,17 @@ public function test_informationitem_feedback_description() {
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output($this->get_contains_question_text_expectation($description),
new question_contains_tag_with_attributes('input', array('type' => 'hidden',
'name' => $this->quba->get_field_prefix($this->slot) . '-seen', 'value' => 1)),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . '-seen', 1),
$this->get_does_not_contain_feedback_expectation());

// Check no hidden input when read-only.
$this->displayoptions->readonly = true;
$this->check_current_output($this->get_contains_question_text_expectation($description),
$this->get_does_not_contain_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . '-seen', 1));
$this->displayoptions->readonly = false;

// Process a submission indicating this question has been seen.
$this->process_submission(array('-seen' => 1));

Expand Down

0 comments on commit f5c493f

Please sign in to comment.