--- loncom/interface/lonviewclasslist.pm 2012/12/31 14:29:08 1.14 +++ loncom/interface/lonviewclasslist.pm 2015/03/17 00:08:48 1.17 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to display the classlist # -# $Id: lonviewclasslist.pm,v 1.14 2012/12/31 14:29:08 raeburn Exp $ +# $Id: lonviewclasslist.pm,v 1.17 2015/03/17 00:08:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -87,10 +87,10 @@ ENDHEADER # Get classlist view settings my %viewsettings = &retrieve_view_settings(); + my $crstype = &Apache::loncommon::course_type(); if (($env{'form.forceedit'}) || ($env{'form.action'} eq 'setconfig')) { if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { - my $crstype = &Apache::loncommon::course_type(); my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $rosterprefs = &roster_prefs($crstype); @@ -157,25 +157,37 @@ ENDHEADER ''. ''); } else { - $r->print('
'. - &mt('No student-viewable course roster settings available.'). - '
'); + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt('No member-viewable community roster settings available.')); + } else { + $r->print(&mt('No student-viewable course roster settings available.')); + } + $r->print('
'); } } } else { - $r->print('
'. - &mt('You do not have rights to modify student-viewable course roster settings.'). - '
'); + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt('You do not have rights to modify member-viewable community roster settings.')); + } else { + $r->print(&mt('You do not have rights to modify student-viewable course roster settings.')); + } + $r->print('
'); } } else { # Print classlist if (keys(%viewsettings) > 0) { - $r->print(&html_classlist($r,\%viewsettings)); + $r->print(&html_classlist($r,$crstype,\%viewsettings)); } else { - $r->print('
'. - &mt("Display of a student-viewable course roster is not currently enabled."). - '
'); + $r->print('
'); + if ($crstype eq 'Community') { + $r->print(&mt("Display of a member-viewable community roster is not currently enabled.")); + } else { + $r->print(&mt("Display of a student-viewable course roster is not currently enabled.")); + } + $r->print('
'); } } # @@ -211,11 +223,13 @@ sub roster_prefs { my %lt; if ($crstype eq 'Community') { %lt = &Apache::lonlocal::texthash ( + svrs => 'Member-viewable roster settings', stuv => 'Member-viewable membership list options', stul => 'Member agreement needed to be listed', ); } else { %lt = &Apache::lonlocal::texthash( + svrs => 'Student-viewable roster settings', stuv => 'Student-viewable classlist options', stul => 'Student agreement needed to be listed', ); @@ -223,7 +237,7 @@ sub roster_prefs { $lt{'incl'} = &mt('Include link to accessible portfolio files'); return - { text => 'Student-viewable roster settings', + { text => $lt{'svrs'}, header => [ {col1 => 'Setting', col2 => $lt{'stuv'}}], ordered => ['student_classlist_view', @@ -238,43 +252,57 @@ sub roster_prefs { } sub html_classlist { - my ($r,$viewsettings) = @_; + my ($r,$crstype,$viewsettings) = @_; my ($Str,$title,$secdisplay,$cid,$cdom,$cnum,$listtype,%publicroster); my $fullroster = &Apache::loncoursedata::get_classlist(); my $classlist; + my $singular = 'student'; + my $plural = 'students'; + my $titleplural = 'Students'; + my $heading = &mt('Student-viewable course roster'); + + if ($crstype eq 'Community') { + $singular = 'member'; + $plural = 'members'; + $titleplural = 'Members'; + $heading = &mt('Member-viewable community roster'); + } + if ($env{'form.action'} eq 'setenv') { - $Str .= &process_student_prefs(); + $Str .= &process_student_prefs($crstype); } - $Str .= '

'.&mt('Student-viewable course roster').'

'; + + $Str .= '

'.$heading.'

'; $cid = $env{'request.course.id'}; $cdom = $env{'course.'.$cid.'.domain'}; $cnum = $env{'course.'.$cid.'.num'}; + my $title; if ($viewsettings->{'limit_to_section'}) { if ($env{'request.course.sec'} eq '') { - $title = '

'.&mt('Students with no section').'

'; + $title = &mt($titleplural.' with no section'); $listtype = 'without a section'; } else { - $title ='

'.&mt('Students in section "[_1]"', - $env{'request.course.sec'}).'

'; + $title = &mt($titleplural.' in section "[_1]"', + $env{'request.course.sec'}); $listtype = 'in the section'; $secdisplay = " ($env{'request.course.sec'}) "; } } else { - $title .= '

'.&mt('Students in any section').'

'; + $title = &mt($titleplural.' in any section'); $listtype = 'in the course'; } if ($viewsettings->{'student_opt_in'}) { if ($env{'request.role'} =~ /^st/) { - $Str .= &print_roster_form(); + $Str .= &print_roster_form($crstype); } %publicroster = &Apache::lonnet::dump('publicroster',$cdom,$cnum); } - $Str .= $title; + $Str .= '

'.$title.'

