Diff for /loncom/interface/lonuserutils.pm between versions 1.109.2.3 and 1.116

version 1.109.2.3, 2010/08/09 23:39:43 version 1.116, 2010/02/19 15:41:40
Line 36  use Apache::loncommon(); Line 36  use Apache::loncommon();
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::longroup;  use Apache::longroup;
 use Apache::lonnavmaps;  
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
 ###############################################################  ###############################################################
Line 1186  sub default_role_selector { Line 1185  sub default_role_selector {
                     'exs'  => "Existing sections",                      'exs'  => "Existing sections",
                     'new'  => "New section",                      'new'  => "New section",
                   );                    );
     $options = '<select name="defaultrole">'."\n";      $options = '<select name="defaultrole">'."\n".
     unless (($context eq 'course') && (&Apache::loncommon::needs_gci_custom())) {                 ' <option value="">'.&mt('Please select').'</option>'."\n"; 
         $options .= ' <option value="">'.&mt('Please select').'</option>'."\n";  
     }  
     if ($context eq 'course') {      if ($context eq 'course') {
         $options .= &default_course_roles($context,$checkpriv,$crstype,%customroles);          $options .= &default_course_roles($context,$checkpriv,$crstype,%customroles);
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
Line 1451  sub print_userlist { Line 1448  sub print_userlist {
     }      }
     if (!(($context eq 'domain') &&       if (!(($context eq 'domain') && 
           (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {            (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
         $r->print('&nbsp;'.&list_submit_button(&mt('Update Display')).          $r->print(
                   "\n</p>\n");              "\n</p>\n"
              .'<p>'
              .&list_submit_button(&mt('Update Display'))
              ."</p>\n"
           );
     }      }
     my ($indexhash,$keylist) = &make_keylist_array();      my ($indexhash,$keylist) = &make_keylist_array();
     my (%userlist,%userinfo,$clearcoursepick);      my (%userlist,%userinfo,$clearcoursepick);
Line 1691  sub role_filter { Line 1692  sub role_filter {
         $role_select .= '</select>';          $role_select .= '</select>';
         $output = '<label><span class="LC_nobreak">'          $output = '<label><span class="LC_nobreak">'
                  .&mt('Role: [_1]',$role_select)                   .&mt('Role: [_1]',$role_select)
                  .'</span></label>';                   .'</span></label> ';
     }      }
     return $output;      return $output;
 }  }
Line 1731  sub section_group_filter { Line 1732  sub section_group_filter {
         }          }
         if (@options > 0) {          if (@options > 0) {
             my $currsel;              my $currsel;
             $markup = '<select name="'.$name{$item}.'" />'."\n";              $markup = '<select name="'.$name{$item}.'">'."\n";
             foreach my $option ('all','none',@options) {               foreach my $option ('all','none',@options) { 
                 $currsel = '';                  $currsel = '';
                 if ($env{'form.'.$name{$item}} eq $option) {                  if ($env{'form.'.$name{$item}} eq $option) {
Line 1746  sub section_group_filter { Line 1747  sub section_group_filter {
                 $markup .= '</option>'."\n";                  $markup .= '</option>'."\n";
             }              }
             $markup .= '</select>'."\n";              $markup .= '</select>'."\n";
             $output .= ('&nbsp;'x3).'<label>'.$title{$item}.': '.$markup.'</label>';              $output .= ('&nbsp;'x3).'<span class="LC_nobreak">'
                         .'<label>'.$title{$item}.': '.$markup.'</label>'
                         .'</span> ';
         }          }
     }      }
     return $output;      return $output;
Line 2096  sub process_date_info { Line 2099  sub process_date_info {
   
 sub show_users_list {  sub show_users_list {
     my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_;      my ($r,$context,$mode,$permission,$statusmode,$userlist,$keylist,$formname)=@_;
     my $custommenu;   
     if ($formname eq '') {      if ($formname eq '') {
         $formname = 'studentform';          $formname = 'studentform';
     }      }
Line 2121  sub show_users_list { Line 2123  sub show_users_list {
         $sortby = 'username';          $sortby = 'username';
     }      }
     my $setting = $env{'form.roletype'};      my $setting = $env{'form.roletype'};
     my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype,      my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype);
         $clickersupport,$displaygroups);  
     if ($context eq 'course') {      if ($context eq 'course') {
         $cid = $env{'request.course.id'};          $cid = $env{'request.course.id'};
         $crstype = &Apache::loncommon::course_type();          $crstype = &Apache::loncommon::course_type();
         ($cnum,$cdom) = &get_course_identity($cid);          ($cnum,$cdom) = &get_course_identity($cid);
         $custommenu = &Apache::loncommon::needs_gci_custom();  
         unless ($custommenu) {  
             $clickersupport = 1;  
             $displaygroups = 1;  
         }  
         ($classgroups) = &Apache::loncoursedata::get_group_memberships(          ($classgroups) = &Apache::loncoursedata::get_group_memberships(
                                      $userlist,$keylist,$cdom,$cnum);                                       $userlist,$keylist,$cdom,$cnum);
         if ($mode eq 'autoenroll') {          if ($mode eq 'autoenroll') {
Line 2252  END Line 2248  END
                        'role'       => "role",                         'role'       => "role",
                        'type'       => "enroll type/action",                         'type'       => "enroll type/action",
                        'email'      => "e-mail address",                         'email'      => "e-mail address",
                        'lastlogin'  => "last login",  
                        'submissions' => "test status",  
                        'photo'      => "photo",                         'photo'      => "photo",
                        'extent'     => "extent",                         'extent'     => "extent",
                        'pr'         => "Proceed",                         'pr'         => "Proceed",
Line 2300  END Line 2294  END
             push(@cols,'status');              push(@cols,'status');
         }          }
         if ($context eq 'course') {          if ($context eq 'course') {
             if ($displaygroups) {              push(@cols,'groups');
                 push(@cols,'groups');  
             }  
         }          }
         push(@cols,'email');          push(@cols,'email');
         if ($context eq 'course') {  
             if ($custommenu) {  
                 push(@cols,'lastlogin');  
                 if (($env{'form.showrole'} eq 'Any') || ($env{'form.showrole'} eq 'st')) {  
                     push(@cols,'submissions');  
                 }  
             }  
         }  
     }      }
   
     my $rolefilter = $env{'form.showrole'};      my $rolefilter = $env{'form.showrole'};
Line 2419  END Line 2403  END
             if ($env{'form.userwin'}) {              if ($env{'form.userwin'}) {
                 $checkwin = ' checked="checked"';                  $checkwin = ' checked="checked"';
             }              }
             $output .= '</td><td valign="top"><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>';              $output .= '</td><td valign="top"  style="border-left: 1px solid;"><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>';
         }          }
         $output .= "\n".'<div class="LC_clear_float_footer">&nbsp;</div>'."\n".          $output .= "\n".'<div class="LC_clear_float_footer">&nbsp;</div>'."\n".
                   &Apache::loncommon::start_data_table().                    &Apache::loncommon::start_data_table().
Line 2435  END Line 2419  END
             }              }
         }          }
         foreach my $item (@cols) {          foreach my $item (@cols) {
             if (grep(/^\Q$item\E$/,@sortable)) {              $output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n";
                 $output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n";  
             } else {  
                 $output .= "<th>$lt{$item}</th>\n";  
             }  
         }          }
         my %role_types = &role_type_names();          my %role_types = &role_type_names();
         if ($context eq 'course' && $mode ne 'autoenroll') {          if ($context eq 'course' && $mode ne 'autoenroll') {
             if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {              if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
                 # Clicker display on or off?                  # Clicker display on or off?
                 if ($clickersupport) {                  my %clicker_options = (
                     my %clicker_options = (                                          'on' => 'Show',
                                             'on' => 'Show',                                          'off' => 'Hide',
                                             'off' => 'Hide',                                        );
                                           );                  my $clickerchg = 'on';
                     my $clickerchg = 'on';                  if ($displayclickers eq 'on') {
                     if ($displayclickers eq 'on') {                      $clickerchg = 'off';
                         $clickerchg = 'off';                  }
                     }                  $output .= '    <th>'."\n".'     '
                     $output .= '    <th>'."\n".'     '                          .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
                        .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'  
                             ,'<a href="javascript:document.'.$formname.'.displayclickers.value='                              ,'<a href="javascript:document.'.$formname.'.displayclickers.value='
                              ."'".$clickerchg."'".';document.'.$formname.'.submit();">'                               ."'".$clickerchg."'".';document.'.$formname.'.submit();">'
                             ,'</a>')                              ,'</a>')
                         ."\n".'    </th>'."\n";                          ."\n".'    </th>'."\n";
                 }  
                 # Photo display on or off?                  # Photo display on or off?
                 if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {                  if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
                     my %photo_options = &Apache::lonlocal::texthash(                      my %photo_options = &Apache::lonlocal::texthash(
Line 2499  END Line 2478  END
             $CSVfile = undef;              $CSVfile = undef;
         }          }
         #          #
         if ($clickersupport) {          push @cols,'clicker';
             push @cols,'clicker';  
         }  
         # Write headers and data to file          # Write headers and data to file
         print $CSVfile '"'.$results_description.'"'."\n";           print $CSVfile '"'.$results_description.'"'."\n"; 
         print $CSVfile '"'.join('","',map {          print $CSVfile '"'.join('","',map {
             &Apache::loncommon::csv_translate($lt{$_})              &Apache::loncommon::csv_translate($lt{$_})
             } (@cols))."\"\n";              } (@cols))."\"\n";
     } elsif ($mode eq 'excel') {      } elsif ($mode eq 'excel') {
         if ($clickersupport) {          push @cols,'clicker';
             push @cols,'clicker';  
         }  
         # Create the excel spreadsheet          # Create the excel spreadsheet
         ($excel_workbook,$excel_filename,$format) =          ($excel_workbook,$excel_filename,$format) =
             &Apache::loncommon::create_workbook($r);              &Apache::loncommon::create_workbook($r);
Line 2546  END Line 2521  END
                                                 Future  => 'Future',                                                  Future  => 'Future',
                                                 Expired => 'Expired',                                                  Expired => 'Expired',
                                                );                                                 );
     # If this is for a single course get last course "log-in" and submissions.  
     my (%crslogins,%stusubmissions,%elapsed,$numparts,%nummultipart,$multipart);  
     my $now = time;  
     if ($context eq 'course') {  
         if ($custommenu) {  
             %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);  
             %stusubmissions=&Apache::lonnet::dump('nohist_submissiontracker',$cdom,$cnum);  
             %elapsed = &Apache::lonlocal::texthash(      
                                          -1 => 'more than a month ago',  
                                     2592000 => 'within last 30 days',  
                                      604800 => 'within last 7 days',  
                                       86400 => 'within last 24 hours',  
                                    );  
             my $navmap = Apache::lonnavmaps::navmap->new();  
             if (defined($navmap)) {  
                 my @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/default_1261144274.sequence',sub { $_[0]->is_problem() },0);  
                 foreach my $resource (@allres) {  
                     my @parts = $resource->parts();  
                     my $count = scalar(@parts);  
                     if ($count > 1) {  
                         $nummultipart{$count} ++;  
                     }  
                     $numparts += $count;  
                 }  
                 if (keys(%nummultipart) > 0) {  
                    $multipart = '<br />'.'contains';  
                    foreach my $key (sort {$a <=> $b} keys(%nummultipart)) {  
                        $multipart .= " nummultipart{$key} multipart questions (with $key parts)";  
                    }  
                 }  
             }  
         }  
     }  
   
     # Get groups, role, permanent e-mail so we can sort on them if      # Get groups, role, permanent e-mail so we can sort on them if
     # necessary.      # necessary.
     foreach my $user (keys(%{$userlist})) {      foreach my $user (keys(%{$userlist})) {
Line 2726  END Line 2667  END
         } else {          } else {
             $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});              $in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
         }          }
         if ($context eq 'course') {  
             if ($custommenu) {  
                 my $lastlogin = $crslogins{$in{'username'}.':'.$in{'domain'}.':'.$in{'section'}.':'.$role};  
                 if ($lastlogin ne '') {  
                     my $sincelogin = $now - $lastlogin;  
                     if ($sincelogin < 86400) {  
                         $in{'lastlogin'} = $elapsed{'86400'};  
                     } elsif ($sincelogin < 604800) {  
                         $in{'lastlogin'} = $elapsed{'604800'};  
                     } elsif ($sincelogin < 2592000 ) {  
                         $in{'lastlogin'} = $elapsed{'2592000'};  
                     } else {  
                         $in{'lastlogin'} = $elapsed{'-1'};  
                     }  
                 }  
             }  
             if ($role eq 'st') {  
                 my $numsub = $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0attempts"} +   
                              $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0pilotsubs"};  
                 if (!$numsub) {  
                     $in{'submissions'} = 'unattempted';  
                 } elsif ($numsub < $numparts) {  
                     $in{'submissions'} = 'incomplete ('.$numsub.'/'.$numparts.')';  
                 } else {  
                     $in{'submissions'} = 'completed';  
                 }  
             }  
         }  
         if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {          if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
             $r->print(&Apache::loncommon::start_data_table_row());              $r->print(&Apache::loncommon::start_data_table_row());
             my $checkval;              my $checkval;
Line 2827  END Line 2740  END
                         $showitem = $ltstatus{$in{$item}};                          $showitem = $ltstatus{$in{$item}};
                     }                      }
                     $r->print('<td>'.$showitem.'</td>'."\n");                      $r->print('<td>'.$showitem.'</td>'."\n");
                 } elsif ($item eq 'submissions') {  
                     if ($in{$item} =~ /^incomplete/) {   
                         $r->print('<td>'.$in{$item}.$multipart.'</td>');  
                     } else {  
                         $r->print('<td>'.$in{$item}.'</td>'."\n");  
                     }  
                 } else {                  } else {
                     $r->print('<td>'.$in{$item}.'</td>'."\n");                      $r->print('<td>'.$in{$item}.'</td>'."\n");
                 }                  }
             }              }
             if (($context eq 'course') && ($mode ne 'autoenroll')) {              if (($context eq 'course') && ($mode ne 'autoenroll')) {
                 if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {                  if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
                     if ($clickersupport) {                      if ($displayclickers eq 'on') {
                         if ($displayclickers eq 'on') {                          my $clickers =
                             my $clickers =  
                    (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];                     (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
                             if ($clickers!~/\w/) { $clickers='-'; }                          if ($clickers!~/\w/) { $clickers='-'; }
                             $r->print('<td>'.$clickers.'</td>');                          $r->print('<td>'.$clickers.'</td>');
                         } else {                      } else {
                             $r->print('    <td>&nbsp;</td>  ');                          $r->print('    <td>&nbsp;</td>  ');
                         }  
                     }                      }
                     if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {                      if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
                         if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {                          if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
Line 3038  sub print_username_link { Line 2943  sub print_username_link {
         $output = $in->{'username'};          $output = $in->{'username'};
     } else {      } else {
         $output = '<a href="javascript:username_display_launch('.          $output = '<a href="javascript:username_display_launch('.
                   "'$in->{'username'}','$in->{'domain'}'".')" />'.                    "'$in->{'username'}','$in->{'domain'}'".')">'.
                   $in->{'username'}.'</a>';                    $in->{'username'}.'</a>';
     }      }
     return $output;      return $output;
Line 3292  ENDJS Line 3197  ENDJS
                 $date_items;                  $date_items;
     if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {      if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {
         my ($cnum,$cdom) = &get_course_identity();          my ($cnum,$cdom) = &get_course_identity();
         my $crstype = &Apache::loncommon::course_type();  
         if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
             $lt{'fors'} = &mt('For member roles changing the section, will result in a section switch as members may only be in one section of a community at a time.');              $lt{'fors'} = &mt('For member roles changing the section, will result in a section switch as members may only be in one section of a community at a time.');
             $lt{'forn'} = &mt('For a role in a community that is not a member role, a user may have roles in more than one section of a community at a time.');              $lt{'forn'} = &mt('For a role in a community that is not a member role, a user may have roles in more than one section of a community at a time.');
Line 3499  sub results_header_row { Line 3403  sub results_header_row {
                 if ($rolefilter eq 'Any') {                  if ($rolefilter eq 'Any') {
                     $description .= &mt('All users with co-author roles in domain',$showfilter);                      $description .= &mt('All users with co-author roles in domain',$showfilter);
                 } else {                  } else {
                     $description .= &mt('All co-authors in domain  with [_1] roles',$rolefilter);                      $description .= &mt('All co-authors in domain with [_1] roles',$rolefilter);
                 }                  }
             }              }
         } elsif (($env{'form.roletype'} eq 'course') ||           } elsif (($env{'form.roletype'} eq 'course') || 
Line 3563  sub show_drop_list { Line 3467  sub show_drop_list {
     my ($r,$classlist,$nosort,$permission,$crstype) = @_;      my ($r,$classlist,$nosort,$permission,$crstype) = @_;
     my $cid = $env{'request.course.id'};      my $cid = $env{'request.course.id'};
     my ($cnum,$cdom) = &get_course_identity($cid);      my ($cnum,$cdom) = &get_course_identity($cid);
     my $displaygroups;  
     unless (&Apache::loncommon::needs_gci_custom()) {  
         $displaygroups = 1;  
     }  
     if (! exists($env{'form.sortby'})) {      if (! exists($env{'form.sortby'})) {
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                                 ['sortby']);                                                  ['sortby']);
Line 3644  END Line 3544  END
     <th>$lt{'sec'}</th>      <th>$lt{'sec'}</th>
     <th>$lt{'start'}</th>      <th>$lt{'start'}</th>
     <th>$lt{'end'}</th>      <th>$lt{'end'}</th>
       <th>$lt{'groups'}</th>
 END  END
         if ($displaygroups) {  
             $r->print("    <th>$lt{'groups'}</th>\n");  
         }  
         $r->print(&Apache::loncommon::end_data_table_header_row());          $r->print(&Apache::loncommon::end_data_table_header_row());
     } else  {      } else  {
         $r->print(&Apache::loncommon::start_data_table().          $r->print(&Apache::loncommon::start_data_table().
Line 3668  END Line 3566  END
        <a href="/adm/createuser?action=$action&sortby=start">$lt{'start'}</a>         <a href="/adm/createuser?action=$action&sortby=start">$lt{'start'}</a>
     </th><th>      </th><th>
        <a href="/adm/createuser?action=$action&sortby=end">$lt{'end'}</a>         <a href="/adm/createuser?action=$action&sortby=end">$lt{'end'}</a>
       </th><th>
          <a href="/adm/createuser?action=$action&sortby=groups">$lt{'groups'}</a>
     </th>      </th>
 END  END
        if ($displaygroups) {  
            $r->print("<th>  
        <a href=\"/adm/createuser?action=$action&sortby=groups\">$lt{'groups'}</a>  
     </th>\n");  
         }  
         $r->print(&Apache::loncommon::end_data_table_header_row());          $r->print(&Apache::loncommon::end_data_table_header_row());
     }      }
     #      #
Line 3727  END Line 3622  END
     <td>$section</td>      <td>$section</td>
     <td>$start $startitem</td>      <td>$start $startitem</td>
     <td>$end</td>      <td>$end</td>
       <td>$active_groups</td>
 END  END
         if ($displaygroups) {  
             $r->print("    <td>$active_groups</td>\n");  
         }  
         $r->print(&Apache::loncommon::end_data_table_row());          $r->print(&Apache::loncommon::end_data_table_row());
     }      }
     $r->print(&Apache::loncommon::end_data_table().'<br />');      $r->print(&Apache::loncommon::end_data_table().'<br />');
Line 3767  sub print_first_users_upload_form { Line 3660  sub print_first_users_upload_form {
     $str .= '<input type="hidden" name="action" value="upload" />';      $str .= '<input type="hidden" name="action" value="upload" />';
     $str .= '<input type="hidden" name="state"  value="got_file" />';      $str .= '<input type="hidden" name="state"  value="got_file" />';
   
     $str .= '<h3>'.&mt('Upload a file containing information about users').'</h3>'."\n";      $str .= '<h2>'.&mt('Upload a file containing information about users').'</h2>'."\n";
   
     # Excel and CSV Help      # Excel and CSV Help
     $str .= '<div class="LC_left_float">'      $str .= '<div class="LC_left_float">'
Line 3778  sub print_first_users_upload_form { Line 3671  sub print_first_users_upload_form {
                 &mt("How do I create a CSV file from a spreadsheet"))                  &mt("How do I create a CSV file from a spreadsheet"))
            .'</div><br clear="all" />'."\n";             .'</div><br clear="all" />'."\n";
     $str .= &Apache::lonhtmlcommon::start_pick_box()      $str .= &Apache::lonhtmlcommon::start_pick_box()
            .&Apache::lonhtmlcommon::row_title(&mt('File'))             .&Apache::lonhtmlcommon::row_title(&mt('File'));
            .&Apache::loncommon::upfile_select_html()      if (&Apache::lonlocal::current_language() ne 'en') {
           if ($context eq 'course') { 
               $str .= '<p class="LC_info">'."\n"
                      .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n"
                      .'</p>'."\n";
           }
       }
       $str .= &Apache::loncommon::upfile_select_html()
            .&Apache::lonhtmlcommon::row_closure()             .&Apache::lonhtmlcommon::row_closure()
            .&Apache::lonhtmlcommon::row_title(             .&Apache::lonhtmlcommon::row_title(
                 '<label for="noFirstLine">'                  '<label for="noFirstLine">'
Line 4932  sub setsections_javascript { Line 4832  sub setsections_javascript {
                     plch => 'Please choose a different section name.',                      plch => 'Please choose a different section name.',
                     mnot => 'may not be used as a section name, as it is the name of a course group.',                      mnot => 'may not be used as a section name, as it is the name of a course group.',
                     secn => 'Section names and group names must be distinct. Please choose a different section name.',                      secn => 'Section names and group names must be distinct. Please choose a different section name.',
                       nonw => 'Section names may only contain letters or numbers.',
                  );                                   );                
     $setsection_js .= <<"ENDSECCODE";      $setsection_js .= <<"ENDSECCODE";
   
 function setSections(formname,crstype) {  function setSections(formname,crstype) {
     var re1 = /^currsec_/;      var re1 = /^currsec_/;
       var re2 =/\\W/;
       var trimleading = /^\\s+/;
       var trimtrailing = /\\s+\$/;
     var groups = new Array($groupslist);      var groups = new Array($groupslist);
     for (var i=0;i<formname.elements.length;i++) {      for (var i=0;i<formname.elements.length;i++) {
         var str = formname.elements[i].name;          var str = formname.elements[i].name;
         var checkcurr = str.match(re1);          var checkcurr = str.match(re1);
         if (checkcurr != null) {          if (checkcurr != null) {
               var num = i;
             if ($checkincluded) {              if ($checkincluded) {
                 $rolecode                  $rolecode
                 if (role == 'cc' || role == 'co') {                  if (role == 'cc' || role == 'co') {
Line 4953  function setSections(formname,crstype) { Line 4858  function setSections(formname,crstype) {
                 } else {                  } else {
                     var sections = '';                      var sections = '';
                     var numsec = 0;                      var numsec = 0;
                     var sections;                      var fromexisting = new Array();
                     for (var j=0; j<formname.elements[i].length; j++) {                      for (var j=0; j<formname.elements[num].length; j++) {
                         if (formname.elements[i].options[j].selected == true ) {                          if (formname.elements[num].options[j].selected == true ) {
                             if (formname.elements[i].options[j].value != "") {                              var addsec = formname.elements[num].options[j].value;
                               if (addsec != "") {
                                   fromexisting.push(addsec);
                                 if (numsec == 0) {                                  if (numsec == 0) {
                                     if (formname.elements[i].options[j].value != "") {                                      sections = addsec;
                                         sections = formname.elements[i].options[j].value;                                  } else {
                                         numsec ++;                                      sections = sections + "," +  addsec;
                                     }  
                                 }  
                                 else {  
                                     sections = sections + "," +  formname.elements[i].options[j].value  
                                     numsec ++;  
                                 }                                  }
                                   numsec ++;
                             }                              }
                         }                          }
                     }                      }
                     if (numsec > 0) {                      var newsecs = formname.elements[num+1].value;
                         if (formname.elements[i+1].value != "" && formname.elements[i+1].value != null) {                      var validsecs = new Array();
                             sections = sections + "," +  formname.elements[i+1].value;                      var validsecstr = '';
                         }                      var badsecs = new Array();
                     }  
                     else {  
                         sections = formname.elements[i+1].value;  
                     }  
                     var newsecs = formname.elements[i+1].value;  
                     var numsplit;  
                     if (newsecs != null && newsecs != "") {                      if (newsecs != null && newsecs != "") {
                         numsplit = newsecs.split(/,/g);                          var numsplit;
                         numsec = numsec + numsplit.length;                          if (newsecs.indexOf(',') == -1) {
                               numsplit = new Array(newsecs);
                           } else {
                               numsplit = newsecs.split(/,/g);
                           }
                           for (var i=0; i<numsplit.length; i++) {
                               var newsec = numsplit[i];
                               newsec = newsec.replace(trimleading,'');
                               newsec = newsec.replace(trimtrailing,'');
                               if (re2.test(newsec) == true) {
                                   badsecs.push(newsec);
                               } else {
                                   if (newsec != '') {
                                       var isnew = 1;
                                       if (fromexisting != null) {
                                           for (var m=0; m<fromexisting.length; m++) {
                                               if (newsec == fromexisting[m]) {
                                                   isnew = 0;
                                               }
                                           }
                                       }
                                       if (isnew == 1) {
                                           validsecs.push(newsec);
                                       }
                                   }
                               }
                           }
                           if (badsecs.length > 0) {
                               alert("$alerts{'nonw'}\\n$alerts{'plch'}");
                               return;
                           }
                           numsec = numsec + validsecs.length;
                     }                      }
   
                     if ((role == 'st') && (numsec > 1)) {                      if ((role == 'st') && (numsec > 1)) {
                         if (crstype == 'Community') {                          if (crstype == 'Community') {
                             alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");                              alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
Line 4992  function setSections(formname,crstype) { Line 4919  function setSections(formname,crstype) {
                             alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");                              alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
                         }                          }
                         return;                          return;
                     }                      } else {
                     else {                          if (validsecs != null) {
                         if (numsplit != null) {                              for (var j=0; j<validsecs.length; j++) {
                             for (var j=0; j<numsplit.length; j++) {                                  if (validsecstr == '' || validsecstr == null) {
                                 if ((numsplit[j] == 'all') ||                                      validsecstr = validsecs[j];
                                     (numsplit[j] == 'none')) {                                  } else {
                                     alert("'"+numsplit[j]+"' $alerts{'mayn'}\\n$alerts{'plch'}");                                      validsecstr += ','+validsecs[j];
                                   }
                                   if ((validsecs[j] == 'all') ||
                                       (validsecs[j] == 'none')) {
                                       alert("'"+validsecs[j]+"' $alerts{'mayn'}\\n$alerts{'plch'}");
                                     return;                                      return;
                                 }                                  }
                                 for (var k=0; k<groups.length; k++) {                                  for (var k=0; k<groups.length; k++) {
                                     if (numsplit[j] == groups[k]) {                                      if (validsecs[j] == groups[k]) {
                                         alert("'"+numsplit[j]+"' $alerts{'mnot'}\\n$alerts{'secn'}");                                          alert("'"+validsecs[j]+"' $alerts{'mnot'}\\n$alerts{'secn'}");
                                         return;                                          return;
                                     }                                      }
                                 }                                  }
                             }                              }
                         }                          }
                         formname.elements[i+2].value = sections;  
                     }                      }
                       if ((validsecstr != '') && (validsecstr != null)) {
                           if (numsec > 0) {
                               sections = sections + "," + validsecstr;
                           } else {
                               sections = validsecstr;
                           }
                       }
                       formname.elements[num+2].value = sections;
                 }                  }
             }              }
         }          }
Line 5135  sub roles_by_context { Line 5073  sub roles_by_context {
         if ($env{'request.role'} =~ m{^dc\./}) {          if ($env{'request.role'} =~ m{^dc\./}) {
             push(@allroles,'ad');              push(@allroles,'ad');
         }          }
         if (&Apache::loncommon::needs_gci_custom()) {          push(@allroles,('ta','ep','in'));
             if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
                 push(@allroles,'co');              push(@allroles,'co');
             } else {  
                 push(@allroles,'cc');  
             }  
         } else {          } else {
             push(@allroles,('ta','ep','in'));              push(@allroles,'cc');
             if ($crstype eq 'Community') {          }
                 push(@allroles,'co');          if ($custom) {
             } else {              push(@allroles,'cr');
                 push(@allroles,'cc');  
             }  
             if ($custom) {  
                 push(@allroles,'cr');  
             }  
         }          }
     } elsif ($context eq 'author') {      } elsif ($context eq 'author') {
         @allroles = ('ca','aa');          @allroles = ('ca','aa');

Removed from v.1.109.2.3  
changed lines
  Added in v.1.116


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