diff --git a/question/format/aiken/tests/qformat_aiken_export_test.php b/question/format/aiken/tests/qformat_aiken_export_test.php index ae089d1723aa1..785d2c0a5a6df 100644 --- a/question/format/aiken/tests/qformat_aiken_export_test.php +++ b/question/format/aiken/tests/qformat_aiken_export_test.php @@ -21,6 +21,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +use core_question\local\bank\question_version_status; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -35,6 +37,7 @@ * * @copyright 2018 Jean-Michel vedrine) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \qformat_aiken */ class qformat_aiken_export_test extends advanced_testcase { /** @@ -113,4 +116,44 @@ public function test_export_multiline_question(): void { EOT; $this->assert_same_aiken($expectedoutput, $exporter->exportprocess()); } + + public function test_hidden_question_not_exported(): void { + $this->resetAfterTest(); + $this->setAdminUser(); + + // Create a new course category and a new course in that. + $category = $this->getDataGenerator()->create_category(); + $course = $this->getDataGenerator()->create_course(['category' => $category->id]); + $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); + $context = context_coursecat::instance($category->id); + $cat = $generator->create_question_category(['contextid' => $context->id]); + + // Create a visible and a hidden question. + $generator->create_question('multichoice', 'one_of_four', [ + 'category' => $cat->id, + 'questiontext' => ['text' => 'This question is the visible one.', 'format' => FORMAT_HTML], + ]); + $generator->create_question('multichoice', 'one_of_four', [ + 'category' => $cat->id, + 'questiontext' => ['text' => 'This question is the hidden one.', 'format' => FORMAT_HTML], + 'status' => question_version_status::QUESTION_STATUS_HIDDEN, + ]); + + // Prepared the expected result. + $expectedoutput = <<category = $cat; + $exporter->setCourse($course); + $this->assert_same_aiken($expectedoutput, $exporter->exportprocess()); + } }