Annotation of loncom/interface/lonpickcourse.pm, revision 1.106

1.1       www         1: # The LearningOnline Network
                      2: # Pick a course
                      3: #
1.106   ! raeburn     4: # $Id: lonpickcourse.pm,v 1.105 2013/02/05 17:02:40 bisitz Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonpickcourse;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
1.106   ! raeburn    34: use Apache::lonhtmlcommon;
1.1       www        35: use Apache::loncoursedata;
                     36: use Apache::lonnet;
1.8       www        37: use Apache::lonlocal;
1.46      raeburn    38: use Apache::longroup;
1.78      raeburn    39: use Apache::courseclassifier;
1.85      raeburn    40: use LONCAPA qw(:DEFAULT :match);
1.1       www        41: 
                     42: sub handler {
                     43:     my $r = shift;
1.8       www        44:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        45:     $r->send_http_header;
                     46:     return OK if $r->header_only;
                     47: 
                     48: # ------------------------------------------------------------ Print the screen
1.40      albertel   49: 
1.55      raeburn    50:     # Get parameters from query string
1.1       www        51:     &Apache::loncommon::get_unprocessed_cgi
1.55      raeburn    52:         ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
1.19      raeburn    53: 			       'cdomelement','cnameelement','roleelement',
1.85      raeburn    54:                                'multiple','type','setroles','fixeddom','cloner']);
1.90      raeburn    55:     my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement,
1.85      raeburn    56:         $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom);
1.55      raeburn    57: 
1.83      raeburn    58:     # Get course type - Course or Community.
1.54      raeburn    59:     $type = $env{'form.type'};
                     60:     if (!defined($env{'form.type'})) {
                     61:         $type = 'Course';
                     62:     }
1.82      bisitz     63:     $title = 'Selecting a '.$type;
1.54      raeburn    64: 
                     65:     # Setup for multiple course selections, if flag for multiples set.
1.55      raeburn    66:     $multiple = $env{'form.multiple'};
                     67:     if ($multiple) {
                     68:         ($jscript,$multelement) = &multiples_tag();
1.82      bisitz     69:         $title = 'Selecting '.$type.'(s)';
1.54      raeburn    70:     }
                     71: 
1.55      raeburn    72:     # if called when a DC is selecting a course 
1.54      raeburn    73:     my $roledom = $env{'form.roleelement'};
                     74:     if ($roledom) {
                     75:         $roleelement = '<input type="hidden" name="roleelement" value="'.$roledom.'" />';
1.66      raeburn    76:         $submitopener = &processpick();
1.54      raeburn    77:         $autosubmit = 'process_pick("'.$roledom.'")';
                     78:     }
1.90      raeburn    79:     if ($env{'form.typeelement'} ne '') {
                     80:         $typeelement = '<input type="hidden" name="typeelement" value="'.$env{'form.typeelement'}.'" />';
                     81:     }
1.54      raeburn    82: 
1.92      raeburn    83:     # if called when a DC is creating a course for another user.
1.85      raeburn    84:     if ($env{'form.form'} eq 'ccrs') {
                     85:         ($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
                     86:     }
                     87: 
                     88:     # if called when requesting a course
                     89:     if ($env{'form.form'} eq 'requestcrs') {
                     90:         $cloneruname = $env{'user.name'};
                     91:         $clonerudom =  $env{'user.domain'};
                     92:     }
                     93: 
1.54      raeburn    94:     my $onlyown = 0;
1.55      raeburn    95:     # if called to assign course-based portfolio access control
1.59      raeburn    96:     if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
1.54      raeburn    97:         $onlyown = 1;
1.49      raeburn    98:     }
1.55      raeburn    99: 
                    100:     my %loaditem;
1.84      raeburn   101:     if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
                    102:         if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
                    103:             $loaditem{'onload'} = 'setElements(document.filterpicker); ';
                    104:         }
1.78      raeburn   105:     }
                    106: 
1.66      raeburn   107:     if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && 
                    108:         ($env{'form.pickedcourse'})) {
1.106   ! raeburn   109:         $loaditem{'onload'} .= 'setDefaultCredits();setRoles();setSections();';
1.30      raeburn   110:     }
1.85      raeburn   111:     my $js = &js_changer();
1.106   ! raeburn   112:     $r->print(&Apache::loncommon::start_page($title,
        !           113:                                              &Apache::lonhtmlcommon::scripttag($js),
1.42      albertel  114: 					     {'add_entries' => \%loaditem,
1.41      albertel  115: 					      'no_nav_bar'  => 1, }));
1.55      raeburn   116: 
                    117:     if ($env{'form.form'} eq 'portform') {
                    118:         $lastaction = 'document.courselist.submit()';
1.67      raeburn   119:     } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' &&
                    120:         !$multiple)) {
1.55      raeburn   121:         $lastaction = 
                    122:              'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
                    123:              'document.courselist.submit();';
1.34      albertel  124:     } else {
1.55      raeburn   125:         $lastaction = 'self.close()';
1.1       www       126:     }
1.19      raeburn   127: 
1.55      raeburn   128:     # if called to assign a role in a course to a user via CUSR
1.66      raeburn   129:     if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') {
1.68      raeburn   130:         $r->print(&create_user_javascript($type));
1.55      raeburn   131:     }
1.54      raeburn   132: 
1.55      raeburn   133:     # print javascript functions for choosing a course 
1.85      raeburn   134:     if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || 
                    135:         $onlyown) {
1.58      raeburn   136:         $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
1.55      raeburn   137:     }
1.105     bisitz    138:     $r->print(&Apache::lonhtmlcommon::scripttag($jscript));
1.55      raeburn   139:     $r->print($submitopener);
1.54      raeburn   140: 
1.55      raeburn   141: # ------------------------------------------ Display of filters to limit search
1.57      raeburn   142:     my $filter = {};
                    143:     my $action = '/adm/pickcourse';
1.99      raeburn   144:     my ($numtitles,$showroles,$nohost,@codetitles);
1.55      raeburn   145:     if (!$onlyown) {
1.94      raeburn   146:         my $filterlist = ['domainfilter'];
                    147:         # created filter for DCs only
                    148:         if ($env{'user.adv'} && $env{'form.domainfilter'} &&
1.95      raeburn   149:             exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})
                    150:             && $env{'form.form'} ne 'portform') {
1.94      raeburn   151:             my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'});
                    152:             if ($loncaparev ne 'unknown_cmd') {
                    153:                 push(@{$filterlist},'createdfilter');
                    154:             }
                    155:         }
                    156:         push(@{$filterlist},('descriptfilter','instcodefilter'));
1.79      raeburn   157:         if ($env{'form.form'} eq 'rules') {
                    158:             push(@{$filterlist},'personfilter');
                    159:             if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) {
                    160:                 if (&Apache::lonnet::homeserver($env{'form.personfilter'},
                    161:                                                  $env{'form.persondomfilter'}) eq 'no_host') {
                    162:                     $nohost = 1;
                    163:                 } else {
                    164:                     $showroles = 1;
                    165:                 } 
                    166:             }
                    167:         } else {
                    168:             push(@{$filterlist},'ownerfilter');
                    169:         }
1.55      raeburn   170:         # course ID filter for DCs only
                    171:         if ($env{'user.adv'} && $env{'form.domainfilter'} &&
                    172:             exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) {
                    173:             push(@{$filterlist},'coursefilter');
                    174:         }
1.85      raeburn   175:         if ($cloneruname ne '' && $clonerudom ne '') {
                    176:             push(@{$filterlist},'cloneableonly');
                    177:         }
                    178: 
1.55      raeburn   179:         $r->print(&build_filters($filterlist,$type,$roleelement,$multelement,
1.85      raeburn   180:                                  $filter,$action,\$numtitles,undef,$cloneruname,
1.99      raeburn   181:                                  $clonerudom,$typeelement,\@codetitles));
1.55      raeburn   182:     }
1.54      raeburn   183: 
                    184: # ---------------------------------------------------------------- Get the data
1.85      raeburn   185:     if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || 
                    186:          $onlyown) {
1.98      raeburn   187:         my $domcloner;
                    188:         if ($env{'form.form'} eq 'ccrs') {
                    189:             if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) &&
                    190:                 (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
                    191:                 $domcloner = 1;
                    192:             }
                    193:         }
