Download users and remove users

Download users and remove users

by Aditya Dubay -
Number of replies: 9
Hi,

I am using Moodle 2.5.5
I wish to know that how can I include fields like "First access" and "Last Access" while downloading users via "Bulk user action".
I feel we should able to choose fields there.
Also I wish to know that is there any option by which user who do not access website from last 2 weeks, removed/disabled automatically?????

Regards,
Aditya
Average of ratings: -
In reply to Aditya Dubay

Re: Download users and remove users

by Aditya Dubay -

Please help sad

In reply to Aditya Dubay

Re: Download users and remove users

by triveni mergu -

Hi Aditya,

Please  update the code in /admin/user/user_bulk_download.php

change following array

$fields = array('id'        => 'id',
                    'username'  => 'username',
                    'email'     => 'email',
                    'firstname' => 'firstname',
                    'lastname'  => 'lastname',
                    'idnumber'  => 'idnumber',
                    'institution' => 'institution',
                    'department' => 'department',
                    'phone1'    => 'phone1',
                    'phone2'    => 'phone2',
                    'city'      => 'city',
                    'url'       => 'url',
                    'icq'       => 'icq',
                    'skype'     => 'skype',
                    'aim'       => 'aim',
                    'yahoo'     => 'yahoo',
                    'msn'       => 'msn',
                    'country'   => 'country');

to

$fields = array('id'        => 'id',
                    'username'  => 'username',
                    'email'     => 'email',
                    'firstname' => 'firstname',
                    'lastname'  => 'lastname',
                    'idnumber'  => 'idnumber',
                    'institution' => 'institution',
                    'department' => 'department',
                    'phone1'    => 'phone1',
                    'phone2'    => 'phone2',
                    'city'      => 'city',
                    'url'       => 'url',
                    'icq'       => 'icq',
                    'skype'     => 'skype',
                    'aim'       => 'aim',
                    'yahoo'     => 'yahoo',
                    'msn'       => 'msn',
                    'country'   => 'country',
                    'firstaccess'=> 'firstaccess',
                    'lastaccess' => 'lastaccess');

// added first access and last access

and if you want to change format of date time

please follow the below steps:

change

  foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

to

      foreach ($fields as $field=>$unused) {
            if(($field == 'firstaccess') || ($field == 'lastaccess')){
                $accesstime = date('d-m-Y H:i:s',$user->$field);
                $worksheet[0]->write($row, $col, $accesstime);    
            }else{
                $worksheet[0]->write($row, $col, $user->$field);    
            }
            
            $col++;
        }

 

 

is this clear for you

In reply to triveni mergu

Re: Download users and remove users

by Aditya Dubay -

Thanks Triveni smile

I got 2 instances of 

foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

Its on line 96 and on line 150.

Which one I need to change as I changed line 96 then it gives me attached result. User_Bulk_Download file is also attached.

There is problem in date format in excel sheet. It wont give me date even I try custom format "d-m-Y H:i:s".


Aditya

In reply to Aditya Dubay

Re: Download users and remove users

by triveni mergu -

Hello Aditya..!

 

Please find the attached file, as i modified your code.

and its working well for me

Average of ratings: Useful (2)
In reply to triveni mergu

Re: Download users and remove users

by Aditya Dubay -

Thanks smile

It works for me smile

I found you made some changes below.

Can you please explain why you made those changes and how it works smile


Aditya

In reply to Aditya Dubay

Re: Download users and remove users

by triveni mergu -

Hello Aditya,

   i modified code in user_download_xls function, since we are using this function for downloading users in excel format.

your changes would be work for ods file format

In reply to triveni mergu

Re: Download users and remove users

by Aditya Dubay -

Ohh

Thanks a ton smile

Now I can identify user access in excel too.

It helps me a lot.

smile

In reply to Aditya Dubay

Re: Download users and remove users

by triveni mergu -
In reply to triveni mergu

Re: Download users and remove users

by Aditya Dubay -

Hi Triveni,

I need your favor smile

Please tell me from where we can get field name which we can add in Bulk user download file???

Like I wish to add enrolled course of user in that file then what I need to add???


Thanks in advance,

Aditya