--- loncom/interface/lonhelper.pm 2015/08/16 00:21:21 1.196 +++ loncom/interface/lonhelper.pm 2018/01/14 22:02:06 1.199 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.196 2015/08/16 00:21:21 raeburn Exp $ +# $Id: lonhelper.pm,v 1.199 2018/01/14 22:02:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2464,7 +2464,7 @@ BUTTONS $resource_name . "'/> "; } else { $col .= - " "; } @@ -3183,7 +3183,7 @@ It takes the standard attributes "variab "allowempty" and "nextstate", meaning what they do for most other elements. -also takes a boolean 'onlysections' whcih will restrict this to only +also takes a boolean 'onlysections' which will restrict this to only have sections and not include groups =cut @@ -3277,6 +3277,10 @@ It takes the standard attributes "variab "allowempty" and "nextstate", meaning what they do for most other elements. +also takes a boolean grouponly, which if true, will restrict choice to +groups in which user is a member, unless user has the mdg priv in the course, +in which case all groups will be possible choices. Defaults to false. + =cut no strict; @@ -3306,6 +3310,7 @@ sub start_group { $helper->declareVar($paramHash->{'variable'}); $paramHash->{'multichoice'} = $token->[2]{'multichoice'}; $paramHash->{'allowempty'} = $token->[2]{'allowempty'}; + $paramHash->{'grouponly'} = $token->[2]{'grouponly'}; if (defined($token->[2]{'nextstate'})) { $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; } @@ -3313,7 +3318,12 @@ sub start_group { # Populate the CHOICES element my %choices; - my %curr_groups = &Apache::longroup::coursegroups(); + my %curr_groups; + if ((!$paramHash->{'grouponly'}) || (&Apache::lonnet::allowed('mdg',$Apache::lonnet::env{'request.course.id'}))) { + %curr_groups = &Apache::longroup::coursegroups(); + } elsif ($Apache::lonnet::env{'request.course.groups'} ne '') { + map { $curr_groups{$_} = 1; } split(/,/,$Apache::lonnet::env{'request.course.groups'}); + } foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) { push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } @@ -3816,38 +3826,54 @@ sub render { if ($vars->{GRANULARITY} eq 'whole_course') { $resourceString .= '
  • '.&mt('for [_1]all resources in the course[_2]','','').'
  • '; if ($vars->{TARGETS} eq 'course') { - $level = 14; # general course, see lonparmset.pm perldoc + $level = 18; # general course, see lonparmset.pm perldoc } elsif ($vars->{TARGETS} eq 'section') { - $level = 9; + $level = 12; } elsif ($vars->{TARGETS} eq 'group') { - $level = 6; + $level = 8; } else { - $level = 3; + $level = 4; } $affectedResourceId = "0.0"; $symb = 'a'; $paramlevel = 'general'; - } elsif ($vars->{GRANULARITY} eq 'map') { + } elsif (($vars->{GRANULARITY} eq 'map') || ($vars->{GRANULARITY} eq 'maprecurse')) { my $navmap = Apache::lonnavmaps::navmap->new(); if (defined($navmap)) { my $res = $navmap->getByMapPc($vars->{RESOURCE_ID}); my $title = $res->compTitle(); $symb = $res->symb(); - $resourceString .= '
  • '.&mt('for the map named [_1]',"$title").'
  • '; + if ($vars->{GRANULARITY} eq 'map') { + $resourceString .= '
  • '.&mt('for the map named [_1]',"$title").'
  • '; + } else { + $resourceString .= '
  • '.&mt('for the map named [_1] (applies recursively to sub-folders)',"$title").'
  • '; + } } else { $resourceString .= '
  • '.&mt('for the map ID [_1] (name unavailable)',''.$vars->{RESOURCE_ID}.'').'
  • '; &Apache::lonnet::logthis('Retrieval of map title failed in lonhelper.pm - could not create navmap object for course.'); } - if ($vars->{TARGETS} eq 'course') { - $level = 13; # general course, see lonparmset.pm perldoc - } elsif ($vars->{TARGETS} eq 'section') { - $level = 8; - } elsif ($vars->{TARGETS} eq 'group') { - $level = 5; - } else { - $level = 2; - } + if ($vars->{GRANULARITY} eq 'maprecurse') { + if ($vars->{TARGETS} eq 'course') { + $level = 17; # general course, see lonparmset.pm perldoc + } elsif ($vars->{TARGETS} eq 'section') { + $level = 11; + } elsif ($vars->{TARGETS} eq 'group') { + $level = 7; + } else { + $level = 3; + } + } else { + if ($vars->{TARGETS} eq 'course') { + $level = 16; # general course, see lonparmset.pm perldoc + } elsif ($vars->{TARGETS} eq 'section') { + $level = 10; + } elsif ($vars->{TARGETS} eq 'group') { + $level = 6; + } else { + $level = 2; + } + } $affectedResourceId = $vars->{RESOURCE_ID}; $paramlevel = 'map'; } else { @@ -3864,11 +3890,11 @@ sub render { &Apache::lonnet::logthis('Retrieval of resource title failed in lonhelper.pm - could not create navmap object for course.'); } if ($vars->{TARGETS} eq 'course') { - $level = 10; # general course, see lonparmset.pm perldoc + $level = 13; # general course, see lonparmset.pm perldoc } elsif ($vars->{TARGETS} eq 'section') { - $level = 7; + $level = 9; } elsif ($vars->{TARGETS} eq 'group') { - $level = 4; + $level = 5; } else { $level = 1; } @@ -3884,7 +3910,7 @@ sub render { if ($vars->{GRANULARITY} eq 'resource') { $result .= "&\"") . "' />\n"; - } elsif ($vars->{GRANULARITY} eq 'map') { + } elsif (($vars->{GRANULARITY} eq 'map') || ($vars->{GRANULARITY} eq 'maprecurse')) { $result .= "\n"; }