MDL-71696 core_question: class autoload changes

This commit implements some class autoloading
fixes to align with core question structure.
This commit is contained in:
Safat Shahin
2022-02-03 22:22:50 +11:00
parent 3008edd366
commit bf55e5a481
38 changed files with 61 additions and 92 deletions
+2 -2
View File
@@ -81,6 +81,6 @@ $renamedclasses = [
'preview_options_form' => 'qbank_previewquestion\\form\\preview_options_form',
'question_preview_options' => 'qbank_previewquestion\\output\\question_preview_options',
'core_question\\form\\tags' => 'qbank_tagquestion\\form\\tags_form',
'context_to_string_translator' => 'core_question\\lib\\context_to_string_translator',
'question_edit_contexts' => 'core_question\\lib\\question_edit_contexts',
'context_to_string_translator' => 'core_question\\local\\bank\\context_to_string_translator',
'question_edit_contexts' => 'core_question\\local\\bank\\question_edit_contexts',
];
+2 -2
View File
@@ -1609,7 +1609,7 @@ function question_extend_settings_navigation(navigation_node $navigationnode, $c
];
}
$contexts = new core_question\lib\question_edit_contexts($context);
$contexts = new core_question\local\bank\question_edit_contexts($context);
foreach ($corenavigations as $key => $corenavigation) {
if ($contexts->have_one_edit_tab_cap($key)) {
$questionnode->add($corenavigation['title'], new moodle_url(
@@ -1754,7 +1754,7 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f
require_login($course, false, $cm);
require_once($CFG->dirroot . '/question/editlib.php');
$contexts = new core_question\lib\question_edit_contexts($context);
$contexts = new core_question\local\bank\question_edit_contexts($context);
// Check export capability.
$contexts->require_one_edit_tab_cap('export');
$categoryid = (int)array_shift($args);
+11 -11
View File
@@ -48,13 +48,13 @@ class edit_renderer extends \plugin_renderer_base {
*
* @param \quiz $quizobj object containing all the quiz settings information.
* @param structure $structure object containing the structure of the quiz.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param \moodle_url $pageurl the canonical URL of this page.
* @param array $pagevars the variables from {@link question_edit_setup()}.
* @return string HTML to output.
*/
public function edit_page(\quiz $quizobj, structure $structure,
\core_question\lib\question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
\core_question\local\bank\question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
$output = '';
// Information at the top.
@@ -495,7 +495,7 @@ class edit_renderer extends \plugin_renderer_base {
*
* @param structure $structure object containing the structure of the quiz.
* @param \stdClass $section information about the section.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return string HTML to output.
@@ -515,7 +515,7 @@ class edit_renderer extends \plugin_renderer_base {
*
* @param structure $structure object containing the structure of the quiz.
* @param int $slot which slot we are outputting.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return string HTML to output.
@@ -548,7 +548,7 @@ class edit_renderer extends \plugin_renderer_base {
*
* @param structure $structure object containing the structure of the quiz.
* @param int $slot the first slot on the page we are outputting.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return string HTML to output.
@@ -582,12 +582,12 @@ class edit_renderer extends \plugin_renderer_base {
* @param structure $structure object containing the structure of the quiz.
* @param int $page the page number that this menu will add to.
* @param \moodle_url $pageurl the canonical URL of this page.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @return string HTML to output.
*/
public function add_menu_actions(structure $structure, $page, \moodle_url $pageurl,
\core_question\lib\question_edit_contexts $contexts, array $pagevars) {
\core_question\local\bank\question_edit_contexts $contexts, array $pagevars) {
$actions = $this->edit_menu_actions($structure, $page, $pageurl, $pagevars);
if (empty($actions)) {
@@ -1139,13 +1139,13 @@ class edit_renderer extends \plugin_renderer_base {
* is handled with the specific code for those.)
*
* @param structure $structure object containing the structure of the quiz.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return bool Always returns true
*/
protected function initialise_editing_javascript(structure $structure,
\core_question\lib\question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl) {
\core_question\local\bank\question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl) {
$config = new \stdClass();
$config->resourceurl = '/mod/quiz/edit_rest.php';
@@ -1245,13 +1245,13 @@ class edit_renderer extends \plugin_renderer_base {
* HTML for a page, with ids stripped, so it can be used as a javascript template.
*
* @param structure $structure object containing the structure of the quiz.
* @param \core_question\lib\question_edit_contexts $contexts the relevant question bank contexts.
* @param \core_question\local\bank\question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @param \moodle_url $pageurl the canonical URL of this page.
* @return string HTML for a new page.
*/
protected function new_page_template(structure $structure,
\core_question\lib\question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl) {
\core_question\local\bank\question_edit_contexts $contexts, array $pagevars, \moodle_url $pageurl) {
if (!$structure->has_questions()) {
return '';
}
@@ -48,7 +48,7 @@ class custom_view extends \core_question\local\bank\view {
/**
* Constructor.
* @param \core_question\lib\question_edit_contexts $contexts
* @param \core_question\local\bank\question_edit_contexts $contexts
* @param \moodle_url $pageurl
* @param \stdClass $course course settings
* @param \stdClass $cm activity settings.
+1 -1
View File
@@ -1250,7 +1250,7 @@ class structure {
public function can_add_random_questions() {
if ($this->canaddrandom === null) {
$quizcontext = $this->quizobj->get_context();
$relatedcontexts = new \core_question\lib\question_edit_contexts($quizcontext);
$relatedcontexts = new \core_question\local\bank\question_edit_contexts($quizcontext);
$usablecontexts = $relatedcontexts->having_cap('moodle/question:useall');
$this->canaddrandom = !empty($usablecontexts);
+1 -1
View File
@@ -67,7 +67,7 @@ $catcontext = context::instance_by_id($category->contextid);
require_capability('moodle/question:useall', $catcontext);
$thiscontext = context_module::instance($cm->id);
$contexts = new core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
// Create the editing form.
$mform = new mod_quiz\form\randomquestion_form(new moodle_url('/mod/quiz/editrandom.php'), ['contexts' => $contexts]);
+1 -1
View File
@@ -2413,7 +2413,7 @@ function mod_quiz_output_fragment_add_random_question_form($args) {
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/addrandomform.php');
$contexts = new \core_question\lib\question_edit_contexts($args['context']);
$contexts = new \core_question\local\bank\question_edit_contexts($args['context']);
$formoptions = [
'contexts' => $contexts,
'cat' => $args['cat']
@@ -51,7 +51,7 @@ class quiz_question_bank_view_testcase extends advanced_testcase {
$cm = get_coursemodule_from_instance('quiz', $quiz->id);
// Create a question in the default category.
$contexts = new core_question\lib\question_edit_contexts($context);
$contexts = new core_question\local\bank\question_edit_contexts($context);
$cat = question_make_default_categories($contexts->all());
$questiondata = $questiongenerator->create_question('numerical', null,
['name' => 'Example question', 'category' => $cat->id]);
+1 -3
View File
@@ -26,8 +26,6 @@
require_once(__DIR__ . '/../../../config.php');
require_once(__DIR__ . '/../../editlib.php');
use \core_question\lib\question_edit_contexts;
global $DB, $OUTPUT, $PAGE, $COURSE;
$moveselected = optional_param('move', false, PARAM_BOOL);
@@ -55,7 +53,7 @@ if ($cmid) {
throw new moodle_exception('missingcourseorcmid', 'question');
}
$contexts = new \core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
$url = new moodle_url('/question/bank/bulkmove/move.php');
$PAGE->set_url($url);
+2 -2
View File
@@ -16,7 +16,7 @@
namespace qbank_bulkmove;
use core_question\lib\question_edit_contexts;
use core_question\local\bank\question_edit_contexts;
defined('MOODLE_INTERNAL') || die();
@@ -55,7 +55,7 @@ class helper_test extends \advanced_testcase {
protected $context;
/**
* @var \question_edit_contexts $contexts
* @var \core_question\local\bank\question_edit_contexts $contexts
*/
protected $contexts;
@@ -65,7 +65,7 @@ class comment_created_deleted_test extends advanced_testcase {
$this->context = context_course::instance($this->course->id);
// Create a question in the default category.
$contexts = new \core_question\lib\question_edit_contexts($this->context);
$contexts = new \core_question\local\bank\question_edit_contexts($this->context);
$cat = question_make_default_categories($contexts->all());
$this->questiondata = $questiongenerator->create_question('numerical', null,
['name' => 'Example question', 'category' => $cat->id]);
+1 -1
View File
@@ -51,7 +51,7 @@ if ($cmid) {
throw new moodle_exception('missingcourseorcmid', 'question');
}
$contexts = new core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
$url = new moodle_url('/question/bank/deletequestion/delete.php');
$PAGE->set_url($url);
+1 -1
View File
@@ -108,7 +108,7 @@ if ($cmid) {
} else {
throw new moodle_exception('missingcourseorcmid', 'question');
}
$contexts = new core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
$PAGE->set_pagelayout('admin');
if (optional_param('addcancel', false, PARAM_BOOL)) {
+1 -1
View File
@@ -50,7 +50,7 @@ if ($cmid) {
require_sesskey();
// Load the necessary data.
$contexts = new core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
$questiondata = question_bank::load_question_data($questionid);
// Check permissions.
+1 -1
View File
@@ -51,7 +51,7 @@ $category->context = $categorycontext;
// This page can be called without courseid or cmid in which case.
// We get the context from the category object.
if ($contexts === null) { // Need to get the course from the chosen category.
$contexts = new question_edit_contexts($categorycontext);
$contexts = new core_question\local\bank\question_edit_contexts($categorycontext);
$thiscontext = $contexts->lowest();
if ($thiscontext->contextlevel == CONTEXT_COURSE) {
require_login($thiscontext->instanceid, false);
@@ -205,7 +205,7 @@ class helper_test extends \advanced_testcase {
public function test_question_category_select_menu() {
$this->qgenerator->create_question_category(['contextid' => $this->context->id, 'name' => 'Test this question category']);
$contexts = new \core_question\lib\question_edit_contexts($this->context);
$contexts = new \core_question\local\bank\question_edit_contexts($this->context);
ob_start();
helper::question_category_select_menu($contexts->having_cap('moodle/question:add'));
@@ -231,7 +231,7 @@ class helper_test extends \advanced_testcase {
$qcategory2 = $this->qgenerator->create_question_category(['contextid' => $this->context->id, 'parent' => $qcategory1->id]);
$qcategory3 = $this->qgenerator->create_question_category(['contextid' => $this->context->id]);
$contexts = new \core_question\lib\question_edit_contexts($this->context);
$contexts = new \core_question\local\bank\question_edit_contexts($this->context);
// Validate that we have the array with the categories tree.
$categorycontexts = helper::question_category_options($contexts->having_cap('moodle/question:add'));
@@ -25,7 +25,7 @@ use context;
use context_course;
use context_module;
use moodle_url;
use core_question\lib\question_edit_contexts;
use core_question\local\bank\question_edit_contexts;
use stdClass;
/**
@@ -27,7 +27,7 @@ use context;
use core\plugininfo\qbank;
use core_question\local\bank\edit_menu_column;
use core_question\local\bank\view;
use core_question\lib\question_edit_contexts;
use core_question\local\bank\question_edit_contexts;
use moodle_url;
use question_bank;
use question_definition;
@@ -19,7 +19,6 @@ namespace qbank_previewquestion;
use context_course;
use moodle_url;
use core\plugininfo\qbank;
use \core_question\lib\question_edit_contexts;
use question_bank;
use question_engine;
use stdClass;
@@ -75,7 +74,7 @@ class helper_test extends \advanced_testcase {
$course = $generator->create_course();
$this->context = context_course::instance($course->id);
// Create a question in the default category.
$contexts = new \core_question\lib\question_edit_contexts($this->context);
$contexts = new \core_question\local\bank\question_edit_contexts($this->context);
$cat = question_make_default_categories($contexts->all());
$this->questiondata = $questiongenerator->create_question('numerical', null,
['name' => 'Example question', 'category' => $cat->id]);
+1 -1
View File
@@ -89,7 +89,7 @@ class submit_tags extends external_api {
$cantag = question_has_capability_on($question, 'tag');
$questioncontext = \context::instance_by_id($question->contextid);
$contexts = new \core_question\lib\question_edit_contexts($editingcontext);
$contexts = new \core_question\local\bank\question_edit_contexts($editingcontext);
$formoptions = [
'editingcontext' => $editingcontext,
+1 -1
View File
@@ -61,7 +61,7 @@ function qbank_tagquestion_output_fragment_tags_form($args) {
WHERE q.id = :id";
$category = $DB->get_record_sql($sql, ['id' => $question->id]);
$questioncontext = \context::instance_by_id($category->contextid);
$contexts = new \core_question\lib\question_edit_contexts($editingcontext);
$contexts = new \core_question\local\bank\question_edit_contexts($editingcontext);
// Load the question tags and filter the course tags by the current course.
if (core_tag_tag::is_enabled('core_question', 'question')) {
+2 -2
View File
@@ -173,7 +173,7 @@ class core_question_external extends external_api {
$cantag = question_has_capability_on($question, 'tag');
$questioncontext = \context::instance_by_id($question->contextid);
$contexts = new \core_question\lib\question_edit_contexts($editingcontext);
$contexts = new \core_question\local\bank\question_edit_contexts($editingcontext);
$formoptions = [
'editingcontext' => $editingcontext,
@@ -300,7 +300,7 @@ class core_question_external extends external_api {
$categorycontextid = $DB->get_field('question_categories', 'contextid', ['id' => $categoryid], MUST_EXIST);
$categorycontext = \context::instance_by_id($categorycontextid);
$editcontexts = new \core_question\lib\question_edit_contexts($categorycontext);
$editcontexts = new \core_question\local\bank\question_edit_contexts($categorycontext);
// The user must be able to view all questions in the category that they are requesting.
$editcontexts->require_cap('moodle/question:viewall');
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_question\local\bank;
/**
* Converts contextlevels to strings and back to help with reading/writing contexts to/from import/export files.
*
@@ -22,19 +24,6 @@
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_question\lib;
defined('MOODLE_INTERNAL') || die();
/**
* Class context_to_string_translator.
*
* @package core_question
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class context_to_string_translator {
/**
@@ -68,8 +57,7 @@ class context_to_string_translator {
* @return false|int|string
*/
public function string_to_context($contextname) {
$contextid = array_search($contextname, $this->contexttostringarray);
return $contextid;
return array_search($contextname, $this->contexttostringarray);
}
/**
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_question\local\bank;
/**
* Tracks all the contexts related to the one we are currently editing questions and provides helper methods to check permissions.
*
@@ -22,19 +24,6 @@
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_question\lib;
defined('MOODLE_INTERNAL') || die();
/**
* Class question_edit_contexts.
*
* @package core_question
* @copyright 2007 Jamie Pratt me@jamiep.org
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class question_edit_contexts {
/**
+2 -2
View File
@@ -70,7 +70,7 @@ class view {
protected $editquestionurl;
/**
* @var \core_question\lib\question_edit_contexts
* @var \core_question\local\bank\question_edit_contexts
*/
protected $contexts;
@@ -157,7 +157,7 @@ class view {
/**
* Constructor for view.
*
* @param \core_question\lib\question_edit_contexts $contexts
* @param \core_question\local\bank\question_edit_contexts $contexts
* @param \moodle_url $pageurl
* @param object $course course settings
* @param object $cm (optional) activity settings.
+1 -1
View File
@@ -327,7 +327,7 @@ function question_build_edit_resources($edittab, $baseurl, $params) {
}
if ($thiscontext){
$contexts = new core_question\lib\question_edit_contexts($thiscontext);
$contexts = new core_question\local\bank\question_edit_contexts($thiscontext);
$contexts->require_one_edit_tab_cap($edittab);
} else {
$contexts = null;
+1 -1
View File
@@ -117,7 +117,7 @@ abstract class question_test_helper {
*/
public static function get_question_editing_form($cat, $questiondata) {
$catcontext = context::instance_by_id($cat->contextid, MUST_EXIST);
$contexts = new core_question\lib\question_edit_contexts($catcontext);
$contexts = new core_question\local\bank\question_edit_contexts($catcontext);
$dataforformconstructor = new stdClass();
$dataforformconstructor->createdby = $questiondata->createdby;
$dataforformconstructor->qtype = $questiondata->qtype;
+1 -1
View File
@@ -136,7 +136,7 @@ class qformat_default {
*/
public function setContexts($contexts) {
$this->contexts = $contexts;
$this->translator = new core_question\lib\context_to_string_translator($this->contexts);
$this->translator = new core_question\local\bank\context_to_string_translator($this->contexts);
}
/**
+1 -1
View File
@@ -65,7 +65,7 @@ function core_question_output_fragment_tags_form($args) {
WHERE q.id = :id";
$category = $DB->get_record_sql($sql, ['id' => $question->id]);
$questioncontext = \context::instance_by_id($category->contextid);
$contexts = new \core_question\lib\question_edit_contexts($editingcontext);
$contexts = new \core_question\local\bank\question_edit_contexts($editingcontext);
// Load the question tags and filter the course tags by the current course.
if (core_tag_tag::is_enabled('core_question', 'question')) {
+2 -2
View File
@@ -49,7 +49,7 @@ class core_question_bank_view_testcase extends advanced_testcase {
$context = context_course::instance($course->id);
// Create a question in the default category.
$contexts = new core_question\lib\question_edit_contexts($context);
$contexts = new core_question\local\bank\question_edit_contexts($context);
$cat = question_make_default_categories($contexts->all());
$questiondata = $questiongenerator->create_question('numerical', null,
['name' => 'Example question', 'category' => $cat->id]);
@@ -93,7 +93,7 @@ class core_question_bank_view_testcase extends advanced_testcase {
$context = context_course::instance($course->id);
// Create a question in the default category.
$contexts = new core_question\lib\question_edit_contexts($context);
$contexts = new core_question\local\bank\question_edit_contexts($context);
$cat = question_make_default_categories($contexts->all());
$questiondata = $questiongenerator->create_question('numerical', null,
['name' => 'Example question', 'category' => $cat->id]);
+2 -7
View File
@@ -28,7 +28,6 @@ use qbank_managecategories\question_category_object;
use qtype_description;
use qtype_description_edit_form;
use qtype_description_test_helper;
use question_edit_contexts;
use test_question_maker;
defined('MOODLE_INTERNAL') || die();
@@ -57,7 +56,7 @@ class events_test extends \advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$quiz = $this->getDataGenerator()->create_module('quiz', ['course' => $course->id]);
$contexts = new \core_question\lib\question_edit_contexts(context_module::instance($quiz->cmid));
$contexts = new \core_question\local\bank\question_edit_contexts(\context_module::instance($quiz->cmid));
$defaultcategoryobj = question_make_default_categories([$contexts->lowest()]);
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
@@ -108,11 +107,7 @@ class events_test extends \advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$quiz = $this->getDataGenerator()->create_module('quiz', ['course' => $course->id]);
<<<<<<< HEAD:question/tests/event/events_test.php
$contexts = new question_edit_contexts(\context_module::instance($quiz->cmid));
=======
$contexts = new core_question\lib\question_edit_contexts(context_module::instance($quiz->cmid));
>>>>>>> MDL-71696 core_question: Changes for versioning:question/tests/events_test.php
$contexts = new \core_question\local\bank\question_edit_contexts(\context_module::instance($quiz->cmid));
$defaultcategoryobj = question_make_default_categories([$contexts->lowest()]);
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
+2 -2
View File
@@ -45,7 +45,7 @@ class question_bank_column_testcase extends advanced_testcase {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$questionbank = new core_question\local\bank\view(
new core_question\lib\question_edit_contexts(context_course::instance($course->id)),
new core_question\local\bank\question_edit_contexts(context_course::instance($course->id)),
new moodle_url('/'),
$course
);
@@ -79,7 +79,7 @@ class question_bank_column_testcase extends advanced_testcase {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$questionbank = new core_question\local\bank\view(
new core_question\lib\question_edit_contexts(context_course::instance($course->id)),
new core_question\local\bank\question_edit_contexts(context_course::instance($course->id)),
new moodle_url('/'),
$course
);
@@ -63,7 +63,7 @@ class qtype_ddimageortext_edit_form_test extends advanced_testcase {
$fakequestion->inputs = null;
$form = new qtype_ddimageortext_edit_form(new moodle_url('/'), $fakequestion, $category,
new core_question\lib\question_edit_contexts($syscontext));
new core_question\local\bank\question_edit_contexts($syscontext));
return [$form, $category];
}
@@ -63,7 +63,7 @@ class qtype_ddmarker_edit_form_test extends advanced_testcase {
$fakequestion->inputs = null;
$form = new qtype_ddmarker_edit_form(new moodle_url('/'), $fakequestion, $category,
new core_question\lib\question_edit_contexts($syscontext));
new core_question\local\bank\question_edit_contexts($syscontext));
return [$form, $category];
}
@@ -65,7 +65,7 @@ class qtype_ddwtos_edit_form_test extends advanced_testcase {
$fakequestion->inputs = null;
$form = new $classname(new moodle_url('/'), $fakequestion, $category,
new core_question\lib\question_edit_contexts($syscontext));
new core_question\local\bank\question_edit_contexts($syscontext));
return [$form, $category];
}
+1 -1
View File
@@ -69,7 +69,7 @@ class qtype_essay_edit_form_test extends advanced_testcase {
new moodle_url('/'),
$fakequestion,
$category,
new question_edit_contexts($syscontext)
new core_question\local\bank\question_edit_contexts($syscontext)
);
return [$form, $category];
+2 -2
View File
@@ -48,7 +48,7 @@ class qtype_essay_restore_testcase extends restore_date_testcase {
// Create a course with one essay question in its question bank.
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$contexts = new core_question\lib\question_edit_contexts(context_course::instance($course->id));
$contexts = new core_question\local\bank\question_edit_contexts(context_course::instance($course->id));
$category = question_make_default_categories($contexts->all());
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$essay = $questiongenerator->create_question('essay', null, array('category' => $category->id));
@@ -60,7 +60,7 @@ class qtype_essay_restore_testcase extends restore_date_testcase {
$newcourseid = $this->backup_and_restore($course);
// Verify that the restored question has options.
$contexts = new core_question\lib\question_edit_contexts(context_course::instance($newcourseid));
$contexts = new core_question\local\bank\question_edit_contexts(context_course::instance($newcourseid));
$newcategory = question_make_default_categories($contexts->all());
$newessay = $DB->get_record_sql('SELECT q.*
FROM {question} q
@@ -94,7 +94,7 @@ class qtype_gapselect_edit_form_test extends advanced_testcase {
$fakequestion->inputs = null;
$form = new $classname(new moodle_url('/'), $fakequestion, $category,
new core_question\lib\question_edit_contexts($syscontext));
new core_question\local\bank\question_edit_contexts($syscontext));
return [$form, $category];
}