--- loncom/interface/loncoursegroups.pm 2012/07/21 21:20:06 1.114 +++ loncom/interface/loncoursegroups.pm 2017/03/19 17:59:15 1.127.2.1 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.114 2012/07/21 21:20:06 raeburn Exp $ +# $Id: loncoursegroups.pm,v 1.127.2.1 2017/03/19 17:59:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,11 +31,13 @@ use strict; use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::lonhtmlgateway; use Apache::lonlocal; use Apache::lonnavmaps(); use Apache::longroup(); use Apache::portfolio(); use Apache::Constants qw(:common :http); +use HTML::Entities; use LONCAPA::map(); use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -134,7 +136,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'; @@ -168,13 +170,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', @@ -188,7 +190,7 @@ sub display_groups { crtd => 'Created', last => 'Last Modified', func => 'Collaborative Tools', - quot => 'Quota (Mb)', + quot => 'Quota (MB)', memb => 'Members', file => 'Files', dibd => 'Discussion Boards', @@ -225,7 +227,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; } @@ -248,7 +250,7 @@ sub display_groups { $lt{'crea'} $lt{'crtd'} $lt{'last'} - $lt{'func'} + $lt{'func'} $lt{'quot'} $lt{'memb'} $lt{'file'} @@ -327,25 +329,30 @@ 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); + 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'). @@ -400,7 +407,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; } @@ -416,7 +423,12 @@ END } } } else { - $r->print(&mt('You are not currently a member of any active '.$gpterm.'s in this '.lc($crstype).'.')); + $r->print( + '

' + .&mt('You are not currently a member of any active '.$gpterm.'s' + .' in this '.lc($crstype).'.') + .'

' + ); } } return; @@ -806,7 +818,7 @@ sub group_administration { } var maxposs = '.sprintf("%.2f",$maxposs).'; if (newquota > maxposs) { - alert("The group portfolio quota you entered for this group ("+newquota+" Mb) exceeds the maximum possible ("+maxposs+" Mb). Please enter a smaller number."); + alert("The group portfolio quota you entered for this group ("+newquota+" MB) exceeds the maximum possible ("+maxposs+" MB). Please enter a smaller number."); return; } var re_quota = '.$float_check.'; @@ -825,7 +837,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; } } @@ -891,7 +903,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',}); } @@ -1487,7 +1499,7 @@ sub header { {'add_entries' => $loaditems,}); my $output = <<"END"; $start_page -
+ END if ($action eq 'create' || $action eq 'modify') { @@ -1581,7 +1593,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) { @@ -1696,7 +1708,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'}) .'
' @@ -1751,19 +1763,19 @@ sub groupsettings_options { } else { $r->print(&mt('Quota allocated to group portfolio:')); } - $r->print(' '.&mt('[_1] Mb','')); + $r->print(' '.&mt('[_1] MB','')); if ($action eq 'create') { $r->print('
' - .&mt('A total of [_1] Mb can be divided amongst all '.$gpterm.'s in the ' - .lc($crstype).', and [_2] Mb are currently unallocated.' + .&mt('A total of [_1] MB can be divided amongst all '.$gpterm.'s in the ' + .lc($crstype).', and [_2] MB are currently unallocated.' ,$crsquota,sprintf("%.2f",$freespace)) ); } else { - $r->print('  ('.&mt('The quota is currently [_1] Mb', + $r->print('  ('.&mt('The quota is currently [_1] MB', $$stored{'quota'}).').'); $r->print('
' - .&mt('The quota can be increased to [_1] Mb, ' + .&mt('The quota can be increased to [_1] MB, ' .'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.' ,sprintf("%.2f",$maxposs))); } @@ -2011,10 +2023,10 @@ sub print_current_settings { dfac => 'Default access dates', ygrs => "Your group selections - ", tfwa => "The following settings will apply to the group:", - difn => 'Different collaborative tools
for different members:', stda => 'Start date:', enda => 'End date:', ); + $lt{'difn'} = &mt('Different collaborative tools[_1]for different members:','
'); my $showstart = &Apache::lonlocal::locallocaltime($startdate); my $showend; if ($enddate == 0) { @@ -2064,7 +2076,7 @@ sub print_current_settings { $r->print(''); } - my $quota_text=&mt('[_1] Mb',$quota); + my $quota_text=&mt('[_1] MB',$quota); my $granu_text=&mt($granularity); $r->print(<<"END"); @@ -2254,11 +2266,12 @@ sub privilege_specificity { "for users who receive specific sections/roles in the course ", 'asyo' => "As you have chosen not to include any collaborative tools ". "in the group, no default optional privileges need to be set.", - 'plin' => 'Indicate which optional privileges members '. 'will receive by default for a specific tool.', 'oppr' => 'Optional privileges', 'defp' => 'The default privileges new members will receive are:', ); + $lt{'plin'} = &mt('Indicate which [_1]optional[_2] privileges members '. + 'will receive by default for a specific tool.','',''); if ($crstype eq 'Community') { $lt{'thes'} = &mt('These will be the privileges given to members assigned in the future via automatic group assignment for users who receive specific sections/roles in the community '); } @@ -2542,6 +2555,7 @@ sub current_membership { 'actn' => 'Action?', 'name' => 'Name', 'usnm' => 'Username', + 'stid' => 'ID', 'doma' => 'Domain', 'stda' => 'Start Date', 'enda' => 'End Date', @@ -2603,7 +2617,7 @@ END $lt{'name'} $lt{'usnm'} $lt{'doma'} - ID + $lt{'ID'} $lt{'stda'} $lt{'enda'} END @@ -2727,7 +2741,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; } @@ -2795,7 +2812,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'))); @@ -3191,7 +3208,7 @@ sub write_group_data { $quota = 0; $r->print('
' .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm - .' contained invalid characters, so it has been set to 0 Mb. You can change this by' + .' contained invalid characters, so it has been set to 0 MB. You can change this by' .' modifying the '.$gpterm.' settings.') .'
'); } @@ -3199,7 +3216,7 @@ sub write_group_data { $quota = $maxposs; $r->print('
' .&mt('The value you entered for the quota for the group portfolio in this '.$gpterm - .' exceeded the maximum possible value, so it has been set to [_1] Mb ' + .' exceeded the maximum possible value, so it has been set to [_1] MB ' .'(the maximum possible value).',sprintf("%.2f",$maxposs)) .'
'); } @@ -3358,10 +3375,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')) { @@ -3744,21 +3762,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', @@ -4114,10 +4132,9 @@ sub create_homepage { my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm,$now) = @_; my $functionality = join(',',@{$tools}); my $content = &unescape($$groupinfo{description}); - $content=~s/\s+$//s; - $content=~s/^\s+//s; - $content=~s/\$//s; - $content=&Apache::lonfeedback::clear_out_html($content,1); + chomp($content); + my $gateway = Apache::lonhtmlgateway->new(); + $content = $gateway->process_incoming_html($content,1); my %pageinfo = ( 'aaa_title' => "$ucgpterm: $name", @@ -4177,43 +4194,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 [_1]',$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 [_1] which previously existed',$gpterm). - $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('[_1] name:',$ucgpterm).' '.$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;