Diff for /loncom/interface/loncoursequeueadmin.pm between versions 1.52.2.5.2.3 and 1.59

version 1.52.2.5.2.3, 2023/09/04 17:10:13 version 1.59, 2020/07/01 20:08:54
Line 506  sub build_queue_display { Line 506  sub build_queue_display {
     my %crstypes;      my %crstypes;
     my $output =  &Apache::loncommon::start_data_table().      my $output =  &Apache::loncommon::start_data_table().
                   &Apache::loncommon::start_data_table_header_row();                    &Apache::loncommon::start_data_table_header_row();
     unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) {      unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { 
         $output .= '<th>'.&mt('Action').'</th>';          $output .= '<th>'.&mt('Action').'</th>';
     }      }
     $output .= '<th>'.&mt('Requestor').'</th>';      $output .= '<th>'.&mt('Requestor').'</th>';
Line 528  sub build_queue_display { Line 528  sub build_queue_display {
                         unofficial => 'Unofficial course',                          unofficial => 'Unofficial course',
                         community  => 'Community',                          community  => 'Community',
                         textbook   => 'Textbook course',                          textbook   => 'Textbook course',
                           placement  => 'Placement test',
                     );                      );
         $output .= '<th>'.&mt('Type').'</th>'.          $output .= '<th>'.&mt('Type').'</th>'.
                    '<th>'.&mt('Date requested').'</th>'.                     '<th>'.&mt('Date requested').'</th>'.
Line 609  sub build_queue_display { Line 610  sub build_queue_display {
                 } elsif ($context eq 'requestusername') {                  } elsif ($context eq 'requestusername') {
                     $row .= '<td>'.$showtime.'</td>'."\n".                      $row .= '<td>'.$showtime.'</td>'."\n".
                             '<td>'.$detailslink.'</td>'."\n";                              '<td>'.$detailslink.'</td>'."\n";
                 } else {                  } else { 
                     if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') {                      if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') {
                         $row .= '<td>'.$instcode.'</td>'."\n";                          $row .= '<td>'.$instcode.'</td>'."\n";
                     } else {                      } else {
Line 1619  sub course_creation { Line 1620  sub course_creation {
             (ref($longroles) eq 'HASH')) {              (ref($longroles) eq 'HASH')) {
         return ('error: Invalid request');          return ('error: Invalid request');
     }      }
     my ($result,$ownername,$ownerdom,$autocoowner);      my ($result,$ownername,$ownerdom);
     my $crstype = $details->{'crstype'};      my $crstype = $details->{'crstype'};
     my $coursedesc = $details->{'cdescr'};      my $coursedesc = $details->{'cdescr'};
     my $accessstart = $details->{'accessstart'};      my $accessstart = $details->{'accessstart'};
     my $accessend = $details->{'accessend'};      my $accessend = $details->{'accessend'};
     my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses','autoenroll'],$dom);      my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
     if (ref($domconfig{'requestcourses'}) eq 'HASH') {      if (ref($domconfig{'requestcourses'}) eq 'HASH') {
         if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {          if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
             if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {              if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
Line 1632  sub course_creation { Line 1633  sub course_creation {
             }              }
         }          }
     }      }
     if (ref($domconfig{'autoenroll'}) eq 'HASH') {  
         $autocoowner = $domconfig{'autoenroll'}{'co-owners'};  
     }  
     if ($context eq 'domain') {      if ($context eq 'domain') {
         $ownername = $details->{'owner'};          $ownername = $details->{'owner'};
         $ownerdom  = $details->{'domain'};          $ownerdom  = $details->{'domain'};
Line 1649  sub course_creation { Line 1647  sub course_creation {
         $owneremail = $emails{$email};          $owneremail = $emails{$email};
         last if ($owneremail ne '');          last if ($owneremail ne '');
     }      }
     my %reqdetails = &build_batchcreatehash($dom,$cnum,$context,$details,$owneremail,$domdefs);      my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs);
     my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',      my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',
                   \%reqdetails,$longroles,$logmsg,$clonemsg,$newusermsg,$addresult,                    \%reqdetails,$longroles,$logmsg,$clonemsg,$newusermsg,$addresult,
                   $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,                    $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,
Line 1664  sub course_creation { Line 1662  sub course_creation {
         $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,          $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,
                                                            $ownerdom,$fullname,$coursedesc,$code,                                                             $ownerdom,$fullname,$coursedesc,$code,
                                                            $accessstart,$accessend,$customhash);                                                             $accessstart,$accessend,$customhash);
         if ($autocoowner) {  
             my $instcode = $details->{'instcode'};  
             if (($instcode ne '') && (ref($reqdetails{'users'}) eq 'HASH')) {  
                 my @posscoowners;  
                 my $now = time;  
                 foreach my $person (keys(%{$reqdetails{'users'}})) {  
                     my ($uname,$udom) = split(/:/,$person);  
                     next if (($udom ne $dom) || (($uname eq $ownername) && ($udom eq $ownerdom)));  
                     if ((&Apache::lonnet::homeserver($uname,$udom,1) ne 'no_host') &&  
                         (ref($reqdetails{'users'}{$person}) eq 'HASH')) {  
                         if ((grep(/^cc$/,keys(%{$reqdetails{'users'}{$person}}))) &&  
                             (ref($reqdetails{'users'}{$person}{'cc'}) eq 'HASH')) {  
                             my $start = $reqdetails{'users'}{$person}{'cc'}{'start'};  
                             my $end = $reqdetails{'users'}{$person}{'cc'}{'end'};  
                             if ((($start eq '') || ($start <= $now)) &&  
                                 (($end eq '') || ($end >= $now))) {  
                                 push(@posscoowners,$person);  
                             }  
                         }  
                     }  
                 }  
                 my @coowners;  
                 if (@posscoowners) {  
                     foreach my $user (@posscoowners) {  
                         my ($checkcc,$desc) =  
                             &Apache::lonnet::auto_validate_instcode($cnum,$dom,$instcode,$user);  
                         unless ($checkcc eq 'valid') {  
                             if (ref($reqdetails{'crosslists'}) eq 'HASH') {  
                                 foreach my $key (keys(%{$reqdetails{'crosslists'}})) {  
                                     if (ref($reqdetails{'crosslists'}{$key}) eq 'HASH') {  
                                         my $inst_crosslist = $reqdetails{'crosslists'}{$key}{'inst'};  
                                         if ($inst_crosslist ne '') {  
                                             $checkcc =  
                                                 &Apache::lonnet::auto_validate_inst_crosslist($cnum,$dom,$instcode,  
                                                                                               $inst_crosslist,$user);  
                                             last if ($checkcc eq 'valid');  
                                         }  
                                     }  
                                 }  
                             }  
                         }  
                         if ($checkcc eq 'valid') {  
                             if (@coowners > 0) {  
                                 unless (grep(/^\Q$user\E$/,@coowners)) {  
                                     push(@coowners,$user);  
                                 }  
                             } else {  
                                 push(@coowners,$user);  
                             }  
                         }  
                     }  
                 }  
                 if (@coowners > 0) {  
                     my $chome = &Apache::lonnet::homeserver($cnum,$dom);  
                     unless ($chome eq 'no_host') {  
                         &Apache::lonnet::store_coowners($dom,$cnum,$chome,'',@coowners);  
                     }  
                 }  
             }  
         }  
     } else {      } else {
         $result = 'error: '.$cid;          $result = 'error: '.$cid;
     }      }
Line 1731  sub course_creation { Line 1669  sub course_creation {
 }  }
   
 sub build_batchcreatehash {  sub build_batchcreatehash {
     my ($dom,$cnum,$context,$details,$owneremail,$domdefs) = @_;      my ($dom,$context,$details,$owneremail,$domdefs) = @_;
     my %batchhash;      my %batchhash;
     my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift tinyurls enrollstart enrollend accessstart accessend sections users uniquecode};      my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift tinyurls enrollstart enrollend accessstart accessend sections crosslists users uniquecode};
     if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {      if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {
         my $emailenc = &escape($owneremail);          my $emailenc = &escape($owneremail);
         my $owner = $details->{'owner'}.':'.$details->{'domain'};          my $owner = $details->{'owner'}.':'.$details->{'domain'};
         foreach my $item (@items) {          foreach my $item (@items) {
             $batchhash{$item} = $details->{$item};              $batchhash{$item} = $details->{$item};
         }          }
         if (ref($details->{'crosslists'}) eq 'HASH') {  
             foreach my $key (keys(%{$details->{'crosslists'}})) {  
                 if (ref($details->{'crosslists'}->{$key}) eq 'HASH') {  
                     my $instsec = $details->{crosslists}->{$key}->{instsec};  
                     $batchhash{'crosslists'}{$key}{'inst'} = $details->{crosslists}->{$key}->{instcode};  
                     my $crskey = $cnum.':'.$batchhash{'crosslists'}{$key}{'inst'};  
                     my %formatted = &Apache::lonnet::auto_instsec_reformat($dom,'clutter',  
                                                                            {$crskey => [$instsec]});  
                     if (ref($formatted{$crskey}) eq 'ARRAY') {  
                         $batchhash{'crosslists'}{$key}{'inst'} .= $formatted{$crskey}->[0];  
                     }  
                     $batchhash{'crosslists'}{$key}{'loncapa'} = $details->{crosslists}->{$key}->{loncapa};  
                 }  
             }  
         }  
         $batchhash{'title'} = $details->{'cdescr'};          $batchhash{'title'} = $details->{'cdescr'};
         $batchhash{'coursecode'} = $details->{'instcode'};          $batchhash{'coursecode'} = $details->{'instcode'};
         if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {          if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
Line 1767  sub build_batchcreatehash { Line 1690  sub build_batchcreatehash {
         $batchhash{'authparam'} = $domdefs->{'auth_arg_def'};          $batchhash{'authparam'} = $domdefs->{'auth_arg_def'};
         if ($details->{'crstype'} eq 'community') {          if ($details->{'crstype'} eq 'community') {
             $batchhash{'crstype'} = 'Community';              $batchhash{'crstype'} = 'Community';
           } elsif ($details->{'crstype'} eq 'placement') {
               $batchhash{'crstype'} = 'Placement';
         } else {          } else {
             if ($details->{'crstype'} eq 'textbook') {              if ($details->{'crstype'} eq 'textbook') {
                 if ($details->{'clonecrs'} && $details->{'clonedom'}) {                  if ($details->{'clonecrs'} && $details->{'clonedom'}) {
                     my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});                      my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});
                     $batchhash{'textbook'} = $clonedfrom{'description'};                      $batchhash{'textbook'} = $clonedfrom{'description'};
                 }                  }
             } elsif ($details->{'crstype'} eq 'lti') {  
                 $batchhash{'lti'} = 1;  
             }              }
             $batchhash{'crstype'} = 'Course';              $batchhash{'crstype'} = 'Course';
         }          }
Line 2318  sub postprocess_crsenv { Line 2241  sub postprocess_crsenv {
         my %needcrsidput = (          my %needcrsidput = (
                               'internal.selfenroll_types'      => 1,                                'internal.selfenroll_types'      => 1,
                               'internal.selfenroll_start_date' => 1,                                'internal.selfenroll_start_date' => 1,
                               'internal.selfenroll_end_date'   => 1,                                'internal. selfenroll_end_date'  => 1,
                            );                             );
         my (@needupdate,%newcrsenv);          my (@needupdate,%newcrsenv);
         foreach my $key (keys(%{$postprocessenv})) {           foreach my $key (keys(%{$postprocessenv})) { 

Removed from v.1.52.2.5.2.3  
changed lines
  Added in v.1.59


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