1.85      raeburn   194:         my %courses = &search_courses($r,$type,$onlyown,$filter,$numtitles,
1.99      raeburn   195:                                       $cloneruname,$clonerudom,$domcloner,\@codetitles);
1.79      raeburn   196:         if ($nohost) {
                    197:             $r->print ('<span class="LC_warning">'.
                    198:                        &mt('User does not exist - username: [_1], domain: [_2].',
                    199:                            '<b>'.$filter->{'personfilter'}.'</b>',
                    200:                            '<b>'.$filter->{'persondomfilter'}.'</b>').'</span>');
                    201:         } else {
1.85      raeburn   202:             &display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,
                    203:                                      $clonerudom,%courses);
1.79      raeburn   204:         }
1.54      raeburn   205:     }
                    206:     $r->print(&Apache::loncommon::end_page());
                    207:     return OK;
                    208: }
                    209: 
1.85      raeburn   210: sub js_changer {
1.106   ! raeburn   211:     return <<ENDJS;
1.85      raeburn   212: <script type="text/javascript">
1.106   ! raeburn   213: // <![CDATA[
1.85      raeburn   214: function updateFilters(caller) {
                    215:     if (typeof(caller) != "undefined") {
                    216:         document.filterpicker.updater.value = caller.name;
                    217:     }
                    218:     document.filterpicker.submit();
                    219: }
1.106   ! raeburn   220: // ]]
1.85      raeburn   221: </script>
                    222: 
                    223: ENDJS
                    224: }
                    225: 
1.66      raeburn   226: sub processpick {
                    227:     my $openerform = 'rolechoice';
                    228:     if ($env{'form.form'} eq 'studentform') {
                    229:         $openerform = $env{'form.form'};
                    230:     }
                    231:     my $process_pick = <<"ENDONE";
                    232: <script type="text/javascript">
                    233: function process_pick(dom) {
                    234:     var pickedCourse=opener.document.$openerform.$env{'form.cnumelement'}.value;
                    235:     var pickedDomain=opener.document.$openerform.$env{'form.cdomelement'}.value;
                    236:     var okDomain = 0;
                    237: ENDONE
                    238:     if ($openerform eq 'rolechoice') {
                    239:         $process_pick .= <<"ENDTWO";
                    240:     if (pickedDomain == dom) {
                    241:         if (pickedCourse != '') {
1.88      raeburn   242:             var ccrole = "cc";
                    243:             var pickedType = "$env{'form.type'}";
                    244:             if (pickedType == "Community") {
                    245:                 ccrole = "co";
                    246:             }
                    247:             var courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse
1.66      raeburn   248:             opener.document.title='Role selected. Please stand by.';
                    249:             opener.status='Role selected. Please stand by.';
                    250:             opener.document.rolechoice.newrole.value=courseTarget
                    251:             opener.document.rolechoice.submit();
                    252:         }
                    253:     } 
                    254:     else {
                    255:         alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
                    256:     }
                    257: ENDTWO
                    258:     } else {
                    259:         $process_pick .= <<"ENDTHREE";
                    260:     if (pickedDomain != dom) {
                    261:         alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
                    262:         return;
                    263:     }
                    264: ENDTHREE
                    265:     }
                    266:     $process_pick .= "
                    267: }
                    268: 
                    269: </script>
                    270: ";
                    271:     return $process_pick;
                    272: }
                    273: 
1.55      raeburn   274: sub create_user_javascript {
                    275:     my ($type) = @_;
                    276:     my $output;
                    277:     #javascript for reporting sections and groups then closing
                    278:     if ($env{'form.pickedcourse'}) {
1.87      raeburn   279:         my %coursedescription = 
                    280:             &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
                    281:                                                {'one_time' => '1'});
                    282:         my $cdom = $coursedescription{'domain'};
                    283:         my $cnum = $coursedescription{'num'};
                    284:         my $crstype = $coursedescription{'type'};
1.106   ! raeburn   285:         my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
        !           286:         my ($showcredits,$credits);
        !           287:         if (($crstype ne 'Community') &&
        !           288:             ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'})) {
        !           289:             $showcredits = 1; 
        !           290:             $credits = $coursedescription{'internal.defaultcredits'};
        !           291:         }
1.55      raeburn   292:         my $sec_element = 'currsec';
                    293:         my $grplist_element = 'groups';
                    294:         my ($sections,$groups) =
                    295:           &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type);
                    296:         my $num_sections = scalar(@{$sections});
                    297:         my $seclist = join(',',@{$sections});
                    298:         my $num_groups = scalar(@{$groups});
                    299:         my $groupslist = join(',',@{$groups});
                    300:         $output = qq|
                    301: <script type="text/javascript">
1.106   ! raeburn   302: // <![CDATA[
1.55      raeburn   303: function setSections() {
                    304:     opener.document.$env{"form.form"}.$grplist_element.value='$groupslist';
                    305:     window.opener.setSect('$seclist');
1.87      raeburn   306:     self.close();
                    307: }
                    308: function setRoles() {
                    309:     window.opener.setRole('$crstype');
1.55      raeburn   310: }
1.106   ! raeburn   311: |;
        !           312:         if ($showcredits) {
        !           313:             $output .= qq|
        !           314: function setDefaultCredits() {
        !           315:     window.opener.setCredits('$credits');
        !           316: }
        !           317: |;
        !           318:         }
        !           319:         $output .= qq|
        !           320: // ]]>
1.55      raeburn   321: </script>
                    322: |;
                    323:     }
                    324:     return $output;
                    325: }
                    326: 
1.54      raeburn   327: sub display_matched_courses {
1.85      raeburn   328:     my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,%courses) = @_;
1.55      raeburn   329:     if ($env{'form.form'} eq 'portform') {
                    330:         $action = '/adm/portfolio';
                    331:     }
1.68      raeburn   332:     my $numcourses = keys(%courses);
1.55      raeburn   333:     $r->print('<form name="courselist" method="post" action="'.$action.'">');
1.68      raeburn   334:     if ($env{'form.form'} eq 'modifycourse') {
                    335:         if ($numcourses > 0) {
1.89      raeburn   336:             my $ccrole = 'cc';
                    337:             if ($type eq 'Community') {
                    338:                 $ccrole = 'co';
                    339:             }
                    340:             my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.68      raeburn   341:             my $dctitle = &Apache::lonnet::plaintext('dc');
1.93      raeburn   342:             my $ccrolechk = ' ';
                    343:             my $menuchk = ' checked="checked" ';
1.68      raeburn   344:             $r->print(
1.106   ! raeburn   345:                 '<div class="LC_left_float">'
        !           346:                .'<fieldset>'
        !           347:                .'<legend>'.&mt('Pick action').'</legend>'
        !           348:                .'<span class="LC_nobreak"><label>'
1.75      bisitz    349:                .'<input type="radio" name="phase" value="ccrole"'.$ccrolechk.'/>'
1.89      raeburn   350:                .'&nbsp;');
                    351:             if ($type eq 'Community') {
                    352:                 $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
                    353:             } else {
                    354:                 $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
                    355:             }
1.106   ! raeburn   356:             $r->print('</label></span><br />'
        !           357:                .'<span class="LC_nobreak"><label>'
1.89      raeburn   358:                .'<input type="radio" name="phase" value="menu"'.$menuchk.'/>&nbsp;');
                    359:             if ($type eq 'Community') {
                    360:                 $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
                    361:             } else {
                    362:                 $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
                    363:             }
1.106   ! raeburn   364:             $r->print('</label></span>'
        !           365:                .'</fieldset></div>'
        !           366:                .'<br clear="all" />'
1.75      bisitz    367:             );
1.68      raeburn   368:         }
                    369:     }
1.54      raeburn   370:     my %by_descrip;
                    371:     foreach my $course (keys(%courses)) {
                    372:         my $descr;
1.64      raeburn   373:         if (ref($courses{$course}) eq 'HASH') {
1.65      raeburn   374:             $descr = $courses{$course}{'description'};
1.64      raeburn   375:         } elsif ($courses{$course} =~ m/^([^:]*):/i) {
1.54      raeburn   376:             $descr = &unescape($1);
1.34      albertel  377:         } else {
1.54      raeburn   378:             $descr = &unescape($courses{$course});
                    379:         }
                    380:         my $description = $descr;
                    381:         push (@{$by_descrip{$description}}, $course);
                    382:     }
