--- loncom/interface/lonparmset.pm 2008/03/06 21:37:59 1.392
+++ 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.392 2008/03/06 21:37:59 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'
+# .'('.&mt('in the past').')'
+# .'';
+# }
+# 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
#
@@ -1010,7 +1038,7 @@ sub extractResourceInformation {
$$mapp{$mapid}=$$mapp{$id};
$$allmaps{$mapid}=$$mapp{$id};
if ($mapid eq '1') {
- $$maptitles{$mapid}='Main Course Documents';
+ $$maptitles{$mapid}=&mt('Main Course Documents');
} else {
$$maptitles{$mapid}=
&Apache::lonnet::gettitle($$mapp{$id});
@@ -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,28 +1144,53 @@ ENDSCRIPT
$cnt=0;
}
}
- $r->print('
-');
+ $r->print(''
+ .''
+ );
}
sub partmenu {
my ($r,$allparts,$psprt)=@_;
$r->print('');
$r->print('print(' selected') unless (@{$psprt});
+ $r->print(' selected="selected"') unless (@{$psprt});
$r->print('>'.&mt('All Parts').' ');
my %temphash=();
foreach (@{$psprt}) { $temphash{$_}=1; }
@@ -1147,7 +1200,7 @@ sub partmenu {
unless ($tempkey =~ /\./) {
$r->print('print(' selected');
+ $r->print(' selected="selected"');
}
$r->print('>'.$$allparts{$tempkey}.' ');
}
@@ -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'}.': ';
}
+
if (%sectionhash && %grouphash && $parmlev ne 'full') {
- $sections .= ' or ';
+ $sections .= ' '.&mt('or').' ';
$sections .= qq|
';
-
+ my ($jscript,$categorize_js);
+ my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
+ if ($can_categorize) {
+ $categorize_js = <'."\n".
+ $browse_js."\n".$categorize_js."\n".'';
my $start_page =
&Apache::loncommon::start_page('Set Course Environment',
- $browse_js);
+ $jscript);
my $end_page =
&Apache::loncommon::end_page();
my $end_table=&Apache::loncommon::end_data_table();
@@ -2445,17 +2580,110 @@ $start_page
$breadcrumbs
$end_page
ENDENV
}
+
+sub can_modify_catsettings {
+ my ($dom) = @_;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
+ my ($can_toggle_cat,$can_categorize);
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+ $can_toggle_cat = 1;
+ }
+ if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+ $can_categorize = 1;
+ }
+ }
+ return ($can_toggle_cat,$can_categorize);
+}
+
+sub assign_course_categories {
+ my ($r) = @_;
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $hascats = 0;
+ my $cathash;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($cathash) eq 'HASH') {
+ $hascats = 1;
+ }
+ }
+ my $catwin_js;
+ if ($hascats) {
+ my $alert = &mt('Use \"Save\" in the main window to save course categories');
+ $catwin_js = <
+
+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();
+ return;
+}
+
+
+ENDSCRIPT
+ } else {
+ my $onload;
+ }
+ my $start_page =
+ &Apache::loncommon::start_page('Course Categories',$catwin_js,
+ {'only_body' => 1,});
+ my $end_page = &Apache::loncommon::end_page();
+ my $categoriesform = ''.&mt('Categorize Course').' ';
+ if ($hascats) {
+ my %currsettings =
+ &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
+ $categoriesform .= &mt('Assign one or more categories to this course.').' '.
+ ' ';
+ } else {
+ $categoriesform .= &mt('No categories defined for this domain');
+ }
+ $r->print($start_page.$categoriesform.$end_page);
+ return;
+}
+
##################################################
# Overview mode
##################################################
@@ -2750,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') {
@@ -2821,7 +3049,7 @@ my %strings =
[ 'no', 'No' ]],
'string_problemstatus'
=> [[ 'yes', 'Yes' ],
- [ 'answer', 'Yes, and show correct answer if they exceed the maxium number of tries.' ],
+ [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
[ 'no', 'No, don\'t show correct/incorrect feedback.' ],
[ 'no_feedback_ever', 'No, show no feedback at all.' ]],
);
@@ -3604,7 +3832,7 @@ sub order_meta_fields {
my $ordered_fields = join ",", @neworder;
my $put_result = &Apache::lonnet::put('environment',
{'metadata.addedorder'=>$ordered_fields},$dom,$crs);
- &Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields);
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
}
my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
my $ordered_fields;
@@ -4317,7 +4545,9 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
text=>"Shifting Dates"});
&date_shift_two($r);
- }
+ } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
+ &assign_course_categories($r);
+ }
} else {
# ----------------------------- Not in a course, or not allowed to modify parms
if ($exists) {