Diff for /loncom/interface/loncoursequeueadmin.pm between versions 1.32 and 1.41

version 1.32, 2012/08/16 17:02:55 version 1.41, 2014/01/03 18:39:51
Line 213  sub send_selfserve_notification { Line 213  sub send_selfserve_notification {
                       mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring space reqests[_3]to display a list of pending requests, which you can either approve or reject.',                        mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring space reqests[_3]to display a list of pending requests, which you can either approve or reject.',
                       args => ["\n","\n\n  ","\n\n"],                        args => ["\n","\n\n  ","\n\n"],
                      });                       });
   
     } elsif ($context eq 'requestauthor') {      } elsif ($context eq 'requestauthor') {
         $rawsubj = 'Authoring space request';          $rawsubj = 'Authoring space request';
         $msgtxt = 'Your request for an authoring space requested on [_1]has been reviewed by a Domain Coordinator.';          $msgtxt = 'Your request for an authoring space requested on [_1]has been reviewed by a Domain Coordinator.';
Line 224  sub send_selfserve_notification { Line 223  sub send_selfserve_notification {
         if (ref($textstr) eq 'ARRAY') {          if (ref($textstr) eq 'ARRAY') {
             push(@rawmsg,@{$textstr});              push(@rawmsg,@{$textstr});
         }          }
       } elsif ($context eq 'uniquecode') {
           $rawsubj = 'Course Identifier';
           if (ref($textstr) eq 'ARRAY') {
               push(@rawmsg,@{$textstr});
           }
       } elsif ($context eq 'queuedcrsreq') {
           $rawsubj = 'Course Request Queued';
           if (ref($textstr) eq 'ARRAY') {
               push(@rawmsg,@{$textstr});
           }
       } elsif ($context eq 'createdcrsreq') {
           $rawsubj = 'Course Creation Information';
           if (ref($textstr) eq 'ARRAY') {
               push(@rawmsg,@{$textstr});
           }
     }      }
     my @to_notify = split(/,/,$notifylist);      my @to_notify = split(/,/,$notifylist);
     my $numsent = 0;      my $numsent = 0;
Line 435  sub build_queue_display { Line 449  sub build_queue_display {
                         official   => 'Official course',                          official   => 'Official course',
                         unofficial => 'Unofficial course',                          unofficial => 'Unofficial course',
                         community  => 'Community',                          community  => 'Community',
                           textbook   => 'Textbook course',
                     );                      );
         $output .= '<th>'.&mt('Type').'</th>'.          $output .= '<th>'.&mt('Type').'</th>'.
                    '<th>'.&mt('Date requested').'</th>'.                     '<th>'.&mt('Date requested').'</th>'.
Line 533  sub update_request_queue { Line 548  sub update_request_queue {
         @processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,          @processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,
         @rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,          @rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,
         %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,          %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
         $firsturl);          $firsturl,$uniquecode,%codes);
     my $count=0;      my $count=0;
     while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {      while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {
         if (@course[0] =~ /^\d+:.*/) {          if ($course[0] =~ /^\d+:.*/) {
             push(@approvals,@course[0]);              push(@approvals,$course[0]);
         } elsif (@course[0] =~ /^later:.*/) {          } elsif ($course[0] =~ /^later:.*/) {
             #decide later              #decide later
         } else {          } else {
             push(@rejections,@course[0]);              push(@rejections,$course[0]);
         }          }
         $count+=1;          $count+=1;
     }      }
Line 783  sub update_request_queue { Line 798  sub update_request_queue {
                                                      $ownerdom,$ownername);                                                       $ownerdom,$ownername);
                         if ((ref($history{'details'}) eq 'HASH') &&                           if ((ref($history{'details'}) eq 'HASH') && 
                             ($history{'disposition'} eq $queue)) {                              ($history{'disposition'} eq $queue)) {
                             my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg);                              my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code,%customitems);
                             my $result = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,                              my $fullname = '';
                                                       \$newusermsg,\$addresult,\$enrollcount,                              my $inprocess = &Apache::lonnet::auto_crsreq_update($cdom,$cnum,$crstype,'process',$ownername,
                                                       \$response,\$keysmsg,\%domdefs,$longroles);                                                                                  $ownerdom,$fullname,$coursedesc);
                               if (ref($inprocess) eq 'HASH') {
                                   foreach my $key (keys(%{$inprocess})) {
                                       if (exists($history{'details'}{$key})) { 
                                           $customitems{$key} = $history{'details'}{$key};
                                       }
                                   }
                               }
                               my ($result,$postprocess) = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,
                                                           \$newusermsg,\$addresult,\$enrollcount,
                                                           \$response,\$keysmsg,\%domdefs,$longroles,\$code,\%customitems);
                             if ($result eq 'created') {                              if ($result eq 'created') {
                                 if ($crstype eq 'community') {                                  if ($crstype eq 'community') {
                                     $approvedmsg = $approvalmsg{'community'};                                      $approvedmsg = $approvalmsg{'community'};
Line 798  sub update_request_queue { Line 823  sub update_request_queue {
                                     if (ref($approvedmsg->[1]) eq 'HASH') {                                      if (ref($approvedmsg->[1]) eq 'HASH') {
                                         $approvedmsg->[1]->{'args'} = [$firsturl];                                          $approvedmsg->[1]->{'args'} = [$firsturl];
                                     }                                      }
                                       if ($code) {
                                           push(@{$approvedmsg},
                                               {
                                                 mt   => 'Students can automatically select your course by entering this code: [_1]',
                                                 args => [$code],
                                               });
                                           $codes{$cnum} = $code;
                                       }
                                       if (ref($postprocess) eq 'HASH') {
                                           if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
                                               foreach my $item (@{$postprocess->{'createdmsg'}}) {
                                                   if (ref($item) eq 'HASH') {
                                                       if ($item->{'mt'} ne '') {
                                                           push(@{$approvedmsg},$item);
                                                       }
                                                   }
                                               }
                                           }
                                       }
                                 }                                  }
                                 push(@completed,$cnum);                                  push(@completed,$cnum);
                                                                   
Line 1047  sub update_request_queue { Line 1091  sub update_request_queue {
                         }                          }
                         my $syllabuslink =                          my $syllabuslink =
                             &Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);                              &Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
                           if ($codes{$cnum}) {
                               $syllabuslink .= &mt('Unique code: [_1]',$codes{$cnum});
                           }
                         $output .= '<li>'.$syllabuslink.'</li>';                          $output .= '<li>'.$syllabuslink.'</li>';
                     }                      }
                     $output .= '</ul></p>';                      $output .= '</ul></p>';