1.71      bisitz    383:  
1.54      raeburn   384:     if ($numcourses > 1 && $multiple) {
1.104     bisitz    385:         $r->print('<input type="button" value="'.&mt('check all').'"
1.54      raeburn   386:                   onclick="javascript:checkAll(document.courselist.course_id)" />
1.104     bisitz    387:                   &nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"
1.54      raeburn   388:                   onclick="javascript:uncheckAll(document.courselist.course_id)" />
                    389:                   <br /><br />');
                    390:     }
1.71      bisitz    391: 
                    392:     if (%courses) {
                    393:         $r->print(&Apache::loncommon::start_data_table());
                    394:         $r->print(&Apache::loncommon::start_data_table_header_row());
1.89      raeburn   395:         my $titlehdr = &mt('Course Title');
                    396:         if ($type eq 'Community') {
                    397:             $titlehdr = &mt('Community Title');
                    398:         }
1.71      bisitz    399:         $r->print('<th>'.&mt('Select').'</th>'
1.89      raeburn   400:                  .'<th>'.$titlehdr.'</th>'
                    401:                  .'<th>'.&mt('Domain').'</th>');
                    402:         unless ($type eq 'Community') {
                    403:             $r->print('<th>'.&mt('Course Code').'</th>');
                    404:         }
                    405:         $r->print('<th>'.&mt('Owner/Co-owner(s)').'</th>');
1.79      raeburn   406:         if ($showroles) {
                    407:             $r->print('<th>'.&mt("Role(s) for [_1]",
                    408:                 &Apache::loncommon::plainname($env{'form.personfilter'},
                    409:                                               $env{'form.persondomfilter'},'firstname')).'</th>');
                    410:         }
1.71      bisitz    411:         $r->print(&Apache::loncommon::end_data_table_header_row());
                    412:     }
1.92      raeburn   413:     my %cc_cloneable;
                    414:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    415:         my ($coord_cloneable,$warning) =
                    416:             &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
                    417:         if ($coord_cloneable) {
                    418:             map {$cc_cloneable{$_} = 1;} split('&',$coord_cloneable);
                    419:         }
                    420:     }
1.54      raeburn   421:     foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) {
                    422:         foreach my $course (@{$by_descrip{$description}}) {
1.72      raeburn   423:             $r->print(&Apache::loncommon::start_data_table_row());
1.54      raeburn   424:             my $cleandesc=&HTML::Entities::encode($description,'<>&"');
                    425:             $cleandesc=~s/'/\\'/g;
                    426:             my ($cdom,$cnum)=split(/\_/,$course);
1.85      raeburn   427:             my ($descr,$instcode,$ttype,$canclone,@owners);
1.64      raeburn   428:             if (ref($courses{$course}) eq 'HASH') {
                    429:                 $descr = $courses{$course}{'description'};
1.85      raeburn   430:                 $instcode = $courses{$course}{'inst_code'};
                    431:                 $ttype = $courses{$course}{'type'};
                    432:                 if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
1.98      raeburn   433:                     if ($env{'form.form'} eq 'ccrs') {
                    434:                         if (($env{'request.role.domain'} eq $cdom) &&
                    435:                             (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
                    436:                             $canclone = 1;
                    437:                         }
                    438:                     }
                    439:                     unless ($canclone) { 
                    440:                         if ($cc_cloneable{$cnum.':'.$cdom}) {
                    441:                             $canclone = 1;
                    442:                         }
1.92      raeburn   443:                     }
                    444:                     unless ($canclone) {
                    445:                         my $cloners = $courses{$course}{'cloners'};
                    446:                         if ($cloners ne '') { 
                    447:                             my @cloneable = split(',',$cloners);
                    448:                             if (grep(/^\*$/,@cloneable)) {
                    449:                                 $canclone = 1;
                    450:                             }
1.97      raeburn   451:                             if (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) {
1.92      raeburn   452:                                 $canclone = 1;
                    453:                             }
                    454:                             if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) {
                    455:                                 $canclone = 1;
                    456:                             }
1.85      raeburn   457:                         }
                    458:                     }
                    459:                 }
1.101     raeburn   460:                 push(@owners,$courses{$course}{'owner'});
                    461:                 if ($courses{$course}{'co-owners'} ne '') {
                    462:                     foreach my $item (split(/,/,$courses{$course}{'co-owners'})) {
                    463:                         push(@owners,$item);
1.64      raeburn   464:                     }
                    465:                 }
                    466:             } else {
                    467:                 my $singleowner; 
                    468:                 ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course});
                    469:                 push(@owners,&unescape($singleowner));
                    470:             }
1.93      raeburn   471:             my $ownerstr = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } @owners);
1.85      raeburn   472:             $r->print('<td>'.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).'</td>');
1.71      bisitz    473:             $r->print('<td>'.$description.'</td>');
                    474:             $r->print('<td>');
                    475:             $r->print(&Apache::lonnet::domain($cdom,'description')?
                    476:                       $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom);
                    477:             $r->print('</td>');
1.89      raeburn   478:             unless ($type eq 'Community') { 
                    479:                 $r->print('<td>');
                    480:                 if ($instcode ne '') {
                    481:                     $r->print(&unescape($instcode));
                    482:                 } else {
                    483:                     $r->print('&nbsp;');
                    484:                 }
                    485:                 $r->print('</td>');
1.54      raeburn   486:             }
1.72      raeburn   487:             $r->print('<td>'.$ownerstr.'</td>');
1.79      raeburn   488:             if ($showroles) {
                    489:                 $r->print('<td>');
                    490:                 my $rolestr;
                    491:                 if (ref($courses{$course}{'roles'}) eq 'ARRAY') {
                    492:                     my @roles = sort(@{$courses{$course}{'roles'}});
                    493:                     foreach my $role (@roles) {
                    494:                         if ($role =~ /^cr/) {
                    495:                             my (undef,$crdom,$crname,$crtitle) = split('/',$role);
                    496:                             $rolestr .= $crtitle.', ';
                    497:                         } else {
1.89      raeburn   498:                             $rolestr .= &Apache::lonnet::plaintext($role,$type).', ';
1.79      raeburn   499:                         }
                    500:                     }
                    501:                     $rolestr =~ s/\, $//;
                    502:                 }
                    503:                 $r->print($rolestr.'</td>');
                    504:             }
1.54      raeburn   505:             if ($multiple) { $r->print("</label>\n"); }
1.72      raeburn   506:             $r->print(&Apache::loncommon::end_data_table_row());
1.71      bisitz    507:             # $r->print("<br />\n");
1.19      raeburn   508:         }
                    509:     }
1.72      raeburn   510:     if (%courses) {
                    511:         $r->print(&Apache::loncommon::end_data_table());
                    512:     }
1.71      bisitz    513: 
1.54      raeburn   514:     if (!%courses) {
1.104     bisitz    515:         $r->print('<p class="LC_info">'.&mt('None found').'</p>');
1.54      raeburn   516:     } elsif ($multiple) {
1.104     bisitz    517:         $r->print('<input type="button" value="'.&mt('Submit').'" onClick="gochoose('."'','','')".'" />');
1.54      raeburn   518:     }
                    519:     $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'.
                    520:               "\n".'<input type="hidden" name="pickedcourse" value="" />'."\n".
                    521:               '<input type="hidden" name="type" value="'.$type.'" />'."\n");
                    522:     if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
                    523:         $r->print('<input type="hidden" name="roleelement" value="'.
                    524:                   $env{'form.roleelement'}.'" />'."\n");
                    525:     }
1.55      raeburn   526:     if ($env{'form.form'} eq 'portform') {
                    527:         $r->print('<input type="hidden" name="cnum" value="" />');
                    528:         $r->print('<input type="hidden" name="cdom" value="" />');
                    529:         $r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />');
                    530:         $r->print('<input type="hidden" name="action" value="rolepicker" />');
1.57      raeburn   531:     } elsif ($env{'form.form'} eq 'modifycourse') {
1.85      raeburn   532:         $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state']));
1.57      raeburn   533:     } else {
                    534:         $r->print('<input type="hidden" name="cnumelement" value="'.
                    535:                   $env{'form.cnumelement'}.'" />'."\n".  
                    536:                   '<input type="hidden" name="cdomelement" value="'.
                    537:                   $env{'form.cdomelement'}.'" />'."\n");
1.90      raeburn   538:         if ($env{'form.typeelement'} ne '') {
                    539:             $r->print('<input type="hidden" name="typeelement" value="'.
                    540:                       $env{'form.typeelement'}.'" />'."\n");
                    541: 
                    542:         }
1.55      raeburn   543:     }
1.78      raeburn   544:     if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) {
                    545:         $r->print('<input type="hidden" name="fixeddom" value="'.
                    546:                   $env{'form.fixeddom'}.'" />');
                    547:     }
                    548:     if ($env{'form.numtitles'}) {
                    549:         $r->print('<input type="hidden" name="numtitles" value="'.
                    550:                   $env{'form.numtitles'}.'" />');
                    551:     }
