--- loncom/interface/loncoursegroups.pm 2013/12/18 01:31:43 1.122 +++ loncom/interface/loncoursegroups.pm 2023/07/29 20:33:25 1.132 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.122 2013/12/18 01:31:43 raeburn Exp $ +# $Id: loncoursegroups.pm,v 1.132 2023/07/29 20:33:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,7 +36,9 @@ use Apache::lonlocal; use Apache::lonnavmaps(); use Apache::longroup(); use Apache::portfolio(); +use Apache::lonuserutils(); use Apache::Constants qw(:common :http); +use HTML::Entities; use LONCAPA::map(); use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -135,7 +137,7 @@ function changeSort(caller) { } function openGroupRoster(group,status) { var url = '/adm/grouproster?'; - url += 'group='+group+'&status='+status+'&ref=popup'; + url += 'group='+group+'&status='+status+'&ref=popup'; var title = 'Group_Membership'; var options = 'scrollbars=1,resizable=1,menubar=0'; options += ',width=700,height=600'; @@ -169,13 +171,13 @@ sub display_groups { my %curr_groups = (); my %grp_info = (); my %actionlinks = ( - modify => ' ' '/adm/coursegroups?action=modify&refpage='. + $env{'form.refpage'}.'&state=pick_task&groupname=', + view => '', + delete => '/adm/coursegroups?action=delete&refpage='. + $env{'form.refpage'}.'&state=verify&groupname=', + reenable => '/adm/coursegroups?action=reenable&refpage='. + $env{'form.refpage'}.'&state=verify&groupname=', ); my %lt = &Apache::lonlocal::texthash( modify => 'Modify', @@ -226,7 +228,7 @@ sub display_groups { if (!defined($navmap)) { $r->print('
'. &mt('An error occurred retrieving information about resources in the course.').'
'. - &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','
',''). + &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','',''). '
'); return; } @@ -249,7 +251,7 @@ sub display_groups { $lt{'crea'} $lt{'crtd'} $lt{'last'} - $lt{'func'} + $lt{'func'} $lt{'quot'} $lt{'memb'} $lt{'file'} @@ -328,25 +330,31 @@ END if (!$functionality) { $functionality = &mt('None available'); } - my $link = $actionlinks{$action}; + my $link; if ($action eq 'modify' || $action eq 'delete' || $action eq 'reenable') { - $link .= $group; + $link = ''.$lt{$action}.''; } else { - $link .= - &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap); - $link .= (($link=~/\?/)?'&':'?').'ref=grouplist'; - if (exists($env{'form.refpage'})) { - $link .= '&refpage='.$env{'form.refpage'}; + $link = + &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap, + $view_permission); + if ($link) { + $link = ''.$lt{$action}.''; } } - $link .= '">'.$lt{$action}.''; if ($action eq 'view') { if ($manage_permission) { - $link .= '  '.$actionlinks{'modify'}. - $group.'">'.$lt{'modify'}.''. - '  '.$actionlinks{'delete'}. - $group.'">'.$lt{'delete'}.''; + $link .= '  '.$lt{'modify'}.'  '.$lt{'delete'}.''; } } $r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense'). @@ -394,6 +402,7 @@ END } else { my @coursegroups = split(/:/,$env{'request.course.groups'}); if (@coursegroups > 0) { + my $numlinks = 0; $r->print('

'); my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); if (%curr_groups) { @@ -401,7 +410,7 @@ END if (!defined($navmap)) { $r->print('
'. &mt('An error occurred retrieving information about resources in the course.').'
'. - &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','',''). + &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this page.','',''). '
'); return; } @@ -410,12 +419,36 @@ END $curr_groups{$group}); my $description = &unescape( $group_info{description}); - my $link = - &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap). - '&ref=grouplist'; - $r->print(''.$group,'
'.$description.'

'); + my ($link,$hidden) = + &Apache::longroup::get_group_link($cdom,$cnum,$group,$navmap, + $view_permission); + if ($link) { + $link .= '&ref=grouplist'; + $r->print(''. + $description.'

'); + $numlinks ++; + } elsif ($hidden) { + my $numtools = 0; + my $refarg = '&ref=grouplist'; + my $output = + &Apache::longroup::display_group_links($r,$env{'form.grade_target'},$group,'view', + $refarg,\$numtools,$hidden,%group_info); + if ($numtools) { + $r->print(''.$description.''. + '
'.$output.'

