--- loncom/interface/loncreateuser.pm 2014/03/31 02:31:05 1.398 +++ loncom/interface/loncreateuser.pm 2016/09/27 21:47:48 1.413 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.398 2014/03/31 02:31:05 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.413 2016/09/27 21:47:48 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 = + my ($userpicker,$cansearch) = &Apache::loncommon::user_picker($dom,$srch,$forcenewuser, 'document.crtuser',$cancreate,$usertype); my $srchbutton = &mt('Search'); @@ -822,7 +827,9 @@ sub entry_form { } elsif ($cancreate && $responsemsg ne '' && $inexact) { $srchbutton = &mt('Search or Add New User'); } - my $output = <<"ENDBLOCK"; + my $output; + if ($cansearch) { + $output = <<"ENDBLOCK";
@@ -830,6 +837,9 @@ $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'); @@ -2244,8 +2254,8 @@ sub personal_data_display { ''; $rowcount ++; $output .= &Apache::lonhtmlcommon::row_closure(1); - my $upassone = ''; - my $upasstwo = ''; + my $upassone = ''; + my $upasstwo = ''; $output .= &Apache::lonhtmlcommon::row_title(&mt('Password').'*', 'LC_pick_box_title', 'LC_oddrow_value')."\n". @@ -2282,19 +2292,15 @@ sub personal_data_display { } } else { if ($context eq 'selfcreate') { - if (($item eq 'permanentemail') && ($newuser eq 'email')) { - $row .= $ccuname; - } else { - if ($canmodify{$item}) { - if ($newuser eq 'email') { - $row .= ''; - } else { - $row .= ''; - } - $editable ++; + if ($canmodify{$item}) { + if ($newuser eq 'email') { + $row .= ''; } else { - $hiderow = 1; + $row .= ''; } + $editable ++; + } else { + $hiderow = 1; } } else { $row .= ''; @@ -2355,7 +2361,7 @@ sub personal_data_display { } if (($context eq 'selfcreate') && ($newuser eq 'email')) { if ($captchaform) { - $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}, + $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}.'*', 'LC_pick_box_title')."\n". $captchaform."\n".'

'. &Apache::lonhtmlcommon::row_closure(1); @@ -2583,7 +2589,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'}); @@ -2756,7 +2762,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) { @@ -3047,8 +3053,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')) { + 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}) { @@ -3114,7 +3121,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 = @@ -3156,9 +3163,9 @@ sub update_user_data { $rolestr = &mt('No roles'); } if ($context eq 'course') { - $contextname = &mt('course'); + $contextname = 'course'; } elsif ($context eq 'author') { - $contextname = &mt('co-author'); + $contextname = 'co-author'; } $r->print(&mt('The following fields were not updated: ').''); if (@mod_disallowed == 1) { - $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname)); + $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future $contextname roles:")); } else { - $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname)); + $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future $contextname roles:")); } my $helplink = 'javascript:helpMenu('."'display'".')'; $r->print(''.$rolestr.'
' @@ -3257,6 +3264,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:', @@ -3629,7 +3637,7 @@ sub update_roles { my @rolechanges; my %disallowed; $r->print('

'.&mt('Modifying Roles').'

'); - foreach my $key (keys (%env)) { + foreach my $key (keys(%env)) { next if (! $env{$key}); next if ($key eq 'form.action'); # Revoke roles @@ -3811,7 +3819,7 @@ sub update_roles { } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { if (($sec eq 'none') || ($sec eq 'all') || exists($curr_groups{$sec})) { $disallowed{$sec} = $url; @@ -3857,7 +3865,7 @@ sub update_roles { my %curr_groups = &Apache::longroup::coursegroups($one,$two); my $emptysec = 0; - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { $sec =~ s/\W//g; if ($sec ne '') { if (($sec eq 'none') || ($sec eq 'all') || @@ -3897,7 +3905,7 @@ sub update_roles { $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); } else { my $emptysec = 0; - foreach my $sec (sort {$a cmp $b} keys %sections) { + foreach my $sec (sort {$a cmp $b} keys(%sections)) { if ($sec ne '') { my $securl = $url.'/'.$sec; $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context)); @@ -4993,6 +5001,7 @@ sub handler { selfenroll_end_access => $env{'course.'.$cid.'.internal.selfenroll_end_access'}, default_enrollment_start_date => $env{'course.'.$cid.'.default_enrollment_start_date'}, default_enrollment_end_date => $env{'course.'.$cid.'.default_enrollment_end_date'}, + uniquecode => $env{'course.'.$cid.'.internal.uniquecode'}, ); push(@{$brcrum}, {href => '/adm/createuser?action=selfenroll', @@ -5012,7 +5021,7 @@ sub handler { bread_crumbs_component => 'Self-enrollment result'}; $r->print(&header(undef,$args)); $r->print('

'.&mt('Self-enrollment with a student role').'

'."\n"); - &update_selfenroll_config($r,$cid,$cdom,$cnum,\%currsettings); + &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings); } } else { $r->print(&header(undef,{'no_nav_bar' => 1}). @@ -5403,6 +5412,7 @@ sub print_main_menu { groups => 'Community Groups', }, ); + $linktext{'Placement'} = $linktext{'Course'}; my %linktitle = ( 'Course' => { @@ -5417,6 +5427,8 @@ sub print_main_menu { }, ); + $linktitle{'Placement'} = $linktitle{'Course'}; + push(@{ $menu[0]->{items} }, #Category: Single Users { linktext => $linktext{$crstype}{'single'}, @@ -5547,6 +5559,7 @@ sub print_selfenroll_menu { butn => 'but no user types have been checked.', wilf => "Please uncheck 'activate' or check at least one type.", ); + &js_escape(\%alerts); my $selfenroll_js = <<"ENDSCRIPT"; function update_types(caller,num) { var delidx = getIndexByName('selfenroll_delete'); @@ -5740,28 +5753,70 @@ ENDSCRIPT '// ]]>'."\n". ''."\n". '

'.$lt->{'selfenroll'}.'

'."\n"; - my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum); - if (ref($visactions) eq 'HASH') { - if ($visible) { - $output .= '

'.$visactions->{'vis'}.'

'; - } else { - $output .= '

'.$visactions->{'miss'}.'

' - .$visactions->{'yous'}. - '

'.$visactions->{'gen'}.'
'.$visactions->{'coca'}; - if (ref($vismsgs) eq 'ARRAY') { - $output .= '
'.$visactions->{'make'}.'

'; + $output .= '

'; } - $output .= '

'; } } my $actionhref = '/adm/createuser'; if ($context eq 'domain') { $actionhref = '/adm/modifycourse'; } + + my %noedit; + unless ($context eq 'domain') { + %noedit = &get_noedit_fields($cdom,$cnum,$crstype,$row); + } $output .= '
'."\n". &Apache::lonhtmlcommon::start_pick_box(); if (ref($row) eq 'ARRAY') { @@ -5776,6 +5831,37 @@ ENDSCRIPT if (ref($currsettings) eq 'HASH') { $curr_types = $currsettings->{'selfenroll_types'}; } + if ($noedit{$item}) { + if ($curr_types eq '*') { + $output .= &mt('Any user in any domain'); + } else { + my @entries = split(/;/,$curr_types); + if (@entries > 0) { + $output .= ''; + } else { + $output .= &mt('None'); + } + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $showdomdesc = 1; my $includeempty = 1; my $num = 0; @@ -5844,6 +5930,15 @@ ENDSCRIPT if (ref($currsettings) eq 'HASH') { $registered = $currsettings->{'selfenroll_registered'}; } + if ($noedit{$item}) { + if ($registered) { + $output .= &mt('Must be registered in course'); + } else { + $output .= &mt('No requirement'); + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } if ($registered) { $regon = ' checked="checked" '; $regoff = ' '; @@ -5868,6 +5963,12 @@ ENDSCRIPT $endtime = $currsettings->{'default_enrollment_end_date'}; } } + if ($noedit{$item}) { + $output .= &mt('From: [_1], to: [_2]',&Apache::lonlocal::locallocaltime($starttime), + &Apache::lonlocal::locallocaltime($endtime)); + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $startform = &Apache::lonhtmlcommon::date_setter($formname,'selfenroll_start_date',$starttime, undef,undef,undef,undef,undef,undef,undef,$nolink); @@ -5887,6 +5988,12 @@ ENDSCRIPT $endtime = $currsettings->{'default_enrollment_end_date'}; } } + if ($noedit{$item}) { + $output .= &mt('From: [_1], to: [_2]',&Apache::lonlocal::locallocaltime($starttime), + &Apache::lonlocal::locallocaltime($endtime)); + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $startform = &Apache::lonhtmlcommon::date_setter($formname,'selfenroll_start_access',$starttime, undef,undef,undef,undef,undef,undef,undef,$nolink); @@ -5906,6 +6013,15 @@ ENDSCRIPT $newsecval = $currsec; } } + if ($noedit{$item}) { + if ($currsec ne '') { + $output .= $currsec; + } else { + $output .= &mt('No specific section'); + } + $output .= '
'.&mt('(Set by Domain Coordinator)'); + next; + } my $sections_select = &Apache::lonuserutils::course_sections(\%sections_count,'st',$currsec); $output .= ''."\n". @@ -5915,7 +6031,6 @@ ENDSCRIPT &mt('New section').'
'."\n". ''."\n". ''."\n". - ''."\n". '
'."\n"; } elsif ($item eq 'approval') { my ($currnotified,$currapproval,%appchecked); @@ -5927,6 +6042,11 @@ ENDSCRIPT if ($currapproval !~ /^[012]$/) { $currapproval = 0; } + if ($noedit{$item}) { + $output .= $selfdescs{'approval'}{$currapproval}. + '
'.&mt('(Set by Domain Coordinator)'); + next; + } $appchecked{$currapproval} = ' checked="checked"'; for my $i (0..2) { $output .= '