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