mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-47178 question: Retain question authors when restoring backups.
This commit is contained in:
parent
c71355941b
commit
1f3aacf8fc
3 changed files with 203 additions and 6 deletions
|
@ -4711,10 +4711,28 @@ class restore_create_categories_and_questions extends restore_structure_step {
|
|||
}
|
||||
|
||||
$userid = $this->get_mappingid('user', $data->createdby);
|
||||
$data->createdby = $userid ? $userid : $this->task->get_userid();
|
||||
if ($userid) {
|
||||
// The question creator is included in the backup, so we can use their mapping id.
|
||||
$data->createdby = $userid;
|
||||
} else {
|
||||
// Leave the question creator unchanged when we are restoring the same site.
|
||||
// Otherwise use current user id.
|
||||
if (!$this->task->is_samesite()) {
|
||||
$data->createdby = $this->task->get_userid();
|
||||
}
|
||||
}
|
||||
|
||||
$userid = $this->get_mappingid('user', $data->modifiedby);
|
||||
$data->modifiedby = $userid ? $userid : $this->task->get_userid();
|
||||
if ($userid) {
|
||||
// The question modifier is included in the backup, so we can use their mapping id.
|
||||
$data->modifiedby = $userid;
|
||||
} else {
|
||||
// Leave the question modifier unchanged when we are restoring the same site.
|
||||
// Otherwise use current user id.
|
||||
if (!$this->task->is_samesite()) {
|
||||
$data->modifiedby = $this->task->get_userid();
|
||||
}
|
||||
}
|
||||
|
||||
// With newitemid = 0, let's create the question
|
||||
if (!$questionmapping->newitemid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue