Databases: SQL query - getting all grades of students

Databases: SQL query - getting all grades of students

by Markus Fic -
Number of replies: 0

Hello, I've a problem with displaying all grades of each student.

I've written the following query to get all grades:

SELECT t3.itemname, t2.username, t2.email, from_unixtime(t1.timemodified), t1.rawgrade FROM prefix_grade_grades_history t1, prefix_user t2, prefix_grade_items t3 WHERE t1.userid = t2.id AND t3.id = t1.itemid AND t2.id=%%USERID%% AND t3.itemname <> "" ORDER BY t3.itemname, t1.timemodified

A student can take (scorm) quizzes multiple times. Each student can access & run the query to determine his "attempts". But the problem is, that if a student takes a quiz 2 or more times and reaches the same points as before, there is no new record created... Only if the last grade/score is different from the new one, there will be a new entry written.

Example:

Quiz attempt1: Points: 90% <- Record created

Quiz attempt2: Points: 80% <- Record created

Quiz attempt3: Points: 80% <- NO Record created

Quiz attempt4: Points: 100% <- Record created

Is it possible to show this missing grade and date/time anyway?

I'm using Moodle 2.1.1.

I'm very thankfull for every kind of help.

Thanks!

Average of ratings: -