Diff for /loncom/interface/lonhelper.pm between versions 1.196 and 1.200

version 1.196, 2015/08/16 00:21:21 version 1.200, 2018/01/15 00:51:42
Line 2047  be filtered out. The 'addstatus' attribu Line 2047  be filtered out. The 'addstatus' attribu
 and long status display columns to the display. The 'addparts'  and long status display columns to the display. The 'addparts'
 attribute will add in a part selector beside problems that have more  attribute will add in a part selector beside problems that have more
 than 1 part. The 'includecourse' attribute if true, will include  than 1 part. The 'includecourse' attribute if true, will include
 the toplevel default.sequence in the results.  the toplevel default.sequence in the results. The 'modalLink' attribute,
   if true, will cause links to be launched as modal pop-ups, instead of 
   replacing the resource selection listing, currently being displayed. 
   
 =head3 SUB-TAGS  =head3 SUB-TAGS
   
Line 2159  sub start_resource { Line 2161  sub start_resource {
     $paramHash->{'toponly'} = $token->[2]{'toponly'};      $paramHash->{'toponly'} = $token->[2]{'toponly'};
     $paramHash->{'addstatus'} = $token->[2]{'addstatus'};      $paramHash->{'addstatus'} = $token->[2]{'addstatus'};
     $paramHash->{'addparts'} = $token->[2]{'addparts'};      $paramHash->{'addparts'} = $token->[2]{'addparts'};
       $paramHash->{'modalLink'} = $token->[2]{'modallink'};
     if ($paramHash->{'addparts'}) {      if ($paramHash->{'addparts'}) {
  $helper->declareVar($paramHash->{'variable'}.'_part');   $helper->declareVar($paramHash->{'variable'}.'_part');
     }      }
Line 2365  BUTTONS Line 2368  BUTTONS
     my $option_texts   = $self->{OPTION_TEXTS};      my $option_texts   = $self->{OPTION_TEXTS};
     my $option_types   = $self->{OPTION_TYPES};      my $option_types   = $self->{OPTION_TYPES};
     my $addparts       = $self->{'addparts'};      my $addparts       = $self->{'addparts'};
       my $modalLink      = $self->{'modalLink'};
     my $headings_done  = 0;      my $headings_done  = 0;
   
     # Evaluate the map url as needed      # Evaluate the map url as needed
Line 2464  BUTTONS Line 2468  BUTTONS
     $resource_name . "'/> </td>";      $resource_name . "'/> </td>";
     } else {      } else {
  $col .=    $col .= 
     "<td align='center'><input type=$option_type name ='$option_var".      "<td align='center'><input type='$option_type' name ='$option_var".
     "_forminput' value='".      "_forminput' value='".
     $resource_name . "' $checked /> </td>";      $resource_name . "' $checked /> </td>";
     }      }
Line 2549  RADIO Line 2553  RADIO
                                        'suppressEmptySequences' => $self->{'suppressEmptySequences'},                                         'suppressEmptySequences' => $self->{'suppressEmptySequences'},
        'include_top_level_map' => $self->{'include_top_level_map'},         'include_top_level_map' => $self->{'include_top_level_map'},
                                        'iterator_map' => $mapUrl,                                         'iterator_map' => $mapUrl,
                                        'map_no_edit_link' => 1, }                                          'map_no_edit_link' => 1,
                                          'modalLink' => $modalLink, }
                                        );                                         );
   
     $result .= $buttons;      $result .= $buttons;
Line 3183  It takes the standard attributes "variab Line 3188  It takes the standard attributes "variab
 "allowempty" and "nextstate", meaning what they do for most other  "allowempty" and "nextstate", meaning what they do for most other
 elements.  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  have sections and not include groups
   
 =cut  =cut
Line 3277  It takes the standard attributes "variab Line 3282  It takes the standard attributes "variab
  "allowempty" and "nextstate", meaning what they do for most other   "allowempty" and "nextstate", meaning what they do for most other
  elements.   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  =cut
   
 no strict;  no strict;
Line 3306  sub start_group { Line 3315  sub start_group {
     $helper->declareVar($paramHash->{'variable'});      $helper->declareVar($paramHash->{'variable'});
     $paramHash->{'multichoice'} = $token->[2]{'multichoice'};      $paramHash->{'multichoice'} = $token->[2]{'multichoice'};
     $paramHash->{'allowempty'} = $token->[2]{'allowempty'};      $paramHash->{'allowempty'} = $token->[2]{'allowempty'};
       $paramHash->{'grouponly'} = $token->[2]{'grouponly'};
     if (defined($token->[2]{'nextstate'})) {      if (defined($token->[2]{'nextstate'})) {
         $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};          $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
     }      }
Line 3313  sub start_group { Line 3323  sub start_group {
     # Populate the CHOICES element      # Populate the CHOICES element
     my %choices;      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))) {      foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) {
  push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);   push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
     }      }
Line 3816  sub render { Line 3831  sub render {
     if ($vars->{GRANULARITY} eq 'whole_course') {      if ($vars->{GRANULARITY} eq 'whole_course') {
         $resourceString .= '<li>'.&mt('for [_1]all resources in the course[_2]','<b>','</b>').'</li>';          $resourceString .= '<li>'.&mt('for [_1]all resources in the course[_2]','<b>','</b>').'</li>';
  if ($vars->{TARGETS} eq 'course') {   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') {   } elsif ($vars->{TARGETS} eq 'section') {
     $level = 9;      $level = 12;
  } elsif ($vars->{TARGETS} eq 'group') {   } elsif ($vars->{TARGETS} eq 'group') {
     $level = 6;      $level = 8;
  } else {   } else {
     $level = 3;      $level = 4;
  }   }
         $affectedResourceId = "0.0";          $affectedResourceId = "0.0";
         $symb = 'a';          $symb = 'a';
         $paramlevel = 'general';          $paramlevel = 'general';
     } elsif ($vars->{GRANULARITY} eq 'map') {      } elsif (($vars->{GRANULARITY} eq 'map') || ($vars->{GRANULARITY} eq 'maprecurse')) {
         my $navmap = Apache::lonnavmaps::navmap->new();          my $navmap = Apache::lonnavmaps::navmap->new();
         if (defined($navmap)) {          if (defined($navmap)) {
              my $res = $navmap->getByMapPc($vars->{RESOURCE_ID});               my $res = $navmap->getByMapPc($vars->{RESOURCE_ID});
              my $title = $res->compTitle();               my $title = $res->compTitle();
              $symb = $res->symb();               $symb = $res->symb();
              $resourceString .= '<li>'.&mt('for the map named [_1]',"<b>$title</b>").'</li>';               if ($vars->{GRANULARITY} eq 'map') {
                    $resourceString .= '<li>'.&mt('for the map named [_1]',"<b>$title</b>").'</li>';
                } else {
                    $resourceString .= '<li>'.&mt('for the map named [_1] (applies recursively to sub-folders)',"<b>$title</b>").'</li>';
                }
         } else {          } else {
             $resourceString .= '<li>'.&mt('for the map ID [_1] (name unavailable)','<b>'.$vars->{RESOURCE_ID}.'</b>').'</li>';              $resourceString .= '<li>'.&mt('for the map ID [_1] (name unavailable)','<b>'.$vars->{RESOURCE_ID}.'</b>').'</li>';
             &Apache::lonnet::logthis('Retrieval of map title failed in lonhelper.pm - could not create navmap object for course.');              &Apache::lonnet::logthis('Retrieval of map title failed in lonhelper.pm - could not create navmap object for course.');
   
         }          }
  if ($vars->{TARGETS} eq 'course') {          if ($vars->{GRANULARITY} eq 'maprecurse') {
     $level = 13; # general course, see lonparmset.pm perldoc              if ($vars->{TARGETS} eq 'course') {
  } elsif ($vars->{TARGETS} eq 'section') {                  $level = 17; # general course, see lonparmset.pm perldoc
     $level = 8;              } elsif ($vars->{TARGETS} eq 'section') {
  } elsif ($vars->{TARGETS} eq 'group') {                  $level = 11;
     $level = 5;              } elsif ($vars->{TARGETS} eq 'group') {
  } else {                  $level = 7;
     $level = 2;              } 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};          $affectedResourceId = $vars->{RESOURCE_ID};
         $paramlevel = 'map';          $paramlevel = 'map';
     } else {      } else {
Line 3864  sub render { Line 3895  sub render {
             &Apache::lonnet::logthis('Retrieval of resource title failed in lonhelper.pm - could not create navmap object for course.');              &Apache::lonnet::logthis('Retrieval of resource title failed in lonhelper.pm - could not create navmap object for course.');
         }          }
  if ($vars->{TARGETS} eq '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') {   } elsif ($vars->{TARGETS} eq 'section') {
     $level = 7;      $level = 9;
  } elsif ($vars->{TARGETS} eq 'group') {   } elsif ($vars->{TARGETS} eq 'group') {
     $level = 4;      $level = 5;
  } else {   } else {
     $level = 1;      $level = 1;
  }   }
Line 3884  sub render { Line 3915  sub render {
     if ($vars->{GRANULARITY} eq 'resource') {      if ($vars->{GRANULARITY} eq 'resource') {
  $result .= "<input type='hidden' name='symb' value='".   $result .= "<input type='hidden' name='symb' value='".
     HTML::Entities::encode($symb,"'<>&\"") . "' />\n";      HTML::Entities::encode($symb,"'<>&\"") . "' />\n";
     } elsif ($vars->{GRANULARITY} eq 'map') {      } elsif (($vars->{GRANULARITY} eq 'map') || ($vars->{GRANULARITY} eq 'maprecurse')) {
  $result .= "<input type='hidden' name='pschp' value='".   $result .= "<input type='hidden' name='pschp' value='".
     $affectedResourceId."' />\n";      $affectedResourceId."' />\n";
     }      }

Removed from v.1.196  
changed lines
  Added in v.1.200


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>