version 1.251, 2005/09/23 20:16:50
|
version 1.257, 2005/10/03 20:21:24
|
Line 2702 ENDMAINFORMHEAD
|
Line 2702 ENDMAINFORMHEAD
|
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
{ text => 'Set Instructor Defined Metadata', |
{ text => 'Set Portfolio Metadata', |
action => 'setinstmeta', |
action => 'setinstmeta', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
Line 2749 ENDMAINFORMHEAD
|
Line 2749 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
### Set instructor defined metadata |
### 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'}; |
|
my $checked; |
|
unless (defined($options)) { |
|
$options = 'active,stuadd'; |
|
$values = 'Type a list of values separated by commas.'; |
|
} |
|
if ($options =~ m/active/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<tr><td><center><input type="checkbox" name="'.$field_name.'_active" value="yes"'.$checked.' /></center></td>'; |
|
$output.='<td><strong>'.$field_text.'</strong></td>'; |
|
$output.='<td><input name="'.$field_name.'_values" type="text" value="'.$values.'" /></td>'; |
|
if ($options =~ m/onlyone/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><center><input type="checkbox" name="'.$field_name.'_onlyone" value="yes"'.$checked.' /></center></td>'; |
|
if ($options =~ m/stuadd/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><input type="checkbox" name="'.$field_name.'_stuadd" value="yes"'.$checked.' /></td>'; |
|
|
|
$output.='</tr>'; |
|
return ($output); |
|
} |
sub setinstmeta { |
sub setinstmeta { |
my ($r)=@_; |
my ($r)=@_; |
my $next_meta; |
my $next_meta; |
Line 2758 sub setinstmeta {
|
Line 2792 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 Set Portfolio Metadata</title> |
</head>'); |
</head>'); |
$r->print(&Apache::loncommon::bodytag('Set Instructor Metadata')); |
$r->print(&Apache::loncommon::bodytag('Set Portfolio Metadata')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
'Set Instructor Metadata')); |
'Set Portfolio 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'}.'.metadata.'}; |
foreach my $field (%env) { |
my $save_field = ''; |
# start by looking for populated fields |
if ($env{'form.instmeta'}) { |
if ($field=~m/type(\d+)/) { |
foreach my $field (sort(keys(%env))) { |
my $name; |
if ($field=~m/^form.(.+)_(.+)$/) { |
my $value; |
my $options; |
$put_result = &Apache::lonnet::put('environment', |
my $meta_field = $1; |
{$name=>$value},$dom,$crs); |
my $meta_key = $2; |
$put_result = &Apache::lonnet::put('environment', |
if ($save_field ne $meta_field) { |
{$name=>$value},$dom,$crs); |
$save_field = $meta_field; |
} |
if ($env{'form.'.$meta_field.'_stuadd'}) { |
if ($field=~m/newfield/) { |
$options.='stuadd,'; |
my $name = 'metadata.'.$env{'form.titlenew'}; |
} |
my %meta_hash = {values=>[$env{'form.valuesnew'}], |
if ($env{'form.'.$meta_field.'_onlyone'}) { |
allow_pick=>'many', |
$options.='onlyone,'; |
allow_type=>'no'}; |
} |
|
if ($env{'form.'.$meta_field.'_active'}) { |
my $value = \%meta_hash; |
$options.='active,'; |
$put_result = &Apache::lonnet::put('environment', |
} |
{$name=>$value},$dom,$crs); |
my $name = 'metadata.'.$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'}); |
} |
foreach my $key (sort keys %env) { |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) { |
my %metadata_fields = &Apache::lonmeta::fieldnames(); |
my $meta_data_item = $1; |
|
my $meta_hash=$env{$key}; |
foreach my $field (sort(keys (%metadata_fields))) { |
$output.='<tr><td>'.$meta_data_item.'</td>'; |
|
$output.='<td>Select one: <input type="checkbox" name="" value="one" /><br />'; |
if ($field =~ m/metadata/) { |
$output.='Select many: <input type="checkbox" name="type" value="many" /></td>'; |
$output.= &output_row($r, $field, $metadata_fields{$field}); |
$output.='<td><input name="values" type="text" value="$env{$key_base.$item_num.'.'" /></td></tr>'; |
|
} |
} |
} |
} |
$output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
|
$output.='<input type="text" name="titlenew" /></td>'; |
|
$output.='<td>students must pick only one: <input type="checkbox" name="pickonenew" value="one" /><br />'; |
|
$output.='Allow student to type extra info: <input type="checkbox" name="typeextranew" value="extra" /></td>'; |
|
$output.='<td><input name="valuesnew" type="text" value="" /></td></tr>'; |
|
$output.='<input type="hidden" name="serial" value="'.$next_meta.'" />'; |
|
$output.='<input type="hidden" name="state" value="save" /></tr>'; |
|
$r->print(<<ENDenv); |
$r->print(<<ENDenv); |
<form method="post" action="/adm/parmset?action=setinstmeta" name="form"> |
<form method="post" action="/adm/parmset?action=setinstmeta" name="form"> |
|
|
<p> |
<p> |
<table border=2> |
<table border=2> |
<tr><th>Title</th><th>Options</th><th>Choices</th></tr> |
<tr><th>Active</th><th>Metadata Item</th><th>Values</th><th>Only One Choice</th><th>Student Can Add Choices</th></tr> |
$output |
$output |
</table> |
</table> |
<input type="submit" name="instmeta" value="Update Instructor Metadata"> |
<input type="submit" name="instmeta" value="Update Portfolio Metadata"> |
</form> |
</form> |
|
|
ENDenv |
ENDenv |
Line 3057 sub handler {
|
Line 3089 sub handler {
|
&overview($r); |
&overview($r); |
} elsif ($env{'form.action'} eq 'setinstmeta' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setinstmeta' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setinstmeta', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setinstmeta', |
text=>"Instructor Metadata"}); |
text=>"Portfolio Metadata"}); |
&setinstmeta($r); |
&setinstmeta($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', |