moodle: A query to see where lessons come from

June 18, 2014

updated 2016-12-08

to see where-how the modules for each "Topic" are stored and kept in order


SELECT cs.id, cs.course, cs.section, cs.sequence,
cm.id AS cm_id, cm.module, cm.instance
FROM mdl_course_sections AS cs
JOIN mdl_course_modules AS cm
ON FIND_IN_SET(cm.id, cs.sequence)
WHERE cs.course = 40
AND cs.sequence <> ''
AND cs.visible = 1
AND cm.visible = 1
ORDER BY cs.course, cs.section, FIND_IN_SET(cm.id, cs.sequence) ;

look at your list of modules in the mdl_modules table
here are a few core modules:

id name
==-====
11 lesson
12 quiz
13 resource
14 scorm
15 survey
16 wiki
17 workshop
19 feedback
23 page
24 url
25 assign

this example shows a course (#233) with mostly 3 or 4 lesson (11) modules per topic:

+------+--------+---------+---------------------+-------+--------+----------+
| id | course | section | sequence | cm_id | module | instance |
+------+--------+---------+---------------------+-------+--------+----------+
| 8667 | 233 | 0 | 8473 | 8473 | 11 | 7387 |
| 8668 | 233 | 1 | 8474 | 8474 | 11 | 7388 |
| 8669 | 233 | 2 | 8475,8476 | 8475 | 11 | 7389 |
| 8669 | 233 | 2 | 8475,8476 | 8476 | 29 | 3 |
| 8671 | 233 | 3 | 8477,8478,8479 | 8477 | 11 | 7390 |
| 8671 | 233 | 3 | 8477,8478,8479 | 8478 | 29 | 4 |
| 8671 | 233 | 3 | 8477,8478,8479 | 8479 | 29 | 5 |
| 8672 | 233 | 4 | 8480 | 8480 | 11 | 7391 |
| 8673 | 233 | 5 | 8481,8487 | 8481 | 11 | 7392 |
| 8673 | 233 | 5 | 8481,8487 | 8487 | 29 | 6 |
| 8674 | 233 | 6 | 8482,8493,8494,8495 | 8482 | 11 | 7393 |
| 8674 | 233 | 6 | 8482,8493,8494,8495 | 8493 | 11 | 7400 |
| 8674 | 233 | 6 | 8482,8493,8494,8495 | 8494 | 11 | 7401 |
| 8674 | 233 | 6 | 8482,8493,8494,8495 | 8495 | 11 | 7402 |
| 8675 | 233 | 7 | 8488 | 8488 | 11 | 7395 |
| 8676 | 233 | 8 | 8483 | 8483 | 11 | 7394 |
| 8677 | 233 | 9 | 8490,8491,8492 | 8490 | 11 | 7397 |
| 8677 | 233 | 9 | 8490,8491,8492 | 8491 | 11 | 7398 |
| 8677 | 233 | 9 | 8490,8491,8492 | 8492 | 11 | 7399 |
| 8838 | 233 | 10 | 8523,8484 | 8523 | 11 | 7429 |
| 8838 | 233 | 10 | 8523,8484 | 8484 | 19 | 43 |
+------+--------+---------+---------------------+-------+--------+----------+

Leave a Reply

Your email address will not be published. Required fields are marked *

We try to post all comments within 1 business day