Line 1256  sub update_request_queue { Line 1303  sub update_request_queue {
             }              }
             $output .= '</ul></p>';              $output .= '</ul></p>';
         } else {          } else {
             $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'<ul>';              $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>';
             foreach my $cnum (@warn_dels) {              foreach my $cnum (@warn_dels) {
                 my $showcourse;                  my $showcourse;
                 if (ref($requesthash{$cnum.'_'.$queue})) {                  if (ref($requesthash{$cnum.'_'.$queue})) {
Line 1308  sub get_student_counts { Line 1355  sub get_student_counts {
   
 sub course_creation {  sub course_creation {
     my ($dom,$cnum,$context,$details,$logmsg,$newusermsg,$addresult,$enrollcount,$output,      my ($dom,$cnum,$context,$details,$logmsg,$newusermsg,$addresult,$enrollcount,$output,
         $keysmsg,$domdefs,$longroles) =  @_;          $keysmsg,$domdefs,$longroles,$coderef,$customhash) =  @_;
     unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') &&       unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') && 
             (ref($longroles) eq 'HASH')) {              (ref($longroles) eq 'HASH')) {
         return 'error: Invalid request';          return 'error: Invalid request';
     }      }
     my ($result,$ownername,$ownerdom);      my ($result,$ownername,$ownerdom);
     my $crstype = $details->{'crstype'};      my $crstype = $details->{'crstype'};
       my $coursedesc = $details->{'cdescr'};
       my %domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'],$dom);
       if (ref($domconfig{'requestcourses'}) eq 'HASH') {
           if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
               if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
                   $details->{'uniquecode'} = 1;
               }
           }
       }
     if ($context eq 'domain') {      if ($context eq 'domain') {
         $ownername = $details->{'owner'};          $ownername = $details->{'owner'};
         $ownerdom  = $details->{'domain'};          $ownerdom  = $details->{'domain'};
Line 1322  sub course_creation { Line 1378  sub course_creation {
         $ownername = $env{'user.name'};          $ownername = $env{'user.name'};
         $ownerdom  = $env{'user.domain'};          $ownerdom  = $env{'user.domain'};
     }      }
       my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
     my $owneremail;      my $owneremail;
     my %emails = &Apache::loncommon::getemails($ownername,$ownerdom);      my %emails = &Apache::loncommon::getemails($ownername,$ownerdom);
     foreach my $email ('permanentemail','critnotification','notification') {      foreach my $email ('permanentemail','critnotification','notification') {
Line 1331  sub course_creation { Line 1388  sub course_creation {
     my %reqdetails = &build_batchcreatehash($dom,$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,$newusermsg,$addresult,                    \%reqdetails,$longroles,$logmsg,$newusermsg,$addresult,
                   $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype);                    $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,$coderef);
       my $postprocess;
     if ($cid eq "/$dom/$cnum") {      if ($cid eq "/$dom/$cnum") {
         $result = 'created';          $result = 'created';
           my $code;
           if (ref($coderef)) {
               $code = $$coderef;
           }
           $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,
                                                              $ownerdom,$fullname,$coursedesc,$code,$customhash);
     } else {      } else {
         $result = 'error: '.$cid;          $result = 'error: '.$cid;
     }      }
     return $result;      return ($result,$postprocess);
 }  }
   
 sub build_batchcreatehash {  sub build_batchcreatehash {
     my ($dom,$context,$details,$owneremail,$domdefs) = @_;      my ($dom,$context,$details,$owneremail,$domdefs) = @_;
     my %batchhash;      my %batchhash;
     my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users};      my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift 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'};
Line 1352  sub build_batchcreatehash { Line 1416  sub build_batchcreatehash {
         }          }
         $batchhash{'title'} = $details->{'cdescr'};          $batchhash{'title'} = $details->{'cdescr'};
         $batchhash{'coursecode'} = $details->{'instcode'};          $batchhash{'coursecode'} = $details->{'instcode'};
           if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
               $batchhash{'defaultcredits'} = $details->{'defaultcredits'};
           }
         $batchhash{'emailenc'} = $emailenc;          $batchhash{'emailenc'} = $emailenc;
         $batchhash{'adds'} = $details->{'autoadds'};          $batchhash{'adds'} = $details->{'autoadds'};
         $batchhash{'drops'} = $details->{'autodrops'};          $batchhash{'drops'} = $details->{'autodrops'};
Line 1360  sub build_batchcreatehash { Line 1427  sub build_batchcreatehash {
         if ($details->{'crstype'} eq 'community') {          if ($details->{'crstype'} eq 'community') {
             $batchhash{'crstype'} = 'Community';              $batchhash{'crstype'} = 'Community';
         } else {          } else {
               if ($details->{'crstype'} eq 'textbook') {
                   if ($details->{'clonecrs'} && $details->{'clonedom'}) {
                       my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});
                       $batchhash{'textbook'} = $clonedfrom{'description'};
                   }
               }
             $batchhash{'crstype'} = 'Course';              $batchhash{'crstype'} = 'Course';
         }          }
         my ($owner_firstname,$owner_lastname);          my ($owner_firstname,$owner_lastname);
Line 1470  sub get_processtype { Line 1543  sub get_processtype {
         } else {          } else {
             my %alltasks;              my %alltasks;
             if (($isadv) && ($settings{'_LC_adv'} ne '')) {              if (($isadv) && ($settings{'_LC_adv'} ne '')) {
                 $val = $settings{$crstype}{'_LC_adv'};                  $val = $settings{'_LC_adv'};
                 @{$inststatuses} = ('_LC_adv_');                  @{$inststatuses} = ('_LC_adv_');
             } else {              } else {
                 if ($userenv{'inststatus'} ne '') {                  if ($userenv{'inststatus'} ne '') {
Line 1696  sub process_official_reqs { Line 1769  sub process_official_reqs {
                 }                  }
                 $reqstatus = $disposition;                  $reqstatus = $disposition;
                 if ($disposition eq 'process') {                  if ($disposition eq 'process') {
                     my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg);                      my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code);
                     my $result = &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles);                      my %customitems;
                       my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
                       my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$ownername,
                                                                           $ownerdom,$fullname,$cdescr);
                       if (ref($inprocess) eq 'HASH') {
                           foreach my $key (keys(%{$inprocess})) {
                               if (exists($history{'details'}{$key})) {
                                   $customitems{$key} = $history{'details'}{$key};
                               }
                           }
                       }
                       my ($result,$postprocess) = 
                           &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,
                                            \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,\$code,\%customitems);
                     if ($result eq 'created') {                      if ($result eq 'created') {
                         $disposition = 'created';                          $disposition = 'created';
                         $reqstatus = 'created';                          $reqstatus = 'created';
Line 1721  sub process_official_reqs { Line 1807  sub process_official_reqs {
                                     mt => 'If currently logged-in to LON-CAPA, log-out and log-in again to select your new course role.'                                      mt => 'If currently logged-in to LON-CAPA, log-out and log-in again to select your new course role.'
                                  }];                                   }];
                             my $sender = $dcname.':'.$dcdom;                              my $sender = $dcname.':'.$dcdom;
                               if (ref($postprocess) eq 'HASH') {
                                   if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
                                       foreach my $item (@{$postprocess->{'createdmsg'}}) {
                                           if (ref($item) eq 'HASH') {
                                                if ($item->{'mt'} ne '') {
                                                    push(@{$approvedmsg},$item);
                                                }
                                           }
                                       }
                                   }
                               }
                             &send_selfserve_notification($owner,$approvedmsg,                              &send_selfserve_notification($owner,$approvedmsg,
                                                          $cid,$cdescr,$now,                                                           $cid,$cdescr,$now,
                                                          $beneficiary,$sender,                                                           $beneficiary,$sender,
Line 1840  sub process_reqauthor { Line 1937  sub process_reqauthor {
     unless ($env{'environment.canrequest.author'}) {      unless ($env{'environment.canrequest.author'}) {
         return '<span class="LC_warning">'.          return '<span class="LC_warning">'.
                 &mt('You do not currently have rights to request an authoring space.').'<br />'.                  &mt('You do not currently have rights to request an authoring space.').'<br />'.
                 &mt('Please contact the [_1]helpdesk[_2].','<a href="/adm/helpdesk">',                  &mt('Please contact the [_1]helpdesk[_2] for assistance.','<a href="/adm/helpdesk">',
                 '</a>').'</span>';                  '</a>').'</span>';
     }      }
     my $queued = &reqauthor_check();      my $queued = &reqauthor_check();

Removed from v.1.32  
changed lines
  Added in v.1.41


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