prefix}role_assignments rs INNER JOIN {$CFG->prefix}role r ON rs.roleid=r.id INNER JOIN {$CFG->prefix}context e ON rs.contextid=e.id INNER JOIN {$CFG->prefix}enrol en ON e.instanceid=en.courseid INNER JOIN {$CFG->prefix}course c ON c.id=en.courseid INNER JOIN {$CFG->prefix}user_enrolments ue ON en.id=ue.enrolid WHERE rs.userid=:aluno'"; //pegar o idaluno selecionado $params['aluno'] = $_REQUEST['idaluno']; $rowscursos = $DB->get_records_sql($sql); foreach ($rowscursos as $rowcurso){ echo ''; } ?>