How can I extract the participants' data from current course?

Re: How can I extract the participants' data from current course?

by Rosario Carcò -
Number of replies: 0

Sorry, as I got a "more than one record found" error, I had to add the $USER->id as another criterion. So it looks like that now:

    if (!$this->mycold && $CFG->block_mycourses_notvisitedsince > 0 ) {
        $timestamp = time() - $CFG->block_mycourses_notvisitedsince * 86400;//Cr: calculate timestamp - number of days in seconds from today back

        $lastaccess = $DB->get_field('user_lastaccess', 'timeaccess', array('courseid' => $course->id, 'userid' => $USER->id));
//Cr: for debugging
//print_r(array('courseid and lastaccess: ',$course->id, $lastaccess));
        if ($lastaccess < $timestamp) {//Cr: skip this course
            return;
        }           
    }            

$this->mycold is the flag the users can toggle on/off to display/not display the old courses.