'.
+ return '';
@@ -971,9 +1000,15 @@ sub extractResourceInformation {
#
my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
- my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
- my $parmdis = $display;
- $parmdis =~ s/\[Part.*$//g;
+ my ($display,$parmdis);
+ $display = &standard_parameter_names($name);
+ if ($display eq '') {
+ $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+ $parmdis = $display;
+ $parmdis =~ s/\s*\[Part.*$//g;
+ } else {
+ $parmdis = &mt($display);
+ }
$$allparms{$name}=$parmdis;
if (ref($defkeytype)) {
$$defkeytype{$name}=
@@ -985,7 +1020,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 +1045,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});
@@ -1099,15 +1134,15 @@ sub parmmenu {
ENDSCRIPT
$r->print();
- $r->print("\n'
+ );
}
sub partmenu {
my ($r,$allparts,$psprt)=@_;
- $r->print('');
+ $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 +1207,7 @@ sub partmenu {
unless ($tempkey =~ /\./) {
$r->print('print(' selected');
+ $r->print(' selected="selected"');
}
$r->print('>'.$$allparts{$tempkey}.' ');
}
@@ -1160,21 +1220,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();
@@ -2424,17 +2660,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
##################################################
@@ -2708,15 +3037,16 @@ sub listdata {
}
if ($part ne $oldpart) {
$r->print(&tableend().
- "\n".&mt('Part').": $part ");
+ "\n".''.&mt('Part').": $part ");
$oldpart=$part;
}
#
# Ready to print
#
+ my $parmitem = &standard_parameter_names($name);
$r->print(&tablestart().
&Apache::loncommon::start_data_table_row().
- ''.&standard_parameter_names($name).
+ ' '.&mt($parmitem).
' ');
$foundkeys++;
@@ -2729,6 +3059,8 @@ sub listdata {
$$resourcedata{$thiskey},
'',1,'','').
' '.
+(($$resourcedata{$thiskey}!=0)?''.
+&mt('Shift all dates based on this date').' ':'').
&date_sanity_info($$resourcedata{$thiskey})
);
} elsif ($thistype eq 'date_interval') {
@@ -2741,7 +3073,7 @@ sub listdata {
$r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
}
$r->print(' ');
+ $thistype.'" />');
$r->print(' '.&Apache::loncommon::end_data_table_row());
}
}
@@ -2798,7 +3130,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.' ]],
);
@@ -2824,6 +3156,41 @@ sub string_selector {
return $result;
}
+#
+# Shift all start and end dates by $shift
+#
+
+sub dateshift {
+ my ($shift)=@_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
+# ugly retro fix for broken version of types
+ foreach my $key (keys %data) {
+ if ($key=~/\wtype$/) {
+ my $newkey=$key;
+ $newkey=~s/type$/\.type/;
+ $data{$newkey}=$data{$key};
+ delete $data{$key};
+ }
+ }
+ my %storecontent=();
+# go through all parameters and look for dates
+ foreach my $key (keys %data) {
+ if ($data{$key.'.type'}=~/^date_(start|end)$/) {
+ my $newdate=$data{$key}+$shift;
+ $storecontent{$key}=$newdate;
+ }
+ }
+ my $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$dom,$crs);
+ if ($reply eq 'ok') {
+ &log_parmset(\%storecontent);
+ }
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
+ return $reply;
+}
+
sub newoverview {
my ($r) = @_;
@@ -3043,7 +3410,7 @@ ENDOVER
$r->print(''.
&mt('These parameters refer to resources that do not exist.').
' '.
- ' '.' '.
+ ' '.' '.
' ');
$r->print(&Apache::loncommon::start_data_table().
''.
@@ -3066,9 +3433,10 @@ ENDOVER
$display_value =
&Apache::lonlocal::locallocaltime($display_value);
}
+ my $parmitem = &standard_parameter_names($data{'parameter_name'});
+ $parmitem = &mt($parmitem);
$r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
- &standard_parameter_names($data{'parameter_name'}),
- $resourcedata->{$thiskey}));
+ $parmitem,$resourcedata->{$thiskey}));
$r->print(' ');
if ($data{'scope_type'} eq 'all') {
$r->print(&mt('All users'));
@@ -3096,11 +3464,56 @@ ENDOVER
}
}
$r->print(&Apache::loncommon::end_data_table().''.
- ' '.
+ ' '.
'
'.
&Apache::loncommon::end_page());
}
+sub date_shift_one {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print(<print('');
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub date_shift_two {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print(<print(&mt('Shifting all dates such that [_1] becomes [_2]',
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)));
+ my $delta=$timeshifted-$env{'form.timebase'};
+ &dateshift($delta);
+ $r->print(&Apache::loncommon::end_page());
+}
+
sub parse_key {
my ($key) = @_;
my %data;
@@ -3437,21 +3850,21 @@ sub output_row {
my $multiple_checked;
my $single_checked;
if ($options =~ m/onlyone/) {
- $multiple_checked = "";
- $single_checked = " CHECKED ";
+ $multiple_checked = '';
+ $single_checked = ' checked="checked"';
} else {
- $multiple_checked = " CHECKED ";
- $single_checked = "";
+ $multiple_checked = ' checked="checked"';
+ $single_checked = '';
}
$output .= &Apache::loncommon::continue_data_table_row();
$output .= ''.(' ' x 10).'
-
- Student may select multiple choices from list ';
+
+ '.&mt('Student may select multiple choices from list').'';
$output .= &Apache::loncommon::end_data_table_row();
$output .= &Apache::loncommon::continue_data_table_row();
$output .= ''.(' ' x 10).'
- Student may select only one choice from list ';
+ '.&mt('Student may select only one choice from list').'';
$output .= &Apache::loncommon::end_data_table_row();
}
return ($output);
@@ -3501,7 +3914,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;
@@ -3914,7 +4327,6 @@ sub load_parameter_names {
close($config);
$standard_parms{'int_pos'} = 'Positive Integer';
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
- %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
}
sub standard_parameter_names {
@@ -4028,15 +4440,18 @@ sub parm_change_log {
} else {
$makenewrow=1;
}
+ my $parmitem = &standard_parameter_names($parmname);
$output .=''.$realm.' '.$section.' '.
- &standard_parameter_names($parmname).' '.
+ &mt($parmitem).' '.
($part?&mt('Part: [_1]',$part):&mt('All Parts')).' ';
my $stillactive=0;
if ($parmlog{$id}{'delflag'}) {
$output .= &mt('Deleted');
} else {
if ($typeflag) {
- $output .= &mt('Type: [_1]',&standard_parameter_names($value));
+ my $parmitem = &standard_parameter_names($value);
+ $parmitem = &mt($parmitem);
+ $output .= &mt('Type: [_1]',$parmitem);
} else {
my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
$uname,$udom,$issection,$issection,$courseopt);
@@ -4054,8 +4469,11 @@ sub parm_change_log {
}
$output .= ' ';
if ($stillactive) {
- my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
- my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
+ my $parmitem = &standard_parameter_names($parmname);
+ $parmitem = &mt($parmitem);
+ my $title=&mt('Changed [_1]',$parmitem);
+ my $description=&mt('Changed [_1] for [_2] to [_3]',
+ $parmitem,$realmdescription,
(&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
if (($uname) && ($udom)) {
$output .=
@@ -4126,7 +4544,7 @@ sub handler {
'pres_marker',
'pres_value',
'pres_type',
- 'udom','uname','symb','serial']);
+ 'udom','uname','symb','serial','timebase']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -4206,7 +4624,17 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
text=>"Clean Parameters"});
&clean_parameters($r);
- }
+ } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ &date_shift_one($r);
+ } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
+ &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) {