'); + $numlinks ++; + } + } } } + if (!$numlinks) { + $r->print( + '

' + .&mt('You do not currently have access to any '.$gpterm.'s' + .' in this '.lc($crstype).'.') + .'

' + ); + } } else { $r->print( '

' @@ -831,7 +864,7 @@ sub group_administration { } } if (warn_zero == 1) { - alert("You have indicated that the group portfolio should be enabled, but you have set the respository quota to 0 MB.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature."); + alert("You have indicated that the group portfolio should be enabled, but you have set the repository quota to 0 MB.\nThis will prevent any upload of files.\nPlease set a value or disable the repository feature."); return; } } @@ -897,7 +930,7 @@ function changeSort(caller) { faq=>9,bug=>'Instructor Interface',}); if ($action eq 'modify' || $action eq 'delete') { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>"/adm/coursegroups?refpage=cusr&action=$action", + ({href=>"/adm/coursegroups?refpage=cusr&action=$action", text=>"Groups", faq=>9,bug=>'Instructor Interface',}); } @@ -909,7 +942,8 @@ function changeSort(caller) { if ($env{'form.refpage'} eq 'grouplist') { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/$cdom/$cnum/$env{'form.groupname'}/smppg?ref=grouplist", - text=>"Group: $description",}); + text=>&mt('Group').": $description", + no_mt=>1}); } } @@ -1587,7 +1621,7 @@ sub group_members { future => 0, ); my $totalmembers = 0; - foreach my $member (keys %memberhash) { + foreach my $member (keys(%memberhash)) { $totalmembers ++; my ($end,$start) = split(/:/,$memberhash{$member}); unless ($start == -1) { @@ -1702,7 +1736,7 @@ sub groupsettings_options { if ($remnum) { $halfnum ++; } - my @allfunctions = sort(keys (%{$functions})); + my @allfunctions = sort(keys(%{$functions})); $r->print(&Apache::lonhtmlcommon::row_title($lt{'func'}) .'

