version 1.253, 2005/09/28 23:19:25
|
version 1.266, 2005/11/14 14:01:52
|
Line 316 sub storeparm_by_symb {
|
Line 316 sub storeparm_by_symb {
|
# store parameter |
# store parameter |
&storeparm_by_symb_inner |
&storeparm_by_symb_inner |
($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec); |
|
# don't do anything if parameter was reset |
|
unless ($nval) { return; } |
my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/); |
my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/); |
# remember that this was set |
# remember that this was set |
$recstack{$parm}=1; |
$recstack{$parm}=1; |
Line 2702 ENDMAINFORMHEAD
|
Line 2704 ENDMAINFORMHEAD
|
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Set Instructor Defined Metadata', |
{ text => 'Set Portfolio Metadata', |
action => 'setinstmeta', |
action => 'setrestrictmeta', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
Line 2749 ENDMAINFORMHEAD
|
Line 2751 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
### Set instructor defined metadata |
### Set portfolio metadata |
sub output_row { |
sub output_row { |
my ($r, $field_name) = @_; |
my ($r, $field_name, $field_text) = @_; |
my $output; |
my $output; |
my $active=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.active'}; |
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; |
my $onlyone=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.onlyone'}; |
|
my $stuadd=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.stuadd'}; |
|
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
my $checked; |
unless (defined($options)) { |
unless (defined($active)) { |
$options = 'active,stuadd'; |
$active = 'no'; |
$values = ''; |
$stuadd = 'yes'; |
} |
$values = 'Type a list of values separated by commas.'; |
$output.='<strong>'.$field_text.':</strong>'; |
$onlyone = 'no'; |
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />'; |
} |
|
$output.='<tr><td><strong>'.$field_name.'</strong></td>'; |
my @options= ( ['active', 'Show to student'], |
$output.='<td><input name="'.$field_name.'_values" type="text" value="'.$values.'" /></td>'; |
['onlyone','Student may select only one choice'], |
if ($onlyone eq 'no') { |
['stuadd', 'Student may type choices']); |
$checked = ' CHECKED '; |
foreach my $opt (@options) { |
} else { |
my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; |
$checked = ' '; |
$output.=(' 'x5).'<label><input type="checkbox" name="'. |
} |
$field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'. |
$output.='<td><center><input type="checkbox" name="'.$field_name.'_onlyone"" value="yes"'.$checked.' /></center></td>'; |
&mt($opt->[1]).'</label> <br />'; |
if ($stuadd eq 'yes') { |
|
$checked = ' CHECKED '; |
|
} else { |
|
$checked = ' '; |
|
} |
} |
$output.='<td><input type="checkbox" name="'.$field_name.'_stuadd" value="yes"'.$checked.' /></td>'; |
|
$output.='</tr>'; |
|
return ($output); |
return ($output); |
} |
} |
sub setinstmeta { |
|
|
sub setrestrictmeta { |
my ($r)=@_; |
my ($r)=@_; |
my $next_meta; |
my $next_meta; |
my $output; |
my $output; |
Line 2789 sub setinstmeta {
|
Line 2784 sub setinstmeta {
|
my $put_result; |
my $put_result; |
$r->print(&Apache::lonxml::xmlbegin()); |
$r->print(&Apache::lonxml::xmlbegin()); |
$r->print('<head> |
$r->print('<head> |
<title>LON-CAPA Set Instructor Metadata</title> |
<title>LON-CAPA Restrict Metadata</title> |
</head>'); |
</head>'); |
$r->print(&Apache::loncommon::bodytag('Set Instructor Metadata')); |
$r->print(&Apache::loncommon::bodytag('Restrict Metadata')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
'Set Instructor Metadata')); |
'Restrict Metadata')); |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $key_base = $env{'course.'.$env{'request.course.id'}.'.metadata.'}; |
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; |
my $save_field = ''; |
my $save_field = ''; |
my $stuadd; |
if ($env{'form.restrictmeta'}) { |
my $onlyone; |
foreach my $field (sort(keys(%env))) { |
my $active; |
|
if ($env{'form.instmeta'}) { |
|
foreach my $field (sort %env) { |
|
if ($field=~m/^form.(.+)_(.+)$/) { |
if ($field=~m/^form.(.+)_(.+)$/) { |
|
my $options; |
my $meta_field = $1; |
my $meta_field = $1; |
my $meta_key = $2; |
my $meta_key = $2; |
if ($save_field ne $meta_field) { |
if ($save_field ne $meta_field) { |
$save_field = $meta_field; |
$save_field = $meta_field; |
if ($env{'form.'.$meta_field.'_stuadd'}) { |
if ($env{'form.'.$meta_field.'_stuadd'}) { |
$stuadd='yes'; |
$options.='stuadd,'; |
} else { |
} |
$stuadd='no'; |
|
} |
|
if ($env{'form.'.$meta_field.'_onlyone'}) { |
if ($env{'form.'.$meta_field.'_onlyone'}) { |
$onlyone='no'; |
$options.='onlyone,'; |
} else { |
} |
$onlyone='yes'; |
if ($env{'form.'.$meta_field.'_active'}) { |
|
$options.='active,'; |
} |
} |
$active='yes'; |
my $name = $save_field; |
my $name = 'metadata.'.$save_field; |
|
$put_result = &Apache::lonnet::put('environment', |
$put_result = &Apache::lonnet::put('environment', |
{'metadata.'.$meta_field.'.stuadd'=>$stuadd, |
{'metadata.'.$meta_field.'.options'=>$options, |
'metadata.'.$meta_field.'.onlyone'=>$onlyone, |
|
'metadata.'.$meta_field.'.active'=>$active, |
|
'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'}, |
'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'}, |
},$dom,$crs); |
},$dom,$crs); |
} |
} |
} |
} |
} |
} |
|
|
} |
} |
foreach my $field (%env) { |
|
# start by looking for populated fields |
|
if ($field=~m/type(\d+)/) { |
|
my $name; |
|
my $value; |
|
# $put_result = &Apache::lonnet::put('environment', |
|
# {$name=>$value},$dom,$crs); |
|
# $put_result = &Apache::lonnet::put('environment', |
|
# {$name=>$value},$dom,$crs); |
|
} |
|
if ($field=~m/newfield/) { |
|
my $name = 'metadata.'.$env{'form.titlenew'}; |
|
my %meta_hash = {values=>[$env{'form.valuesnew'}], |
|
allow_pick=>'many', |
|
allow_type=>'no'}; |
|
|
|
my $value = \%meta_hash; |
|
# $put_result = &Apache::lonnet::put('environment', |
|
# {$name=>$value},$dom,$crs); |
|
} |
|
} |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
$output.= &output_row($r, "Title"); |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
$output.= &output_row($r, "Subject"); |
foreach my $field (sort(keys(%metadata_fields))) { |
$output.= &output_row($r, "Keywords"); |
&Apache::lonnet::logthis ($field); |
|
if ($field ne 'courserestricted') { |
|
$output.= &output_row($r, $field, $metadata_fields{$field}); |
|
} |
|
} |
$r->print(<<ENDenv); |
$r->print(<<ENDenv); |
<form method="post" action="/adm/parmset?action=setinstmeta" name="form"> |
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
|
|
<p> |
<p> |
<table border=2> |
|
<tr><th>Metadata Item</th><th>Values</th><th>Only One Choice</th><th>Student Can Add Choices</th></tr> |
|
$output |
$output |
</table> |
<input type="submit" name="restrictmeta" value="Update Metadata Restrictions"> |
<input type="submit" name="instmeta" value="Update Instructor Metadata"> |
|
</form> |
</form> |
|
|
ENDenv |
ENDenv |
|
|
|
|
$r->print('</body> |
$r->print('</body> |
</html>'); |
</html>'); |
return 'ok'; |
return 'ok'; |
Line 3046 Main handler. Calls &assessparms and &c
|
Line 3010 Main handler. Calls &assessparms and &c
|
################################################## |
################################################## |
# use Data::Dumper; |
# use Data::Dumper; |
|
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
Line 3106 sub handler {
|
Line 3071 sub handler {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |
&overview($r); |
&overview($r); |
} elsif ($env{'form.action'} eq 'setinstmeta' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setinstmeta', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
text=>"Instructor Metadata"}); |
text=>"Restrict Metadata"}); |
&setinstmeta($r); |
&setrestrictmeta($r); |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |