google apps script - Create student roster from Classroom -


i'm trying pull student information google classroom roster. here have far:

function studentroster() {   var optionalargs = {     pagesize: 2   };   var getstudents = classroom.courses.students.list("757828465",optionalargs).students;   logger.log(getstudents); } 

sandy's answer below helped solve part of problem , log (names, id's, emails , such changed):

[16-01-05 17:44:04:734 pst] [{profile={photourl=https://lh3.googleusercontent.com/-xduiqdmkcwa/aaaaaaaaaai/aaaaaaaaaaa/4252rscbv5m/photo.jpg, emailaddress=jsdoe@fjuhsd.org, name={givenname=john, familyname=doe, fullname=john doe}, id=108117124004883828162}, courseid=757828465, userid=108117124004883828162}, {profile={photourl=https://lh3.googleusercontent.com/-xduiqdmkcwa/aaaaaaaaaai/aaaaaaaaaaa/4252rscbv5m/photo.jpg, emailaddress=jhdoe@fjuhsd.org, name={givenname=jane, familyname=doe, fullname=jane doe}, id=115613162385930536688}, courseid=757828465, userid=115613162385930536688}]

so question is: how extract pieces of information (like full name , email)?

the end result pushing google sheet.

the collection sections under classroom api reference can clarify of object chaining required access fields want.

the following code generate list of student names, email, , associated course id.

function liststudents() {    var optionalargs = {      pagesize: 0     // max output    };    var response = classroom.courses.students.list(xxxxxxxxx; // put courseid here    var students = response.students;    if(students && students.length > 0){      for( = 0; < students.length; i++){       var student = students[i];       // fullname prefixed s/      use of .substring removes first 2 characters       logger.log('%s %s %s',  student.profile.name.fullname.substring(2), student.profile.emailaddress, student.courseid    );      }    } else {      logger.log('no students in course');    }   }

collection courses.students


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -