--- loncom/interface/lonpickcourse.pm 2006/11/13 20:50:57 1.56 +++ loncom/interface/lonpickcourse.pm 2006/11/14 16:51:42 1.57 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.56 2006/11/13 20:50:57 albertel Exp $ +# $Id: lonpickcourse.pm,v 1.57 2006/11/14 16:51:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,7 +55,7 @@ sub handler { my ($type,$title,$jscript,$multelement,$multiple,$roleelement, $lastaction,$autosubmit,$submitopener); - # Get course type - Course or Non-standard course. + # Get course type - Course or Non-standard Course. $type = $env{'form.type'}; if (!defined($env{'form.type'})) { $type = 'Course'; @@ -114,7 +114,8 @@ sub handler { $r->print($submitopener); # ------------------------------------------ Display of filters to limit search - my (%filter,%list); + my $filter = {}; + my $action = '/adm/pickcourse'; if (!$onlyown) { my $filterlist = ['domainfilter','descriptfilter', 'instcodefilter','ownerfilter', @@ -125,13 +126,13 @@ sub handler { push(@{$filterlist},'coursefilter'); } $r->print(&build_filters($filterlist,$type,$roleelement,$multelement, - \%filter,\%list)); + $filter,$action)); } # ---------------------------------------------------------------- Get the data if ($env{'form.gosearch'} || $onlyown) { - my %courses = &search_courses($r,$type,$onlyown,\%filter); - &display_matched_courses($r,$type,$multiple,%courses); + my %courses = &search_courses($r,$type,$onlyown,$filter); + &display_matched_courses($r,$type,$multiple,$action,%courses); } $r->print(&Apache::loncommon::end_page()); return OK; @@ -166,8 +167,7 @@ function setSections() { } sub display_matched_courses { - my ($r,$type,$multiple,%courses) = @_; - my $action = '/adm/pickcourse'; + my ($r,$type,$multiple,$action,%courses) = @_; if ($env{'form.form'} eq 'portform') { $action = '/adm/portfolio'; } @@ -217,12 +217,10 @@ sub display_matched_courses { if (!%courses) { $r->print(&mt('None found')); } elsif ($multiple) { - $r->print(''); + $r->print(''); } $r->print(''. "\n".''."\n". - ''."\n". - ''."\n". ''."\n"); if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) { $r->print(''); $r->print(''); $r->print(''); + } elsif ($env{'form.form'} eq 'modifycourse') { + $r->print(''."\n"); + $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form'])); + } else { + $r->print(''."\n". + ''."\n"); } $r->print("\n"); return; @@ -246,8 +252,15 @@ sub multiples_tag { } sub build_filters { - my ($filterlist,$type,$roleelement,$multelement,$filter) = @_; + my ($filterlist,$type,$roleelement,$multelement,$filter,$action, + $caller) = @_; my $list; + my $formname; + if (defined($env{'form.form'})) { + $formname = $env{'form.form'}; + } else { + $formname = $caller; + } my ($domainselectform,$sincefilterform,$ownerdomselectform, $instcodeform,$typeselectform); foreach my $item (@{$filterlist}) { @@ -298,51 +311,68 @@ sub build_filters { $typeselectform = ''; } - foreach my $posstype ('Course','Non-standard course') { + foreach my $posstype ('Course','Non-standard Course') { $typeselectform.='\n"; } $typeselectform.=""; - my $name_input; - if ($env{'form.cnameelement'} ne '') { - $name_input =''; - } - my $courseidtag; - if (exists($filter->{'coursefilter'})) { - $courseidtag=&mt('LON-CAPA course ID'). - ':
'; - } - my $output = <<"END"; -
+ my $output = qq| + + +|; + if ($formname eq 'modifycourse') { + $output .= ''; + } else { + my $name_input; + if ($env{'form.cnameelement'} ne '') { + $name_input = ''; + } + $output .= qq| $name_input - $roleelement $multelement -$lt{'cac'}: $sincefilterform -
-$lt{'cdo'}: $domainselectform -
-$lt{'cog'}: $typeselectform -
-$instcodeform -$lt{'cow'}: - -
-$lt{'cod'}: $ownerdomselectform -
-$courseidtag -$lt{'cde'}: - +|; + } + if ($sincefilterform) { + $output .= $lt{'cac'}.': '.$sincefilterform.'
'."\n"; + } + if ($domainselectform) { + $output .= $lt{'cdo'}.': '.$domainselectform.'
'."\n"; + } + if ($typeselectform) { + $output .= $lt{'cog'}.': '.$typeselectform.'
'."\n"; + } + if ($instcodeform) { + $output .= $lt{'cin'}.': '.$instcodeform.'
'."\n"; + } + if (exists($filter->{'ownerfilter'})) { + $output .= $lt{'cow'}.': '. + '
'."\n". + $lt{'cod'}.': '.$ownerdomselectform.'
'."\n"; + } + if (exists($filter->{'coursefilter'})) { + $output .= &mt('LON-CAPA course ID').': '. + '
'; + } + if (exists($filter->{'descriptfilter'})) { + $output .=$lt{'cde'}.': '. + ''."\n"; + } + $output .= qq|


-END +|; return $output; } @@ -396,67 +426,73 @@ sub course_chooser { } sub gochoose_javascript { - my ($type,$autosubmit,$lastaction) = @_; + my ($type,$multiple,$autosubmit,$lastaction) = @_; my %elements = ( 'Course' => { name => 'coursepick', total => 'coursetotal', list => 'courselist', }, - 'Non-standard course' => { + 'Non-standard Course' => { name => 'grouppick', total => 'grouptotal', list => 'grouplist', }, ); - my $name_code; - if ($env{'form.cnameelement'} ne '') { - $name_code = 'opener.document.'.$env{'form.form'}.'.'. - $env{'form.cnameelement'}.'.value=cdesc;'; - } - my $output .= <<"ENDSCRIPT"; + my $output .= qq| -ENDSCRIPT +|; return $output; } @@ -512,7 +550,7 @@ Course Activity - how recently was cours Course Domain - the domain of the course =item * -Course Type - Course or Non-standard course +Course Type - Course or Non-standard Course =item * Course Institutional Code - the institutional identifier assigned to the course @@ -565,7 +603,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 Non-standard Course Output: 1 - $output - javascript wrapped in EscriptEE/scriptE tags @@ -576,9 +614,9 @@ javascript code for reporting selected s =item * X -B: +B: -Input: 4 - request object, course type, multiple (0 or 1), hash of courses. +Input: 5 - request object, course type, multiple (0 or 1), form action; hash of courses. Output: 0 @@ -597,10 +635,10 @@ Side Effects: None =item * X -B: +B: -Input: 5 - anonymous array of search criteria; course type; $roleelement ; $multelement ; anonymous hash of criteria and their values. +Input: 6 - anonymous array of search criteria; course type; $roleelement ; $multelement ; anonymous hash of criteria and their values; form action. Output: 1 - $output - HTML for display of search criteria, and hidden form elements. @@ -631,9 +669,9 @@ Side Effects: None =item * X -B: +B: -Input: 3 - course type; in context of DC selecting a CC role in a course: javascript code from Apache::lonroles::processpick(); final action to take after user chooses course(s): either close window, or submit form for display of next page etc. +Input: 4 - course type; single (0) or multiple courses (1); in context of DC selecting a CC role in a course: javascript code from Apache::lonroles::processpick(); final action to take after user chooses course(s): either close window, or submit form for display of next page etc. Output: 1 $output - javascript wrapped in EscriptEE/scriptE tags