Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod_quizgame: Add Backup / Restore support #33

Merged
merged 4 commits into from
Feb 18, 2018
Merged

Conversation

sbourget
Copy link
Collaborator

Proposed patch adds backup / restore support to mod_quizgame.
Fixes issue #31

@xow
Copy link
Owner

xow commented Feb 3, 2018

Thanks @sbourget. Unfortunately I'm getting

Notice: Undefined property: stdClass::$userid in /home/john/www/moodle/mod/quizgame/backup/moodle2/restore_quizgame_stepslib.php on line 52

@sbourget
Copy link
Collaborator Author

sbourget commented Feb 3, 2018

Thanks @xow. I just added a commit to fix that. Could you take another look?

@xow
Copy link
Owner

xow commented Feb 3, 2018

Unfortunately seems to error out when you attempt to restore to a different course (because the question bank is not available there maybe?)

Debug info: ERROR: invalid input syntax for integer: "1,2"
SELECT * FROM mdl_backup_ids_temp WHERE backupid = $1 AND itemname = $2 AND itemid = $3
[array (
0 => '28945923630efa63a48b7b80ea4973b2',
1 => 'question_category',
2 => '1,2',
)]
Error code: dmlreadexception

@sbourget
Copy link
Collaborator Author

sbourget commented Feb 4, 2018

Any chance you can post a copy of the backup file? I cannot reproduce the issue here (MacOS / My SQL) I've been able to create the backup, delete the original course including the question category & questions, then restore the backup creating a new course. I've been able to play the game successfully in this new course accessing all of the original questions.

What context are your questions / question categories in (course / category/ or system?)

Improve logic for mapping to the question bank.
@sbourget
Copy link
Collaborator Author

I was finally able to reproduce the issue and have added a fix. It seems sometimes the questioncategory field is just holding the ID, while other times it is holding the id,context for the corresponding category in the question bank. I've added logic to the restore code to check to see what we are working with, and then to handle it appropriately.

@xow
Copy link
Owner

xow commented Feb 15, 2018

Thanks @sbourget for fixing that! Unfortunately now I get the following error

Backup is missing XML file: [tempdir]/backup/017dd7ec37ee0f0d1655d9bd61a0f968/activities/quizgame_2/grades.xml

@sbourget
Copy link
Collaborator Author

@xow, I'm a bit confused on that error. What options are you using when creating the backup? Are you backing up the whole course or just the activity?

@xow
Copy link
Owner

xow commented Feb 15, 2018

Just the activity on the front page... must be a bit of an edge case!

@sbourget
Copy link
Collaborator Author

@xow, Not sure if there is much I can do in that scenario. I've added some additional logging, but it seems activity backups MAY not include everything we would need to restore the instance. (for example, If you select a question category that is assigned to the course context or higher and perform the activity only backup, the question category is not actually included in the backup, even though the dependency is marked. This seems to be an issue with moodle core, and I'm not sure how to even approach trying to fix that)

How would you suggest I proceed from here?

@xow xow merged commit 26fcbd4 into xow:master Feb 18, 2018
@xow
Copy link
Owner

xow commented Feb 18, 2018

Thanks @sbourget. I tried course restore and had the same error (or similar)

However I thought it would be worth merging this even if it's not perfect (especially if it's a core problem). Because at least in most cases it will work. Thanks again!

@sbourget
Copy link
Collaborator Author

Thanks @xow I'll look at putting together some automated (behat) tests for backup/restore once I finish fixing issue #22 and fix the debugging notice from issue #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants