Problem course restores and users

Problem course restores and users

by Albert Ramsbottom -
Number of replies: 8

Hi

We have a problem with educators restoring old courses in to our new Moodle with users. These users are coming through as Manual and as they are already registered via OpenID Connect it is duplicating them.

Is there a way of setting via admin so that all course backups and restores even from legacy courses from a different Moodle, do not include users


Cheers

Average of ratings: -
In reply to Albert Ramsbottom

Re: Problem course restores and users

by Albert Ramsbottom -

Ok, I have another question? Can i set in a role so that teachers cannot restore users when restoring courses?


I.e. grey out the restore users checkbox, through roles


Cheers

In reply to Albert Ramsbottom

Re: Problem course restores and users

by Ken Task -
Picture of Particularly helpful Moodlers

What version of Moodle?

Site Preferences for restoring now exist!

In 3.5.x
/admin/settings.php?section=restoregeneralsettings


'Legacy courses' ... does that mean 1.9 backups?

In the restore process, if teacher doesn't use 'skip to end' and steps through
the various screens, isn't there a screen that allows them to check 'no users'?

in config-dist.php of a 3.5.highest,

// Completely disable user creation when restoring a course, bypassing any
// permissions granted via roles and capabilities. Enabling this setting
// results in the restore process stopping when a user attempts to restore a
// course requiring users to be created.
//     $CFG->disableusercreationonrestore = true;

Seems you are progressing with other options and not really giving anyone a chance to respond to the first .... might be digging a rabbit hole! smile

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Problem course restores and users

by Albert Ramsbottom -

Thanks Ken

We are using 3.4, but this needs to be done as we have a solution to our duplicate users but need to stop any further restores from our old moodle. Well stop any users from selecting users as part of the restore

Yes we can educate them to not do this, but we feel that this will only be partly responisble

Thanks

In reply to Albert Ramsbottom

Re: Problem course restores and users

by Albert Ramsbottom -

Ok I found this witch might work, I will have to test

Restore user datamoodle/restore:userinfo


Thanks Ken


In reply to Albert Ramsbottom

Re: Problem course restores and users

by Albert Ramsbottom -

Well that doesnt seem to work. I have switched to Manager role and changed the capabilities of that role and unchecked the allow radio button on 

Restore user datamoodle/restore:userinfo


But it still restores users from the old course


Cheers


In reply to Albert Ramsbottom

Re: Problem course restores and users

by Ken Task -
Picture of Particularly helpful Moodlers

In config-dist.php of version 3.4 ...

// Completely disable user creation when restoring a course, bypassing any
// permissions granted via roles and capabilities. Enabling this setting
// results in the restore process stopping when a user attempts to restore a
// course requiring users to be created.
//     $CFG->disableusercreationonrestore = true;

Have not tried it on any site.   Wonder if this kicks in after having stepped through the beginning of the restore process where person restoring has option to de-select users.

OR if the setting looks for an extracted users.xml in moodledata/temp/backup/[hasheddir]/ and if not blank, then stops the process.

So some 'education' of those that do have ability to restore, might be in order to avoid their frustration, but if they have been informed it will happen and they have to attempt restore again .... well, what can I say ...  If it hurts don't do it! smile

Bout the only way I can think of to avoid any mistake by person restoring, etc. is to edit the xml files in an archive of the backup, removing users, then re-archiving so the restore can proceed without restore user having to think/do anything.

While the above could be automated via bash shell scripts, if one has tons of courses, could take some time.  And, all that could be circumvented if person restoring has a backup of their own in possession .... wouldn't be accessing the file system repo containing the 'scrubbed' .mbz backups.

Since you are in trials, add the line to config and try one restore with users. smile

Depending upon how it behaves you might have to monitor moodledata/temp/backup/ for a while to see it's being cleaned up as it should via cron/task.

'spirit of sharing', Ken


In reply to Ken Task

Re: Problem course restores and users

by Albert Ramsbottom -

I am again back on this as now it appears that

moodle/restore:userinfo, does sort of work insofar as it works then asks the educator to remap the module leader, manager and editing teacher roles to "None"

The odd thing is if i prohibit the

moodle/restore:createuser 

capability, it will not restore the course as the users are missing


ummmmmm


I havent tried the config setting that wil be next

In reply to Albert Ramsbottom

Re: Problem course restores and users

by Ken Task -
Picture of Particularly helpful Moodlers

You could be in-between a rock and a hard place ... IF teachers are to restore old backups.

If all the students (same students) accounts have been established already wouldn't it make sense to restore the courses *without* users/roles and then have the teacher/higher level folk enroll students or have student enroll themselves?

Think I've already suggested that but you desire that teachers NOT have to think ... so that means the other end ... has to be done at server level - without duplicating accounts.

Don't know how server is gonna do that if users exist and the accounts in the backup don't conflict with existing users then it will create new users ... which you don't want (understand that also).

So have you inspected a users.xml file from extracted backup to see what's in columns?   There will be a 'auth' column in users.xml but no password and assuming all other information concerning the students accounts are the same info, what if users.xml was edited and using simple search/replace all 'auth' tags reset from manual to oauth2/openid or what ever it should be now.   User.xml saved.   Files extracted re-packaged as a .mbz.

mbz then made available to teacher for restoring from a file system repo. ... conversion of the backup such as described above done on the server via a bash shell script.

Teachers don't have to think then.

Now you might have to really study what's in users.xml to see if there aren't other tags that need to be changed.

You could try the above with one course and one teacher to see how that goes.

'spirit of sharing', Ken




Average of ratings: Useful (1)