Skip to content

Instantly share code, notes, and snippets.

@isubas
Last active January 6, 2017 08:17
Show Gist options
  • Save isubas/0f02c28ed5abe3be99fd5d35b503e6b3 to your computer and use it in GitHub Desktop.
Save isubas/0f02c28ed5abe3be99fd5d35b503e6b3 to your computer and use it in GitHub Desktop.
Moodle Öğrenci Derslerini Çekme (SQL)
use moodle;
SELECT cc.name AS Bolum,
c.fullname AS DersAdi,
c.idnumber AS DersIdNumber,
c.visible AS DersGorunurluk,
c.shortname AS DersKisaAdi,
uid.data AS TCVeyaOGR,
uif.name AS DataAdi,
u.idnumber AS OgrenciIdNumber,
u.username AS KullaniciADİ,
u.firstname AS Ad ,
u.lastname AS Soyad,
u.email AS Eposta,
u.phone1 AS Tel1,
u.phone2 AS Tel2,
u.institution AS Okul,
u.department AS Bolum,
mg.name AS GrupAdı
FROM mdl_user u
JOIN mdl_user_enrolments ue ON ue.userid = u.id
JOIN mdl_enrol e ON e.id = ue.enrolid
JOIN mdl_role_assignments ra ON ra.userid = u.id
JOIN mdl_context ct ON ct.id = ra.contextid AND ct.contextlevel = 50
JOIN mdl_course c ON c.id = ct.instanceid AND e.courseid = c.id
LEFT JOIN mdl_groups_members mgm ON mgm.userid = u.id
LEFT JOIN mdl_groups mg ON mgm.groupid = mg.id AND mg.courseid = c.id
JOIN mdl_course_categories cc ON c.category = cc.id
JOIN mdl_role r ON r.id = ra.roleid AND r.shortname = 'student'
JOIN mdl_user_info_data uid ON uid.userid = u.id
JOIN mdl_user_info_field uif ON uif.id = uid.fieldid AND uif.shortname = "tc"
WHERE e.status = 0 AND u.suspended = 0 AND u.deleted = 0 AND c.visible = 1
AND (ue.timeend = 0 OR ue.timeend > NOW()) AND ue.status = 0
INTO OUTFILE '/var/lib/mysql-files/users2.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment