';
if ($context eq 'crosslist') {
$output .= ''.&mt('Include?').' '.
@@ -2513,6 +3224,26 @@ sub coursecode_form {
return $output;
}
+sub sections_form {
+ my ($dom,$instcode,$num) = @_;
+ my $rowtitle;
+ if ($instcode eq '') {
+ $rowtitle = &mt('Sections');
+ } else {
+ $rowtitle = &mt('Sections of [_1]',$instcode);
+ }
+ return &Apache::lonhtmlcommon::row_title($rowtitle).
+ ''.
+ &Apache::lonhtmlcommon::row_closure(1);
+}
+
sub get_course_dom {
my $codedom = &Apache::lonnet::default_login_domain();
if ($env{'form.showdom'} ne '') {
@@ -2605,9 +3336,10 @@ sub display_navbuttons {
}
sub print_request_outcome {
- my ($dom,$codetitles,$code_order) = @_;
+ my ($lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
- %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
+ %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,
+ $uniquecode);
my $sectotal = $env{'form.sectotal'};
my $crosslisttotal = 0;
$cnum = $env{'form.cnum'};
@@ -2615,15 +3347,17 @@ sub print_request_outcome {
$output = &mt('Invalid LON-CAPA course number for the new course')."\n";
return $output;
}
-
- %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
+ $crstype = $env{'form.crstype'};
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
if (ref($domconfig{'requestcourses'}) eq 'HASH') {
if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') {
$req_notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
}
+ if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
+ $uniquecode = $domconfig{'requestcourses'}{'uniquecode'}{$crstype};
+ }
}
$now = time;
- $crstype = $env{'form.crstype'};
my $ccrole = 'cc';
if ($crstype eq 'community') {
$ccrole = 'co';
@@ -2642,6 +3376,10 @@ sub print_request_outcome {
push(@instsections,$sec);
}
$sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
+ $sections{$i}{'loncapa'} =~ s/\W//g;
+ if ($sections{$i}{'loncapa'} eq 'none') {
+ $sections{$i}{'loncapa'} = '';
+ }
}
}
}
@@ -2667,6 +3405,7 @@ sub print_request_outcome {
$enrollstart = '';
$enrollend = '';
}
+ my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg,%skipped);
for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
my $uname = $env{'form.person_'.$i.'_uname'};
my $udom = $env{'form.person_'.$i.'_dom'};
@@ -2678,6 +3417,56 @@ sub print_request_outcome {
lastname => $env{'form.person_'.$i.'_lastname'},
emailaddr => $env{'form.person_'.$i.'_emailaddr'},
};
+ if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
+ my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);
+ if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {
+ my ($allowed,$msg,$authtype,$authparam) =
+ &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,
+ \%inst_results,\%curr_rules,\%got_rules);
+ if ($allowed) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);
+ if ($usertype eq 'official') {
+ if ($authtype eq '') {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ } else {
+ if ($authtype eq 'loc') {
+ $authtype = 'localauth';
+ } elsif ($authtype eq 'int') {
+ $authtype = 'internal';
+ }
+ if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ }
+ } elsif ($usertype eq 'unofficial') {
+ if ($authtype eq '') {
+ $authtype = 'internal';
+ $authparam = '';
+ }
+ } else {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ if (($authtype eq '') ||
+ (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||
+ ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ } else {
+ $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
+ $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
+ }
+ } else {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ }
+ } else {
+ $skipped{$uname.':'.$udom} = 1;
+ next;
+ }
+ }
}
my $role = $env{'form.person_'.$i.'_role'};
unless ($role eq '') {
@@ -2723,6 +3512,11 @@ sub print_request_outcome {
push(@baduname,$uname.':'.$udom);
}
}
+ if (keys(%skipped)) {
+ foreach my $key (keys(%skipped)) {
+ delete($personnel{$key});
+ }
+ }
my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
my $autodrops = 0;
if ($env{'form.autodrops'}) {
@@ -2730,18 +3524,22 @@ sub print_request_outcome {
}
my $autoadds = 0;
if ($env{'form.autoadds'}) {
- $autodrops = $env{'form.autoadds'};
- }
- if ($env{'form.autoadds'}) {
- $autodrops = $env{'form.autoadds'};
+ $autoadds = $env{'form.autoadds'};
}
my $instcode = '';
if (exists($env{'form.instcode'})) {
$instcode = $env{'form.instcode'};
}
+ my $credits;
+ if ($instcredits) {
+ $credits = $instcredits;
+ } elsif (exists($env{'form.coursecredits'})) {
+ $credits = $env{'form.coursecredits'};
+ }
my $clonecrs = '';
my $clonedom = '';
- if (($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
+ if (($env{'form.cloning'}) &&
+ ($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
($env{'form.clonedom'} =~ /^($match_domain)$/)) {
my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
$env{'form.clonedom'});
@@ -2765,6 +3563,8 @@ sub print_request_outcome {
cdescr => $env{'form.cdescr'},
crstype => $env{'form.crstype'},
instcode => $instcode,
+ defaultcredits => $credits,
+ uniquecode => $uniquecode,
clonedom => $clonedom,
clonecrs => $clonecrs,
datemode => $env{'form.datemode'},
@@ -2781,10 +3581,19 @@ sub print_request_outcome {
accessend => $accessend,
personnel => \%personnel,
};
- my (@inststatuses,$storeresult,$creationresult);
+ my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
+ $req_notifylist,\@instsections,\%domconfig);
+ return ($result,$output);
+}
+
+sub process_request {
+ my ($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
+ $domconfig) = @_;
+ my (@inststatuses,$storeresult,$creationresult,$output);
my $val =
- &Apache::loncoursequeueadmin::get_processtype($env{'user.name'},$env{'user.domain'},
- $env{'user.adv'},$dom,$crstype,\@inststatuses,\%domconfig);
+ &Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'},
+ $env{'user.domain'},$env{'user.adv'},
+ $dom,$crstype,\@inststatuses,$domconfig);
if ($val eq '') {
if ($crstype eq 'official') {
$output = &mt('You are not permitted to request creation of official courses.');
@@ -2792,12 +3601,14 @@ sub print_request_outcome {
$output = &mt('You are not permitted to request creation of unofficial courses.');
} elsif ($crstype eq 'community') {
$output = &mt('You are not permitted to request creation of communities');
+ } elsif ($crstype eq 'textbook') {
+ $output = &mt('You are not permitted to request creation of textbook courses');
} else {
$output = &mt('Unrecognized course type: [_1]',$crstype);
}
$storeresult = 'notpermitted';
} else {
- my ($disposition,$message,$reqstatus);
+ my ($disposition,$message,$reqstatus,$coursedesc);
my %reqhash = (
reqtime => $now,
crstype => $crstype,
@@ -2805,6 +3616,11 @@ sub print_request_outcome {
);
my $requestkey = $dom.'_'.$cnum;
my $validationerror;
+ my $fullname = &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'});
+ if (ref($details) eq 'HASH') {
+ $coursedesc = $details->{'cdescr'};
+ }
if ($val eq 'autolimit=') {
$disposition = 'process';
} elsif ($val =~ /^autolimit=(\d+)$/) {
@@ -2812,18 +3628,37 @@ sub print_request_outcome {
$disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
$dom,$crstype,$limit,\$message);
} elsif ($val eq 'validate') {
- my ($inststatuslist,$validationchk,$validation);
+ my ($inststatuslist,$validationchk,$validation,%custominfo);
if (@inststatuses > 0) {
$inststatuslist = join(',',@inststatuses);
}
my $instseclist;
- if (@instsections > 0) {
- $instseclist = join(',',@instsections);
+ if (ref($instsections) eq 'ARRAY') {
+ if (@{$instsections} > 0) {
+ $instseclist = join(',',@{$instsections});
+ }
+ }
+ my $preprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'prevalidate',$env{'user.name'},
+ $env{'user.domain'},$fullname,$coursedesc);
+ if (ref($preprocess) eq 'HASH') {
+ if (ref($preprocess->{'formitems'}) eq 'HASH') {
+ foreach my $key (keys(%{$preprocess->{'formitems'}})) {
+ if ($preprocess->{'formitems'}->{$key} eq 'multiple') {
+ if (exists($env{'form.'.$key})) {
+ @{$custominfo{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
+ }
+ } else {
+ if (exists($env{'form.'.$key})) {
+ $custominfo{$key} = $env{'form.'.$key};
+ }
+ }
+ }
+ }
}
$validationchk =
&Apache::lonnet::auto_courserequest_validation($dom,
$env{'user.name'}.':'.$env{'user.domain'},$crstype,
- $inststatuslist,$instcode,$instseclist);
+ $inststatuslist,$instcode,$instseclist,\%custominfo);
if ($validationchk =~ /:/) {
($validation,$message) = split(':',$validationchk);
} else {
@@ -2840,7 +3675,27 @@ sub print_request_outcome {
}
$reqhash{'disposition'} = $disposition;
$reqstatus = $disposition;
- my ($modified,$queued);
+ my ($modified,$queued,$coursedesc,$token,%customitems);
+ unless ($disposition eq 'rejected') {
+ my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$env{'user.name'},
+ $env{'user.domain'},$fullname,$coursedesc);
+ if (ref($inprocess) eq 'HASH') {
+ if (ref($inprocess->{'formitems'}) eq 'HASH') {
+ foreach my $key (keys(%{$inprocess->{'formitems'}})) {
+ if ($inprocess->{'formitems'}->{$key} eq 'multiple') {
+ if (exists($env{'form.'.$key})) {
+ @{$customitems{$key}} = &Apache::loncommon::get_env_multiple($env{'form.'.$key});
+ }
+ } else {
+ if (exists($env{'form.'.$key})) {
+ $customitems{$key} = $env{'form.'.$key};
+ $reqhash{'custom'}{$key} = $customitems{$key};
+ }
+ }
+ }
+ }
+ }
+ }
if ($disposition eq 'rejected') {
if ($crstype eq 'community') {
$output = &mt('Your community request was rejected.');
@@ -2853,7 +3708,7 @@ sub print_request_outcome {
$storeresult = 'rejected';
} elsif ($disposition eq 'process') {
my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
- my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles);
+ my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles,$code);
my $type = 'Course';
if ($crstype eq 'community') {
$type = 'Community';
@@ -2862,9 +3717,10 @@ sub print_request_outcome {
foreach my $role (@roles) {
$longroles{$role}=&Apache::lonnet::plaintext($role,$type);
}
- my $result = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
- 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
- \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles);
+ my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
+ 'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
+ \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
+ \$code,\%customitems);
if ($result eq 'created') {
$disposition = 'created';
$reqstatus = 'created';
@@ -2875,6 +3731,22 @@ sub print_request_outcome {
} else {
$output = ''.&mt('Your course request has been processed and the course has been created.');
}
+ if (($code) || ((ref($postprocess) eq 'HASH') &&
+ (($postprocess->{'createdweb'}) || ($postprocess->{'createdmsg'})))) {
+ $output .= ¬ification_information($disposition,$env{'user.name'}.':'.$env{'user.domain'},
+ $dom,$cnum,$now,$code,$postprocess);
+ }
+ if ($code) {
+ $reqhash{'code'} = $code;
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdactions'}) eq 'HASH') {
+ if (ref($postprocess->{'createdactions'}{'environment'}) eq 'HASH') {
+ &Apache::loncoursequeueadmin::postprocess_crsenv($dom,$cnum,
+ $postprocess->{'createdactions'}{'environment'});
+ }
+ }
+ }
$output .= ' '.$role_result.' ';
$creationresult = 'created';
} else {
@@ -2891,15 +3763,19 @@ sub print_request_outcome {
}
} else {
my $requestid = $cnum.'_'.$disposition;
- my $request = {
+ my $request = {
$requestid => {
timestamp => $now,
crstype => $crstype,
ownername => $env{'user.name'},
ownerdom => $env{'user.domain'},
- description => $env{'form.cdescr'},
+ description => $env{'form.cdescr'},
+ lonhost => $lonhost,
},
};
+ if ($crstype eq 'official') {
+ $request->{$requestid}->{'instcode'} = $instcode;
+ }
my $statuskey = 'status:'.$dom.':'.$cnum;
my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
$env{'user.domain'},$env{'user.name'});
@@ -2912,9 +3788,19 @@ sub print_request_outcome {
if (($queuehash{$cnum.'_approval'} ne '') ||
($queuehash{$cnum.'_pending'} ne '')) {
$queued = 1;
+ if (ref($queuehash{$cnum.'_pending'}) eq 'HASH') {
+ $token = $queuehash{$cnum.'_pending'}{'token'};
+ }
}
}
unless ($queued) {
+ if (($disposition eq 'pending') && ($crstype ne 'official')) {
+ my %reqinfo = (
+ $cnum.':'.$dom => $now.':'.$env{'user.name'}.':'.$env{'user.domain'},
+ );
+ $token = &Apache::lonnet::tmpput(\%reqinfo,$lonhost);
+ $request->{$requestid}->{'token'} = $token;
+ }
my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,
$dom);
if ($putresult eq 'ok') {
@@ -2923,9 +3809,11 @@ sub print_request_outcome {
} else {
$output .= &mt('Your course request has been recorded.')
}
- $output .= ' '.
- ¬ification_information($disposition,$req_notifylist,
- $cnum,$now);
+ unless ($disposition eq 'pending') {
+ $output .= ' '.
+ ¬ification_information($disposition,$req_notifylist,
+ $dom,$cnum,$now);
+ }
} else {
$reqstatus = 'domainerror';
$reqhash{'disposition'} = $disposition;
@@ -2934,36 +3822,55 @@ sub print_request_outcome {
}
}
}
- my ($statusresult);
- if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- $storeresult = &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
- 'courserequests');
- if ($storeresult eq 'ok') {
- my %status = (
- 'status:'.$dom.':'.$cnum => $reqstatus,
- );
- $statusresult = &Apache::lonnet::put('courserequests',\%status);
+ ($storeresult,my $updateresult) =
+ &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
+ $cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'});
+ if ($storeresult eq 'ok') {
+ my $postprocess;
+ if (($disposition eq 'approval') || ($disposition eq 'pending')) {
+ my $updateaction = $disposition;
+ if ($disposition eq 'approval') {
+ $updateaction = 'queued';
+ }
+ my $fullname = &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'});
+ $postprocess =
+ &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$updateaction,$env{'user.name'},
+ $env{'user.domain'},$fullname,$env{'form.cdescr'});
}
- } else {
- $storeresult = 'error: invalid requestkey format';
- }
- if ($storeresult ne 'ok') {
- $output .= ''.&mt('An error occurred saving a record of the details of your request: [_1].',$storeresult).' ';
- &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
- } elsif ($statusresult ne 'ok') {
- $output .= ''.&mt('An error occurred saving a record of the status of your request: [_1].',$statusresult).' ';
- &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
- }
- if ($modified && $queued && $storeresult eq 'ok') {
- if ($crstype eq 'community') {
- $output .= ''.&mt('Your community request has been updated').' ';
- } else {
- $output .= ''.&mt('Your course request has been updated').' ';
+ if ($modified && $queued) {
+ if ($crstype eq 'community') {
+ $output .= ''.&mt('Your community request has been updated').' ';
+ } else {
+ $output .= ''.&mt('Your course request has been updated').' ';
+ }
+ if ($disposition eq 'approval') {
+ $output .= ¬ification_information($disposition,$req_notifylist,$dom,$cnum,$now);
+ }
+ }
+ if ($disposition eq 'approval') {
+ if ((ref($postprocess) eq 'HASH') &&
+ ((ref($postprocess->{'queuedmsg'}) eq 'HASH') || ($postprocess->{'queuedweb'}))) {
+ ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
+ }
+ } elsif ($disposition eq 'pending') {
+ my $pendingform;
+ if ($crstype ne 'official') {
+ $pendingform = &pending_validation_form($dom,$cnum,$crstype,$now,$token,
+ $lonhost,$env{'form.cdescr'});
+ }
+ if ($pendingform) {
+ $output .= $pendingform;
+ } else {
+ $output .= ¬ification_information($disposition,undef,$dom,$cnum,$now,undef,$postprocess);
+ }
}
- $output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now);
}
if ($validationerror ne '') {
- $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'';
+ $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).' ';
+ }
+ if ($updateresult) {
+ $output .= $updateresult;
}
}
if ($creationresult ne '') {
@@ -3109,7 +4016,7 @@ sub update_requestors_roles {
}
sub notification_information {
- my ($disposition,$req_notifylist,$cnum,$now) = @_;
+ my ($disposition,$req_notifylist,$dom,$cnum,$now,$code,$postprocess) = @_;
my %emails = &Apache::loncommon::getemails();
my $address;
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
@@ -3127,20 +4034,144 @@ sub notification_information {
}
if ($req_notifylist) {
my $fullname = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'});
+ $env{'user.domain'});
my $sender = $env{'user.name'}.':'.$env{'user.domain'};
- &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);
+ &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",
+ 'undef',$env{'form.cdescr'},$now,'coursereq',$sender);
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'queuedmsg'}) eq 'ARRAY') {
+ if (scalar(@{$postprocess->{'queuedmsg'}}) > 0) {
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ my $addmsg = [];
+ foreach my $item (@{$postprocess->{'queuedmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,undef,
+ $env{'form.cdescr'},$now,
+ 'queuedcrsreq',$sender);
+ }
+ }
+ }
+ if ($postprocess->{'queuedweb'}) {
+ $output .= $postprocess->{'queuedweb'};
+ }
}
} elsif ($disposition eq 'pending') {
- $output .= ''.
+ my $pending_default = ' '.
&mt('Your request has been placed in a queue pending administrative action.').' '.
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").' '.
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
- ' ';
+ ' ';
+ if (ref($postprocess) eq 'HASH') {
+ if ($postprocess->{'pendingweb'}) {
+ $output .= $postprocess->{'pendingweb'};
+ } else {
+ $output .= $pending_default;
+ }
+ } else {
+ $output .= $pending_default;
+ }
+ } elsif ($disposition eq 'created') {
+ if (($code) || ((ref($postprocess) eq 'HASH') &&
+ ((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) {
+ my $addmsg = [];
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ if ($code) {
+ push(@{$addmsg},{
+ mt => 'Students can automatically select your course: "[_1]" by entering this code: [_2]',
+ args => [$env{'form.cdescr'},$code],
+ });
+ $output .= ''.
+ &mt('Students can automatically select your course by entering this code: [_1].',''.$code.'').
+ ' '.
+ &mt('A message has been sent to your LON-CAPA account with this information.');
+ if ($address ne '') {
+ $output.= ' '.&mt('An e-mail has also been sent to: [_1] with this code.',$address);
+ }
+ $output .= ' ';
+ }
+ 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(@{$addmsg},$item);
+ }
+ }
+ }
+ }
+ if ($postprocess->{'createdweb'}) {
+ $output .= $postprocess->{'createdweb'}
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ my $type = 'createdcrsreq';
+ if ($code) {
+ $type = 'uniquecode';
+ }
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,$dom.'_'.$cnum,$env{'form.cdescr'},
+ $now,$type,$sender);
+ }
+ }
} else {
$output .= ''.
- &mt('Your request status is: [_1].',$disposition).
- ' '
+ &mt('Your request status is: [_1].',$disposition).
+ '';
+ }
+ return $output;
+}
+
+sub pending_validation_form {
+ my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
+ my $output;
+ my %postvalues = (
+ 'owner' => $env{'user.name'}.':'.$env{'user.domain'},
+ 'course' => $cdom.'_'.$cnum,
+ 'coursetype' => $crstype,
+ );
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
+
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ my ($url,$buttontext,$code,@fields);
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ $postvalues{'description'} = $cdesc;
+ $url = $domconfig{'requestcourses'}{'validation'}{'url'};
+ if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') {
+ @fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}};
+ }
+ $buttontext = $domconfig{'requestcourses'}{'validation'}{'button'};
+ $output .= $domconfig{'requestcourses'}{'validation'}{'markup'};
+ if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
+ $output .= ''."\n";
+ }
+ }
}
return $output;
}
@@ -3159,7 +4190,7 @@ sub check_autolimit {
if (($crstype eq 'community') &&
(exists($crsroles{$cnum.':'.$cdom.':co'}))) {
$count ++;
- } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) &&
+ } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) &&
(exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
$count ++;
}
@@ -3205,18 +4236,31 @@ sub retrieve_settings {
}
$env{'form.clonecrs'} = $reqinfo{'clonecrs'};
$env{'form.clonedom'} = $reqinfo{'clonedom'};
+ if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
+ $env{'form.cloning'} = 1;
+ }
$env{'form.datemode'} = $reqinfo{'datemode'};
$env{'form.dateshift'} = $reqinfo{'dateshift'};
- if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {
- $env{'form.sectotal'} = $reqinfo{'sectotal'};
- $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
- $env{'form.autoadds'} = $reqinfo{'autoadds'};
- $env{'form.autdrops'} = $reqinfo{'autodrops'};
- $env{'form.instcode'} = $reqinfo{'instcode'};
- my $crscode = {
- $cnum => $reqinfo{'instcode'},
- };
- &extract_instcode($dom,'instcode',$crscode,$cnum);
+ if ($reqinfo{'crstype'} eq 'official') {
+ $env{'form.autoadds'} = $reqinfo{'autoadds'};
+ $env{'form.autodrops'} = $reqinfo{'autodrops'};
+ if ($reqinfo{'instcode'} ne '') {
+ $env{'form.sectotal'} = $reqinfo{'sectotal'};
+ $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
+ $env{'form.instcode'} = $reqinfo{'instcode'};
+ my $crscode = {
+ $cnum => $reqinfo{'instcode'},
+ };
+ &extract_instcode($dom,'instcode',$crscode,$cnum);
+ (undef,undef,my $instcredits) =
+ &Apache::lonnet::auto_validate_instcode(undef,$dom,
+ $reqinfo{'instcode'});
+ if ($instcredits ne $reqinfo{'defaultcredits'}) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
+ }
+ }
+ } elsif (($reqinfo{'crstype'} eq 'unofficial') || ($reqinfo{'crstype'} eq 'textbook')) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
@@ -3347,5 +4391,547 @@ sub generate_date_items {
return;
}
+sub print_textbook_form {
+ my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_;
+ my ($bookshash,%ordered);
+ my $crstype = 'textbook';
+#
+# Retrieve list of textbook courses cloneable by user
+#
+ my $numbook = 0;
+ if (ref($settings) eq 'HASH') {
+ $bookshash = $settings->{'textbooks'};
+ if (ref($bookshash) eq 'HASH') {
+ foreach my $item (keys(%{$bookshash})) {
+ my ($clonedom,$clonecrs) = split(/_/,$item);
+ if (ref($bookshash->{$item}) eq 'HASH') {
+ my ($clonedom,$clonecrs) = split(/_/,$item);
+ if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
+ $env{'user.domain'},$clonecrs,$clonedom,$crstype)) {
+
+ my $num = $bookshash->{$item}{'order'};
+ $ordered{$num} = $item;
+ $numbook ++;
+ }
+ }
+ }
+ }
+ }
+
+#
+# Check if domain has multiple library servers
+#
+ my ($home_server_pick,$numlib) =
+ &Apache::loncommon::home_server_form_item($dom,'chome',
+ 'default','hide');
+ if ($numlib > 1) {
+ $home_server_pick = &mt('Home Server for Course').': '.$home_server_pick.' ';
+ }
+
+#
+# Retrieve information about courses owned by user, or in which user has an active or future
+# Course Coordinator role
+#
+ my $numcurrent;
+ my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'},
+ undef,undef,undef,'Course');
+ my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
+ ['active','future'],['cc']);
+ foreach my $role (keys(%ccroles)) {
+ my ($cnum,$cdom,$rest) = split(/:/,$role,3);
+ unless (exists($cloneable{$cdom.'_'.$cnum})) {
+ my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1});
+ $cloneable{$cdom.'_'.$cnum} = \%courseinfo;
+ }
+ }
+
+ my $numcurrent = scalar(keys(%cloneable));
+
+ my $jscript = &textbook_request_javascript($numbook,$numcurrent);
+ my %loaditems;
+ $loaditems{'onload'} = 'javascript:uncheckAllRadio();';
+ $r->print(&header('Course Request',$jscript,\%loaditems));
+
+ if (ref($can_request) eq 'HASH') {
+ unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+
+ &startContentScreen($r,'textbookrequests');
+#
+# Show domain selector form, if required.
+#
+ if (@{$incdoms} > 1) {
+ my $onchange = 'this.form.submit()';
+ $r->print(' |