mirror of
https://github.com/moodle/moodle.git
synced 2025-03-23 09:00:30 +01:00
Merge branch 'MDL-72950' of https://github.com/stronk7/moodle
This commit is contained in:
commit
2a22d5b077
@ -619,7 +619,8 @@ abstract class restore_dbops {
|
||||
// Top-level category counter.
|
||||
$topcats = 0;
|
||||
// get categories in context (bank)
|
||||
$categories = self::restore_get_question_categories($restoreid, $contextid);
|
||||
$categories = self::restore_get_question_categories($restoreid, $contextid, $contextlevel);
|
||||
|
||||
// cache permissions if $targetcontext is found
|
||||
if ($targetcontext = self::restore_find_best_target_context($categories, $courseid, $contextlevel)) {
|
||||
$canmanagecategory = has_capability('moodle/question:managecategory', $targetcontext, $userid);
|
||||
@ -765,8 +766,13 @@ abstract class restore_dbops {
|
||||
/**
|
||||
* Return one array of question_category records for
|
||||
* a given restore operation and one restore context (question bank)
|
||||
*
|
||||
* @param string $restoreid Unique identifier of the restore operation being performed.
|
||||
* @param int $contextid Context id we want question categories to be returned.
|
||||
* @param int $contextlevel Context level we want to restrict the returned categories.
|
||||
* @return array Question categories for the given context id and level.
|
||||
*/
|
||||
public static function restore_get_question_categories($restoreid, $contextid) {
|
||||
public static function restore_get_question_categories($restoreid, $contextid, $contextlevel) {
|
||||
global $DB;
|
||||
|
||||
$results = array();
|
||||
@ -776,7 +782,14 @@ abstract class restore_dbops {
|
||||
AND itemname = 'question_category'
|
||||
AND parentitemid = ?", array($restoreid, $contextid));
|
||||
foreach ($qcats as $qcat) {
|
||||
$results[$qcat->itemid] = backup_controller_dbops::decode_backup_temp_info($qcat->info);
|
||||
$result = backup_controller_dbops::decode_backup_temp_info($qcat->info);
|
||||
// Filter out found categories that belong to another context level.
|
||||
// (this can happen when a higher level category becomes remapped to
|
||||
// a context id that, by coincidence, matches a context id of another
|
||||
// category at lower level). See MDL-72950 for more info.
|
||||
if ($result->contextlevel == $contextlevel) {
|
||||
$results[$qcat->itemid] = $result;
|
||||
}
|
||||
}
|
||||
$qcats->close();
|
||||
|
||||
|
@ -47,11 +47,6 @@ class restore_attempt_test extends \advanced_testcase {
|
||||
public function test_restore_question_attempts_missing_users(): void {
|
||||
global $DB, $USER;
|
||||
|
||||
// TODO: Remove this once MDL-72950 is fixed.
|
||||
if ($DB->get_dbfamily() == 'oracle') {
|
||||
$this->markTestSkipped("Skipping for Oracle until MDL-72950 is fixed.");
|
||||
}
|
||||
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user