--- loncom/interface/lonparmset.pm 2005/07/19 16:42:02 1.239 +++ loncom/interface/lonparmset.pm 2005/11/11 23:07:27 1.265 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.239 2005/07/19 16:42:02 raeburn Exp $ +# $Id: lonparmset.pm,v 1.265 2005/11/11 23:07:27 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1921,6 +1921,9 @@ sub crsenv { 'disablesigfigs' => ''.&mt('Disable checking of Significant Figures').'
'. ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'disableexampointprint' + => ''.&mt('Disable automatically printing point values onto exams.').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', 'tthoptions' => ''.&mt('Default set of options to pass to tth/m when converting tex').'' ); @@ -1947,10 +1950,11 @@ sub crsenv { 'default_enrollment_start_date', 'default_enrollment_end_date', 'tthoptions', - 'disablesigfigs' + 'disablesigfigs', + 'disableexampointprint' ); foreach my $parameter (sort(keys(%values))) { - unless ($parameter =~ m/^internal\./) { + unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { if (! $descriptions{$parameter}) { $descriptions{$parameter}=$parameter; push(@Display_Order,$parameter); @@ -2189,20 +2193,41 @@ sub listdata { my $pointer=0; $tableopen=0; my $foundkeys=0; + my %keyorder=&standardkeyorder(); foreach my $thiskey (sort { if ($sortorder eq 'realmstudent') { - my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); - my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); - if (!defined($astudent) && !defined($bstudent) && - !defined($arealm) && !defined($brealm)) { - ($arealm)=($a=~/^$env{'request.course.id'}\.(.+)\.[^\.]+$/); - ($brealm)=($b=~/^$env{'request.course.id'}\.(.+)\.[^\.]+$/); + my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); + my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); + if (!defined($astudent)) { + ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); + } + if (!defined($bstudent)) { + ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); + } + $arealm=~s/\.type//; + my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); + $aparm=$keyorder{'parameter_0_'.$aparm}; + $brealm=~s/\.type//; + my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); + $bparm=$keyorder{'parameter_0_'.$bparm}; + if ($ares eq $bres) { + if (defined($aparm) && defined($bparm)) { + ($aparm <=> $bparm); + } elsif (defined($aparm)) { + -1; + } elsif (defined($bparm)) { + 1; + } else { + ($arealm cmp $brealm) || ($astudent cmp $bstudent); + } + } else { + ($arealm cmp $brealm) || ($astudent cmp $bstudent); } - ($arealm cmp $brealm) || ($astudent cmp $bstudent); } else { $a cmp $b; } } keys %{$listdata}) { + if ($$listdata{$thiskey.'.type'}) { my $thistype=$$listdata{$thiskey.'.type'}; if ($$resourcedata{$thiskey.'.type'}) { @@ -2677,6 +2702,10 @@ ENDMAINFORMHEAD action => 'crsenv', permission => $parm_permission, }, + { text => 'Set Portfolio Metadata', + action => 'setrestrictmeta', + permission => $parm_permission, + }, { text => 'Set/Modify Resource Parameters - Helper Mode', url => '/adm/helper/parameter.helper', permission => $parm_permission, @@ -2720,8 +2749,93 @@ ENDMAINFORMHEAD $r->print($menu_html); return; } - - +### Set portfolio metadata +sub output_row { + my ($r, $field_name, $field_text) = @_; + my $output; + my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; + my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; + unless (defined($options)) { + $options = 'active,stuadd'; + $values = ''; + } + $output.=''.$field_text.':'; + $output.='
'; + + my @options= ( ['active', 'Show to student'], + ['onlyone','Student may select only one choice'], + ['stuadd', 'Student may type choices']); + foreach my $opt (@options) { + my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; + $output.=(' 'x5).'
'; + } + return ($output); +} + +sub setrestrictmeta { + my ($r)=@_; + my $next_meta; + my $output; + my $item_num; + my $put_result; + $r->print(&Apache::lonxml::xmlbegin()); + $r->print(' + LON-CAPA Restrict Metadata + '); + $r->print(&Apache::loncommon::bodytag('Restrict Metadata')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, + 'Restrict Metadata')); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; + my $save_field = ''; + if ($env{'form.restrictmeta'}) { + foreach my $field (sort(keys(%env))) { + if ($field=~m/^form.(.+)_(.+)$/) { + my $options; + my $meta_field = $1; + my $meta_key = $2; + if ($save_field ne $meta_field) { + $save_field = $meta_field; + if ($env{'form.'.$meta_field.'_stuadd'}) { + $options.='stuadd,'; + } + if ($env{'form.'.$meta_field.'_onlyone'}) { + $options.='onlyone,'; + } + if ($env{'form.'.$meta_field.'_active'}) { + $options.='active,'; + } + my $name = $save_field; + $put_result = &Apache::lonnet::put('environment', + {'metadata.'.$meta_field.'.options'=>$options, + 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'}, + },$dom,$crs); + } + } + } + } + &Apache::lonnet::coursedescription($env{'request.course.id'}); + my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); + foreach my $field (sort(keys(%metadata_fields))) { + &Apache::lonnet::logthis ($field); + if ($field ne 'courserestricted') { + $output.= &output_row($r, $field, $metadata_fields{$field}); + } + } + $r->print(< +

+ $output + + +ENDenv + $r->print(' + '); + return 'ok'; +} ################################################## sub defaultsetter { @@ -2894,6 +3008,7 @@ Main handler. Calls &assessparms and &c ################################################## # use Data::Dumper; + sub handler { my $r=shift; @@ -2907,7 +3022,7 @@ sub handler { 'pres_marker', 'pres_value', 'pres_type', - 'udom','uname','symb']); + 'udom','uname','symb','serial']); &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -2954,6 +3069,10 @@ sub handler { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); &overview($r); + } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', + text=>"Restrict Metadata"}); + &setrestrictmeta($r); } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"});