--- loncom/interface/lonpickcourse.pm 2004/11/30 00:21:24 1.21 +++ loncom/interface/lonpickcourse.pm 2005/09/14 20:42:36 1.29 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.21 2004/11/30 00:21:24 raeburn Exp $ +# $Id: lonpickcourse.pm,v 1.29 2005/09/14 20:42:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,8 +42,9 @@ sub handler { return OK if $r->header_only; # ------------------------------------------------------------ Print the screen + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network with CAPA @@ -53,27 +54,40 @@ ENDDOCUMENT ($ENV{'QUERY_STRING'},['domainfilter','descriptfilter', 'sincefilter','form','cnumelement', 'cdomelement','cnameelement','roleelement', - 'pickedcourse','instcodefilter','ownerfilter']); + 'pickedcourse','instcodefilter', + 'ownerfilter','coursefilter']); # domain filter and selection - my $domainfilter=$ENV{'form.domainfilter'}; + my $domainfilter=$env{'form.domainfilter'}; $domainfilter=~s/\W//g; unless ($domainfilter) { $domainfilter=''; } my $domainselectform=&Apache::loncommon::select_dom_form($domainfilter, 'domainfilter',1); # description filter - my $descriptfilter=$ENV{'form.descriptfilter'}; + my $descriptfilter=$env{'form.descriptfilter'}; unless ($descriptfilter) { $descriptfilter=''; } my $listdescript=&HTML::Entities::encode($descriptfilter,'<>&"'); # institutional code filter - my $instcodefilter=$ENV{'form.instcodefilter'}; + my $instcodefilter=$env{'form.instcodefilter'}; unless ($instcodefilter) { $instcodefilter=''; } my $listinstcode=&HTML::Entities::encode($instcodefilter,'<>&"'); # course owner filter - my $ownerfilter=$ENV{'form.ownerfilter'}; + my $ownerfilter=$env{'form.ownerfilter'}; unless ($ownerfilter) { $ownerfilter=''; } my $listowner=&HTML::Entities::encode($ownerfilter,'<>&"'); +# course ID filter for DCs only + my ($courseidtag,$coursefilter); + if ($env{'user.adv'} && $domainfilter && exists($env{'user.role.dc./'. + $domainfilter.'/'})) { + $coursefilter=$env{'form.coursefilter'}; + unless ($coursefilter) { $coursefilter=''; } + my $listcourseid=&HTML::Entities::encode($coursefilter,'<>&"'); + $courseidtag = &mt('LON-CAPA course ID'); + $courseidtag .= qq| +
+ |; + } # last course activity filter and selection - my $sincefilter=$ENV{'form.sincefilter'}; + my $sincefilter=$env{'form.sincefilter'}; $sincefilter=~s/[^\d-]//g; unless ($sincefilter) { $sincefilter=-1; } my $sincefilterform=&Apache::loncommon::select_form($sincefilter, @@ -90,9 +104,9 @@ ENDDOCUMENT # if called from loncreateuser, report sections, then close my ($loaditem,$seclist); my $num_sections = 0; - if ($ENV{'form.form'} eq 'cu' && $ENV{'form.pickedcourse'}) { + if ($env{'form.form'} eq 'cu' && $env{'form.pickedcourse'}) { $loaditem = 'onLoad="setSections()"'; - my ($cdom,$cnum) = split/_/,$ENV{'form.pickedcourse'}; + my ($cdom,$cnum) = split/_/,$env{'form.pickedcourse'}; my %sections_count = (); $num_sections = &Apache::loncommon::get_sections($cdom,$cnum,\%sections_count); my @sections = (); @@ -101,7 +115,7 @@ ENDDOCUMENT $seclist = join('","',@sections); } } - $r->print(&Apache::loncommon::bodytag("Selecting a Course",undef,$loaditem)); + $r->print(&Apache::loncommon::bodytag("Selecting a Course",undef,$loaditem,undef,undef,undef,undef,1)); my %lt=&Apache::lonlocal::texthash( 'cac' => 'Course Activity', 'cde' => 'Course Description', @@ -109,20 +123,20 @@ ENDDOCUMENT 'cin' => 'Course Institutional Code', 'cow' => "Course Owner's usename"); my ($name_code,$name_input); - if (defined($ENV{'form.cnameelement'}) && $ENV{'form.cnameelement'} ne '') { - $name_code = "opener.document.$ENV{'form.form'}.$ENV{'form.cnameelement'}.value=cdesc;"; + if (defined($env{'form.cnameelement'}) && $env{'form.cnameelement'} ne '') { + $name_code = "opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=cdesc;"; $name_input =''; + $env{'form.cnameelement'}.'" />'; } my $submitopener = ''; my $autosubmit = ''; my $roleelement = ''; my $lastaction = 'self.close()'; - if ($ENV{'form.form'} eq 'cu') { + if ($env{'form.form'} eq 'cu') { $lastaction = 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n". 'document.courselist.submit();'; } - my $roledom = $ENV{'form.roleelement'}; + my $roledom = $env{'form.roleelement'}; if ($roledom) { $roleelement = ''; $submitopener = &Apache::lonroles::processpick($roledom); @@ -132,13 +146,13 @@ ENDDOCUMENT $submitopener
- - + + $name_input - + $roleelement $lt{'cac'}: $sincefilterform
@@ -188,6 +213,7 @@ $lt{'cin'}: $lt{'cow'}:
+$courseidtag $lt{'cde'}:

