General developer forum

Keeping track of students that quit a course

 
 
Picture of Ricardo Godinho
Keeping track of students that quit a course
 

Hello everyone

I'm having a problem here which i'm not sure if it is more PHP or Moodle related.  I have a csv with usernames and emails and I would like to crosscheck these usernames  with the students' usernames that are registered on a Moodle course. If those on Moodle are not present in the csv, I would like to define them a Quit status.  This is particulary useful where Moodle is interacting with an outside management academic platform.

This method lists me all students of a course

$xpta=get_all_students($courseid);
 print_r($xpta);

The output:

Array ( [m.menas] => stdClass Object ( [username] => m.menas ) [m.bexiga] => stdClass Object ( [username] => m.bexiga ) [spm] => stdClass Object ( [username] => spm ) )

My first thought was to call array_diff function but that isn't working. I've had data[0]( which is the position of the usernames) but that expects an array parameter. As it is now, the condition is never checked.

$fp=fopen('sample.csv','r');
        $numberofquitters=0;

        $enrolinfo=' ';
        fgetcsv($fp,1000,";");
        while(($data=fgetcsv($fp,1000,";"))!==FALSE){
        if(array_diff((array)$xpta->username,$data)){
            //echo $xpto->username;
            $enrolinfo=get_string('quitter','local_ecoclipaluno');
            $numberofquitters++;
        }

My goal is to make these usernames show on my table box, as in my picture.

Any ideas?

Cheers,

Ricardo Godinho


 
Average of ratings: -
Picture of Ricardo Godinho
Re: Keeping track of students that quit a course
 

So, can this be done? 

I've converted the students to  array, as well as the contents of my csv. But even with array_diff ()   or   =!in_array($array1,$array2) the only outcome I get is Array()   or every student listed on my course. 

Is there any moodle functionality that prevents this action?  expiration date of a student in a course, for example?

 
Average of ratings: -