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

Invalid course module ID #34

Closed
ghost opened this issue Aug 30, 2016 · 23 comments
Closed

Invalid course module ID #34

ghost opened this issue Aug 30, 2016 · 23 comments

Comments

@ghost
Copy link

ghost commented Aug 30, 2016

When I click on get your custom certificate I get the following error Invalid course module ID.

Version: 3.1 release (Build: 2016052302)

@mdjnelson
Copy link
Owner

Hi, thanks for the report.

What is the page you are viewing? mod/customcert/view,php?

@ghost
Copy link
Author

ghost commented Aug 30, 2016

View.php
By the way thank you for the amazing quick reply.

@mdjnelson
Copy link
Owner

mdjnelson commented Aug 30, 2016

Thanks and no problem.

So the error is happening because of https://github.com/markn86/moodle-mod_customcert/blob/master/view.php#L37 and unfortunately there is not much I can do in terms of code to fix this. It is basically saying that the module does not exist in the database (for whatever reason). Has this been a custom certificate you have been using before that no longer works, or one you just created? It would be great if I could get some replication steps.

@ghost
Copy link
Author

ghost commented Aug 30, 2016

It's one we have been using. Did a update for Moodle and the certificate module over the weekend. Just had a user report it today though.

@mdjnelson
Copy link
Owner

When you say certificate module, do you mean mod_certificate or mod_customcert (you can tell by looking at the URL if it's mod/certificate/view.php or mod/customcert/view.php)? Either way I can't explain why the module would suddenly no longer exist on the site after an upgrade, yet still display in the course. Seems that something messed up somewhere. If a user has reported it, are you also able to reproduce it?

@ghost
Copy link
Author

ghost commented Aug 31, 2016

Sorry about that, it is the customcert. Yes, as logged in as the administrator I get the invalid ID error as well. I also get the error when I attempt to download a previous certificate from another user. I'm not sure what happened either. :) I checked in the database and there seems to be the right information stored in the tables. Either way, I am restoring from a backup now, but I do have the "problem site" backed up so I can try and find a solution if it happens again. Although, if the same happens after I run git pull to update I will be back where I am...here's hoping. :)

@ghost
Copy link
Author

ghost commented Aug 31, 2016

I have finished restoring the site and everything is working fine now.

Before applying the updated mod_customcert, I tested it with another site of mine that is my testing site and determined it has something to do with the update process. I tested the viewing of a certificate before the update and was able to view it just fine, once I applied the update, I started getting the "Invalid course module ID". If you need anything or would like me to dump my "test" database, please let me know.

Either way thank you for all that you do! :)

@mdjnelson
Copy link
Owner

Are you updating the customcert, or the Moodle version? If it's the customcert, what version are you upgrading from?

@ghost
Copy link
Author

ghost commented Sep 1, 2016

I am updating the customcert and the version I'm updating from is Beta release (Build: 2016021900).
My Moodle version 3.1.1+ (Build: 20160811).

@mdjnelson
Copy link
Owner

Ok, so you would have installed from the release 43d20c0. This was before I was upgrading the database with any changes I made because it was still in beta, sorry. Are you able to turn on debugging mode (see https://docs.moodle.org/31/en/Debugging) to provide me with the full strack trace?

@mdjnelson
Copy link
Owner

mdjnelson commented Sep 5, 2016

The only DB change I performed since changing the plugin to Beta was the change to db/install.xml in 6889b04. If you have access to the 'customcert_pages' table can you confirm whether that there is a column 'sequence' there, and not 'pagenumber'?

@ghost
Copy link
Author

ghost commented Sep 5, 2016

I knew I was taking a chance when using the beta version, I was just really loving how easy this module is to use to create a custom certificate. Thank you for taking the time with me!

Here is the stack trace:
Stack trace:
•line 1502 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
•line 1478 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
•line 293 of /mod/customcert/element/grade/classes/element.php: call to moodle_database->get_record()
•line 273 of /mod/customcert/element/grade/classes/element.php: call to customcertelement_grade\element::get_mod_grade()
•line 129 of /mod/customcert/element/date/classes/element.php: call to customcertelement_grade\element::get_grade()
•line 299 of /mod/customcert/classes/template.php: call to customcertelement_date\element->render()
•line 127 of /mod/customcert/view.php: call to mod_customcert\template->generate_pdf()

@mdjnelson
Copy link
Owner

No problem!

It seems the grade element is pointing to a course module that no longer exists. If you edit customcert and then the grade element and re-select the grade item it displays the grade for then it should work as expected. Will have to fix it so the customcert doesn't explode when this happen.

@ghost
Copy link
Author

ghost commented Sep 5, 2016

Alright, if I understand correctly, I should modify the certificate and change the grade for the course? Or do you mean something else? :)

@mdjnelson
Copy link
Owner

Nope. Just re-edit the custom certificate and edit the grade element you added to it, then under 'Grade item' select the grade item you want and then click on 'Save changes'.

@ghost
Copy link
Author

ghost commented Sep 5, 2016

I never had a grade element added to the certificate. I did try and add one and selected the grade item as the course, although I am still getting the same error with the same stack trace.

@mdjnelson
Copy link
Owner

mdjnelson commented Sep 5, 2016

Ahh, nevermind. I looked at the the stack trace incorrectly. It is because the date element is using a function in the grade element that is trying to find a course module that does not exist. Ok, replace everything I said earlier with 'date' rather than 'grade'.

@ghost
Copy link
Author

ghost commented Sep 5, 2016

Alright, it worked! You are awesome! I will update my module on my live site today, if all goes well, your solution will fix my problem there as well.

I do have a question, when editing the element I noticed that the Position X and Y is no longer present. How do you reposition the elements?

@mdjnelson
Copy link
Owner

mdjnelson commented Sep 5, 2016

Glad I helped! :) You can drag and drop the elements by clicking on the 'Reposition elements' link under the list of elements. It should really be more noticeable. Will be addressing the UX experience in #35.

@ghost
Copy link
Author

ghost commented Sep 5, 2016

Thank you!

@ghost ghost closed this as completed Sep 5, 2016
@mdjnelson mdjnelson reopened this Sep 5, 2016
@mdjnelson
Copy link
Owner

mdjnelson commented Sep 5, 2016

Reopening just to remind me to fix this when a course module is missing to avoid it exploding. :)

@ShelterJames
Copy link

I had the same problem on Moodle 3.0, and fixed it simply by editing the date element. Thanks.

@mdjnelson
Copy link
Owner

Fixed.

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

No branches or pull requests

2 participants