[LON-CAPA-admin] Auto update of student/employee ID

Stuart Raeburn raeburn at msu.edu
Mon Feb 23 20:16:44 EST 2015


Hi Hon-Kie,

> See above. How should it be set to update all users on the return from
> $instusers?

If you have *not* defined any institutional status types then
localenroll::allusers_info() needs to populate the $instusers hashref  
in one of the following ways (for username: $uname)

(a) $instusers->{$uname}{'inststatus'} = [];   or
(b) $instusers->{$uname}{'inststatus'} = '';   or
(c) no inststatus key in %{$instusers->{$uname}}

If you have defined institutional status types then   
localenroll::allusers_info() should populate the 'inststatus' array  
ref with each user's type(s), e.g., $instusers->{$uname}{'inststatus'}  
= ['Faculty'];
or $instusers->{$uname}{'inststatus'} = ['Student'];

The "Updatable user data" settings in Main Menu -> Set domain  
configuration -> Display (Auto-update settings checked) should then  
include one row for each type, and a final row for "Other users"  
(which maps to "default"), and you would check the appropriate  
checkboxes for each of the fields you wish to update, for each of the  
different types.

In LON-CAPA 2.10 and earlier, available institutional types were  
specified by customizing the &inst_usertypes() routine in  
localenroll.pm.  Starting with 2.11, those are set using the domain  
coordinators' web GUI:

Main Menu -> Set domain configuration -> Display (Default   
authentication/language/timezone/portal/types checked)

See: adm/help/Domain_Configuration_LangTZAuth.hlp

Those settings can be displayed by a Domain Coordinator in the fsu domain via:
https://loncapa10.fsu.edu/cgi-bin/listdomconfig.pl

>  inststatus = $VAR1 = {
>           'inststatusorder' => [],
>           'inststatustypes' => {},
>           'inststatusguest' => []
>         };

When you display "Default  
authentication/language/timezone/portal/types" in the web GUI,

> There does not seem to have any relevant entries on lonnet.log at around
> 3:30 am.

The fact that you are not seeing anything in lonnet.log indicates that  
$changed is false for each user.  $changed is set in:

foreach my $field (@fields) {
       if ($userhash{$field} ne $instusers{$uname}{$field}) {
           $changed = 1;
       }
}

So, either no fields are being checked for changes (i.e., @fields is  
an empty array), or the values of $userhash{$field} and  
$instusers{$uname}{$field} are the same.

I would check that @fields contains 'id', and then I would print to  
STDERR the values of $userhash{'id'} and $instusers{$uname}{id} for a  
particular user.

As I mentioned in my previous post, it is quite straightforward to  
temporarily modify /home/httpd/perl/Autoupdate.pl to check just one  
user.  (Run from the command line as www). For example, to check user  
information changes for just user: hkng

Replace:

           my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
           &descend_tree($dom,$dir,0,\%users,\%courses);

with

           my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom.'/h/k/n/';
           &descend_tree($dom,$dir,4,\%users,\%courses);

and add the line:

next if ($item ne 'hkng');

