--- loncom/interface/lonpickcourse.pm 2005/02/17 08:29:43 1.26 +++ 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.26 2005/02/17 08:29:43 albertel Exp $ +# $Id: lonpickcourse.pm,v 1.125 2017/01/05 16:17:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,233 +31,1177 @@ package Apache::lonpickcourse; use strict; use Apache::Constants qw(:common); use Apache::loncommon; +use Apache::lonhtmlcommon; use Apache::loncoursedata; use Apache::lonnet; use Apache::lonlocal; +use Apache::longroup; +use LONCAPA qw(:DEFAULT :match); +use JSON::DWIW; sub handler { my $r = shift; + 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'},1); + if ((ref($possroles) eq 'ARRAY') && (ref($description) eq 'HASH')) { + my $response = []; + if (@{$possroles}) { + foreach my $role (@{$possroles}) { + push(@{$response}, + { name => $role, + desc => $description->{$role}, + }); + } + } + $r->print(JSON::DWIW->to_json({roles => $response})); + } + return OK; + } &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; - + # ------------------------------------------------------------ Print the screen - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -The LearningOnline Network with CAPA - -ENDDOCUMENT -# Get parameters from query string + + # Get parameters from query string &Apache::loncommon::get_unprocessed_cgi - ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter', - 'sincefilter','form','cnumelement', + ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement', 'cdomelement','cnameelement','roleelement', - 'pickedcourse','instcodefilter','ownerfilter']); -# domain filter and selection - my $domainfilter=$ENV{'form.domainfilter'}; - $domainfilter=~s/\W//g; - unless ($domainfilter) { $domainfilter=''; } - my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter, - 'domainfilter',1); -# description filter - my $descriptfilter=$ENV{'form.descriptfilter'}; - unless ($descriptfilter) { $descriptfilter=''; } - my $listdescript=&HTML::Entities::encode($descriptfilter,'<>&"'); -# institutional code filter - my $instcodefilter=$ENV{'form.instcodefilter'}; - unless ($instcodefilter) { $instcodefilter=''; } - my $listinstcode=&HTML::Entities::encode($instcodefilter,'<>&"'); -# course owner filter - my $ownerfilter=$ENV{'form.ownerfilter'}; - unless ($ownerfilter) { $ownerfilter=''; } - my $listowner=&HTML::Entities::encode($ownerfilter,'<>&"'); -# last course activity filter and selection - my $sincefilter=$ENV{'form.sincefilter'}; - $sincefilter=~s/[^\d-]//g; - unless ($sincefilter) { $sincefilter=-1; } - my $sincefilterform=&Apache::loncommon::select_form($sincefilter, - 'sincefilter',('-1'=>'', - '86400' => 'today', - '604800' => 'last week', - '2592000' => 'last month', - '7776000' => 'last three months', - '15552000' => 'last six months', - '31104000' => 'last year', - 'select_form_order' => - ['-1','86400','604800','2592000','7776000', - '15552000','31104000'])); -# if called from loncreateuser, report sections, then close - my ($loaditem,$seclist); - my $num_sections = 0; - if ($ENV{'form.form'} eq 'cu' && $ENV{'form.pickedcourse'}) { - $loaditem = 'onLoad="setSections()"'; - my ($cdom,$cnum) = split/_/,$ENV{'form.pickedcourse'}; - my %sections_count = (); - $num_sections = &Apache::loncommon::get_sections($cdom,$cnum,\%sections_count); - my @sections = (); - if ($num_sections > 0) { - @sections = (sort {$a <=> $b} keys %sections_count); - $seclist = join('","',@sections); - } - } - $r->print(&Apache::loncommon::bodytag("Selecting a Course",undef,$loaditem)); - my %lt=&Apache::lonlocal::texthash( - 'cac' => 'Course Activity', - 'cde' => 'Course Description', - 'cdo' => 'Course Domain', - 'cin' => 'Course Institutional Code', - 'cow' => "Course Owner's usename"); - my ($name_code,$name_input); - if (defined($ENV{'form.cnameelement'}) && $ENV{'form.cnameelement'} ne '') { - $name_code = "opener.document.$ENV{'form.form'}.$ENV{'form.cnameelement'}.value=cdesc;"; - $name_input =''; - } - my $submitopener = ''; - my $autosubmit = ''; - my $roleelement = ''; - my $lastaction = 'self.close()'; - if ($ENV{'form.form'} eq 'cu') { - $lastaction = 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n". - 'document.courselist.submit();'; + 'multiple','type','setroles','fixeddom','cloner', + 'crscode','crsdom']); + my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement, + $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom,$crscode, + $crsdom,$rolechooser); + + # Get course type - Course, Community or Placement. + $type = $env{'form.type'}; + if (!defined($env{'form.type'})) { + $type = 'Course'; + } + $title = 'Selecting a '.$type; + + # Setup for multiple course selections, if flag for multiples set. + $multiple = $env{'form.multiple'}; + if ($multiple) { + ($jscript,$multelement) = &multiples_tag(); + $title = 'Selecting '.$type.'(s)'; } - my $roledom = $ENV{'form.roleelement'}; + + # if called when a DC or DH is selecting a course + my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'}); if ($roledom) { - $roleelement = ''; - $submitopener = &Apache::lonroles::processpick($roledom); - $autosubmit = 'process_pick("'.$roledom.'")'; + $roleelement = ''; + $submitopener = &processpick(); + $autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")'; + if ($rolename eq 'dh') { + my %lt = &Apache::lonlocal::texthash( + title => 'Ad hoc role selection', + preamble => 'Please choose an ad hoc role in the course.', + cancel => 'Click "OK" to enter the course, or "Cancel" to choose a different course.', + ); + + $rolechooser = <<"END"; +
+

