Lost Grades through quiz deletion

Lost Grades through quiz deletion

by G. S. -
Number of replies: 5

Dear Moodle-Team,

first of all, I would like to thank you for your great software. We are using it extensivily in our university-courses. Unfortunately I made a bad mistake lately: I removed some quizzes in our course, not knowing that this will also remove the grades of the quizzes. Now losing this grades is quite bad for us since it is hard to re-do the quizzes with the students sad

After some google-ing I found out that the grades are not lost but saved in something called "history tables". I contacted our Admin who promised me to try to recover the grades if I can provide him with a step-by-step description of what to do. That is why I am posting now in this forum. Could you please tell me if  there is a step-by-step description for that problem? And if not, maybe someone could help me please by writing it down?

Yours sincerely,

Gernot

In reply to G. S.

Re: Lost Grades through quiz deletion

by Adi Tedjasaputra -

Hi Gernot,

First thing first ... check whether you have a backup of the related course. If you do, you may be able to restore it.

If you dont have any backup, check whether the history tracking of changes in grades-related tables is not disabled @ Settings > Site Administration > Server > Cleanup

You can then find the tables in the database as described in http://docs.moodle.org/dev/Grades#History_tables

Recovering the grades to the deleted quiz is another thing. In most cases, you may need to write a custom script.

Cheers smile

Adi

In reply to Adi Tedjasaputra

Re: Lost Grades through quiz deletion

by G. S. -

Dear Adi,

thanks for your reply! Unfortunately I have no backup of the course and I do not have admin rights so I cannot check for the "History tracking" options by myself, but good to know that this option exists. Regarding the history table in the database, a step-by-step procedure may look like this:

1) log in to the database server

2) get courseid with SQL

3) get students of course with SQL

4) get lost grades via SQL by:
 "SELECT * FROM grad_outcomes WHERE courseid=id" and "SELECT * FROM grade_grades WHERE courseid=id"

5) Reassemble the grades via Script / Excel or something else

6) Insert grades into moodle manually

Btw. I wanted to formulate SQL Commands of step 2 and 3 but the links of http://docs.moodle.org/dev/Database_Schema seems to be down.

Do you think the above procedure is right?

Best wishes,

Gernot

 

 

 

In reply to G. S.

Re: Lost Grades through quiz deletion

by Adi Tedjasaputra -

Hi Gernot,

It is one option to  to access the database manually, using SQL queries and restore it manually, but a better one is writing a PHP script that automatically: (1) access the database, (2) extract deleted grades from the history tables and (3) restore the grades.

With regards to the SQL queries you posted, the tables that you need to access are supposed to be the history tables, not the actual grade tables, because I presume you had deleted the grades from the tables when you deleted the quiz.

You may want to get your Admin to look into this post and documentation to perform the above.

Kind regards smile

In reply to Adi Tedjasaputra

Re: Lost Grades through quiz deletion

by G. S. -

Dear Adi,

thank you for your reply and your help. I will send the link to our admin. 

Best wishes,

Gernot smile

In reply to Adi Tedjasaputra

Re: Lost Grades through quiz deletion

by G. S. -

Dear Adi,

our Admin told me that grade_grades_history has no field courseid. Therefore he wanted to combine it with grade_outcomes_history. For not-history-table this should be possible with the PHP command grade_get_grades(). However there seems to be no such PHP command for history-tables. Please could you help us how to go on?

Best wishes, Gernot