- JOIN {context} ctx ON ctx.id = ra.contextid
- LEFT JOIN {context} cctx
- ON (cctx.contextlevel = ".CONTEXT_COURSE." AND ctx.path LIKE ".$DB->sql_concat('cctx.path',"'/%'").")
- WHERE ra.userid = :userid AND cctx.id IS NULL";
-
-
+ JOIN {context} ctx
+ ON ctx.id = ra.contextid
+ LEFT JOIN {block_instances} bi
+ ON (ctx.contextlevel = ".CONTEXT_BLOCK." AND bi.id = ctx.instanceid)
+ LEFT JOIN {context} bpctx
+ ON (bpctx.id = bi.parentcontextid)
+ WHERE ra.userid = :userid
+ AND (ctx.contextlevel <= ".CONTEXT_COURSE." OR bpctx.contextlevel < ".CONTEXT_COURSE.")";