1.54      raeburn   552:     $r->print("</form>\n");
                    553:     return;
                    554: }
                    555: 
                    556: sub multiples_tag {
1.55      raeburn   557:     my $jscript = &Apache::loncommon::check_uncheck_jscript();
                    558:     my $multelement = '<input type="hidden" name="multiple" value="1" />';
                    559:     return ($jscript,$multelement);
1.1       www       560: }
1.30      raeburn   561: 
1.54      raeburn   562: sub build_filters {
1.57      raeburn   563:     my ($filterlist,$type,$roleelement,$multelement,$filter,$action,
1.99      raeburn   564:         $numtitlesref,$caller,$cloneruname,$clonerudom,$typeelement,$codetitlesref) = @_;
1.85      raeburn   565:     my ($list,$formname,$fixeddom,$codedom,$jscript);
                    566:     $codedom = $env{'request.role.domain'};
1.57      raeburn   567:     if (defined($env{'form.form'})) {
1.81      raeburn   568:         $formname = $env{'form.form'};
                    569:     } else {
                    570:         $formname = $caller;
1.57      raeburn   571:     }
1.96      bisitz    572:     my $onchange = 'javascript:updateFilters(this)';
1.94      raeburn   573:     my ($domainselectform,$sincefilterform,$createdfilterform,
                    574:         $ownerdomselectform,$persondomselectform,$instcodeform,
                    575:         $typeselectform,$instcodetitle);
1.55      raeburn   576:     foreach my $item (@{$filterlist}) {
1.54      raeburn   577:         $filter->{$item} = $env{'form.'.$item};
                    578:         if ($item ne 'descriptfilter' && $item ne 'instcodefilter') {
1.79      raeburn   579: 	    if ($item eq 'domainfilter') {
1.61      albertel  580: 		$filter->{$item} = &LONCAPA::clean_domain($filter->{$item});
                    581: 	    } elsif ($item eq 'coursefilter') {
                    582: 		$filter->{$item} = &LONCAPA::clean_courseid($filter->{$item});
                    583: 	    } elsif ($item eq 'ownerfilter') {
                    584: 		$filter->{$item} = &LONCAPA::clean_username($filter->{$item});
1.79      raeburn   585:                 $filter->{'ownerdomfilter'} = 
                    586:                     &LONCAPA::clean_domain($env{'form.ownerdomfilter'});
                    587:                 $ownerdomselectform =
                    588:                     &Apache::loncommon::select_dom_form($filter->{'ownerdomfilter'},
                    589:                                                         'ownerdomfilter',1);
                    590:             } elsif ($item eq 'personfilter') {
                    591:                 $filter->{$item} = &LONCAPA::clean_username($filter->{$item});
                    592:                 if ($env{'form.persondomfilter'} eq '') {
1.85      raeburn   593:                     unless ($env{'form.gosearch'}) {
1.79      raeburn   594:                         $filter->{'persondomfilter'} = $env{'request.role.domain'};
                    595:                     }
                    596:                 } else {
                    597:                     $filter->{'persondomfilter'} =
                    598:                         &LONCAPA::clean_domain($env{'form.persondomfilter'});
                    599:                 }
                    600:                 $persondomselectform =
                    601:                     &Apache::loncommon::select_dom_form($filter->{'persondomfilter'},
                    602:                                                         'persondomfilter',1);
1.61      albertel  603: 	    } else {
                    604: 		$filter->{$item} =~ s/\W//g;
                    605: 	    }
1.54      raeburn   606:             if (!$filter->{$item}) {
                    607:                 $filter->{$item} = '';
                    608:             }
                    609:         }
                    610:         if ($item eq 'domainfilter') {
1.63      albertel  611: 	    my $allow_blank = 1;
                    612: 	    if ($formname eq 'portform') {
                    613: 		$filter->{$item} ||= $env{'user.domain'};
                    614: 		$allow_blank=0;
1.67      raeburn   615: 	    } elsif ($formname eq 'studentform') {
                    616:                 $filter->{$item} ||= $env{'request.role.domain'};
                    617:                 $allow_blank=0;
                    618:             }
1.78      raeburn   619:             if ($env{'form.fixeddom'}) {
                    620:                 $domainselectform = '<input type="hidden" name="domainfilter"'.
                    621:                                     'value="'.$env{'request.role.domain'}.'" />'.
                    622:                                     &Apache::lonnet::domain($env{'request.role.domain'},
                    623:                                                             'description');
                    624:                 $codedom = $env{'request.role.domain'};
1.79      raeburn   625:             } else {
1.78      raeburn   626:                 $domainselectform =
                    627: 		    &Apache::loncommon::select_dom_form($filter->{$item},
                    628: 		    				        'domainfilter',
1.84      raeburn   629: 						        $allow_blank,'',$onchange);
1.78      raeburn   630:                 $codedom = $filter->{'domainfilter'};
                    631:             }
1.54      raeburn   632:         } else {
                    633:             $list->{$item} = &HTML::Entities::encode($filter->{$item},'<>&"');
                    634:         }
                    635:     }
                    636: 
                    637:     # last course activity filter and selection
1.94      raeburn   638:     $sincefilterform = &timebased_select_form('sincefilter',$filter);
                    639: 
                    640:     # course created filter and selection
                    641:     if (exists($filter->{'createdfilter'})) {
                    642:         $createdfilterform = &timebased_select_form('createdfilter',$filter);
                    643:     }
1.91      bisitz    644: 
                    645:     my %lt = &Apache::lonlocal::texthash(
                    646:                 'cac' => "$type Activity",
1.94      raeburn   647:                 'ccr' => "$type Created", 
1.91      bisitz    648:                 'cde' => "$type Title",
                    649:                 'cdo' => "$type Domain",
                    650:                 'ins' => 'Institutional Code',
                    651:                 'inc' => 'Institutional Categorization',
                    652:                 'cow' => "$type Owner/Co-owner",
                    653:                 'cop' => "$type Personnel Includes",
                    654:                 'cog' => 'Type',
1.54      raeburn   655:              );
1.49      raeburn   656: 
1.89      raeburn   657:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    658:         my $typeval = 'Course';
                    659:         if ($type eq 'Community') {
                    660:             $typeval = 'Community';
                    661:         }
                    662:         $typeselectform = '<input type="hidden" name="type" value="'.$typeval.'" />';
                    663:     } else {
                    664:         $typeselectform =  '<select name="type" size="1"';
                    665:         if ($onchange) {
1.105     bisitz    666:             $typeselectform .= ' onchange="'.$onchange.'"';
1.89      raeburn   667:         }
                    668:         $typeselectform .= '>'."\n";
                    669:         foreach my $posstype ('Course','Community') {
                    670:             $typeselectform.='<option value="'.$posstype.'"'.
                    671:                 ($posstype eq $type ? ' selected="selected" ' : ''). ">".&mt($posstype)."</option>\n";
                    672:         }
                    673:         $typeselectform.="</select>";
1.84      raeburn   674:     }
1.85      raeburn   675:     
                    676:     my ($cloneableonlyform,$cloneabletitle);
                    677:     if (exists($filter->{'cloneableonly'})) {
                    678:         my $cloneableon = '';
                    679:         my $cloneableoff = ' checked="checked"';
                    680:         if ($filter->{'cloneableonly'}) {
                    681:             $cloneableon = $cloneableoff;
                    682:             $cloneableoff = '';
                    683:         }
1.86      raeburn   684:         $cloneableonlyform = '<span class="LC_nobreak"><label><input type="radio" name="cloneableonly" value="1" '.$cloneableon.'/>&nbsp;'.&mt('Required').'</label>'.('&nbsp;'x3).'<label><input type="radio" name="cloneableonly" value="" '.$cloneableoff.' />&nbsp;'.&mt('No restriction').'</label></span>';
1.85      raeburn   685:         if ($env{'form.form'} eq 'ccrs') {
                    686:             $cloneabletitle = &mt('Cloneable for').' '.$cloneruname.':'.$clonerudom;
                    687:         } else {
                    688:             $cloneabletitle = &mt('Cloneable by you');
                    689:         }
                    690:     }
