version 1.251, 2005/09/23 20:16:50
|
version 1.261, 2005/10/17 21:33:52
|
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 => '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 2749 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
### Set instructor defined metadata |
### Set portfolio metadata |
sub setinstmeta { |
sub output_row { |
|
my ($r, $field_name, $field_text) = @_; |
|
my $output; |
|
my $options=$env{'course.'.$env{'request.course.id'}.'.'.$field_name.'.options'}; |
|
my $values=$env{'course.'.$env{'request.course.id'}.'.'.$field_name.'.values'}; |
|
my $checked; |
|
unless (defined($options)) { |
|
$options = 'active,stuadd'; |
|
$values = ''; |
|
} |
|
$output.='<strong>'.$field_text.':</strong>'; |
|
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" /><br />'; |
|
if ($options =~ m/active/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_active" value="yes"'.$checked.' />'; |
|
$output.='Show to student <br />'; |
|
if ($options =~ m/onlyone/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_onlyone" value="yes"'.$checked.' />'; |
|
$output.='Student may select only one choice <br />'; |
|
if ($options =~ m/stuadd/) { |
|
$checked = ' checked="checked" '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.=' <input type="checkbox" name="'.$field_name.'_stuadd" value="yes"'.$checked.' />'; |
|
$output.='Student may type choices <br />'; |
|
return ($output); |
|
} |
|
|
|
sub setrestrictmeta { |
my ($r)=@_; |
my ($r)=@_; |
my $next_meta; |
my $next_meta; |
my $output; |
my $output; |
Line 2758 sub setinstmeta {
|
Line 2794 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'}.'.'}; |
foreach my $field (%env) { |
my $save_field = ''; |
# start by looking for populated fields |
if ($env{'form.restrictmeta'}) { |
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 = $save_field; |
} |
$put_result = &Apache::lonnet::put('environment', |
} |
{$meta_field.'.options'=>$options, |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'}, |
foreach my $key (sort keys %env) { |
},$dom,$crs); |
if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) { |
} |
my $meta_data_item = $1; |
} |
my $meta_hash=$env{$key}; |
|
$output.='<tr><td>'.$meta_data_item.'</td>'; |
|
$output.='<td>Select one: <input type="checkbox" name="" value="one" /><br />'; |
|
$output.='Select many: <input type="checkbox" name="type" value="many" /></td>'; |
|
$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 />'; |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
$output.='<input type="text" name="titlenew" /></td>'; |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
$output.='<td>students must pick only one: <input type="checkbox" name="pickonenew" value="one" /><br />'; |
foreach my $field (sort(keys(%metadata_fields))) { |
$output.='Allow student to type extra info: <input type="checkbox" name="typeextranew" value="extra" /></td>'; |
$output.= &output_row($r, $field, $metadata_fields{$field}); |
$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=setrestrictmeta" name="form"> |
|
|
<p> |
<p> |
<table border=2> |
|
<tr><th>Title</th><th>Options</th><th>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 2995 Main handler. Calls &assessparms and &c
|
Line 3017 Main handler. Calls &assessparms and &c
|
################################################## |
################################################## |
# use Data::Dumper; |
# use Data::Dumper; |
|
|
|
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
|
|
Line 3055 sub handler {
|
Line 3078 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"}); |