--- loncom/interface/Attic/londropadd.pm 2005/04/07 06:56:23 1.127 +++ loncom/interface/Attic/londropadd.pm 2006/04/26 14:52:22 1.140 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.127 2005/04/07 06:56:23 albertel Exp $ +# $Id: londropadd.pm,v 1.140 2006/04/26 14:52:22 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,15 +43,9 @@ use Apache::lonlocal; ############################################################### ############################################################### sub header { - my $html=&Apache::lonxml::xmlbegin(); - my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager'); - my $title = &mt('LON-CAPA Enrollment Manager'); + my $start_page=&Apache::loncommon::start_page('Enrollment Manager'); return(< -$title - -$bodytag +$start_page
ENDHEAD @@ -137,7 +131,8 @@ sub domain_form { ############################################################### # Menu Phase One sub print_main_menu { - my ($r,$enrl_permission,$view_permission)=@_; + my ($r,$enrl_permission,$view_permission,$grp_manage_permission, + $grp_view_permission)=@_; # my ($cdom,$cnum) = split/_/,$env{'request.course.id'}; my @menu = @@ -171,6 +166,26 @@ sub print_main_menu { permission => &Apache::lonnet::auto_run($cnum,$cdom), url => '/adm/populate', }, + { text => 'Create a new group', + help => 'Course_Create_Group', + permission => $grp_manage_permission, + url => '/adm/coursegroups?refpage=enrl&action=create', + }, + { text => 'Modify an existing group', + help => 'Course_Modify_Group', + permission => $grp_manage_permission, + url => '/adm/coursegroups?refpage=enrl&action=modify', + }, + { text => 'Delete an existing group', + help => 'Course_Delete_Group', + permission => $grp_manage_permission, + url => '/adm/coursegroups?refpage=enrl&action=delete', + }, + { text => 'Enter an existing group', + help => 'Course_Display_Group', + permission => $grp_view_permission, + url => '/adm/coursegroups?refpage=enrl&action=view', + }, ); my $menu_html = ''; foreach my $menu_item (@menu) { @@ -253,8 +268,8 @@ sub print_upload_manager_header { $r->print(''); - $r->print(''. - &mt('Ignore First Line')); + $r->print(''); $r->print("
\n". ''); @@ -607,6 +622,7 @@ sub print_upload_manager_footer { $Str .= '

'.&mt('Login Type')."

\n"; $Str .= "

\n". &mt('Note: this will not take effect if the user already exists'). + &Apache::loncommon::help_open_topic('Auth_Options'). "

\n"; $Str .= $krbform."\n

\n". $intform."\n

\n". @@ -616,14 +632,14 @@ sub print_upload_manager_footer { $Str .= "

".&mt('Starting and Ending Dates')."

\n"; $Str .= "

\n".$date_table."

\n"; $Str .= "

".&mt('Full Update')."

\n"; - $Str .= ''. + $Str .= '

\n"; $Str .= "

".&mt('Student Number')."

\n"; - $Str .= "

\n".''; + $Str .= "

\n".'

\n"; + "\n

\n"; $Str .= ''."
\n"; $Str .= &mt('Note: for large courses, this operation may be time '. @@ -852,16 +868,16 @@ sub date_setting_table { my ($starttime,$endtime,$mode) = @_; my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode); my $dateDefault = ''. - ' '. - &mt('make these dates the default for future enrollment'); + ''; if ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') { $dateDefault = ' '; } - my $perpetual = ''; + $perpetual.= ' /> '.&mt('no ending date').''; if ($mode eq 'create_enrolldates') { $perpetual = ' '; } @@ -889,7 +905,8 @@ sub make_dates_default { $result .= "Set default start and end dates for course
"; # # Refresh the course environment - &Apache::lonnet::coursedescription($env{'request.course.id'}); + &Apache::lonnet::coursedescription($env{'request.course.id'}, + {'freshen_cache' => 1}); } else { $result .= &mt('Unable to set default dates for course').":".$put_result. '
'; @@ -986,6 +1003,7 @@ sub print_enroll_single_student_form { 'psam' => "Please select an authentication mechanism", 'mail' => "Email Address" ); + my $authhelp=&Apache::loncommon::help_open_topic('Auth_Options'); $user_data_html = <$lt{'udf'} $username\@$domain @@ -1003,7 +1021,7 @@ sub print_enroll_single_student_form {

$lt{'pswd'}

-$lt{'psam'} +$lt{'psam'}$authhelp

$krbform @@ -1115,8 +1133,10 @@ $date_table

$lt{'idsn'}:

+

@@ -1162,10 +1182,11 @@ sub print_html_classlist { $env{'form.output'} = 'html'; } # - $r->print('
'); + $r->print('
'.&Apache::loncommon::start_data_table()); foreach my $role (sort keys %coursepersonnel) { next if ($role =~ /^\s*$/); - $r->print(''); + $r->print(''.&Apache::loncommon::end_data_table_row()); } - $r->print('
'.$role.''); + $r->print(&Apache::loncommon::start_data_table_row(). + ''.$role.''); foreach my $user (split(',',$coursepersonnel{$role})) { my ($puname,$pudom)=split(':',$user); $r->print(' '.&Apache::loncommon::aboutmewrapper( @@ -1173,9 +1194,9 @@ sub print_html_classlist { $pudom), $puname,$pudom)); } - $r->print('
'); + $r->print(&Apache::loncommon::end_data_table()); # # Interface output $r->print(' + END if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') { if ($linkto eq 'aboutme') { @@ -1255,7 +1282,8 @@ END 'sec' => "section", 'start' => "start date", 'end' => "end date", - 'type' => "enroll type/action" + 'type' => "enroll type/action", + 'photo' => "photo", ); unless ($mode eq 'autoenroll') { $r->print(< END } + if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { + $r->print(' + + '); + } $r->print("

- +".&Apache::loncommon::start_data_table()." "); if ($mode eq 'autoenroll') { @@ -1293,8 +1334,23 @@ END - END + if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { + my %photo_options = &Apache::lonlocal::texthash( + 'on' => 'Show', + 'off' => 'Hide', + ); + my $photochg = 'on'; + if ($displayphotos eq 'on') { + $photochg = 'off'; + } + $r->print(' '."\n"); + } + $r->print(" \n"); } elsif ($mode eq 'csv') { # # Open a file @@ -1385,22 +1441,22 @@ END } else { $end = &Apache::lonlocal::locallocaltime($end); } - $r->print("\n "); + $r->print(&Apache::loncommon::start_data_table_row()); if ($mode eq 'autoenroll') { my $lockedtype = $sdata->[$index{'lockedtype'}]; $studentcount++; my $cellentry; if ($type eq 'auto') { - $cellentry = ''.&mt('auto').'  Change'; + $cellentry = ''.&mt('auto').' '; $autocount ++; } else { - $cellentry = '
$lt{'end'}
'."\n".' '. + ''. + $photo_options{$photochg}.' '.$lt{'photo'}."\n". + '
- END + if ($env{'course.'.$env{'request.course.id'}. + '.internal.showphoto'}) { + if ($displayphotos eq 'on') { + my $imgurl = + &Apache::lonnet::retrievestudentphoto($domain, + $username,'gif', + 'thumbnail'); + + $r->print(' '); + } else { + $r->print(' '); + } + } + $r->print(&Apache::loncommon::end_data_table_row()); } elsif ($mode eq 'csv') { next if (! defined($CSVfile)); # no need to bother with $linkto @@ -1460,16 +1529,20 @@ END $name,$section]); my $col = 5; foreach my $time ($start,$end) { - $excel_sheet->write($row,$col++, + if (defined($time) && $time != 0) { + $excel_sheet->write($row,$col++, &Apache::lonstathelpers::calc_serial($time), $format->{'date'}); + } else { + $excel_sheet->write($row,$col++,'none'); + } } $excel_sheet->write($row,$col++,$status); $row++; } } if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') { - $r->print('
'.&mt('manual').' Change
'; + $cellentry = '
'.&mt('manual').'
'; $manualcount ++; if ($lockedtype) { - $cellentry .= ' '.&mt('Unlock'); + $cellentry .= ''; $unlockcount ++; } else { - $cellentry .= ' '.&mt('Lock'); + $cellentry .= ''; $lockcount ++; } $cellentry .= '
'; @@ -1432,8 +1488,21 @@ END
$section $start $end
 

'); + $r->print(&Apache::loncommon::end_data_table().'
'); } elsif ($mode eq 'excel') { $excel_workbook->close(); $r->print('

'. @@ -1509,7 +1582,7 @@ sub print_modify_student_form { '

'. &mt('Unable to retrieve environment data for').' '.$sname. &mt('in domain').' '.$sdom.'

'. - &mt('Please contact your LON-CAPA administrator regarding this situation.').'

'); + &mt('Please contact your LON-CAPA administrator regarding this situation.').'

'.&Apache::loncommon::end_page()); return; } # determine the students starting and ending times and section @@ -1588,16 +1661,18 @@ $info{'lastname'} $info{'generation'}, $

$lt{'sid'}:

+

$lt{'sec'}:

$current_date_description

$date_table

- END + $r->print(&Apache::loncommon::end_page()); return; } @@ -1605,7 +1680,7 @@ END # modify a single students section # sub modify_single_student { - my $r = shift; + my ($r) = @_; # # Remove non alphanumeric values from the section $env{'form.section'} =~ s/\W//g; @@ -1747,8 +1822,8 @@ END
$Masd - END + $r->print(&Apache::loncommon::end_page()); return; } @@ -1851,8 +1926,8 @@ my %lt=&Apache::lonlocal::texthash('usrn 'end' => "end date", ); if ($nosort) { + $r->print(&Apache::loncommon::start_data_table()); $r->print(<   $lt{'usrn'} @@ -1866,8 +1941,8 @@ my %lt=&Apache::lonlocal::texthash('usrn END } else { + $r->print(&Apache::loncommon::start_data_table()); $r->print(<   $lt{'usrn'} @@ -1927,8 +2002,8 @@ END my $status = $sdata->[$index{'status'}]; next if ($status ne 'Active'); # + $r->print(&Apache::loncommon::start_data_table_row()); $r->print(<<"END"); - $username $domain @@ -1937,10 +2012,10 @@ END $section $start $end - END + $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print('
'); + $r->print(&Apache::loncommon::end_data_table().'
'); %lt=&Apache::lonlocal::texthash( 'dp' => "Drop Students", 'ca' => "check all", @@ -1969,15 +2044,15 @@ sub print_first_courselist_upload_form { $str .= "

\n"; $str .= ''."\n"; - $str .= ' '. - &mt('Ignore First Line')."

\n"; + $str .= '

\n"; $str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List", &mt("How do I create a class list from a spreadsheet")). "
\n"; $str .= &Apache::loncommon::help_open_topic("Course_Convert_To_CSV", &mt("How do I create a CSV file from a spreadsheet")). "
\n"; - $str .= "\n\n"; + $str .= &Apache::loncommon::end_page(); $r->print($str); return; } @@ -2033,7 +2108,7 @@ sub upfile_drop_add { if (! exists($home_servers{$desiredhost})) { $r->print(''.&mt('Error').''. &mt('Invalid home server specified')); - $r->print("\n\n"); + $r->print(&Apache::loncommon::end_page()); return; } } @@ -2208,12 +2283,7 @@ sub upfile_drop_add { sub drop_student_list { my $r=shift; my $count=0; - my @droplist; - if (ref($env{'form.droplist'})) { - @droplist = @{$env{'form.droplist'}}; - } else { - @droplist = ($env{'form.droplist'}); - } + my @droplist = &Apache::loncommon::get_env_multiple('form.droplist'); foreach (@droplist) { my ($uname,$udom)=split(/\:/,$_); # drop student @@ -2284,7 +2354,8 @@ sub handler { if (! ($env{'request.course.fn'})) { # Not in a course $env{'user.error.msg'}= - "/adm/dropadd:cst:0:0:Cannot drop or add students"; + "/adm/dropadd:cst:0:0:Cannot manage or view course groups, ". + "or drop or add students"; return HTTP_NOT_ACCEPTABLE; } # @@ -2292,11 +2363,21 @@ sub handler { &Apache::lonnet::allowed('vcl',$env{'request.course.id'}); my $enrl_permission = &Apache::lonnet::allowed('cst',$env{'request.course.id'}); - if (! $view_permission && ! $enrl_permission) { + + my $grp_view_permission = + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + my $grp_manage_permission = + &Apache::lonnet::allowed('mdg',$env{'request.course.id'}); + + + if (! $grp_view_permission && ! $grp_manage_permission && + ! $view_permission && ! $enrl_permission) { $env{'user.error.msg'}= - "/adm/dropadd:cst:0:0:Cannot drop or add students"; - return HTTP_NOT_ACCEPTABLE; + "/adm/coursegroups:cst:0:0:Cannot manage or view course groups, ". + "or drop or add students"; + return HTTP_NOT_ACCEPTABLE; } + # # Only output the header information if they did not request csv format # @@ -2309,7 +2390,8 @@ sub handler { if (! exists($env{'form.action'})) { $r->print(&Apache::lonhtmlcommon::breadcrumbs (undef,'Enrollment Manager')); - &print_main_menu($r,$enrl_permission,$view_permission); + &print_main_menu($r,$enrl_permission,$view_permission,$grp_manage_permission, + $grp_view_permission); } elsif ($env{'form.action'} eq 'upload' && $enrl_permission) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/dropadd?action=upload&state=', @@ -2398,7 +2480,7 @@ sub handler { } # # Finish up - $r->print(''); + $r->print(''.&Apache::loncommon::end_page()); return OK; }