@@ -195,16 +221,17 @@ $lt{'cde'}:
ENDSCRIPT # ---------------------------------------------------------------- Get the data - if ($ENV{'form.gosearch'}) { + if ($env{'form.gosearch'}) { $r->print(&mt('Searching').' ...
 
'); $r->rflush(); unless ($descriptfilter) { $descriptfilter='.'; } unless ($instcodefilter) { $instcodefilter='.'; } unless ($ownerfilter) { $ownerfilter='.'; } + unless ($coursefilter) { $coursefilter='.'; } my $timefilter=($sincefilter==-1?1:time-$sincefilter); my %courses= &Apache::lonnet::courseiddump - ($domainfilter,$descriptfilter,$timefilter,$instcodefilter,$ownerfilter); + ($domainfilter,$descriptfilter,$timefilter,$instcodefilter,$ownerfilter,$coursefilter); $r->print(''); my %by_descrip; foreach my $course (keys %courses) { @@ -214,24 +241,33 @@ ENDSCRIPT } else { $descr = &Apache::lonnet::unescape($courses{$course}); } - $by_descrip{lc($descr)}=$course; + my $description = lc($descr); + push (@{$by_descrip{$description}}, $course); } foreach my $description (sort(keys(%by_descrip))) { - my $course=$by_descrip{$description}; - my $cleandesc=&HTML::Entities::encode($description,'<>&"'); - $cleandesc=~s/'/\\'/g; - my ($cdom,$cnum)=split(/\_/,$course); - $r->print(' '.$description.' ('. - ($Apache::lonnet::domaindescription{$cdom}? - $Apache::lonnet::domaindescription{$cdom}:$cdom). - ")
\n"); + foreach my $course (@{$by_descrip{$description}}) { + my $cleandesc=&HTML::Entities::encode($description,'<>&"'); + $cleandesc=~s/'/\\'/g; + my ($cdom,$cnum)=split(/\_/,$course); + my ($descr,$instcode,$owner) = split/:/,$courses{$course}; + $r->print(' '.$description.' ('. + ($Apache::lonnet::domaindescription{$cdom}? + $Apache::lonnet::domaindescription{$cdom}:$cdom).")"); + unless ($instcode eq '') { + $r->print(" - ".&Apache::lonnet::unescape($instcode)); + } + unless ($owner eq '') { + $r->print(", owner - ".&Apache::lonnet::unescape($owner)); + } + $r->print("
\n"); + } } if (!%courses) { $r->print(&mt('None found')); } - $r->print(''."\n". + $r->print(''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". '
'); } $r->print('');