Manual DB Grade Insertion with datecreated, missing userids

Manual DB Grade Insertion with datecreated, missing userids

by James Avery -
Number of replies: 2

I have built a custom script that alerts teachers/managers when a student needs to retake their yearly quiz. Ever morning, the cron script looks in the grades table for all 10/10 grades, looks at the the date the record was created, then sends out an email to the corresponding teacher/manager if it was recorded 351 days ago. This script is working as intended.

Here is my problem: My client has asked me to insert some older (pre-moodle) grades into the system. I was provided a pretty organized spreadsheet which appears to have all of the info I need. I looked into converting it to CSV and doing a grade import through the UI. However, I am not seeing the ability to retain the date that the grade was recorded. This information is essential.

So, since the moodle UI doesn't appear to support the ability to retain dates when inserting grades, I can develop a script that will manually insert grades into the grades table. However, when looking at the userids for each grade, and referencing them with the users table, I am seeing that some users have null userids.Some have userids and some don't.

If I can match a name to a user ID I can insert the grades with my script, but since some users do not have userids recorded I am not sure what my next step is.

Can someone please explain the best way to do a batch insert into the grades table, while retaining the date recorded, and connecting that grade to the proper user?

My spreadsheet my client provided contains the full first and last name, the grade, the highest grade possible (100%), the date is was recorded and the quiz name. All of this data is formatted identical to the data in the DB.

Any ideas? Your help is GREATLY appreciated.

In reply to James Avery

Re: Manual DB Grade Insertion with datecreated, missing userids

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I suggest you just edit the code in grade/import/csv, so that it does import the date along with everything else, if it is present.

In reply to Tim Hunt

Re: Manual DB Grade Insertion with datecreated, missing userids

by James Avery -

Thanks. We are trying to get this change made pretty quickly. I would be willing to pay to have someone make this modification for me. Any resources you know of that I could look into to get a reliable coder to make this modification?