by Antoni Bertran Bellido.
Hello I want to backup only one activity with users, but I can't set the setting users to 1 because is Locked
base_setting::LOCKED_BY_PERMISSIONthe activity is a quiz
the code is like:
$cm = get_coursemodule_from_id('', $cmid, 0, true, MUST_EXIST);
// backup the activity
$admin = get_admin();
$bc = new \backup_controller(\backup::TYPE_1ACTIVITY, $cm->id, \backup::FORMAT_MOODLE,
\backup::INTERACTIVE_NO, \backup::MODE_IMPORT, $admin->id);
$backupsettings = array(
'users' => 1,
'role_assignments' => 0,
'comments' => 0,
'userscompletion' => 1,
'logs' => 0,
'grade_histories' => 0
);
foreach ($backupsettings as $name => $value) {
$bc->get_plan()->get_setting($name)->set_value($value);
}
$backupid = $bc->get_backupid();
$backupbasepath = $bc->get_plan()->get_basepath();
$bc->execute_plan();
$bc->destroy();
Thanks!