mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 07:25:30 +02:00
MDL-82875 question export: test for not exporting hidden questions
This commit is contained in:
parent
352ca59dc6
commit
60a1a65eea
@ -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 @@ require_once($CFG->dirroot . '/question/editlib.php');
|
||||
*
|
||||
* @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 @@ ANSWER: A
|
||||
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 = <<<EOT
|
||||
This question is the visible one.
|
||||
A) One
|
||||
B) Two
|
||||
C) Three
|
||||
D) Four
|
||||
ANSWER: A
|
||||
|
||||
EOT;
|
||||
|
||||
// Do the export and verify.
|
||||
$exporter = new qformat_aiken();
|
||||
$exporter->category = $cat;
|
||||
$exporter->setCourse($course);
|
||||
$this->assert_same_aiken($expectedoutput, $exporter->exportprocess());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user