--- loncom/interface/lonparmset.pm 2008/07/15 20:00:58 1.405 +++ loncom/interface/lonparmset.pm 2008/10/23 14:26:17 1.413 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.405 2008/07/15 20:00:58 raeburn Exp $ +# $Id: lonparmset.pm,v 1.413 2008/10/23 14:26:17 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -325,14 +325,31 @@ sub date_sanity_info { my $crsprefix='course.'.$env{'request.course.id'}.'.'; if ($env{$crsprefix.'default_enrollment_end_date'}) { if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) { - $result.='
'.&mt('After course enrollment end!'); + $result.='
' + .&mt('After course enrollment end!') + .'
'; } } if ($env{$crsprefix.'default_enrollment_start_date'}) { if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) { - $result.='
'.&mt('Before course enrollment start!'); + $result.='
' + .&mt('Before course enrollment start!') + .'
'; } } +# Preparation for additional warnings about dates in the past/future. +# An improved, more context sensitive version is recommended, +# e.g. warn for due and answer dates which are defined before the corresponding open date, etc. +# if ($checkdate'; +# } +# if ($checkdate>time) { +# $result.='
' +# .'('.&mt('in the future').')' +# .'
'; +# } return $result; } ################################################## @@ -551,27 +568,38 @@ sub valout { } else { if ($type eq 'date_interval') { my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); + my @timer; $year=$year-70; $mday--; if ($year) { - $result.=$year.' yrs '; +# $result.=&mt('[quant,_1,yr]',$year).' '; + push(@timer,&mt('[quant,_1,yr]',$year)); } if ($mon) { - $result.=$mon.' mths '; +# $result.=&mt('[quant,_1,mth]',$mon).' '; + push(@timer,&mt('[quant,_1,mth]',$mon)); } if ($mday) { - $result.=$mday.' days '; +# $result.=&mt('[quant,_1,day]',$mday).' '; + push(@timer,&mt('[quant,_1,day]',$mday)); } if ($hour) { - $result.=$hour.' hrs '; +# $result.=&mt('[quant,_1,hr]',$hour).' '; + push(@timer,&mt('[quant,_1,hr]',$hour)); } if ($min) { - $result.=$min.' mins '; +# $result.=&mt('[quant,_1,min]',$min).' '; + push(@timer,&mt('[quant,_1,min]',$min)); } if ($sec) { - $result.=$sec.' secs '; +# $result.=&mt('[quant,_1,sec]',$sec).' '; + push(@timer,&mt('[quant,_1,sec]',$sec)); } - $result=~s/\s+$//; +# $result=~s/\s+$//; + if (!@timer) { # Special case: all entries 0 -> display "0 secs" intead of empty field to keep this field editable + push(@timer,&mt('[quant,_1,sec]',0)); + } + $result.=join(", ",@timer); } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -973,7 +1001,7 @@ sub extractResourceInformation { if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); my $parmdis = $display; - $parmdis =~ s/\[Part.*$//g; + $parmdis =~ s/\s*\[Part.*$//g; $$allparms{$name}=$parmdis; if (ref($defkeytype)) { $$defkeytype{$name}= @@ -985,7 +1013,7 @@ sub extractResourceInformation { # allparts is a hash of all parts # my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); - $$allparts{$part} = "Part: $part"; + $$allparts{$part} = &mt('Part: [_1]',$part); # # Remember all keys going with this resource # @@ -1107,8 +1135,8 @@ ENDSCRIPT if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { $r->print(' checked'); } - $r->print('>'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} - : $tempkey) + $r->print('>'.($$allparms{$tempkey}=~/\S/ ? &mt($$allparms{$tempkey}) + : &mt($tempkey)) .''); $cnt++; if ($cnt==3) { @@ -1116,21 +1144,46 @@ ENDSCRIPT $cnt=0; } } - $r->print(' - -Select All
-Select Common Only - -Add Problem Dates -Add Content Dates
-Add Discussion Settings -Add Visibilities
-Add Part Parameters - -Unselect All - -'); - $r->print(''); + $r->print('' + .'' + .'' + .'
'.&mt('Parameter Selection').'' + .'' + .'• '.&mt('Select All').'' + .'' + .'
' + .'' + .'• '.&mt('Select Common Only').'' + .'' + .'
' + .'' + .'• '.&mt('Unselect All').'' + .'' + .'
' + .'' + .'' + .'
'.&mt('Add Selection for...').'' + .'' + .'• '.&mt('Problem Dates').'' + .'' + .'' + .' • '.&mt('Content Dates').'' + .'' +# .'
' + .'' + .' • '.&mt('Discussion Settings').'' + .'' + .'' + .' • '.&mt('Visibilities').'' + .'' +# .'
' + .'' + .' • '.&mt('Part Parameters').'' + .'' + .'
' + .'' + .'' + ); } sub partmenu { @@ -1160,21 +1213,18 @@ sub usermenu { my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('parmform','uname','udom'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); - my %lt=&Apache::lonlocal::texthash( - 'se' => "Section", - 'gr' => "Group", - 'fu' => "For User", - 'oi' => "or ID", - 'ad' => "at Domain" - ); + my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); my $groups; my %grouphash = &Apache::longroup::coursegroups(); + my $g_s_header=''; + my $g_s_footer=''; + if (%sectionhash) { - $sections=$lt{'se'}.': print(< -$sections -$groups -
-$lt{'fu'} - -$lt{'oi'} - -$lt{'ad'} -$chooseopt - -ENDMENU + + if (%sectionhash || %grouphash) { + $g_s_header='
'.&mt('Group/Section').'
'; + $g_s_footer='
'; + } + + $r->print('' + .$g_s_header + .$sections + .$groups + .$g_s_footer + .'
'.&mt('User').'
' + .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]' + ,'' + ,' ' + ,$chooseopt) + .'
' + .'
' + ); } sub displaymenu { @@ -1256,7 +1313,7 @@ sub displaymenu { $r->print('
'.&mt('Select Parameters to View').''. &mt('Select Parts to View').'
'); &parmmenu($r,$allparms,$pscat,$keyorder); - $r->print(''); + $r->print(''); &partmenu($r,$allparts,$psprt); $r->print('
'); } @@ -2126,6 +2183,8 @@ sub crsenv { $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '; if ($name =~ /^default_enrollment_(start|end)_date$/) { $setoutput .= &Apache::lonlocal::locallocaltime($value); + } elsif ($name eq 'categories') { + $setoutput .= $env{'form.categories_display'}; } else { $setoutput .= $value; } @@ -2355,6 +2414,8 @@ sub crsenv { 'categories' => ''.&mt('Categorize course').' '. &mt('Display Categories').'', + 'datelocale' + => ''.&mt('Locale used for course calendar').'', ); my @Display_Order = ('url','description','courseid','cloners'); (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom); @@ -2378,6 +2439,7 @@ sub crsenv { 'allow_discussion_post_editing', 'languages', 'timezone', + 'datelocale', 'nothideprivileged', 'rndseed', 'receiptalg', @@ -2431,6 +2493,32 @@ sub crsenv { &Apache::loncommon::select_timezone($parameter.'_value', $timezone, $onchange,$includeempty).''; + } elsif ($parameter eq 'datelocale') { + my $includeempty = 1; + my $locale_obj = &Apache::lonlocal::getdatelocale(); + my $currdatelocale; + if (ref($locale_obj)) { + $currdatelocale = $locale_obj->id(); + } + $output .= ''. + &Apache::loncommon::select_datelocale($parameter.'_value', + $currdatelocale, + $onchange,$includeempty).''; + } elsif ($parameter eq 'categories') { + my $catdisplay; + if ($values{'categories'} ne '') { + my @curritems = split(/\&/,$values{'categories'}); + foreach my $item (@curritems) { + my ($name,$parent,$pos) = split(/:/,$item); + $catdisplay .= &unescape($name).'&'; + } + $catdisplay =~ s/\&$//; + } + $output .= ''. + ''. + ''; } else { $output .= ''. &Apache::lonhtmlcommon::textbox($parameter.'_value', @@ -2541,21 +2629,28 @@ sub assign_course_categories { function updateCategories() { var newcategories = ''; + var unescapedcats = ''; if (document.chgcats.usecategory.length) { for (var i=0; i 0) { newcategories = newcategories.slice(0,-1); } + if (unescapedcats.length > 0) { + unescapedcats = unescapedcats.slice(0,-3); + } } else { if (document.chgcats.usecategory.checked == true) { newcategories = document.chgcats.usecategory.value; + unescapedcats = document.chgcats.catname.value; } } opener.document.envform.categories_value.value = newcategories; + opener.document.envform.categories_display.value = unescapedcats; opener.document.envform.categories_setparmval.checked = true; alert("$alert"); self.close(); @@ -2883,8 +2978,8 @@ sub listdata { $$resourcedata{$thiskey}, '',1,'',''). ''. -(($$resourcedata{$thiskey}!=0)?''. -&mt('Shift all dates based on this date').'':''). +(($$resourcedata{$thiskey}!=0)?''. +&mt('Shift all dates based on this date').'':''). &date_sanity_info($$resourcedata{$thiskey}) ); } elsif ($thistype eq 'date_interval') {