immediately before the line
if ($depth < 4) {

in the descend_tree subroutine.

If you have access to institutional affiliation (i.e., Faculty, Staff,  
Student etc.) in the data you retrieve using  
localenroll::allusers_info() and localenroll::get_userinfo(), then I  
would recommend configuring institutional types for the domain. You  
will then be able to use the domain configuration GUI to assign a  
variety of defaults for users based on affiliation.


Stuart Raeburn
LON-CAPA Academic Consortium


Quoting "H. K. Ng" <hkng at fsu.edu>:

> Thanks Stuart,
>
> See responses below.
>
> -hk
>
>
>
> On Tue, Feb 17, 2015 at 1:41 PM, Stuart Raeburn <raeburn at msu.edu> wrote:
>
>> Hi Hon-Kie,
>>
>> > The bottom line is how do I get the student/employee ID to be update
>> > nightly via the cron jobs?
>>
>> Has Autoupdate.pl successfully updated IDs for users in the fsu domain
>> in the past, or is this a new procedure for your domain?
>>
>
> It has worked before. There is a change in the database server and of
> course, new configurations. I tested the allusers_info and it works fine.
> This is what I have for allusers_info.
>
> $dom is set to 'fsu'
> $instusers - input with keys pointing to usernames.
>      Data retrieved from database is written to instusers as
>   $instusers->{$username} = {firstname => $fname,
> middlename => $mname,
> lastname => $lname,
> generation => $gen,
> id => $id,
> permanentemail => $email
> $instids - not used
> $ lc_users - not used
>
> The alluser_info calls to the database returns the correct info.
>
>
>
>> Autoupdate.pl is successfully updating student/employee IDs in the msu
>> domain.
>>
>> > Auto-update active? set to yes
>> > Update information in classlist? set to yes
>> > User preference to lock name - not check
>> > Under User population
>> >   All users on the student/employee ID is checked.
>>
>> Those look good, although see the caveat below regarding user
>> population (i.e., "All users").
>>
>> If you are not seeing updates to IDs in the fsu domain, then there may
>> be a problem retrieving user information using the allusers_info()
>> routine in your customized /home/httpd/lib/perl/localenroll.pm
>>
>> Alternatively, it may be that the institutional affiliation of the
>> users retrieved in allusers_info() is not blank (e.g., it might be
>> student), whereas your domain configuration is set to update "All
>> users" (i.e., there are no specific institutional types set for the
>> domain, in which case only users without an affiliation will be
>> updated).
>>
>
> See above. How should it be set to update all users on the return from
> $instusers?
>
>
>
>
>>
>> Are there changes logged in /home/httpd/perl/logs/autoupdate.log?
>> How about in /home/http/perl/logs/lonnet.log?
>>
>> The autoupdate,log has just the following:
>
> Wed Feb 18 03:30:02 am 2015 (EST) Autoupdate messages start for domain: fsu
> --
> --
> Wed Feb 18 03:50:35 am 2015 (EST) Autoupdate messages end
>
> Seems that no users was processed.
>
> There does not seem to have any relevant entries on lonnet.log at around
> 3:30 am.
>
>
>
>> I would expect an entry of the following type in autoupdate.log:
>>
>> User change: <username>:fsu; New values: 1.Name: <fullname>; 2. StuID:
>> <id>; 3. Email: <e-mail address>.
>>
>> and an entry of the following type in lonnet.log
>>
>> Call to modify user fsu, <username>, <id>, , <firtsname>, <middlename>
>> , <lastname>, (forceid: 1; candelete: id) desiredhome = <home> by  at
>> in domain
>>
>> When you log-in to the web GUI, select your domain coordinator role in
>> the fsu domain and display:
>> https://loncapa10.fsu.edu/cgi-bin/listdomconfig.pl
>>
>> What do you see in the autoupdate and inststatus entries for the fsu
>> domain?
>>
>
> autoupdate = $VAR1 = {
>           'lockablenames' => [],
>           'run' => '1',
>           'fields' => {
>                         'default' => [
>                                        'id'
>                                      ]
>                       },
>           'classlists' => '1'
>         };
>
>  inststatus = $VAR1 = {
>           'inststatusorder' => [],
>           'inststatustypes' => {},
>           'inststatusguest' => []
>         };
>
>
>> > In addition to the Auto-update settings, there is the User modification.
>> In
>> > what context is the User modification updateable? Since in my case the
>> > update is done by the cron jobs, Autoaupdate.pl and Antoenroll.pl, it is
>> > not clear how User modification is used. (Seems to be settings for users
>> to
>> > allow them to update themselves??)
>>
>> User modification applies when a Course Coordinator or Author uses
>> "Add/Modify a Course User" or "Add/Modify a Student" to change user
>> information.
>>
>> The domain configuration settings determine which fields may be
>> changed, depending on context (author or course), and role of the user
>>   for whom ichanges are being made. Non-privileged users may not
>> change their own user information settings (except, optionally, at
>> account creation).
>>
>> In addition, Autoenroll.pl will not change user information (name, id,
>> e-mail address) for a user already enrolled in a course (it just
>> manages enrollment in courses).
>>
>> Instead, Autoupdate.pl is intended to support synchronization of user
>> information (regardless of course enrollment, potentially between all
>> LON-CAPA users in a domain and the corresponding institutional data.
>>
>> If you use Autoupdate.pl (and it is working), then the "User
>> modification" settings for changes via the web GUI by authors and CCs
>> are not useful, because any changes made there, will be overwritten by
>> the next run of Autoupdate.pl.
>>
>> See:
>>
>> https://loncapa10.fsu.edu/adm/help/Domain_Configuration_User_Modification.hlp
>> https://loncapa10.fsu.edu/adm/help/Domain_Configuration_Auto_Updates.hlp
>>
>> If the problem is with customizations to localenroll.pm, then you'll
>> like need to do some debugging.  It is fairly straightforward to
>> temporarily modify Autoupdate.pl so it just updates a single user.
>> When running Autopupdate.pl from the command line, be sure to run it
>> as user www.
>>
>> Stuart Raeburn
>> LON-CAPA Academic Consortium
>>
>> Quoting "H. K. Ng" <hkng at fsu.edu>:
>>
>> > Hi,
>> >
>> > I have loncapa to automatically update the roster and also, update the
>> > first name, ... via Autoupdate.pl. However, when a student ID is changed,
>> > the ID is not being updated. The domain is configured to update the
>> > following (via Auto-update settings):
>> > Auto-update active? set to yes
>> > Update information in classlist? set to yes
>> > User preference to lock name - not check
>> > Under User population
>> >   All users on the student/employee ID is checked.
>> >
>> > In addition to the Auto-update settings, there is the User modification.
>> In
>> > what context is the User modification updateable? Since in my case the
>> > update is done by the cron jobs, Autoaupdate.pl and Antoenroll.pl, it is
>> > not clear how User modification is used. (Seems to be settings for users
>> to
>> > allow them to update themselves??)
>> >
>> > The bottom line is how do I get the student/employee ID to be update
>> > nightly via the cron jobs?
>> >
>> > Regards,
>> > -hk



More information about the LON-CAPA-admin mailing list