--- loncom/interface/loncreateuser.pm 2016/10/22 15:53:55 1.406.2.4 +++ loncom/interface/loncreateuser.pm 2016/04/02 04:30:20 1.411 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.406.2.4 2016/10/22 15:53:55 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.411 2016/04/02 04:30:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -251,13 +251,15 @@ sub build_tools_display { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', 'requestauthor' => 'Can request author space', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community','requestcourses.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'requestcourses.community','requestcourses.textbook', + 'requestcourses.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -447,12 +449,14 @@ sub coursereq_externaluser { 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', 'textbook' => 'Can request creation of textbook courses', + 'placement' => 'Can request creation of placement tests', ); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'reqcrsotherdom.official','reqcrsotherdom.unofficial', - 'reqcrsotherdom.community','reqcrsotherdom.textbook'); - @usertools = ('official','unofficial','community','textbook'); + 'reqcrsotherdom.community','reqcrsotherdom.textbook', + 'reqcrsotherdom.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options = ('approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($cdom); my $optregex = join('|',@options); @@ -533,6 +537,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', + placement => 'Placement Tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -813,7 +818,7 @@ sub entry_form { } my $cancreate = &Apache::lonuserutils::can_create_user($dom,$context,$usertype); - my ($userpicker,$cansearch) = + my $userpicker = &Apache::loncommon::user_picker($dom,$srch,$forcenewuser, 'document.crtuser',$cancreate,$usertype); my $srchbutton = &mt('Search'); @@ -822,9 +827,7 @@ sub entry_form { } elsif ($cancreate && $responsemsg ne '' && $inexact) { $srchbutton = &mt('Search or Add New User'); } - my $output; - if ($cansearch) { - $output = <<"ENDBLOCK"; + my $output = <<"ENDBLOCK";
@@ -832,9 +835,6 @@ $userpicker
ENDBLOCK - } else { - $output = '

'.$userpicker.'

'; - } if ($env{'form.phase'} eq '') { my $defdom=$env{'request.role.domain'}; my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); @@ -2584,7 +2584,7 @@ sub update_user_data { my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); my @usertools = ('aboutme','blog','webdav','portfolio'); - my @requestcourses = ('official','unofficial','community','textbook'); + my @requestcourses = ('official','unofficial','community','textbook','placement'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2757,7 +2757,7 @@ sub update_user_data { 'requestcourses.community','requestcourses.textbook', 'reqcrsotherdom.official','reqcrsotherdom.unofficial', 'reqcrsotherdom.community','reqcrsotherdom.textbook', - 'requestauthor'], + 'reqcrsotherdom.placement','requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -3048,8 +3048,9 @@ sub update_user_data { ($env{'user.domain'} eq $env{'form.ccdomain'})) { my %newenvhash; foreach my $key (keys(%changed)) { - if (($key eq 'official') || ($key eq 'unofficial') - || ($key eq 'community') || ($key eq 'textbook')) { + if (($key eq 'official') || ($key eq 'unofficial') || + ($key eq 'community') || ($key eq 'textbook') || + ($key eq 'placement')) { $newenvhash{'environment.requestcourses.'.$key} = $changeHash{'requestcourses.'.$key}; if ($changeHash{'requestcourses.'.$key}) { @@ -3115,7 +3116,7 @@ sub update_user_data { \%newsettingstext); if ($env{'form.cid'} ne $userenv{'id'}) { &Apache::lonnet::idput($env{'form.ccdomain'}, - ($env{'form.ccuname'} => $env{'form.cid'})); + {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids'); if (($recurseid) && (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { my $idresult = @@ -3258,6 +3259,7 @@ sub display_userinfo { 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', 'textbook' => 'Can Request Textbook Courses', + 'placement' => 'Can Request Placement Tests', 'requestauthor' => 'Can Request Author Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', @@ -5405,6 +5407,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5419,6 +5422,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -6828,29 +6833,13 @@ sub user_search_result { } } if ($response ne '') { - $response = ''.$response.'
'; + $response = ''.$response.''; } if ($srch->{'srchin'} eq 'instd') { - my $instd_chk = &instdirectorysrch_check($srch); + my $instd_chk = &directorysrch_check($srch); if ($instd_chk ne 'ok') { - my $domd_chk = &domdirectorysrch_check($srch); - $response .= ''.$instd_chk.'
'; - if ($domd_chk eq 'ok') { - $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.'); - } - $response .= '

'; - } - } else { - unless (($context eq 'requestcrs') && ($srch->{'srchtype'} eq 'exact')) { - my $domd_chk = &domdirectorysrch_check($srch); - if ($domd_chk ne 'ok') { - my $instd_chk = &instdirectorysrch_check($srch); - $response .= ''.$domd_chk.'
'; - if ($instd_chk eq 'ok') { - $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.'); - } - $response .= '

'; - } + $response = ''.$instd_chk.''. + '
'.&mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').'

'; } } if ($response ne '') { @@ -7025,26 +7014,7 @@ sub user_search_result { return ($currstate,$response,$forcenewuser,\%srch_results); } -sub domdirectorysrch_check { - my ($srch) = @_; - my $response; - my %dom_inst_srch = &Apache::lonnet::get_dom('configuration', - ['directorysrch'],$srch->{'srchdomain'}); - my $showdom = &display_domain_info($srch->{'srchdomain'}); - if (ref($dom_inst_srch{'directorysrch'}) eq 'HASH') { - if ($dom_inst_srch{'directorysrch'}{'lcavailable'} eq '0') { - return &mt('LON-CAPA directory search is not available in domain: [_1]',$showdom); - } - if ($dom_inst_srch{'directorysrch'}{'lclocalonly'}) { - if ($env{'request.role.domain'} ne $srch->{'srchdomain'}) { - return &mt('LON-CAPA directory search in domain: [_1] is only allowed for users with a current role in the domain.',$showdom); - } - } - } - return 'ok'; -} - -sub instdirectorysrch_check { +sub directorysrch_check { my ($srch) = @_; my $can_search = 0; my $response;