mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
90 stars 158 forks source link

Letter grade on certificate does not respect exclude empty grades in gradebook #511

Open cam-howard opened 2 years ago

cam-howard commented 2 years ago

Hi Mark,

Thanks for looking into issue #445 last year. I'm sorry I was not able to get back to you at that time. That issue is understandably closed, so I'm opening a new issue with new information.

We have run into this issue again in several courses. We are now using Moodle 3.11.4 and Custom certificate 3.11.1 (2021051701).

You are right that when you get to my Step 7 in issue #445, the numeric grade total in the course gradebook matches the numeric grade on the certificate.

I see now I neglected to say that we are using letter grades. It's the letter grade that doesn't match.

Here are two examples:

Student 1: Course gradebook reports final grade as: 86.75 (B) Certificate reports final grade as: C

Student 2: Course gradebook reports final grade as: 98.00 (A+) Certificate reports final grade as: B

You can see how students would be concerned about a full letter grade difference on the certificate!

The courses where this is happening have two or three categories in the gradebook. One of the grade categories in each course is set to exclude empty grades while the other categories and the courses as a whole are set to include empty grades. This is necessary because each course has a gradebook category where students are not required to submit all assignments, thus empty grades are excluded just for that category.

Is there a way to make the letter grade on the Custom certificate match the letter grade in the course gradebook?

Thanks, Cam

mdjnelson commented 5 months ago

Think I replicated this, or there is another weird bug going on. I went through this and even though the student has 50% if I change it to percentage on the certificate this turns into an 'F' if I swap it to a letter grade. I'll keep looking into it.

mdjnelson commented 5 months ago

Ah, I didn't realise the default standard grading system shipped with Moodle meant 50% was equal to an F.

mdjnelson commented 5 months ago

@cam-howard are you able to create a simple course and back it up and attach it here so I can replicate this? The grades dont even change when I tell it to exclude empty grades. It's the Moodle gradebook and a horrible mess to work with.

cam-howard commented 5 months ago

@mdjnelson -- Thanks for looking at this. We are now using Moodle 4.3.3. Yes, I will create a generic course illustrating the issue and upload the backup file this week.

mdjnelson commented 5 months ago

Thanks Cam.

cam-howard commented 4 months ago

@mdjnelson -- Attached is a backup of a short course with an abbreviated version of the structure used in the courses where we are running into this issue.

The course has four students, divided into two groups. The gradebook has two categories, one where all students submit all the work and empty grades are not excluded, and the other where students submit only the work related to their group and empty grades are excluded.

If you compare the final grades in the gradebook with the grade displayed on the custom certificate (called a "Grade Report" in the course), you'll see a big difference. I think that's because the certificate is ignoring the "exclude empty grades" setting in one of the gradebook categories.

Let me know if you have questions or need more information.

Thanks! Cam

backup-moodle2-course-94-test_course_for_letter_grades-20240402-1725-nf.zip

mdjnelson commented 4 months ago

Hi @cam-howard, when I try and restore this I get "The selected file is not a valid Moodle backup file and can't be restored." Which version of Moodle was this created on?

mdjnelson commented 4 months ago

Error is happening because https://github.com/moodle/moodle/blob/MOODLE_402_STABLE/backup/util/helper/backup_general_helper.class.php#L313 is returning the format backup::FORMAT_UNKNOWN.

I'll look into this further.

cam-howard commented 4 months ago

Hi Mark,

The course was created on and backed up from a Moodle Workplace site using Moodle 4.3.3. I tested restoring it on a Moodle 4.3.3 site that is not using Workplace and it worked fine.

GitHub would not let me upload the .mbz backup file from Moodle, so I zipped that file into a .zip file. You may need to unzip the zip file and then use the .mbz file to restore the course. (Or maybe you've already done that, it's just a thought about why you got the error message you did.)

~Cam

mdjnelson commented 4 months ago

Thanks @cam-howard. For some reason when I unzipped the .zip it also then unzipped the .mbz file and just showed me a folder. I then tried to change .zip to .mbz but that didn't work. I used a different unarchiving tool and it just spat out the .mbz file which is useable. Thanks!

cam-howard commented 4 months ago

@mdjnelson -- OK, great, thanks!

mdjnelson commented 4 months ago

I can see the problem. Ill try figure out what's going on.

mdjnelson commented 4 months ago

For whatever reason the code https://github.com/moodle/moodle/blob/MOODLE_402_STABLE/lib/gradelib.php#L906 is changing the 90 to 69.230769230769. This isn't the custom certificate code but core Moodle code. It is potentially a bug with Moodle and not this plugin.

mdjnelson commented 4 months ago

The reason is because the course total has been set to 130.00 in the grader report, so it's doing the percentage of 90 out of 130 and getting the letter responding to that.

mdjnelson commented 4 months ago

I changed it so the gradebook would display letters and they display correctly in the report, just not on the custom certificate. So, yeh confirming it's a bug with my code. Just need more time to investigate it.

cam-howard commented 4 months ago

Thanks. I had the gradebook set to display both the letter grade and the number of points earned so you could see that the letter grade in the gradebook for the student who earned 90 points is displayed as A- (using the standard Moodle letter grades) and is displayed as D+ in the certificate. I'm sorry if that didn't get saved in the backup so it was easier to see!

I've been assuming that meant the Moodle gradebook was taking into account the "exclude empty grades" setting on one of the gradebook categories and the custom certificate was not, but it could be something else.

Thanks for all the investigating!

mdjnelson commented 4 months ago

So, it seems to me the Gradebook API in Moodle is completely broken and the report just uses 100 as default instead of what is set. No matter how I try and obtain the grade through the convoluted and horrible Gradebook code I get the same result. Unfortunately I won't have time to look at this again for a while as I need to focus on actual work as I need $$ to survive.

cam-howard commented 4 months ago

Hi Mark -- I understand. Thanks for taking the time to look at the issue and see what's going on. I appreciate it. I hope your regular work goes well. ~Cam