';
if ($context eq 'crosslist') {
$output .= ''.&mt('Include?').' '.
@@ -2753,6 +2986,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 '') {
@@ -2845,7 +3098,7 @@ sub display_navbuttons {
}
sub print_request_outcome {
- my ($r,$dom,$codetitles,$code_order) = @_;
+ my ($dom,$codetitles,$code_order) = @_;
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
%sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
my $sectotal = $env{'form.sectotal'};
@@ -2882,6 +3135,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'} = '';
+ }
}
}
}
@@ -2907,6 +3164,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'};
@@ -2918,6 +3176,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 '') {
@@ -2963,6 +3271,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'}) {
@@ -2970,10 +3283,7 @@ 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'})) {
@@ -2981,16 +3291,12 @@ sub print_request_outcome {
}
my $clonecrs = '';
my $clonedom = '';
- if ((($env{'form.cloning'}) ||
- (($dom eq 'gcitest') && ($env{'form.concepttest'} eq 'cloning'))) &&
+ if (($env{'form.cloning'}) &&
($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
($env{'form.clonedom'} =~ /^($match_domain)$/)) {
- if ($dom eq 'gcitest') {
- $env{'form.clonedom'} = 'gcitest';
- }
my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
$env{'form.clonedom'});
- if ($clonehome ne 'no_host') {
+ if ($clonehome ne 'no_host') {
my $canclone =
&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
$env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
@@ -3026,27 +3332,10 @@ sub print_request_outcome {
accessend => $accessend,
personnel => \%personnel,
};
- if ($dom eq 'gcitest') {
- if ($env{'form.concepttest'} eq 'editmyown') {
- $details->{'firstres'} = 'nav';
- } else {
- $details->{'firstres'} = 'blank';
- }
- if ($env{'form.concepttest'} eq 'cloning') {
- if (($clonecrs) && ($clonedom eq 'gcitest')) {
- $details->{'cloneroster'} = $env{'form.cloneroster'};
- } else {
- $details->{'clonedom'} = 'gci';
- $details->{'clonecrs'} = '8v226795a882b4bcagcil1';
- }
- } else {
- $details->{'clonedom'} = 'gci';
- $details->{'clonecrs'} = '8v226795a882b4bcagcil1';
- }
- $details->{'datemode'} = 'delete';
- }
my (@inststatuses,$storeresult,$creationresult);
- my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
+ my $val =
+ &Apache::loncoursequeueadmin::get_processtype($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.');
@@ -3137,71 +3426,7 @@ sub print_request_outcome {
} else {
$output = ''.&mt('Your course request has been processed and the course has been created.');
}
- if ($dom eq 'gcitest') {
- my $caller = 'requestcrs';
- &acquire_cc_role($dom,$cnum,'cc./'.$dom.'/'.$cnum);
- my %parmresult =
- &store_crsparms($dom,$cnum,$now,$accessstart,$accessend);
- &Apache::londocsgci::setdefaults();
- my %crsenvhash = (
- suppress_tries => 'yes',
- );
- my $putresult = &Apache::lonnet::put('environment',\%crsenvhash,$dom,$cnum);
- if ($env{'form.concepttest'} eq 'cloning') {
- &Apache::lonuserstate::readmap($dom.'/'.$cnum);
- if (($clonecrs) && ($clonedom eq 'gcitest')) {
- my $cloneid = $clonedom.'/'.$clonecrs;
- my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
- my $oldcdesc = $clonedesc{'description'};
- $output .= ' '.&mt('A concept test has been copied from your existing test: [_1].',''.$oldcdesc.'').' ';
- if ($env{'form.cloneroster'}) {
- $output .= ' '.&mt('You requested copying of the old student roster to the new course.');
- if ($logmsg =~ /\Q\0\E/) {
- my @logging = split("\0",$logmsg);
- if (@logging) {
- $output .= ''.$logging[-1].' ';
- }
- }
- $output .= ''.
- '- '.&mt('Access starts:').' '.
- &Apache::lonlocal::locallocaltime($accessstart).'
'.
- '- '.&mt('Access ends:').' '.&Apache::lonlocal::locallocaltime($accessend).'
'.
- ' '.
- ''.&mt('Manage Test').'';
- $r->print($output);
- $output = '';
- } else {
- &roster_upload_form($r,$output);
- $output = '';
- }
- } else {
- $output .= '';
- &roster_upload_form($r,$output);
- $output = '';
- }
- } elsif ($env{'form.concepttest'} eq 'defchosen') {
- $output .= ' ';
- my $error = &Apache::londocsgci::store($caller,$dom,$cnum);
- if ($error) {
- $output .= ''.
- &mt('An error occurred saving an auto-generated concept test: [_1].',$error).
- '';
- } else {
- &Apache::lonuserstate::readmap($dom.'/'.$cnum);
- $output .= &mt('A concept test has also been generated.');
- }
- $output .= '';
- &roster_upload_form($r,$output);
- $output = '';
- } else {
- $output .= ' '.&mt('The next step is to chose which questions are to be included in the Concept Test.').'';
- $r->print($output);
- &Apache::londocsgci::editor($r,'requestcrs',$dom,$cnum);
- $output = '';
- }
- } else {
- $output .= ' '.$role_result.'';
- }
+ $output .= ' '.$role_result.'';
$creationresult = 'created';
} else {
$output = '';
@@ -3226,6 +3451,9 @@ sub print_request_outcome {
description => $env{'form.cdescr'},
},
};
+ 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'});
@@ -3260,26 +3488,9 @@ 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);
- }
- } 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");
- }
+ ($storeresult,my $updateresult) =
+ &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
+ $cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'});
if ($modified && $queued && $storeresult eq 'ok') {
if ($crstype eq 'community') {
$output .= ''.&mt('Your community request has been updated').' ';
@@ -3289,7 +3500,10 @@ sub print_request_outcome {
$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 '') {
@@ -3434,96 +3648,6 @@ sub update_requestors_roles {
return $output;
}
-sub acquire_cc_role {
- my ($cdom,$cnum,$trolecode,$csec) = @_;
- my %coursegroups = &Apache::lonnet::get_active_groups(
- $env{'user.domain'},$env{'user.name'},$cdom, $cnum);
- my $cgrps = join(':',keys(%coursegroups));
- if ($env{'environment.recentroles'}) {
- my %frozen_roles =
- &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
- &Apache::lonhtmlcommon::store_recent('roles',$trolecode,' ',
- $frozen_roles{$trolecode});
- }
-
- &Apache::lonnet::appenv({"request.course.id" => '',
- "request.course.fn" => '',
- "request.course.uri" => '',
- "request.course.sec" => '',
- "request.role" => 'cm',
- "request.role.adv" => $env{'user.adv'},
- "request.role.domain" => $env{'user.domain'}});
-
- &Apache::lonnet::log($env{'user.domain'},
- $env{'user.name'},
- $env{'user.home'},
- "Role ".$trolecode);
-
- &Apache::lonnet::appenv(
- {'request.role' => $trolecode,
- 'request.role.domain' => $cdom,
- 'request.course.sec' => $csec,
- 'request.course.groups' => $cgrps});
- my ($furl,$ferr) = &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
- my $tadv;
- if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
- &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
- return;
-}
-
-sub store_crsparms {
- my ($cdom,$cnum,$now,$accessstart,$accessend) = @_;
- my $topsymb = '___0___uploaded/'.$cdom.'/'.$cnum.'/default.sequence';
- my %crsparms = (
- buttonshide => {
- value => 'yes',
- type => 'string_yesno',
- },
- opendate => {
- value => $accessstart,
- type => 'date_start',
- },
- duedate => {
- value => $accessend,
- type => 'date_end',
- },
- problemstatus => {
- value => 'no',
- type => 'string_problemstatus',
- },
- maxtries => {
- value => '1',
- type => 'intpos',
- },
- discussend => {
- value => $now,
- type => 'date_end',
- },
- discusshide => {
- value => 'yes',
- type => 'string_yesno',
- }
- );
- my %parmresult;
- foreach my $item (keys(%crsparms)) {
- $parmresult{$item} =
- &Apache::lonparmset::storeparm_by_symb($topsymb,
- '0_'.$item,14,$crsparms{$item}{'value'},
- $crsparms{$item}{'type'},undef,$cdom);
- }
- return %parmresult;
-}
-
-sub roster_upload_form {
- my ($r,$output) = @_;
- $r->print(''.&mt('If you have a text file available containing student e-mail addresses and initial passwords, you may upload it now.').' '.
- &mt('You may also enroll students at a later date by visiting the [_1]"Menu"[_2] page and choosing: [_1]"Manage Enrollment"[_2].','','').' '.
- '');
-}
-
sub notification_information {
my ($disposition,$req_notifylist,$cnum,$now) = @_;
my %emails = &Apache::loncommon::getemails();
@@ -3555,100 +3679,12 @@ sub notification_information {
'';
} else {
$output .= ''.
- &mt('Your request status is: [_1].',$disposition).
- ' '
+ &mt('Your request status is: [_1].',$disposition).
+ '';
}
return $output;
}
-sub get_processtype {
- my ($dom,$crstype,$inststatuses,$domconfig) = @_;
- return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
- my (%userenv,%settings,$val);
- my @options = ('autolimit','validate','approval');
- if ($dom eq $env{'user.domain'}) {
- %userenv =
- &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
- 'requestcourses.'.$crstype,'inststatus');
- if ($userenv{'requestcourses.'.$crstype}) {
- $val = $userenv{'requestcourses.'.$crstype};
- @{$inststatuses} = ('_custom_');
- } else {
- my ($task,%alltasks);
- if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
- %settings = %{$domconfig->{'requestcourses'}};
- if (ref($settings{$crstype}) eq 'HASH') {
- if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
- $val = $settings{$crstype}{'_LC_adv'};
- @{$inststatuses} = ('_LC_adv_');
- } else {
- if ($userenv{'inststatus'} ne '') {
- @{$inststatuses} = split(',',$userenv{'inststatus'});
- } else {
- @{$inststatuses} = ('default');
- }
- foreach my $status (@{$inststatuses}) {
- if (exists($settings{$crstype}{$status})) {
- my $value = $settings{$crstype}{$status};
- next unless ($value);
- unless (exists($alltasks{$value})) {
- if (ref($alltasks{$value}) eq 'ARRAY') {
- unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
- push(@{$alltasks{$value}},$status);
- }
- } else {
- @{$alltasks{$value}} = ($status);
- }
- }
- }
- }
- my $maxlimit = 0;
-
- foreach my $key (sort(keys(%alltasks))) {
- if ($key =~ /^autolimit=(\d*)$/) {
- if ($1 eq '') {
- $val ='autolimit=';
- last;
- } elsif ($1 > $maxlimit) {
- $maxlimit = $1;
- }
- }
- }
- if ($maxlimit) {
- $val = 'autolimit='.$maxlimit;
- } else {
- foreach my $option (@options) {
- if ($alltasks{$option}) {
- $val = $option;
- last;
- }
- }
- }
- }
- }
- }
- }
- } else {
- %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},
- $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'});
- if ($userenv{'reqcrsotherdom.'.$crstype}) {
- my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
- my $optregex = join('|',@options);
- foreach my $item (@doms) {
- my ($extdom,$extopt) = split(':',$item);
- if ($extdom eq $dom) {
- if ($extopt =~ /^($optregex)(=?\d*)$/) {
- $val = $1.$2;
- }
- last;
- }
- }
- @{$inststatuses} = ('_external_');
- }
- }
- return $val;
-}
-
sub check_autolimit {
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
@@ -3709,18 +3745,23 @@ 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);
+ }
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
@@ -3851,16 +3892,5 @@ sub generate_date_items {
return;
}
-sub show_cloneable {
- my $showclone;
- if (&Apache::loncommon::needs_gci_custom()) {
- my %courses = &Apache::loncommon::existing_gcitest_courses('cc');
- my $numcourses = scalar(keys(%courses));
- return $numcourses;
- } else {
- return 1;
- }
-}
-
1;
|