1.80      raeburn   691:     my $officialjs;
1.54      raeburn   692:     if ($type eq 'Course') {
1.85      raeburn   693:         if (exists($filter->{'instcodefilter'})) {
                    694:             if (($env{'form.fixeddom'}) || ($formname eq 'requestcrs')
                    695:                 || ($formname eq 'modifycourse')) {
                    696:                 $officialjs = 1;
                    697:                 ($instcodeform,$jscript,$$numtitlesref) = 
1.99      raeburn   698:                     &instcode_selectors($codedom,'filterpicker',$officialjs,$codetitlesref);
1.85      raeburn   699:                 if ($jscript) {
                    700:                     $jscript = '<script type="text/javascript" language="Javascript">'.
                    701:                                $jscript.'</script>'."\n";
                    702:                 }
                    703:             }
                    704:             if ($instcodeform eq '') {
                    705:                 $instcodeform = 
                    706:                     '<input type="text" name="instcodefilter" size="10" value="'.
                    707:                     $list->{'instcodefilter'}.'" />';
                    708:                 $instcodetitle = $lt{'ins'};
                    709:             } else {
                    710:                 $instcodetitle = $lt{'inc'};
                    711:             }
                    712:             if ($env{'form.fixeddom'}) {
                    713:                 $instcodetitle .= '<br />('.$codedom.')';
                    714:             }
1.78      raeburn   715:         }
1.54      raeburn   716:     }
1.84      raeburn   717: 
1.57      raeburn   718:     my $output = qq|
1.85      raeburn   719: <form method="post" name="filterpicker" action="$action">
1.57      raeburn   720: <input type="hidden" name="form" value="$formname" />
                    721: |;
                    722:     if ($formname eq 'modifycourse') {
1.68      raeburn   723:         $output .= '<input type="hidden" name="phase" value="courselist" />'."\n".
                    724:                    '<input type="hidden" name="prevphase" value="'.
                    725:                    $env{'form.prevphase'}.'" />'."\n";
                    726:     } else {
1.57      raeburn   727:         my $name_input;
                    728:         if ($env{'form.cnameelement'} ne '') {
                    729:             $name_input = '<input type="hidden" name="cnameelement" value="'.
                    730:                           $env{'form.cnameelement'}.'" />';
                    731:         }
                    732:         $output .= qq|
1.27      albertel  733: <input type="hidden" name="cnumelement" value="$env{'form.cnumelement'}" />
                    734: <input type="hidden" name="cdomelement" value="$env{'form.cdomelement'}" />
1.13      albertel  735: $name_input
1.18      raeburn   736: $roleelement
1.35      raeburn   737: $multelement
1.90      raeburn   738: $typeelement
1.57      raeburn   739: |;
1.59      raeburn   740:         if ($formname eq 'portform') {
1.78      raeburn   741:             $output .= '<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />'."\n";
1.59      raeburn   742:         }
1.57      raeburn   743:     }
1.78      raeburn   744:     if ($env{'form.fixeddom'}) { 
                    745:         $output .= '<input type="hidden" name="fixeddom" value="'.$env{'form.fixeddom'}.'" />'."\n";
                    746:     }
1.74      bisitz    747:     $output .= "<br />\n".&Apache::lonhtmlcommon::start_pick_box();
1.57      raeburn   748:     if ($sincefilterform) { 
1.74      bisitz    749:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cac'})
                    750:                   .$sincefilterform
                    751:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   752:     }
1.94      raeburn   753:     if ($createdfilterform) {
                    754:         $output .= &Apache::lonhtmlcommon::row_title($lt{'ccr'})
                    755:                   .$createdfilterform
                    756:                   .&Apache::lonhtmlcommon::row_closure();
                    757:     }
1.57      raeburn   758:     if ($domainselectform) {
1.74      bisitz    759:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cdo'})
                    760:                   .$domainselectform
                    761:                   .&Apache::lonhtmlcommon::row_closure();
1.78      raeburn   762:     } 
1.57      raeburn   763:     if ($typeselectform) {
1.89      raeburn   764:         if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    765:             $output .= $typeselectform;
                    766:         } else {
                    767:             $output .= &Apache::lonhtmlcommon::row_title($lt{'cog'})
                    768:                       .$typeselectform
                    769:                       .&Apache::lonhtmlcommon::row_closure();
                    770:         }
1.57      raeburn   771:     }
                    772:     if ($instcodeform) {
1.78      raeburn   773:         $output .= &Apache::lonhtmlcommon::row_title($instcodetitle)
1.74      bisitz    774:                   .$instcodeform
                    775:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   776:     }
                    777:     if (exists($filter->{'ownerfilter'})) {
1.79      raeburn   778:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cow'}).
                    779:                    '<table><tr><td>'.&mt('Username').'<br />'.
                    780:                    '<input type="text" name="ownerfilter" size="20" value="'.
                    781:                    $list->{'ownerfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
                    782:                    $ownerdomselectform.'</td></tr></table>'.
                    783:                    &Apache::lonhtmlcommon::row_closure();
                    784:     }
                    785:     if (exists($filter->{'personfilter'})) {
                    786:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cop'}).
                    787:                    '<table><tr><td>'.&mt('Username').'<br />'.
                    788:                    '<input type="text" name="personfilter" size="20" value="'.
                    789:                    $list->{'personfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
                    790:                    $persondomselectform.'</td></tr></table>'.
                    791:                    &Apache::lonhtmlcommon::row_closure();
1.57      raeburn   792:     }
                    793:     if (exists($filter->{'coursefilter'})) {
1.74      bisitz    794:         $output .= &Apache::lonhtmlcommon::row_title(&mt('LON-CAPA course ID'))
                    795:                   .'<input type="text" name="coursefilter" size="25" value="'
                    796:                   .$list->{'coursefilter'}.'" />'
                    797:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   798:     }
1.85      raeburn   799:     if ($cloneableonlyform) {
                    800:         $output .= &Apache::lonhtmlcommon::row_title($cloneabletitle).
                    801:                    $cloneableonlyform.&Apache::lonhtmlcommon::row_closure();
                    802:     }
1.57      raeburn   803:     if (exists($filter->{'descriptfilter'})) {
1.74      bisitz    804:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cde'})
                    805:                   .'<input type="text" name="descriptfilter" size="40" value="'
                    806:                   .$list->{'descriptfilter'}.'" />'
                    807:                   .&Apache::lonhtmlcommon::row_closure(1);
1.57      raeburn   808:     }
1.85      raeburn   809:     $output .= &Apache::lonhtmlcommon::end_pick_box().'<p>';
1.92      raeburn   810:     my ($coord_cloneable,$warning);
1.85      raeburn   811:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
1.92      raeburn   812:         ($coord_cloneable,$warning) = 
                    813:             &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
                    814:         if ($env{'form.form'} eq 'ccrs') {
                    815:             $output .= '<input type="hidden" name="cloner" value="'.$env{'form.cloner'}.'" />'."\n";
1.85      raeburn   816:         }
1.92      raeburn   817:         if ($coord_cloneable) {
                    818:             $output .= '<input type="hidden" name="cc_clone" value="'.$coord_cloneable.'" />';
1.85      raeburn   819:         }
                    820:     }
1.105     bisitz    821:     $output .= '<input type="hidden" name="updater" value="" />'."\n".
1.84      raeburn   822:                '<input type="submit" name="gosearch" value="'. 
1.70      raeburn   823:                &mt('Search').'" /></p>'."\n".'</form>'."\n".'<hr />'."\n";
1.85      raeburn   824:     return $jscript.$warning.$output;
1.78      raeburn   825: }
                    826: 
