mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-72843 qbank_comment: unit test fix for individual testsuite
This change resolves a unit test issue while running an individual testsuite rather than the entire one after the first init call for phpunit. It requires the file so it can point back to the comment api while required.
This commit is contained in:
parent
385938b472
commit
f4b1b63684
2 changed files with 10 additions and 13 deletions
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
|
require_once($CFG->dirroot. '/comment/lib.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate comment parameter before perform other comments actions.
|
* Validate comment parameter before perform other comments actions.
|
||||||
*
|
*
|
||||||
|
@ -105,7 +107,6 @@ function qbank_comment_preview_display($question, $courseid): string {
|
||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @return string rendered output
|
* @return string rendered output
|
||||||
* @todo cleanup after class renaming to remove check for previewlib.php MDL-71679
|
|
||||||
*/
|
*/
|
||||||
function qbank_comment_output_fragment_question_comment($args): string {
|
function qbank_comment_output_fragment_question_comment($args): string {
|
||||||
global $USER, $PAGE, $CFG;
|
global $USER, $PAGE, $CFG;
|
||||||
|
@ -115,19 +116,16 @@ function qbank_comment_output_fragment_question_comment($args): string {
|
||||||
$quba = question_engine::make_questions_usage_by_activity(
|
$quba = question_engine::make_questions_usage_by_activity(
|
||||||
'core_question_preview', context_user::instance($USER->id));
|
'core_question_preview', context_user::instance($USER->id));
|
||||||
|
|
||||||
|
// Just in case of any regression, it should not break the modal, just show the comments.
|
||||||
if (class_exists('\\qbank_previewquestion\\question_preview_options')) {
|
if (class_exists('\\qbank_previewquestion\\question_preview_options')) {
|
||||||
$options = new \qbank_previewquestion\question_preview_options($question);
|
$options = new \qbank_previewquestion\question_preview_options($question);
|
||||||
} else {
|
$options->load_user_defaults();
|
||||||
require_once($CFG->dirroot . '/question/previewlib.php');
|
$options->set_from_request();
|
||||||
$options = new question_preview_options($question);
|
$quba->set_preferred_behaviour($options->behaviour);
|
||||||
|
$slot = $quba->add_question($question, $options->maxmark);
|
||||||
|
$quba->start_question($slot, $options->variant);
|
||||||
|
$displaydata['question'] = $quba->render_question($slot, $options, '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$options->load_user_defaults();
|
|
||||||
$options->set_from_request();
|
|
||||||
$quba->set_preferred_behaviour($options->behaviour);
|
|
||||||
$slot = $quba->add_question($question, $options->maxmark);
|
|
||||||
$quba->start_question($slot, $options->variant);
|
|
||||||
$displaydata['question'] = $quba->render_question($slot, $options, '1');
|
|
||||||
$displaydata['comment'] = qbank_comment_preview_display($question, $args['courseid']);
|
$displaydata['comment'] = qbank_comment_preview_display($question, $args['courseid']);
|
||||||
$displaydata['commenstdisabled'] = false;
|
$displaydata['commenstdisabled'] = false;
|
||||||
if (empty($displaydata['comment']) && !$CFG->usecomments) {
|
if (empty($displaydata['comment']) && !$CFG->usecomments) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
global $CFG;
|
global $CFG;
|
||||||
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
|
||||||
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
|
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
|
||||||
|
require_once($CFG->dirroot. '/comment/lib.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Question comment backup and restore unit tests.
|
* Question comment backup and restore unit tests.
|
||||||
|
@ -138,7 +138,6 @@ class qbank_comment_backup_restore_test extends \advanced_testcase {
|
||||||
*/
|
*/
|
||||||
public function test_backup_restore() {
|
public function test_backup_restore() {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$this->resetAfterTest();
|
$this->resetAfterTest();
|
||||||
$this->setAdminUser();
|
$this->setAdminUser();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue