--- loncom/interface/lonpopulate.pm 2004/06/28 15:41:20 1.15 +++ loncom/interface/lonpopulate.pm 2004/06/29 04:30:00 1.16 @@ -1,5 +1,5 @@ # automated enrollment configuration handler -# $Id: lonpopulate.pm,v 1.15 2004/06/28 15:41:20 albertel Exp $ +# $Id: lonpopulate.pm,v 1.16 2004/06/29 04:30:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,11 +52,12 @@ ENDHEAD ############################################################### sub choose_header { + my $action = shift; my $bodytag=&Apache::loncommon::bodytag('Classlist Manager'); my $scripttag = qq| |; @@ -241,7 +291,7 @@ sub print_main_frame { Use the menu on the left to choose an enrollment management task.

  - Use "Automated adds/drops" to enable or disable automatic nightly adds or drops in your LON-CAPA course based on instututional enrollment information. + Use "Automated adds/drops" to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.   @@ -271,6 +321,10 @@ sub print_main_frame { Use "Update roster now" to add and/or drop students from your course based on the most current institutional classlist information. +   + Use "View students and change type" to display the current course roster, and (optionally) change enrollment type for selected students from 'auto' to 'manual' and vice versa. + +   @@ -921,6 +975,10 @@ Note: Any students previously added manu $$tasktitleref{$action} + + Section changes, name changes, and class drops that can be set to occur either automatically or when using the 'Update roster now' feature, will affect only those students with an enroll type of 'auto'. Students with an enroll type of 'manual', will be converted automatically to the 'auto' type, when they first appear in the institutional classlist for the course - as long as nightly adds are enabled and active, or the update roster utility is used. Use the 'Lock' checkbox for any manually enrolled students for whom you wish to prevent type conversion. Use the 'Change' checkbox to switch the enroll type from auto to manual, and vice versa. Use the 'Unlock' checkbox for any maually enrolled students for whom you no longer wish to lock the enroll type. Click the 'Go' button at the end of the page to process your desired changes. + +   @@ -943,19 +1001,58 @@ Note: Any students previously added manu $r->print(''. "\n

\n"); - my $studentcount = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist); + my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$ENV{'form.Status'},$classlist,$keylist); $r->print(" "); if ($studentcount > 0) { $r->print(" - + "); @@ -992,7 +1089,9 @@ sub print_accessdate_table { 'setl' => 'Set date of last access', 'freg' => 'for registered students added via automated enrollment', 'fnew' => 'for new students added when you update the class roster', - 'ifad' => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access. These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.' + 'ifad' => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access. These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.', + 'ncds' => 'changing default start and end access dates will affect future enrollments and ALSO currently inactive students (i.e., those for whom access will begin in the future). To change access dates for currently active students, you should change the access dates via this screen, then use Enrollment manager -> Drop Students to drop the students, and then use Automated Enrollment Manager -> Update roster now to re-enroll them with the new access dates.' + ); my $dateshow; if ( ($oldendshow eq '') && ($oldstartshow eq '') ) { @@ -1071,6 +1170,12 @@ ENDFOUR + + + + + +
+ "); + my $cellcount = 0; + if ($autocount > 0) { + $cellcount ++; + $r->print(<
 Change auto   +
+END + } + if ($manualcount > 0) { + $cellcount ++; + $r->print(<
 Change manual   +
+END + } + if ($lockcount > 0) { + if ($cellcount == 2) { + $r->print("
"); + } + $cellcount ++; + $r->print(<
 Lock manual   +
+END + } + if ($unlockcount > 0) { + if ($cellcount == 2) { + $r->print("
"); + } + $cellcount ++; + $r->print(<
 Unlock manual   +
+END + } + $r->print(" +
+
 
- +
$lt{'ifad'}
 
".&mt('Note').": ".$lt{'ncds'}."
"); } elsif ($action eq 'updatenow') { @@ -2087,48 +2192,117 @@ sub print_viewclass_response { my $chgok = 0; my $chgfail = 0; my $othdom = 0; + my $locktotal = 0; + my $lockok = 0; + my $lockfail = 0; my $cid = $dom."_".$crs; my %chg = (); my %nochg = (); my %otherdom = (); - my $modreply = ''; + my %lockchg = (); + my %nolockchg = (); my $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs); my $endidx = &Apache::loncoursedata::CL_END; my $startidx = &Apache::loncoursedata::CL_START; my $ididx=&Apache::loncoursedata::CL_ID; my $secidx=&Apache::loncoursedata::CL_SECTION; my $typeidx=&Apache::loncoursedata::CL_TYPE; - foreach (sort keys %ENV) { - if (/^form\.switch:(.+)$/) { - my $student = $1; - my ($uname,$udom) = split/:/,$student; - my $sdata = $classlist->{$student}; - my $section = $sdata->[$secidx]; - my $uid = $sdata->[$ididx]; - my $start = $sdata->[$startidx]; - my $end = $sdata->[$endidx]; - my $type = $sdata->[$typeidx]; - $chgtotal ++; - my $newtype = 'auto'; - my $change = 'auto'; - my $oldtype = 'manual'; - if ($type eq 'auto') { - $oldtype = 'auto'; - $newtype = ''; - $change = 'manual'; + my $lockedidx=&Apache::loncoursedata::CL_LOCKEDTYPE; + my @typechglist = (); + my @lockchglist = (); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chgauto','chgmanual','lockchg','unlockchg']); + if ($ENV{'form.chgauto'}) { + if (ref($ENV{'form.chgauto'}) eq 'ARRAY') { + push @typechglist, @{$ENV{'form.chgauto'}}; + } else { + push @typechglist, $ENV{'form.chgauto'}; + } + } + if ($ENV{'form.chgmanual'}) { + if (ref($ENV{'form.chgmanual'}) eq 'ARRAY') { + push @typechglist, @{$ENV{'form.chgmanual'}}; + } else { + push @typechglist, $ENV{'form.chgmanual'}; + } + } + if ($ENV{'form.lockchg'}) { + if (ref($ENV{'form.lockchg'}) eq 'ARRAY') { + push @lockchglist, @{$ENV{'form.lockchg'}}; + } else { + push @lockchglist, $ENV{'form.lockchg'}; + } + } + if ($ENV{'form.unlockchg'}) { + if (ref($ENV{'form.unlockchg'}) eq 'ARRAY') { + push @lockchglist, @{$ENV{'form.unlockchg'}}; + } else { + push @lockchglist, $ENV{'form.unlockchg'}; + } + } + foreach my $student (sort @typechglist) { + my ($uname,$udom) = split/:/,$student; + my $sdata = $classlist->{$student}; + my $section = $sdata->[$secidx]; + my $uid = $sdata->[$ididx]; + my $start = $sdata->[$startidx]; + my $end = $sdata->[$endidx]; + my $type = $sdata->[$typeidx]; + my $lock = $sdata->[$lockedidx]; + my $newlock = $lock; + $chgtotal ++; + my $newtype = 'auto'; + my $change = 'auto'; + my $oldtype = 'manual'; + if ($type eq 'auto') { + $oldtype = 'auto'; + $newtype = ''; + $change = 'manual'; + } + if ($udom eq $dom) { + if ($newtype eq 'auto') { + $newlock = ''; + } elsif ($newtype eq '') { + $newlock = '1'; } - if ($udom eq $dom) { - $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$cid); - if ($modreply eq 'ok') { - $chgok ++; - $chg{$student} = "Changed to $change"; - } else { - $chgfail ++; - $nochg{$student} = "Still set to $oldtype"; - } + my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid); + if ($modreply eq 'ok') { + $chgok ++; + $chg{$student} = "Changed to $change"; } else { - $othdom ++; - $otherdom{$student} = "Still set to $oldtype"; + $chgfail ++; + $nochg{$student} = "Still set to $oldtype"; + } + } else { + $othdom ++; + $otherdom{$student} = "Still set to $oldtype"; + } + } + foreach my $student (@lockchglist) { + my ($uname,$udom) = split/:/,$student; + my $sdata = $classlist->{$student}; + my $section = $sdata->[$secidx]; + my $uid = $sdata->[$ididx]; + my $start = $sdata->[$startidx]; + my $end = $sdata->[$endidx]; + my $type = $sdata->[$typeidx]; + my $lock = $sdata->[$lockedidx]; + my $newlock = 1; + my $oldlockname = &mt('unlocked'); + my $newlockname = &mt('locked'); + $locktotal++; + unless ($type eq 'auto') { + if ($lock) { + $newlock = ''; + $newlockname = &mt('unlocked'); + $oldlockname = &mt('locked'); + } + my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid); + if ($lockreply eq 'ok') { + $lockok ++; + $lockchg{$student} = 'Changed to '.$newlockname; + } else { + $lockfail ++; + $nolockchg{$student} = 'Still set to '.$oldlockname; } } } @@ -2147,13 +2321,26 @@ sub print_viewclass_response { $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':
"; $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx); } + $response .= "

"; + } + if ($locktotal > 0) { + $response .= "You requested locking/unlocking for $locktotal manually enrolled students.

\n"; + $classlist = &Apache::loncoursedata::get_classlist($cid,$dom,$crs); + if ($lockok > 0) { + $response .= "The following $lockok changes were successful:
"; + $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx); + } + if ($lockfail > 0) { + $response .= "The following $lockfail students were not modified successfully: 
"; + $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx); + } } &print_reply($r,$response,$$tasktitleref{$action}); return; } sub enrolltype_result { - my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx) = @_; + my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_; my $reply = " @@ -2362,7 +2549,7 @@ sub handler { updatenow => "Update roster now", newcross => "Add crosslistings", newsections => "Add sections", - viewclass => "View students and type", + viewclass => "View students and change type", ); my %tasktitle = ( @@ -2405,12 +2592,12 @@ sub handler { $r->print(&header()); } else { if ($state eq "choose") { - $r->print(&choose_header()); + $r->print(&choose_header($action)); } else { if ($action eq "crosslist") { if ( exists($ENV{'form.numcross'}) ) { if ( $ENV{'form.numcross'} > 0 ) { - $r->print(&choose_header()); + $r->print(&choose_header($action)); } else { $r->print(&header()); } @@ -2420,7 +2607,7 @@ sub handler { } elsif ($action eq "sections") { if ( exists($ENV{'form.numsec'}) ) { if ( $ENV{'form.numsec'} > 0 ) { - $r->print(&choose_header()); + $r->print(&choose_header($action)); } else { $r->print(&header()); }