1.94      raeburn   827: sub timebased_select_form {
                    828:     my ($item,$filter) = @_;
                    829:     if (ref($filter) eq 'HASH') {
                    830:         $filter->{$item} = $env{'form.'.$item};
                    831:         $filter->{$item} =~ s/[^\d-]//g;
                    832:         if (!$filter->{$item}) { $filter->{$item}=-1; }
                    833:         return &Apache::loncommon::select_form( 
                    834:                             $filter->{$item},
                    835:                             $item,
1.95      raeburn   836:                             {      '-1' => '',
1.94      raeburn   837:                                 '86400' => &mt('today'),
                    838:                                '604800' => &mt('last week'),
                    839:                               '2592000' => &mt('last month'),
                    840:                               '7776000' => &mt('last three months'),
                    841:                              '15552000' => &mt('last six months'),
                    842:                              '31104000' => &mt('last year'),
                    843:                     'select_form_order' =>
                    844:                            ['-1','86400','604800','2592000','7776000',
1.95      raeburn   845:                             '15552000','31104000']});
1.94      raeburn   846:     }
                    847: }
                    848: 
1.92      raeburn   849: sub get_coordinator_cloneable {
                    850:     my ($cloneruname,$clonerudom,$type) = @_;
1.100     www       851:     if (($cloneruname!~/\w/) || ($clonerudom!~/\w/)) {
                    852:         my $warning = '<div class="LC_warning">'.&mt('Intended course owner not specified').
                    853:                    '</div>';
                    854:         return ('',$warning);
                    855:     } elsif (&Apache::lonnet::homeserver($cloneruname,$clonerudom) eq 'no_host') {
1.92      raeburn   856:         my $warning = '<div class="LC_error">'.&mt('Intended course owner does not exist').
                    857:                    '</div>';
                    858:         return ('',$warning);
                    859:     } else {
                    860:         my ($cc_clone,$ccrole);
                    861:         if ($type eq 'Community') {
                    862:             $ccrole = 'co';
                    863:         } elsif ($type eq 'Course') {
                    864:             $ccrole = 'cc';
                    865:         }
                    866:         my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom,
                    867:                                                     'userroles',['active'], [$ccrole]);
                    868:         foreach my $key (sort(keys(%ccroles))) {
                    869:             my ($cnum,$cdom,$role) = split(':',$key);
                    870:             $cc_clone .= $cdom.':'.$cnum.'&';
                    871:         }
                    872:         $cc_clone =~ s/\&$//;
                    873:         return ($cc_clone);
                    874:     }
                    875: }
                    876: 
1.78      raeburn   877: sub instcode_selectors {
1.99      raeburn   878:     my ($codedom,$formname,$officialjs,$codetitles) = @_;
                    879:     my ($output,%cat_titles,%cat_order,%cat_items);
1.78      raeburn   880:     my ($jscript,$totcodes,$numtitles,$lasttitle) =
                    881:         &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
1.99      raeburn   882:                            \%cat_items,$codetitles,\%cat_titles,\%cat_order,$officialjs);
1.78      raeburn   883:     if ($numtitles > 0) {
1.84      raeburn   884:         my $official = ' checked="checked" ';
                    885:         my $unofficial = '';
                    886:         if ($env{'form.official'} eq 'off') {
                    887:             $unofficial = $official;
                    888:             $official = '';
1.80      raeburn   889:         }
                    890:         $output .= '<span class="LC_nobreak">'.&mt('Official course:').'&nbsp;<label>'.
1.84      raeburn   891:                    '<input type="radio" name="official" value="on"'.$official.' />'.
1.80      raeburn   892:                    &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.
1.84      raeburn   893:                    '<input type="radio" name="official" value="off"'.$unofficial.
1.80      raeburn   894:                    ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br />'.
                    895:                    &Apache::courseclassifier::build_instcode_selectors($numtitles,
1.99      raeburn   896:                    $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order)."\n".
1.80      raeburn   897:                    '<input type="hidden" name="numtitles" value="'.$numtitles.'" />'."\n".
                    898:                    '<input type="hidden" name="state" value="listing" />'."\n";
1.78      raeburn   899:  
                    900:     }
                    901:     return ($output,$jscript,$numtitles);
1.54      raeburn   902: }
                    903: 
                    904: sub search_courses {
1.99      raeburn   905:     my ($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner,$codetitles) = @_;
1.89      raeburn   906:     my (%courses,%showcourses,$cloner,$ccrole);
                    907:     if ($type eq 'Community') {
                    908:         $ccrole = 'co';
                    909:     } else {
                    910:         $ccrole = 'cc';
                    911:     }
1.54      raeburn   912:     if (!$onlyown) {
1.106   ! raeburn   913:         $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
1.6       www       914:         $r->rflush();
1.54      raeburn   915:         if (($filter->{'ownerfilter'} ne '') ||
                    916:             ($filter->{'ownerdomfilter'} ne '')) {
                    917:             $filter->{'combownerfilter'} = $filter->{'ownerfilter'}.':'.
                    918:                                            $filter->{'ownerdomfilter'};
                    919:         }
1.80      raeburn   920:         foreach my $item ('descriptfilter','coursefilter','combownerfilter') {
1.54      raeburn   921:             if (!$filter->{$item}) {
                    922:                 $filter->{$item}='.';
                    923:             }
1.52      raeburn   924:         }
1.94      raeburn   925:         my $now = time;
1.54      raeburn   926:         my $timefilter = 
1.94      raeburn   927:            ($filter->{'sincefilter'}==-1?1:$now-$filter->{'sincefilter'});
                    928:         my ($createdbefore,$createdafter);
                    929:         if (($filter->{'createdfilter'} ne '') && ($filter->{'createdfilter'} !=-1)) {
                    930:             $createdbefore = $now;
                    931:             $createdafter = $now-$filter->{'createdfilter'};
                    932:         }
1.78      raeburn   933:         my ($instcodefilter,$regexpok);
                    934:         if ($numtitles) {
1.84      raeburn   935:             if ($env{'form.official'} eq 'on') {
1.80      raeburn   936:                 $instcodefilter = 
1.99      raeburn   937:                     &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles,$codetitles);
1.80      raeburn   938:                 $regexpok = 1;
1.84      raeburn   939:             } elsif ($env{'form.official'} eq 'off') {
1.99      raeburn   940:                 $instcodefilter = &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles,$codetitles);
1.84      raeburn   941:                 unless ($instcodefilter eq '') {
                    942:                     $regexpok = -1;
                    943:                 }
1.80      raeburn   944:             }
1.78      raeburn   945:         } else {
                    946:             $instcodefilter = $filter->{'instcodefilter'};
                    947:         }
1.80      raeburn   948:         if ($instcodefilter eq '') { $instcodefilter = '.'; }
                    949:         if ($type eq '') { $type = '.'; }
1.85      raeburn   950:  
                    951:         if (($clonerudom ne '') && ($cloneruname ne '')) {
                    952:             $cloner = $cloneruname.':'.$clonerudom;  
                    953:         }
1.54      raeburn   954:         %courses = 
                    955:             &Apache::lonnet::courseiddump($filter->{'domainfilter'},
                    956:                                           $filter->{'descriptfilter'},
                    957:                                           $timefilter,
1.78      raeburn   958:                                           $instcodefilter,
1.54      raeburn   959:                                           $filter->{'combownerfilter'},
                    960:                                           $filter->{'coursefilter'},
1.85      raeburn   961:                                           undef,undef,$type,$regexpok,undef,undef,
                    962:                                           undef,undef,$cloner,$env{'form.cc_clone'},
1.94      raeburn   963:                                           $filter->{'cloneableonly'},
1.98      raeburn   964:                                           $createdbefore,$createdafter,undef,
                    965:                                           $domcloner);
1.79      raeburn   966:         if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) {
                    967:             my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'},
                    968:                                                          $filter->{'persondomfilter'},
                    969:                                                          'userroles',undef,
1.89      raeburn   970:                                                          [$ccrole,'in','ad','ep','ta','cr'],
1.79      raeburn   971:                                                          $filter->{'domainfilter'});
                    972:             foreach my $role (keys(%rolehash)) {
                    973:                 my ($cnum,$cdom,$courserole) = split(':',$role);
                    974:                 my $cid = $cdom.'_'.$cnum;
                    975:                 if (exists($courses{$cid})) {
                    976:                     if (ref($courses{$cid}) eq 'HASH') {
                    977:                         if (ref($courses{$cid}{roles}) eq 'ARRAY') {
                    978:                             if (!grep(/^\Q$courserole\E$/,@{$courses{$cid}{roles}})) { 
                    979:                                 push (@{$courses{$cid}{roles}},$courserole);
                    980:                             }
                    981:                         } else {
                    982:                             $courses{$cid}{roles} = [$courserole];
                    983:                         }
                    984:                         $showcourses{$cid} = $courses{$cid};
                    985:                     }
                    986:                 }
                    987:             }
                    988:             %courses = %showcourses;
                    989:         }
