--- loncom/interface/lonpickcourse.pm 2009/10/31 14:27:48 1.88 +++ loncom/interface/lonpickcourse.pm 2009/12/02 18:33:27 1.91 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a course # -# $Id: lonpickcourse.pm,v 1.88 2009/10/31 14:27:48 raeburn Exp $ +# $Id: lonpickcourse.pm,v 1.91 2009/12/02 18:33:27 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,7 +51,7 @@ sub handler { ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement', 'cdomelement','cnameelement','roleelement', 'multiple','type','setroles','fixeddom','cloner']); - my ($type,$title,$jscript,$multelement,$multiple,$roleelement, + my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement, $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom); # Get course type - Course or Community. @@ -75,6 +75,9 @@ sub handler { $submitopener = &processpick(); $autosubmit = 'process_pick("'.$roledom.'")'; } + if ($env{'form.typeelement'} ne '') { + $typeelement = ''; + } # if called when a DC is creating a course if ($env{'form.form'} eq 'ccrs') { @@ -102,10 +105,7 @@ sub handler { if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && ($env{'form.pickedcourse'})) { - if ($env{'form.form'} eq 'cu') { - $loaditem{'onload'} .= 'setRoles();'; - } - $loaditem{'onload'} .= 'setSections();'; + $loaditem{'onload'} .= 'setRoles();setSections();'; } my $js = &js_changer(); $r->print(&Apache::loncommon::start_page($title,$js, @@ -168,7 +168,7 @@ sub handler { $r->print(&build_filters($filterlist,$type,$roleelement,$multelement, $filter,$action,\$numtitles,undef,$cloneruname, - $clonerudom)); + $clonerudom,$typeelement)); } # ---------------------------------------------------------------- Get the data @@ -300,7 +300,11 @@ sub display_matched_courses { $r->print('
'); if ($env{'form.form'} eq 'modifycourse') { if ($numcourses > 0) { - my $cctitle = &Apache::lonnet::plaintext('cc',$type); + my $ccrole = 'cc'; + if ($type eq 'Community') { + $ccrole = 'co'; + } + my $cctitle = &Apache::lonnet::plaintext($ccrole,$type); my $dctitle = &Apache::lonnet::plaintext('dc'); my $ccrolechk = ' checked="checked" '; my $menuchk = ' '; @@ -313,12 +317,21 @@ sub display_matched_courses { .''.&mt('Action').'' .'
' + .' '); + if ($type eq 'Community') { + $r->print(&mt('Enter the community with the role of [_1].',$cctitle)); + } else { + $r->print(&mt('Enter the course with the role of [_1].',$cctitle)); + } + $r->print('' .'
' + .' '); + if ($type eq 'Community') { + $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle)); + } else { + $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle)); + } + $r->print('' .'' .'
' ); @@ -349,13 +362,17 @@ sub display_matched_courses { if (%courses) { $r->print(&Apache::loncommon::start_data_table()); $r->print(&Apache::loncommon::start_data_table_header_row()); + my $titlehdr = &mt('Course Title'); + if ($type eq 'Community') { + $titlehdr = &mt('Community Title'); + } $r->print(''.&mt('Select').'' - .''.&mt('Course Title').'' - .''.&mt('Domain').'' - .''.&mt('Course Code').'' - .''.&mt('Owner/Co-owner(s)').'' - .''.&mt('Type').'' - ); + .''.$titlehdr.'' + .''.&mt('Domain').''); + unless ($type eq 'Community') { + $r->print(''.&mt('Course Code').''); + } + $r->print(''.&mt('Owner/Co-owner(s)').''); if ($showroles) { $r->print(''.&mt("Role(s) for [_1]", &Apache::loncommon::plainname($env{'form.personfilter'}, @@ -407,21 +424,16 @@ sub display_matched_courses { $r->print(&Apache::lonnet::domain($cdom,'description')? $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom); $r->print(''); - $r->print(''); - if ($instcode ne '') { - $r->print(&unescape($instcode)); - } else { - $r->print(' '); + unless ($type eq 'Community') { + $r->print(''); + if ($instcode ne '') { + $r->print(&unescape($instcode)); + } else { + $r->print(' '); + } + $r->print(''); } - $r->print(''); $r->print(''.$ownerstr.''); - $r->print(''); - if ($ttype ne '') { - $r->print(&mt(&unescape($ttype))); - } else { - $r->print(' '); - } - $r->print(''); if ($showroles) { $r->print(''); my $rolestr; @@ -432,7 +444,7 @@ sub display_matched_courses { my (undef,$crdom,$crname,$crtitle) = split('/',$role); $rolestr .= $crtitle.', '; } else { - $rolestr .= &Apache::lonnet::plaintext($role,$ttype).', '; + $rolestr .= &Apache::lonnet::plaintext($role,$type).', '; } } $rolestr =~ s/\, $//; @@ -472,6 +484,11 @@ sub display_matched_courses { $env{'form.cnumelement'}.'" />'."\n". ''."\n"); + if ($env{'form.typeelement'} ne '') { + $r->print(''."\n"); + + } } if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) { $r->print(' &mt("$type Title"), - 'cdo' => &mt("$type Domain"), - 'ins' => &mt('Institutional Code'), - 'inc' => &mt('Institutional Categorization'), - 'cow' => &mt("$type Owner/Co-owner"), - 'cop' => &mt("$type Personnel Includes"), - 'cog' => &mt('Type') + $sincefilterform=&Apache::loncommon::select_form( + $filter->{'sincefilter'}, + 'sincefilter', + ( '-1' => '', + '86400' => &mt('today'), + '604800' => &mt('last week'), + '2592000' => &mt('last month'), + '7776000' => &mt('last three months'), + '15552000' => &mt('last six months'), + '31104000' => &mt('last year'), + 'select_form_order' => + ['-1','86400','604800','2592000','7776000', + '15552000','31104000'])); + + my %lt = &Apache::lonlocal::texthash( + 'cac' => "$type Activity", + 'cde' => "$type Title", + 'cdo' => "$type Domain", + 'ins' => 'Institutional Code', + 'inc' => 'Institutional Categorization', + 'cow' => "$type Owner/Co-owner", + 'cop' => "$type Personnel Includes", + 'cog' => 'Type', ); - $typeselectform = '".&mt($posstype)."\n"; + } + $typeselectform.=""; } - $typeselectform .= '>'."\n"; my ($cloneableonlyform,$cloneabletitle); if (exists($filter->{'cloneableonly'})) { @@ -643,11 +675,6 @@ sub build_filters { } } - foreach my $posstype ('Course','Community') { - $typeselectform.='\n"; - } - $typeselectform.=""; my $output = qq| @@ -668,6 +695,7 @@ sub build_filters { $name_input $roleelement $multelement +$typeelement |; if ($formname eq 'portform') { $output .= ''."\n"; @@ -688,9 +716,13 @@ $multelement .&Apache::lonhtmlcommon::row_closure(); } if ($typeselectform) { - $output .= &Apache::lonhtmlcommon::row_title($lt{'cog'}) - .$typeselectform - .&Apache::lonhtmlcommon::row_closure(); + if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) { + $output .= $typeselectform; + } else { + $output .= &Apache::lonhtmlcommon::row_title($lt{'cog'}) + .$typeselectform + .&Apache::lonhtmlcommon::row_closure(); + } } if ($instcodeform) { $output .= &Apache::lonhtmlcommon::row_title($instcodetitle) @@ -738,11 +770,17 @@ $multelement $warning = '
'.&mt('Intended course owner does not exist'). '
'; } else { + my $ccrole; + if ($type eq 'Community') { + $ccrole = 'co'; + } elsif ($type eq 'Course') { + $ccrole = 'cc'; + } if ($env{'form.form'} eq 'ccrs') { $output .= ''."\n"; } my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom, - 'userroles',['active'], ['cc']); + 'userroles',['active'], [$ccrole]); foreach my $key (sort(keys(%ccroles))) { my ($cnum,$cdom,$role) = split(':',$key); $cc_clone .= $cdom.':'.$cnum.'&'; @@ -788,7 +826,12 @@ sub instcode_selectors { sub search_courses { my ($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom) = @_; - my (%courses,%showcourses,$cloner); + my (%courses,%showcourses,$cloner,$ccrole); + if ($type eq 'Community') { + $ccrole = 'co'; + } else { + $ccrole = 'cc'; + } if (!$onlyown) { $r->print(&mt('Searching ...').'
 
'); $r->rflush(); @@ -839,7 +882,7 @@ sub search_courses { my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'}, $filter->{'persondomfilter'}, 'userroles',undef, - ['cc','in','ad','ep','ta','cr'], + [$ccrole,'in','ad','ep','ta','cr'], $filter->{'domainfilter'}); foreach my $role (keys(%rolehash)) { my ($cnum,$cdom,$courserole) = split(':',$role); @@ -949,13 +992,19 @@ function gochoose(cname,cdom,cdesc) { } ENDSCRIPT } else { - my $name_code; + my ($name_code,$type_code); if ($env{'form.cnameelement'} ne '') { $name_code = 'opener.document.'.$env{'form.form'}.'.'. $env{'form.cnameelement'}.'.value=cdesc;'; } + if ($env{'form.typeelement'} ne '') { + $type_code = 'opener.document.'.$env{'form.form'}.'.'. + $env{'form.typeelement'}.'.value=document.courselist.type;'; + } + $output .= qq| $name_code + $type_code opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname; var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'}; if (slct.options == undefined) { @@ -1097,10 +1146,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); caller context (e.g., set to 'modifycourse' when routine is called from lonmodifycourse.pm). +Input: 11 - 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, $tyepelem Output: 1 - $output - HTML for display of search criteria, and hidden form elements.