title: Linking Assignments to Rubrics in Moodle
body: <p>Rubrics in Moodle are fine but it's hard to get an overview of all the rubrics used in a course.
  I'm trying to write a query that lists all the assignments together with their rubric criteria.
  This is my query:</p>
  
  <pre><code>SELECT cou.fullname, ass.name, def.name, cri.description
  FROM mdl_course cou
  inner join mdl_assign ass on ass.course = cou.id
  inner join mdl_course_modules cmod on cmod.course = cou.id
  inner join mdl_context ctx on ctx.instanceid = cmod.id
  inner join mdl_grading_areas are on are.contextid = ctx.id
  inner join mdl_grading_definitions def on def.areaid = are.id
  inner join mdl_gradingform_rubric_criteria cri on cri.definitionid = def.id
  where cou.fullname like '%rduin%1%' 
  order by cou.fullname, ass.name, cri.sortorder
  </code></pre>
  
  <p>It took me about two hours to find the link between Assignments and their grading_definitions, but the query still generates too many records. I guess I have to add another join or relationship, but can't figure out which.
  Any help would be appreciated!</p>