' @@ -1785,7 +1819,24 @@ sub get_quota_constraints { my ($crsquota,$freespace,$maxposs); $crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'}; if ($crsquota eq '') { - $crsquota = 20; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = &Apache::loncommon::course_type(); + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + my %coursehash = ( + 'internal.coursecode' => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}, + 'internal.textbook' => $env{'course.'.$env{'request.course.id'}.'.internal.textbook'}, + ); + my %staticdefaults = ( + coursequota => 20, + ); + my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%coursehash); + if ($crsquota eq '') { + $crsquota = $domdefs{$quotatype.'coursequota'}; + if ($crsquota eq '') { + $crsquota = $staticdefaults{'coursequota'}; + } + } } $freespace = $crsquota - &Apache::longroup::sum_quotas(); if ($action eq 'create') { @@ -2549,6 +2600,7 @@ sub current_membership { 'actn' => 'Action?', 'name' => 'Name', 'usnm' => 'Username', + 'stid' => 'ID', 'doma' => 'Domain', 'stda' => 'Start Date', 'enda' => 'End Date', @@ -2610,7 +2662,7 @@ END $lt{'name'} $lt{'usnm'} $lt{'doma'} - ID + $lt{'ID'} $lt{'stda'} $lt{'enda'} END @@ -2734,7 +2786,10 @@ END } $r->print(&Apache::loncommon::end_data_table()); } else { - $r->print(&mt('There are no active, future or previous group members to modify.')); + $r->print( + '

' + .&mt('There are no active, future or previous group members to modify.') + .'

'); } return $numcurrent; } @@ -2802,7 +2857,7 @@ sub change_privs_form { } } if (!$exp_or_del) { - $r->print($lt{'nome'}.'
'); + $r->print('

'.$lt{'nome'}.'

'); } $r->print(&Apache::lonhtmlcommon::topic_bar(4,&mt('Setting optional privileges for specific group members'))); @@ -3365,10 +3420,10 @@ sub write_group_data { &Apache::lonnet::logthis("Failed to store $gpterm $groupname ". 'in '.lc($crstype).': '.$cnum. ' in domain: '.$cdom); - $r->print('
' - .&mt('An error occurred when [_1] the '.$gpterm.'. ' - .'Please try again.',$actiontype{$action}) - .'
'); + $r->print('

' + .&mt('An error occurred when '.$actiontype{$action}.' the '.$gpterm.'. ' + .'Please try again.') + .''; foreach my $user (@{$added{$type}}) { my $privlist = ''; if (!($type eq 'deleted' || $type eq 'expired')) { @@ -3751,21 +3807,21 @@ sub modify_menu { items => [ { linktext => "Modify default $gpterm settings", - url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_settings&branch=settings', + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_settings&branch=settings', icon => 'grp_settings.png', alttext => "Modify default $gpterm settings", permission => '1', help => 'Course_Modify_Group', }, { linktext => 'Modify access, tools and privileges for members', - url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_members&branch=members', + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=change_members&branch=members', icon => 'grp_tools.png', alttext => 'Modify access, tools and privileges for members', permission => '1', help => 'Course_Modify_Group_Membership', }, { linktext => "Add member(s) to the $gpterm", - url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=add_members&branch=adds', + url => '/adm/coursegroups?action=modify&refpage='.$env{'form.refpage'}.'&groupname='.$groupname.'&state=add_members&branch=adds', icon => 'grp_add.png', alttext => "Add member(s) to the $gpterm", permission => '1', @@ -4183,43 +4239,40 @@ sub validate_groupname { } my %lt = &Apache::lonlocal::texthash ( igna => "Invalid $gpterm name", - tgne => "The $gpterm name entered ", grna => "$ucgpterm names and section names used in a ". "$crstype must be unique.", - isno => "is not a valid name.", gnmo => "$ucgpterm names may only contain letters, ". "numbers or underscores.", - cnnb => "can not be used as it is the name of ", - inth => " in this $crstype", - thgr => "- does not correspond to the name of an ". - "existing $gpterm", ); - my $exitmsg = ''.$lt{'igna'}.'

'. - $lt{'tgne'}.' "'.$groupname.'" '; - my $dupmsg = $lt{'grna'}; - my $earlyout; + my $exitmsg = ''.$lt{'igna'}.'

'; + my $nameshown = &Apache::loncommon::cleanup_html($groupname); if (($groupname eq '') || ($groupname =~ /\W/)) { - $earlyout = $exitmsg.$lt{'isno'}.'
'.$lt{'gnmo'}; - return $earlyout; + return $exitmsg. + &mt("The $gpterm name entered '[_1]' is not a valid name.",$nameshown). + '
'.$lt{'gnmo'}; + } elsif ($groupname eq 'syllabus') { + return $exitmsg. + &mt("The $gpterm name entered '[_1]' is reserved for use by LON-CAPA.",$nameshown); } if (exists($sectioncount{$groupname})) { - return $exitmsg.$lt{'cnnb'}.&mt('a section').$lt{'inth'}. - '
'.$lt{'grna'}; + return $exitmsg. + &mt("The $gpterm name entered '[_1]' can not be used as it is the name of a section in this $crstype.",$nameshown). + '
'.$lt{'grna'}; } if ($action eq 'create') { if (exists($curr_groups{$groupname})) { - return $exitmsg.$lt{'cnnb'}.&mt("an existing $gpterm"). - $lt{'inth'}.'.
'.$lt{'grna'}; + return $exitmsg. + &mt("The $gpterm name entered '[_1]' can not be used as it is the name of an existing $gpterm in this $crstype.",$nameshown). + '
'.$lt{'grna'}; } elsif (exists($deleted_groups{$groupname})) { - return $exitmsg.$lt{'cnnb'}.&mt("a $gpterm which previously existed"). - $lt{'inth'}.'.
'.$lt{'grna'}; + return $exitmsg. + &mt("The $gpterm name entered '[_1]' can not be used as it is the name of a $gpterm which previously existed in this $crstype.",$nameshown). + '
'.$lt{'grna'}; } } elsif ($action eq 'modify') { unless(exists($curr_groups{$groupname})) { - $earlyout = &mt("$ucgpterm name:").' '.$groupname.$lt{'thgr'}. - $lt{'inth'}; - return $earlyout; + return &mt("$ucgpterm name: [_1] does not correspond to the name of an existing $gpterm in this $crstype.",$nameshown); } } return; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.