From: stronk7 Date: Sun, 22 Feb 2004 18:15:45 +0000 (+0000) Subject: Added the lesson_get_participants() function X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6e773096a5efe31aa699c7434096fa24a7bf2a89;p=moodle.git Added the lesson_get_participants() function to properly detect all the needed users with data in the activity in order to be able to backup them. --- diff --git a/mod/lesson/backuplib.php b/mod/lesson/backuplib.php index 07ce4d3007..2817ea4e7e 100644 --- a/mod/lesson/backuplib.php +++ b/mod/lesson/backuplib.php @@ -10,12 +10,12 @@ // | lesson_grades // | (UL, pk->id,fk->lessonid) // lesson_pages - // (pk->id,fk->lessonid) + // (CL,pk->id,fk->lessonid) // | // | // | // lesson_answers - // (pk->id,fk->pageid) + // (CL,pk->id,fk->pageid) // | // | // | diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index d4800d348c..35553b4e76 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -276,9 +276,18 @@ function lesson_get_participants($lessonid) { //Must return an array of user records (all data) who are participants //for a given instance of lesson. Must include every user involved //in the instance, independient of his role (student, teacher, admin...) -//See other modules as example. - return false; + global $CFG; + + //Get students + $students = get_records_sql("SELECT DISTINCT u.* + FROM {$CFG->prefix}user u, + {$CFG->prefix}lesson_attempts a + WHERE a.lessonid = '$lessonid' and + u.id = a.userid"); + + //Return students array (it contains an array of unique users) + return ($students); } ////////////////////////////////////////////////////////////////////////////////////// diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 486507bf3d..64e4ec7e10 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -10,12 +10,12 @@ // | lesson_grades // | (UL, pk->id,fk->lessonid) // lesson_pages - // (pk->id,fk->lessonid) + // (CL,pk->id,fk->lessonid) // | // | // | // lesson_answers - // (pk->id,fk->pageid) + // (CL,pk->id,fk->pageid) // | // | // |