'; my $fullcount = 0; my $publiccount = 0; @@ -303,34 +331,34 @@ sub html_classlist { $displaycount = $publiccount; if ($fullcount > $publiccount) { if ($publiccount) { - $Str .= &mt('Only students who have opted to be listed in the roster ([_1] out of [_2] students) are shown.',$publiccount,$fullcount).'
'; + $Str .= &mt('Only '.$plural.' who have opted to be listed in the roster ([_1] out of [_2] '.$plural.') are shown.',$publiccount,$fullcount).'
'; } else { if ($fullcount == 1) { - $Str .= &mt('The single student '.$listtype.'[_1] has opted not to be listed in the roster.',$secdisplay); + $Str .= &mt('The single '.$singular.' '.$listtype.'[_1] has opted not to be listed in the roster.',$secdisplay); } else { - $Str .= &mt('None of the [_1] students '.$listtype.'[_2] have opted to be listed in the roster.',$fullcount,$secdisplay); + $Str .= &mt('None of the [_1] '.$plural.' '.$listtype.'[_2] have opted to be listed in the roster.',$fullcount,$secdisplay); } return $Str; } } else { if ($fullcount > 1) { - $Str .= &mt('All [_1] students '.$listtype.'[_2] have opted to be listed in the roster.',$fullcount,$secdisplay); + $Str .= &mt('All [_1] '.$plural.' '.$listtype.'[_2] have opted to be listed in the roster.',$fullcount,$secdisplay); } elsif ($fullcount == 1) { - $Str .= &mt('The single student '.$listtype.'[_1] has opted to be listed in the roster.',$secdisplay); + $Str .= &mt('The single '.$singular.' '.$listtype.'[_1] has opted to be listed in the roster.',$secdisplay); } } } else { $displaycount = $fullcount; if ($fullcount > 1) { - $Str .= &mt('All [_1] students '.$listtype.'[_2] are listed in the roster.',$fullcount,$secdisplay); + $Str .= &mt('All [_1] '.$plural.' '.$listtype.'[_2] are listed in the roster.',$fullcount,$secdisplay); } elsif ($fullcount == 1) { - $Str .= &mt('There is only a single student '.$listtype.'[_1]',$secdisplay); + $Str .= &mt('There is only a single '.$singular.' '.$listtype.'[_1]',$secdisplay); } } undef($fullroster); if (!$displaycount) { - $Str .= &mt('There are currently no students to display.'); + $Str .= &mt('There are currently no '.$plural.' to display.'); return $Str; } @@ -347,7 +375,7 @@ sub html_classlist { $Str .= '
'.&Apache::loncommon::start_data_table()."\n". &Apache::loncommon::start_data_table_header_row()."\n". ''. # for the count - ''.&mt('Student').''. + ''.&mt('Name').''. ''.&mt('Username').''; if (! $viewsettings->{'limit_to_section'}) { $Str .= ''.&mt('Section').''; @@ -400,6 +428,7 @@ sub html_classlist { } sub print_roster_form { + my ($crstype) = @_; my $cid = $env{'request.course.id'}; my $showinroster = $env{'environment.internal.'.$cid.'.showinroster'}; my ($showoff,$showon); @@ -410,23 +439,31 @@ sub print_roster_form { $showoff = ' checked="checked" '; $showon = ' '; } - my $output = '

'.&mt('Your roster setting').'

'; + my $singular = 'student'; + if ($crstype eq 'Community') { + $singular = 'member'; + } + my $output = + '
' + .'
'.&mt('Your roster setting').''; if ($showinroster) { - $output .= &mt('You are currently listed in the student-viewable roster.'); + $output .= &mt("You are currently listed in the $singular-viewable roster."); } else { - $output .= &mt('You are currently not listed in the student-viewable roster.'); + $output .= &mt("You are currently [_1]not[_2] listed in the $singular-viewable roster.",'',''); } $output .= '
'.&mt('Include yourself in the roster?').'  '. - '
'. + ''. '  

'. ''. - '

'; + ''. + '

'; return $output; } sub process_student_prefs { + my ($crstype) = @_; my $cid = $env{'request.course.id'}; my $cdom = $env{'course.'.$cid.'.domain'}; my $cnum = $env{'course.'.$cid.'.num'}; @@ -443,6 +480,11 @@ sub process_student_prefs { if ($pubroster{$student}) { $sturoster = 1; } + + my $singular = 'student'; + if ($crstype eq 'Community') { + $singular = 'member'; + } my $output; if ($sturoster ne $showinroster) { my %changeHash = ( @@ -454,16 +496,25 @@ sub process_student_prefs { &Apache::lonnet::appenv(\%changeHash); my $result = &Apache::lonnet::put('publicroster',{$student => $showinroster,},$cdom,$cnum); if ($result eq 'ok') { - $output .= &mt('Display of your name in the student-viewable roster set to [_1].',$visibility); + $output .= + &Apache::lonhtmlcommon::confirm_success( + &mt("Display of your name in the $singular-viewable roster set to [_1].",''.$visibility.'')); } else { - $output .= ''.&mt('Error occurred saving display setting.').''; + $output .= + &Apache::lonhtmlcommon::confirm_success( + &mt('Error occurred saving display setting.'),1); } } else { - $output .= ''.&mt('Error occurred saving display setting.').''; + $output .= + &Apache::lonhtmlcommon::confirm_success( + &mt('Error occurred saving display setting.'),1); } } else { - $output .= &mt('Display of your name in the student-viewable roster unchanged (set to [_1]).',$visibility); + $output .= + &Apache::lonhtmlcommon::confirm_success( + &mt("Display of your name in the $singular-viewable roster unchanged (set to [_1]).",''.$visibility.'')); } + $output = &Apache::loncommon::confirmwrapper($output); return $output; }