$lt{'preamble'}

+
+
+
+ +
+

$lt{'cancel'}

+
+END + } } - $r->print(< -function gochoose(cname,cdom,cdesc) { - $name_code - var openerForm = "$ENV{'form.form'}"; - opener.document.$ENV{'form.form'}.$ENV{'form.cnumelement'}.value=cname; - if (openerForm == 'cu' || openerForm == 'rolechoice') { - opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'}.value=cdom; + if ($env{'form.typeelement'} ne '') { + $typeelement = ''; } - else { - var slct=opener.document.$ENV{'form.form'}.$ENV{'form.cdomelement'}; - var i; - for (i=0;i '1'}); + my $cdom = $coursedescription{'domain'}; + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + if (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'})) { + $loaditem{'onload'} .= 'setDefaultCredits();'; + } + } + $loaditem{'onload'} .= 'setRoles();setSections();'; + } + if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) && (!$onlyown)) { + $loaditem{'onload'} .= 'hideSearching(); '; + } + my $js = &Apache::loncommon::js_changer(); + $r->print(&Apache::loncommon::start_page($title,$js, + {'add_entries' => \%loaditem, + 'no_nav_bar' => 1, })); + + if ($env{'form.form'} eq 'portform') { + $lastaction = 'document.courselist.submit()'; + } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' && + !$multiple)) { + $lastaction = + 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n". + 'document.courselist.submit();'; + } else { + $lastaction = 'self.close()'; + } + + # if called to assign a role in a course to a user via CUSR + if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') { + $r->print(&create_user_javascript($type)); + } + + # print javascript functions for choosing a course + if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || + $onlyown) { + $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction, + $rolename,$rolechooser)); + } + $r->print(&Apache::lonhtmlcommon::scripttag($jscript)); + $r->print($submitopener); + +# ------------------------------------------ Display of filters to limit search + my $filter = {}; + my $action = '/adm/pickcourse'; + my ($numtitles,$showroles,$nohost,@codetitles); + unless ($onlyown) { + my $filterlist = ['domainfilter','sincefilter']; + # created filter for DCs only + if ($env{'user.adv'} && $env{'form.domainfilter'} && + exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'}) + && $env{'form.form'} ne 'portform') { + my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'}); + if ($loncaparev ne 'unknown_cmd') { + push(@{$filterlist},'createdfilter'); + } + } + push(@{$filterlist},('descriptfilter','instcodefilter')); + if ($env{'form.form'} eq 'rules') { + push(@{$filterlist},('personfilter','persondomfilter')); + if ($env{'form.persondomfilter'} eq '') { + unless ($env{'form.gosearch'}) { + $filter->{'persondomfilter'} = $env{'request.role.domain'}; + } + } else { + $filter->{'persondomfilter'} = + &LONCAPA::clean_domain($env{'form.persondomfilter'}); + } + if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) { + if (&Apache::lonnet::homeserver($env{'form.personfilter'}, + $env{'form.persondomfilter'}) eq 'no_host') { + $nohost = 1; + } else { + $showroles = 1; + } + } + } else { + push(@{$filterlist},('ownerfilter','ownerdomfilter')); + } + # course ID filter for DCs only + if ($env{'user.adv'} && $env{'form.domainfilter'} && + exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) { + push(@{$filterlist},'coursefilter'); + } + if ($cloneruname ne '' && $clonerudom ne '') { + push(@{$filterlist},'cloneableonly'); + } + if ((ref($filterlist) eq 'ARRAY') && (ref($filter) eq 'HASH')) { + foreach my $item (@{$filterlist}) { + $filter->{$item} = $env{'form.'.$item}; + } + } + if ($env{'form.form'} eq 'portform') { + $filter->{'domainfilter'} ||= $env{'user.domain'}; + } elsif ($env{'form.form'} eq 'studentform') { + $filter->{'domainfilter'} ||= $env{'request.role.domain'}; + } + my $codedom; + if ($env{'form.fixeddom'}) { + $codedom = $env{'request.role.domain'}; + } else { + $codedom = $filter->{'domainfilter'}; + } + my ($clonetext,$clonewarning); + if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) { + (my $coord_cloneable,$clonewarning) = + &get_coordinator_cloneable($cloneruname,$clonerudom,$type); + if ($env{'form.form'} eq 'ccrs') { + $clonetext = ''."\n"; + } + if ($coord_cloneable) { + $clonetext .= ''; + } + if ($crscode ne '') { + $clonetext .= ''; + } + if ($crsdom ne '') { + $clonetext .= ''; + } + } + $r->print(&Apache::loncommon::build_filters($filterlist,$type,$roleelement,$multelement, + $filter,$action,\$numtitles,undef,$cloneruname, + $clonerudom,$typeelement,\@codetitles,$codedom, + $env{'form.form'},$env{'form.fixeddom'}, + $env{'form.prevphase'},$env{'form.cnameelement'}, + $env{'form.cnumelement'},$env{'form.cdomelement'}, + $env{'form.setroles'},$clonetext,$clonewarning)); + } + +# ---------------------------------------------------------------- Get the data + if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || + $onlyown) { + my $domcloner; + if ($env{'form.form'} eq 'ccrs') { + if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) && + (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) { + $domcloner = 1; + } + } + my %courses; + if (!$onlyown) { + $r->print('
'.&mt('Searching ...').'
'); + $r->rflush(); + my $srchdom = $filter->{'domainfilter'}; + %courses = &Apache::loncommon::search_courses($srchdom,$type,$filter,$numtitles, + $cloneruname,$clonerudom,$domcloner, + \@codetitles,$env{'form.cc_clone'}, + $crsdom,$crscode); + } else { + $r->print('
'); + my %coursehash = &Apache::loncommon::findallcourses(); + foreach my $cid (sort(keys(%coursehash))) { + $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'}; + } + } + if ($nohost) { + $r->print (''. + &mt('User does not exist - username: [_1], domain: [_2].', + ''.$filter->{'personfilter'}.'', + ''.$filter->{'persondomfilter'}.'').''); + } else { + &display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname, + $clonerudom,$crsdom,$crscode,%courses); + } + } + $r->print(&Apache::loncommon::end_page()); + return OK; +} + +sub processpick { + my $openerform = 'rolechoice'; + if ($env{'form.form'} eq 'studentform') { + $openerform = $env{'form.form'}; + } + my $process_pick = <<"ENDONE"; + +"; + return $process_pick; +} + +sub create_user_javascript { + my ($type) = @_; + my $output; + #javascript for reporting sections and groups then closing + if ($env{'form.pickedcourse'}) { + my %coursedescription = + &Apache::lonnet::coursedescription($env{'form.pickedcourse'}, + {'one_time' => '1'}); + my $cdom = $coursedescription{'domain'}; + my $cnum = $coursedescription{'num'}; + my $crstype = $coursedescription{'type'}; + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + my ($showcredits,$credits); + if (($crstype ne 'Community') && + (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}))) { + $showcredits = 1; + $credits = $coursedescription{'internal.defaultcredits'}; + } + my $sec_element = 'currsec'; + my $grplist_element = 'groups'; + my ($sections,$groups) = + &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type); + my $num_sections = scalar(@{$sections}); + my $seclist = join(',',@{$sections}); + my $num_groups = scalar(@{$groups}); + my $groupslist = join(',',@{$groups}); + $output = qq| + +|; } - else { - if (numSections == 1) { - opener.document.$ENV{"form.form"}.currsec.multiple=false; - opener.document.$ENV{"form.form"}.currsec.size=1; - opener.document.$ENV{"form.form"}.currsec.options[0] = new Option('Select','',true,true); - opener.document.$ENV{"form.form"}.currsec.options[1] = new Option('No section','',false,false) - opener.document.$ENV{"form.form"}.currsec.options[2] = new Option(sectionsArray[0],sectionsArray[0],false,false); + return $output; +} + +sub display_matched_courses { + my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,$crsdom,$crscode,%courses) = @_; + if ($env{'form.form'} eq 'portform') { + $action = '/adm/portfolio'; + } + my $numcourses = keys(%courses); + $r->print('
'); + if ($env{'form.form'} eq 'modifycourse') { + if ($numcourses > 0) { + my $ccrole = 'cc'; + if ($type eq 'Community') { + $ccrole = 'co'; + } + my $cctitle = &Apache::lonnet::plaintext($ccrole,$type); + my $dctitle = &Apache::lonnet::plaintext('dc'); + my $ccrolechk = ' '; + my $possrole; + my $menuchk = ' checked="checked" '; + $r->print( + '
' + .'
' + .''.&mt('Pick action').''); + my $roleradio = '
'); + } + $r->print('' + .'
' + .'
' + ); } - else { - for (var i=0; i 1 && $multiple) { + $r->print(' +    +

'); + } + + if (%courses) { + $r->print(&Apache::loncommon::start_data_table()); + $r->print(&Apache::loncommon::start_data_table_header_row()); + my $titlehdr = &mt('Course Title'); + if ($type eq 'Community') { + $titlehdr = &mt('Community Title'); + } + $r->print(''.&mt('Select').'' + .''.$titlehdr.'' + .''.&mt('Domain').''); + unless (($type eq 'Community') || ($type eq 'Placement')) { + $r->print(''.&mt('Course Code').''); + } + $r->print(''.&mt('Owner/Co-owner(s)').''); + if ($showroles) { + $r->print(''.&mt("Role(s) for [_1]", + &Apache::loncommon::plainname($env{'form.personfilter'}, + $env{'form.persondomfilter'},'firstname')).''); + } + $r->print(&Apache::loncommon::end_data_table_header_row()); + } + my %cc_cloneable; + if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) { + my ($coord_cloneable,$warning) = + &get_coordinator_cloneable($cloneruname,$clonerudom,$type); + if ($coord_cloneable) { + map {$cc_cloneable{$_} = 1;} split('&',$coord_cloneable); + } + } + my (%gotdomdefaults,%gotcodedefaults); + foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) { + foreach my $course (@{$by_descrip{$description}}) { + $r->print(&Apache::loncommon::start_data_table_row()); + my $cleandesc=&HTML::Entities::encode($description,'<>&"'); + $cleandesc=~s/'/\\'/g; + my ($cdom,$cnum)=split(/\_/,$course); + my ($descr,$instcode,$ttype,$canclone,@owners); + if (ref($courses{$course}) eq 'HASH') { + $descr = $courses{$course}{'description'}; + $instcode = $courses{$course}{'inst_code'}; + $ttype = $courses{$course}{'type'}; + if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) { + if ($env{'form.form'} eq 'ccrs') { + if (($env{'request.role.domain'} eq $cdom) && + (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) { + $canclone = 1; + } + } + unless ($canclone) { + if ($cc_cloneable{$cnum.':'.$cdom}) { + $canclone = 1; + } + } + unless ($canclone) { + my $cloners = $courses{$course}{'cloners'}; + if ($cloners ne '') { + my @cloneable = split(',',$cloners); + if (grep(/^\*$/,@cloneable)) { + $canclone = 1; + } + if (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) { + $canclone = 1; + } + if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) { + $canclone = 1; + } + unless ($canclone) { + if (($instcode) && ($crscode) && ($cdom eq $crsdom)) { + foreach my $cloner (@cloneable) { + if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) && + ($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) { + if ($cloner =~ /\=/) { + my (%codedefaults,@code_order); + if (ref($gotcodedefaults{$cdom}) eq 'HASH') { + if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') { + %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}}; + } + if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') { + @code_order = @{$gotcodedefaults{$cdom}{'order'}}; + } + } else { + &Apache::lonnet::auto_instcode_defaults($cdom, + \%codedefaults, + \@code_order); + $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults; + $gotcodedefaults{$cdom}{'order'} = \@code_order; + } + if (@code_order > 0) { + if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order, + $cloner,$instcode,$crscode)) { + $canclone = 1; + last; + } + } + } + } + } + } + } + } else { + my %domdefs; + if (ref($gotdomdefaults{$cdom}) eq 'HASH') { + %domdefs = %{$gotdomdefaults{$cdom}}; + } else { + %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + $gotdomdefaults{$cdom} = \%domdefs; + } + if ($domdefs{'canclone'}) { + unless ($domdefs{'canclone'} eq 'none') { + if ($domdefs{'canclone'} eq 'domain') { + if ($clonerudom eq $cdom) { + $canclone = 1; + } + } elsif (($instcode) && ($crscode) && + ($cdom eq $crsdom)) { + my (%codedefaults,@code_order); + if (ref($gotcodedefaults{$cdom}) eq 'HASH') { + if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') { + %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}}; + } + if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') { + @code_order = @{$gotcodedefaults{$cdom}{'order'}}; + } + } else { + &Apache::lonnet::auto_instcode_defaults($cdom, + \%codedefaults, + \@code_order); + $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults; + $gotcodedefaults{$cdom}{'order'} = \@code_order; + } + if (@code_order > 0) { + if (&Apache::lonnet::default_instcode_cloning($cdom,$domdefs{'canclone'}, + $instcode,$crscode,\%codedefaults, + \@code_order)) { + $canclone = 1; + } + } + } + } + } + } + } + } + push(@owners,$courses{$course}{'owner'}); + if ($courses{$course}{'co-owners'} ne '') { + foreach my $item (split(/,/,$courses{$course}{'co-owners'})) { + push(@owners,$item); + } + } + } else { + my $singleowner; + ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course}); + push(@owners,&unescape($singleowner)); } - opener.document.$ENV{"form.form"}.currsec.multiple=true - if (numSections < 3) { - opener.document.$ENV{"form.form"}.currsec.size=numSections; + my $ownerstr = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } @owners); + $r->print(''.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).''); + $r->print(''.$description.''); + $r->print(''); + $r->print(&Apache::lonnet::domain($cdom,'description')? + $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom); + $r->print(''); + unless (($type eq 'Community') || ($type eq 'Placement')) { + $r->print(''); + if ($instcode ne '') { + $r->print(&unescape($instcode)); + } else { + $r->print(' '); + } + $r->print(''); } - else { - opener.document.$ENV{"form.form"}.currsec.size=3; + $r->print(''.$ownerstr.''); + if ($showroles) { + $r->print(''); + my $rolestr; + if (ref($courses{$course}{'roles'}) eq 'ARRAY') { + my @roles = sort(@{$courses{$course}{'roles'}}); + foreach my $role (@roles) { + if ($role =~ /^cr/) { + my (undef,$crdom,$crname,$crtitle) = split('/',$role); + $rolestr .= $crtitle.', '; + } else { + $rolestr .= &Apache::lonnet::plaintext($role,$type).', '; + } + } + $rolestr =~ s/\, $//; + } + $r->print($rolestr.''); } - opener.document.$ENV{"form.form"}.currsec.options[0].selected = false + if ($multiple) { $r->print("\n"); } + $r->print(&Apache::loncommon::end_data_table_row()); + # $r->print("
\n"); + } + } + if (%courses) { + $r->print(&Apache::loncommon::end_data_table()); + } + + if (!%courses) { + $r->print('

'.&mt('None found').'

'); + } elsif ($multiple) { + $r->print(''); + } + $r->print(''. + "\n".''."\n". + ''."\n"); + if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) { + $r->print(''."\n"); + } + if ($env{'form.form'} eq 'portform') { + $r->print(''); + $r->print(''); + $r->print(''); + $r->print(''); + } elsif ($env{'form.form'} eq 'modifycourse') { + $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state','adhocrole'])); + } else { + $r->print(''."\n". + ''."\n"); + if ($env{'form.typeelement'} ne '') { + $r->print(''."\n"); + + } + } + if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) { + $r->print(''); + } + if ($env{'form.numtitles'}) { + $r->print(''); + } + $r->print("\n"); + return; +} + +sub multiples_tag { + my $jscript = &Apache::loncommon::check_uncheck_jscript(); + my $multelement = ''; + return ($jscript,$multelement); +} + +sub get_coordinator_cloneable { + my ($cloneruname,$clonerudom,$type) = @_; + if (($cloneruname!~/\w/) || ($clonerudom!~/\w/)) { + my $warning = '
'.&mt('Intended course owner not specified'). + '
'; + return ('',$warning); + } elsif (&Apache::lonnet::homeserver($cloneruname,$clonerudom) eq 'no_host') { + my $warning = '
'.&mt('Intended course owner does not exist'). + '
'; + return ('',$warning); + } else { + my ($cc_clone,$ccrole); + if ($type eq 'Community') { + $ccrole = 'co'; + } else { + $ccrole = 'cc'; + } + my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom, + 'userroles',['active'], [$ccrole]); + foreach my $key (sort(keys(%ccroles))) { + my ($cnum,$cdom,$role) = split(':',$key); + $cc_clone .= $cdom.':'.$cnum.'&'; } + $cc_clone =~ s/\&$//; + return ($cc_clone); } - self.close() } - -$submitopener -
- - -$name_input - -$roleelement -$lt{'cac'}: $sincefilterform -
-$lt{'cdo'}: $domainselectform -
-$lt{'cin'}: - -
-$lt{'cow'}: - -
-$lt{'cde'}: - -

-
-
+ +sub course_chooser { + my ($multiple,$cdom,$cnum,$cleandesc,$canclone) = @_; + my $output; + if ($multiple) { + $output = '