1.54      raeburn   990:     } else {
                    991:         $r->print('<br />');
1.60      raeburn   992:         my %coursehash = &Apache::loncommon::findallcourses(); 
                    993:         foreach my $cid (sort(keys(%coursehash))) {
1.65      raeburn   994:             $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'};
1.36      raeburn   995:         }
1.2       www       996:     }
1.54      raeburn   997:     return %courses;
1.18      raeburn   998: }
1.1       www       999: 
1.30      raeburn  1000: sub course_chooser {
1.85      raeburn  1001:     my ($multiple,$cdom,$cnum,$cleandesc,$canclone) = @_;
1.30      raeburn  1002:     my $output; 
1.35      raeburn  1003:     if ($multiple) {
1.32      albertel 1004:         $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
1.85      raeburn  1005:     } elsif ((($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) && (!$canclone))  {
                   1006:         if ($env{'form.form'} eq 'ccrs') {
                   1007:             $output = &mt('No cloning for ').$env{'form.cloner'}."\n";
                   1008:         } else {
                   1009:             $output = &mt('No rights to clone')."\n";
                   1010:         }
1.30      raeburn  1011:     } else {
1.71      bisitz   1012:         $output = '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
1.30      raeburn  1013:                   "'".$cnum."','".$cdom."','".$cleandesc."')".'" />'."\n";
                   1014:     }
                   1015:     return $output;
1.49      raeburn  1016: }
                   1017: 
1.55      raeburn  1018: sub gochoose_javascript {
1.57      raeburn  1019:     my ($type,$multiple,$autosubmit,$lastaction) = @_;
1.55      raeburn  1020:     my %elements = (
                   1021:                      'Course' => {
                   1022:                                  name  => 'coursepick',
                   1023:                                  total => 'coursetotal',
                   1024:                                  list  => 'courselist',
                   1025:                                  },
1.83      raeburn  1026:                      'Community' => {
1.88      raeburn  1027:                                  name  => 'coursepick',
                   1028:                                  total => 'coursetotal',
                   1029:                                  list  => 'courselist',
1.55      raeburn  1030:                               },
                   1031:                     );
1.57      raeburn  1032:     my $output .= qq|
                   1033: function gochoose(cname,cdom,cdesc) {
1.55      raeburn  1034:     var openerForm = "$env{'form.form'}";
                   1035:     courseCount = 0;
                   1036:     var courses = '';
1.57      raeburn  1037: |;
                   1038:     if ($multiple) {
                   1039:         $output .= <<"ENDSCRIPT";
                   1040:     courseCount = 0;
                   1041:     var courses = '';
                   1042:     if (typeof(document.courselist.course_id.length) == 'undefined') {
                   1043:         // only 1 course checkbox was created
                   1044:         if (document.courselist.course_id.checked) {
                   1045:             courses = courses + document.courselist.course_id.value + "&&";
                   1046:             courseCount ++;
                   1047:         }
                   1048:     } else {
                   1049:         for (var j=0; j<document.courselist.course_id.length; j++) {
                   1050:             if (document.courselist.course_id[j].checked) {
                   1051:                 courses = courses + document.courselist.course_id[j].value + "&&";
1.55      raeburn  1052:                 courseCount ++;
                   1053:             }
1.57      raeburn  1054:         }
                   1055:     }
                   1056:     opener.document.$env{'form.form'}.$elements{$type}{'total'}.value = courseCount;
                   1057:     if (typeof(opener.document.$env{'form.form'}.$elements{$type}{'name'}.length) ==
                   1058:         'undefined') {
                   1059:         if (opener.document.$env{'form.form'}.$elements{$type}{'name'}.value == 'specific') {
                   1060:             opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = true;
1.55      raeburn  1061:         } else {
1.57      raeburn  1062:             opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = false;
1.55      raeburn  1063:         }
1.57      raeburn  1064:     } else {
                   1065:         for (var j=0; j<opener.document.$env{'form.form'}.$elements{$type}{'name'}.length; j++) {
                   1066:             if (opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].value == 'specific') {
                   1067:                 opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = true;
1.55      raeburn  1068:             } else {
1.57      raeburn  1069:                 opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = false;
1.54      raeburn  1070:             }
1.55      raeburn  1071:         }
1.57      raeburn  1072:     }
                   1073:     if (courseCount > 0) {
                   1074:         courses = courses.substr(0,courses.length-2);
                   1075:         opener.document.$env{'form.form'}.$elements{$type}{'list'}.value = courses;
                   1076:     }
                   1077: ENDSCRIPT
                   1078:     } else {
1.90      raeburn  1079:         my ($name_code,$type_code);
1.57      raeburn  1080:         if ($env{'form.cnameelement'} ne '') {
1.103     raeburn  1081:             $name_code = <<ENDNAMECODE;  
                   1082: var showcdesc = cdesc;
                   1083: if (cdesc.length > 25) {
                   1084:     showcdesc = cdesc.substr(0,25)+' ...'; 
                   1085: }
                   1086: opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=showcdesc;
                   1087: ENDNAMECODE
1.55      raeburn  1088:         }
1.90      raeburn  1089:         if ($env{'form.typeelement'} ne '') {
                   1090:             $type_code = 'opener.document.'.$env{'form.form'}.'.'.
                   1091:                           $env{'form.typeelement'}.'.value=document.courselist.type;';
                   1092:         }
                   1093: 
1.57      raeburn  1094:         $output .= qq|
1.55      raeburn  1095:         $name_code
1.90      raeburn  1096:         $type_code
1.55      raeburn  1097:         opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
                   1098:         var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
                   1099:         if (slct.options == undefined) {
                   1100:             opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
                   1101:         }
                   1102:         else {
                   1103:             var i;
                   1104:             for (i=0;i<slct.length;i++) {
                   1105:                 if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
1.54      raeburn  1106:             }
                   1107:         }
1.57      raeburn  1108: |;
1.54      raeburn  1109:     }
1.57      raeburn  1110:     $output .= qq|
1.55      raeburn  1111:     if (openerForm == 'portform') {
                   1112:         document.courselist.cnum.value = cname;
                   1113:         document.courselist.cdom.value = cdom;
                   1114:     }
                   1115:     $autosubmit
                   1116:     $lastaction
1.54      raeburn  1117: }
1.57      raeburn  1118: |;
1.105     bisitz   1119:     return &Apache::lonhtmlcommon::scripttag($output);
1.54      raeburn  1120: }
                   1121: 
1.55      raeburn  1122: 1;
                   1123: __END__
                   1124: 
                   1125: =pod
                   1126: 
                   1127: =head1 NAME
                   1128: 
                   1129: Apache::lonpickcourse - Search for course(s) based on user-specified criteria.   
                   1130: 
                   1131: =head1 SYNOPSIS
                   1132: 
                   1133: Invoked by other LON-CAPA modules, when course(s) need to be selected by the user. 
                   1134: 
                   1135: =head1 OVERVIEW
                   1136: 
                   1137: Two screens are typically displayed to the user.  The first is a set of criteria which are used to constrain the search for courses.
                   1138: 
                   1139: =head2 Search Criteria (Screen One)
                   1140: 
                   1141: =head3 Criteria:
                   1142: 
                   1143: =over 4
                   1144: 
                   1145: =item *
                   1146: Course Activity - how recently was course last visited by anyone.
                   1147: 
                   1148: =item *
                   1149: Course Domain - the domain of the course
                   1150: 
                   1151: =item *
1.84      raeburn  1152: Type - Course or Community
1.55      raeburn  1153: 
                   1154: =item *
                   1155: Course Institutional Code - the institutional identifier assigned to the course
                   1156: 
                   1157: =item * 
                   1158: Course Owner's Username - the username of the owner of the course (assigned by the Domain Coordinator and/or when the course was created).
                   1159: 
                   1160: =item *
                   1161: Course Owner's Domain - the domain of the owner of the course
                   1162: 
                   1163: =item * 
