--- loncom/interface/lonpickcourse.pm 2017/01/03 17:47:57 1.124 +++ loncom/interface/lonpickcourse.pm 2017/01/05 16:17:11 1.125 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.124 2017/01/03 17:47:57 raeburn Exp $ +# $Id: lonpickcourse.pm,v 1.125 2017/01/05 16:17:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,7 +44,7 @@ sub handler { if ($env{'form.context'} eq 'adhoc') { &Apache::loncommon::content_type($r,'application/json'); $r->send_http_header; - my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.cid'}); + my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.cid'},1); if ((ref($possroles) eq 'ARRAY') && (ref($description) eq 'HASH')) { my $response = []; if (@{$possroles}) { @@ -440,7 +440,7 @@ sub display_matched_courses { $action = '/adm/portfolio'; } my $numcourses = keys(%courses); - $r->print('
'); + $r->print(''); if ($env{'form.form'} eq 'modifycourse') { if ($numcourses > 0) { my $ccrole = 'cc'; @@ -469,39 +469,36 @@ sub display_matched_courses { $r->print(&mt('Enter the course with the role of [_1].',$cctitle)); } } elsif (&Apache::lonnet::allowed('rar',$crsdom)) { - my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'}, - 'adhocroles.'.$crsdom); - if ($adhocroles{'adhocroles.'.$crsdom} ne '') { - $possrole = 1; - $r->print($roleradio); - my @adhoc = split(/,/,$adhocroles{'adhocroles.'.$crsdom}); - if (@adhoc > 1) { - my %adhochash; - map { $adhochash{$_} = $_; } @adhoc; - my $selector = &Apache::loncommon::select_form($adhoc[0],'adhocrole',\%adhochash); + my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($crsdom); + if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) { + if (@{$roles_by_num} > 1) { + $r->print($roleradio); if ($type eq 'Community') { - $r->print(&mt('Enter the community with one of the available ad hoc roles: [_1].', - $selector)); + $r->print(&mt('Enter the community with one of the available ad hoc roles.')); } elsif ($type eq 'Placement') { - $r->print(&mt('Enter the placement test with one of the available ad hoc roles: [_1].', - $selector)); + $r->print(&mt('Enter the placement test with one of the available ad hoc roles.')); } else { - $r->print(&mt('Enter the course with one of the available ad hoc roles: [_1].', - $selector)); + $r->print(&mt('Enter the course with one of the available ad hoc roles.')); } - } else { + $possrole = 1; + } elsif (@{$roles_by_num} == 1) { + $r->print($roleradio); + my $rolename = $description->{$roles_by_num->[0]}; if ($type eq 'Community') { - $r->print(&mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0])); + $r->print(&mt('Enter the community with the ad hoc role of: [_1]',$rolename)); } elsif ($type eq 'Placement') { - $r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0])); + $r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$rolename)); } else { - $r->print(&mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0])); + $r->print(&mt('Enter the course with the ad hoc role of: [_1]',$rolename)); } - $r->print(''); + $possrole = 1; + } + if ($possrole) { + $r->print(''); } } } - if ($possrole) { + if ($possrole) { $r->print('
'); } $r->print('