See all Courses of a teacher

See all Courses of a teacher

by Ashish Tiwari -
Number of replies: 1
Hi to all ,

Am a developer and developing a custom moodle layer written in php for Students, in simpler words , for students there will be a seperate URL , fully different look & feel of moodle. (for admin & Teachers & others , UI is same of Moodle)

In Moodle : In profile page I can see his details and a number of courses in which the teacher has enrolled.

in my page i want to put same funcnality. but it is not working.

I used the Query


SELECT c.id,c.sortorder,c.shortname,c.idnumber,c.category,c.fullname,c.teacher,c.teachers,c.student,c.students,c.guest,c.startdate,c.visible,c.newsitems,c.cost,c.enrol,c.groupmode,c.groupmodeforce, ctxid, ctxpath, ctxdepth, ctxlevel, categorypath
FROM (
SELECT c.id,
ctx.id AS ctxid, ctx.path AS ctxpath,
ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel,
cc.path AS categorypath
FROM mdl_course c
JOIN mdl_course_categories cc
ON c.category=cc.id
JOIN mdl_context ctx
ON (c.id=ctx.instanceid AND ctx.contextlevel=50)
JOIN mdl_role_assignments ra
ON (ra.contextid=ctx.id AND ra.userid=3)
UNION
SELECT c.id,
ctx.id AS ctxid, ctx.path AS ctxpath,
ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel,
cc.path AS categorypath
FROM mdl_course c
JOIN mdl_course_categories cc
ON c.category=cc.id
JOIN mdl_context ctx
ON (c.id=ctx.instanceid AND ctx.contextlevel=50)
JOIN mdl_role_capabilities rc
ON (rc.contextid=ctx.id AND (rc.capability='moodle/course:view' ))
) inline_view
INNER JOIN mdl_course c
ON inline_view.id = c.id

where ra.userid is the user id. ithis query works fine with many users (teachers to be exact), but for some users it is giving wrong results. little more going in the code revealed that the function has_capability_in_accessdata is deleting some courses.

this is a complex function and am unable to interpret it.
Average of ratings: -