1.76      bisitz   1164: Course Title - text which appears in the Course Title, as set in the Course Parameters.
1.55      raeburn  1165: 
                   1166: =item *
                   1167: Course ID - the internal course number (course ID part after initial 'domain_') used by LON-CAPA (this criterion is only displayed to Domain Coordinators selecting a course in the same domain as their DC role).
                   1168: 
                   1169: =back
                   1170: 
                   1171: The criteria setting screen is not displayed if course picking is done by a user who does not have advanced privileges (as defined by $env{'user.adv'}).
                   1172: 
                   1173: =head2 Course Display (Screen Two)
                   1174: 
                   1175: A list of courses matching the search criteria is displayed.  If the user is not an advanced user, screen one will have been skipped and the courses displayed will be all courses in which the user has currently active roles. The information displayed for each course is:
                   1176: 
                   1177: =over 4
                   1178: 
                   1179: =item *
                   1180: Course description
                   1181: 
                   1182: =item *
                   1183: Domain description of course domain
                   1184: 
                   1185: =item *
                   1186: Course institutional code
                   1187: 
                   1188: =item * 
                   1189: Course owner (username:domain)   
                   1190:  
                   1191: =back
                   1192: 
                   1193: Depending on context, the display may include a single select box for each course, allowing selection of only a single course, or may include checkboxes allowing selection of more than one course.
                   1194: 
                   1195: Following selection, and/or submission, the course description, number and domain are transferred to the browser window from which the course picker window was opened.  In most cases, the child window containing the course picker screens will be closed.  However, in some cases closure will be delayed until a third screen has been displayed (e.g., setting of course-based conditional access controls for portfolio files).  In this case the page is generated via /adm/portfolio and the page features select boxes to allow the user to select roles, access types, sections and groups.
                   1196: 
                   1197: =head1 SUBROUTINES
                   1198: 
                   1199: =over 4
                   1200: 
                   1201: =item *
                   1202: X<create_user_javascript()>
                   1203: B<create_user_javascript($type)>:
                   1204: 
1.83      raeburn  1205: Input: 1 - $type  - the course type - Course or Community
1.55      raeburn  1206: 
                   1207: Output: 1 - $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags 
                   1208: 
                   1209: Side Effects: None 
                   1210: 
                   1211: javascript code for reporting selected sections (as a string of comma separated sections) and groups in the selected course (as a comma separated list) then calling setSect() javscript function in the opener window (to populate section select box) then closing current window.
                   1212: 
                   1213: 
                   1214: =item *
                   1215: X<display_matched_courses()>
1.85      raeburn  1216: B<display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,%courses)>:
1.55      raeburn  1217: 
1.85      raeburn  1218: Input: 7 - request object, course type, multiple (0 or 1), form action, whether to show roles (for course personnel filter), username of new course owner, domain of new course owner, hash of courses.
1.55      raeburn  1219: 
                   1220: Output: 0
                   1221: 
                   1222: Side Effects: prints select buttons (multiple = 0) or checkboxes (multiple = 1) and hidden form elements for selection of one or more courses which met search criteria.
                   1223: 
                   1224: =item *
                   1225: X<multiples_tag()>
                   1226: B<multiples_tag()>:
                   1227: 
                   1228: 
                   1229: Input: 0
                   1230: 
                   1231: Output: 2 - $jscript - javascript for check all/uncheck all checkboxes; $multelement - hidden form element with multiple set to 1.
                   1232: 
                   1233: Side Effects: None
                   1234: 
                   1235: =item *
                   1236: X<build_filters()>
1.99      raeburn  1237: B<build_filters($filterlist,$type,$roleelement,$multelement,$filter,$action,$numfiltersref,$caller,$cloneruname,$clonerudom,$typeelem,$codetitlesref>:
1.55      raeburn  1238: 
                   1239: 
1.99      raeburn  1240: Input: 12 - anonymous array of search criteria; course type; $roleelement ; $multelement ; anonymous hash of criteria and their values; form action; ref to scalar (count of number of elements in institutional codes -- e.g., 4 for year, semester, department, and number); caller context (e.g., set to 'modifycourse' when routine is called from lonmodifycourse.pm); username and domain of new course owner who wants to clone, $typeelem; reference to array of titles of components in institutional codes (official courses). 
1.55      raeburn  1241: 
                   1242: Output: 1 - $output - HTML for display of search criteria, and hidden form elements. 
                   1243: 
                   1244: Side Effects: None
                   1245: 
                   1246: =item *
                   1247: X<search_courses()>
1.98      raeburn  1248: B<search_courses($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,
1.99      raeburn  1249:                  $domcloner,$codetitles)>:
1.55      raeburn  1250: 
                   1251: 
1.99      raeburn  1252: Input: 9 -  request object, course type, search scope: only courses in which user has active role (1), or any course (0); anonymous hash of criteria and their values; for institutional codes - number of categories; optional username of new course owner, optional domain of new course owner). Seventh and eighth needed when search is for courses to clone from course request form, or course creation form (DC). Optional "domcloner" flag (has value=1 if user has ccc priv in  
                   1253: domain being filtered by (used when DC is using course creation form). Ninth is reference to array of titles of components in institutional codes (official courses).
1.55      raeburn  1254: 
                   1255: Output: 1 - %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type.
                   1256: 
                   1257: Side Effects: None
                   1258: 
                   1259: 
                   1260: =item *
                   1261: X<course_chooser()>
1.85      raeburn  1262: B<course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone)>:
1.55      raeburn  1263: 
1.85      raeburn  1264: Input: 5 - single (0) or multiple (1) courses; course domain, course number; course description; can clone course (1 if new course owner has cloning rights). 
1.55      raeburn  1265: 
1.85      raeburn  1266: Output: 1 - HTML for either checkbox (multiple=1) or select button (multiple=0) for user to indicate course selection.
1.55      raeburn  1267: 
                   1268: Side Effects: None
                   1269: 
                   1270: 
                   1271: =item *
                   1272: X<gochoose_javascript()>
1.57      raeburn  1273: B<gochoose_javascript($type,$multiple,$autosubmit,$lastaction)>:
1.55      raeburn  1274: 
1.66      raeburn  1275: Input: 4 - course type; single (0) or multiple courses (1); in context of DC selecting a CC role in a course: javascript code from &processpick(); final action to take after user chooses course(s):  either close window, or submit form for display of next page etc.
1.55      raeburn  1276: 
                   1277: Output: 1  $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
                   1278: 
                   1279: Side Effects: None
                   1280: 
                   1281: javascript functions used when user selects a course(s). Different behavior depending on context:
                   1282: 
                   1283: =back
                   1284: 
                   1285: =over 8
                   1286: 
                   1287: =item
                   1288: 
                   1289: (a) Domain Coordinator using MAIL to select recipients of broadcast e-mail - && separated list of selected courses written to hidden form element in opener window. Child window closes.
                   1290: 
                   1291: =item
                   1292: 
                   1293: (b) Domain Coordinator choosing a course for adoption of a CC role from roles screen - write course identifying information to hidden form elements in opener window and automatically submit role selection form in opener window. Child window closes.
                   1294: 
                   1295: =item
                   1296: 
                   1297: (c) Domain Coordinator creating a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
                   1298: 
                   1299: =item
1.54      raeburn  1300: 
1.55      raeburn  1301: (d) User selecting a course for course-based conditional access control for a portfolio file - form is submitted, and new page is displayed for selection of roles, access types, sections and groups to be used in conditional ACL. New page is generated by /adm/portfolio. 
1.54      raeburn  1302: 
1.55      raeburn  1303: =item
1.54      raeburn  1304: 
1.55      raeburn  1305: (e) Domain Coordinator assigning a role to a user - form is submitted, and new page does an onload call to a javascript function to (a) write lists of sections and groups to hidden elements in opener window, (b) call function in opener window to dynamically populate select box showing current sections.
1.54      raeburn  1306: 
1.55      raeburn  1307: =item
1.54      raeburn  1308: 
1.55      raeburn  1309: (f) Author modifying a rights entry in a .rights file - selected course number and domain are witten to visible form elements in opener window.  Child window closes. 
1.54      raeburn  1310: 
1.55      raeburn  1311: =item
1.49      raeburn  1312: 
1.102     bisitz   1313: (g) Bubblesheet Scanning Operator uploading a bubblesheet file to a course - course number is written to visible form element in opener window. Child window closes.
1.30      raeburn  1314: 
1.84      raeburn  1315: =item
                   1316: 
                   1317: (h) User requesting creation of a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
                   1318: 
1.55      raeburn  1319: =back
                   1320:      
                   1321: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>