--- loncom/interface/lonparmset.pm 2007/09/11 01:59:30 1.381 +++ loncom/interface/lonparmset.pm 2007/11/02 23:29:49 1.384 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.381 2007/09/11 01:59:30 albertel Exp $ +# $Id: lonparmset.pm,v 1.384 2007/11/02 23:29:49 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2124,9 +2124,19 @@ sub crsenv { if ($name eq 'cloners') { &change_clone($value,\@oldcloner); } - # Flush the course logs so course description is immediately updated + # Update environment and nohist_courseids.db if ($name eq 'description' && defined($value)) { - &Apache::lonnet::flushcourselogs(); + my %crsinfo = + &Apache::lonnet::courseiddump($dom,'.',1,'.','.', + $crs,undef,undef,'Course'); + &Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.description' => $value); + if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { + $crsinfo{$env{'request.course.id'}}{'description'} = $value; + my $chome = &Apache::lonnet::homeserver($crs,$dom); + my $putresult = + &Apache::lonnet::courseidput($dom,\%crsinfo, + $chome,'notime'); + } } } else { $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). @@ -2493,16 +2503,24 @@ sub storedata { if ($tuname) { $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; } - if ($cmd eq 'set') { - my $data=$env{$_}; - my $typeof=$env{'form.typeof_'.$thiskey}; - if ($$olddata{$thiskey} ne $data) { + if ($cmd eq 'set' || $cmd eq 'datepointer') { + my ($data, $typeof, $text); + if ($cmd eq 'set') { + $data=$env{$_}; + $typeof=$env{'form.typeof_'.$thiskey}; + $text = &mt('Saved modified parameter for'); + } elsif ($cmd eq 'datepointer') { + $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); + $typeof=$env{'form.typeof_'.$thiskey}; + $text = &mt('Saved modified date for'); + } + if (defined($data) and $$olddata{$thiskey} ne $data) { if ($tuname) { if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, $tkey.'.type' => $typeof}, $tudom,$tuname) eq 'ok') { &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); - $r->print('
'.&mt('Saved modified parameter for').' '. + $r->print('
'.$text.' '. &Apache::loncommon::plainname($tuname,$tudom)); } else { $r->print('
'. @@ -2527,26 +2545,6 @@ sub storedata { } else { push (@deldata,$thiskey,$thiskey.'.type'); } - } elsif ($cmd eq 'datepointer') { - my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); - my $typeof=$env{'form.typeof_'.$thiskey}; - if (defined($data) and $$olddata{$thiskey} ne $data) { - if ($tuname) { - if (&Apache::lonnet::put('resourcedata',{$tkey=>$data, - $tkey.'.type' => $typeof}, - $tudom,$tuname) eq 'ok') { - &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); - $r->print('
'.&mt('Saved modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); - } else { - $r->print('
'. - &mt('Error saving parameters').'
'); - } - &Apache::lonnet::devalidateuserresdata($tuname,$tudom); - } else { - $newdata{$thiskey}=$data; - $newdata{$thiskey.'.type'}=$typeof; - } - } } } } @@ -2729,30 +2727,11 @@ sub listdata { ''. &date_sanity_info($$resourcedata{$thiskey}) ); - } elsif ($thistype eq 'string_yesno') { - my $showval; - if (defined($$resourcedata{$thiskey})) { - $showval=$$resourcedata{$thiskey}; - } - $r->print(' '); - $r->print(''); + } elsif ($thistype =~ m/^string/) { + $r->print(&string_selector($thistype,$thiskey, + $$resourcedata{$thiskey})); } else { - my $showval; - if (defined($$resourcedata{$thiskey})) { - $showval=$$resourcedata{$thiskey}; - } - $r->print(''); + $r->print(&default_selector($thiskey,$$resourcedata{$thiskey})); } $r->print(''); @@ -2762,6 +2741,43 @@ sub listdata { return $foundkeys; } +sub default_selector { + my ($thiskey, $showval) = @_; + return '' ; +} + +my %strings = + ( + 'string_yesno' + => [[ 'yes', 'Yes' ], + [ 'no', 'No' ]], + 'string_problemstatus' + => [[ 'yes', 'Yes' ], + [ 'no', 'No, don\'t show correct/incorrect feedback.' ], + [ 'no_feedback_ever', 'No, show no feedback at all.' ]], + ); + + +sub string_selector { + my ($thistype, $thiskey, $showval) = @_; + + if (!exists($strings{$thistype})) { + return &default_selector($thiskey,$showval); + } + + my $result; + foreach my $possibilities (@{ $strings{$thistype} }) { + my ($name, $description) = @{ $possibilities }; + $result .= '