--- loncom/interface/lonpickcourse.pm 2009/05/04 13:24:12 1.79 +++ loncom/interface/lonpickcourse.pm 2009/07/29 22:32:44 1.84 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.79 2009/05/04 13:24:12 raeburn Exp $ +# $Id: lonpickcourse.pm,v 1.84 2009/07/29 22:32:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,22 +51,21 @@ sub handler { ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement', 'cdomelement','cnameelement','roleelement', 'multiple','type','setroles','fixeddom']); - my ($type,$title,$jscript,$multelement,$multiple,$roleelement, $lastaction,$autosubmit,$submitopener); - # Get course type - Course or Non-standard Course. + # Get course type - Course or Community. $type = $env{'form.type'}; if (!defined($env{'form.type'})) { $type = 'Course'; } - $title = &mt('Selecting a [_1]',$type); + $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 = &mt('Selecting [_1](s)',lc($type)); + $title = 'Selecting '.$type.'(s)'; } # if called when a DC is selecting a course @@ -84,8 +83,10 @@ sub handler { } my %loaditem; - if ($env{'form.numtitles'}) { - $loaditem{'onload'} = 'setElements(); '; + if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) { + if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) { + $loaditem{'onload'} = 'setElements(document.filterpicker); '; + } } if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && @@ -113,7 +114,7 @@ sub handler { } # print javascript functions for choosing a course - if ($env{'form.gosearch'} || $onlyown) { + if (($env{'form.command'} eq 'gosearch') || $onlyown) { $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction)); } $r->print(''."\n"; - } } - foreach my $posstype ('Course','Non-standard Course') { + $jscript .= <<"END_JS"; + +function setCommand() { + document.filterpicker.command.value = 'gosearch'; + return; +} + +END_JS + + $jscript = ''."\n"; + + foreach my $posstype ('Course','Community') { $typeselectform.='\n"; } $typeselectform.=""; my $output = qq| -
+ |; if ($formname eq 'modifycourse') { @@ -625,22 +646,34 @@ $multelement .&Apache::lonhtmlcommon::row_closure(1); } $output .= &Apache::lonhtmlcommon::end_pick_box(); - $output .= '

'."\n". + '

'."\n".'
'."\n".'
'."\n"; return $jscript.$output; } sub instcode_selectors { - my ($codedom,$formname) = @_; + my ($codedom,$formname,$officialjs) = @_; my ($output,@codetitles,%cat_titles,%cat_order,%cat_items); my ($jscript,$totcodes,$numtitles,$lasttitle) = &Apache::courseclassifier::instcode_selectors_data($codedom,$formname, - \%cat_items,\@codetitles,\%cat_titles,\%cat_order); + \%cat_items,\@codetitles,\%cat_titles,\%cat_order,$officialjs); if ($numtitles > 0) { - $output = &Apache::courseclassifier::build_instcode_selectors($numtitles, - $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order)."\n". - ''."\n". - ''."\n"; + my $official = ' checked="checked" '; + my $unofficial = ''; + if ($env{'form.official'} eq 'off') { + $unofficial = $official; + $official = ''; + } + $output .= ''.&mt('Official course:').' '.(' 'x3).'
'. + &Apache::courseclassifier::build_instcode_selectors($numtitles, + $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order)."\n". + ''."\n". + ''."\n"; } return ($output,$jscript,$numtitles); @@ -657,24 +690,30 @@ sub search_courses { $filter->{'combownerfilter'} = $filter->{'ownerfilter'}.':'. $filter->{'ownerdomfilter'}; } - foreach my $item ('descriptfilter','instcodefilter','coursefilter', - 'combownerfilter') { + foreach my $item ('descriptfilter','coursefilter','combownerfilter') { if (!$filter->{$item}) { $filter->{$item}='.'; } } - if ($type eq '') { $type = '.'; } my $timefilter = ($filter->{'sincefilter'}==-1?1:time-$filter->{'sincefilter'}); my ($instcodefilter,$regexpok); if ($numtitles) { - $instcodefilter = - &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'}, - $numtitles); - $regexpok = 1; + if ($env{'form.official'} eq 'on') { + $instcodefilter = + &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles); + $regexpok = 1; + } elsif ($env{'form.official'} eq 'off') { + $instcodefilter = &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles); + unless ($instcodefilter eq '') { + $regexpok = -1; + } + } } else { $instcodefilter = $filter->{'instcodefilter'}; } + if ($instcodefilter eq '') { $instcodefilter = '.'; } + if ($type eq '') { $type = '.'; } %courses = &Apache::lonnet::courseiddump($filter->{'domainfilter'}, $filter->{'descriptfilter'}, @@ -737,7 +776,7 @@ sub gochoose_javascript { total => 'coursetotal', list => 'courselist', }, - 'Non-standard Course' => { + 'Community' => { name => 'grouppick', total => 'grouptotal', list => 'grouplist', @@ -854,7 +893,7 @@ Course Activity - how recently was cours Course Domain - the domain of the course =item * -Course Type - Course or Non-standard Course +Type - Course or Community =item * Course Institutional Code - the institutional identifier assigned to the course @@ -907,7 +946,7 @@ Following selection, and/or submission, X B: -Input: 1 - $type - the course type - Course or Non-standard Course +Input: 1 - $type - the course type - Course or Community Output: 1 - $output - javascript wrapped in EscriptEE/scriptE tags @@ -939,10 +978,10 @@ Side Effects: None =item * X -B: +B: -Input: 7 - 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). +Input: 7 - 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). Output: 1 - $output - HTML for display of search criteria, and hidden form elements. @@ -1015,6 +1054,10 @@ javascript functions used when user sele (g) Scantron Operator uploading a scantron file to a course - course number is written to visible form element in opener window. Child window closes. +=item + +(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. + =back =cut