version 1.245, 2005/08/30 00:40:12
|
version 1.246, 2005/08/30 01:25:53
|
Line 2730 sub setinstmeta {
|
Line 2730 sub setinstmeta {
|
my $next_meta; |
my $next_meta; |
my $output; |
my $output; |
my $item_num; |
my $item_num; |
|
my $put_result; |
if ($env{'form.serial'}) { |
if ($env{'form.serial'}) { |
$next_meta = $env{'form.serial'}; |
$next_meta = $env{'form.serial'}; |
} else { |
} else { |
Line 2745 sub setinstmeta {
|
Line 2746 sub setinstmeta {
|
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.'}; |
if ($env{'form.state'}eq 'add') { |
foreach my $field (%env) { |
$r->print('<strong>Compose a new metadata item:</strong><br />'); |
# start by looking for populated fields |
$r->print('<form method="post" action="/adm/parmset">'); |
if ($field=~m/type(\d+)/) { |
$r->print ('Title of item: '.&Apache::lonhtmlcommon::textbox("title",undef,undef,undef).'<br />'); |
my $item_num = $1; |
$r->print ('List if items (comma separated): '.&Apache::lonhtmlcommon::textbox("values",undef,undef,undef).'<br />'); |
my $name = 'metadata.'.$item_num.'.type'; |
$r->print ('Select one: <input type="radio" name="type" value="one"><br />'); |
my $value = $env{'form.type'.$item_num}; |
$r->print ('Select many: <input type="radio" name="type" value="many"><br />'); |
$put_result = &Apache::lonnet::put('environment', |
$r->print('<input type="hidden" name="serial" value="'.$next_meta.'" />'); |
|
$r->print('<input type="hidden" name="action" value="setinstmeta" />'); |
|
$r->print('<input type="hidden" name="state" value="save" />'); |
|
$r->print('<input type="submit" value="Save Metadata">'); |
|
$r->print('</form>'); |
|
} elsif ($env{'form.state'}eq 'save') { |
|
$r->print('Here we save the metadata'); |
|
$key_base.=$env{'form.serial'}.'.'; |
|
$r->print('The title: '.$env{'form.title'}.'<br>'); |
|
$r->print('The values: '.$env{'form.values'}.'<br>'); |
|
$r->print('The type: '.$env{'form.type'}.'<br>'); |
|
$r->print('The number: '.$env{'form.serial'}.'<br>'); |
|
my $name = 'metadata.'.$env{'form.serial'}.'.title'; |
|
my $value = $env{'form.title'}; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
$r->print('the put result was: '.$put_result.'<br />'); |
$name = 'metadata.'.$item_num.'.values'; |
$name = 'metadata.'.$env{'form.serial'}.'.type'; |
$value = $env{'form.values'.$item_num}; |
$value = $env{'form.type'}; |
$put_result = &Apache::lonnet::put('environment', |
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
$name = 'metadata.'.$env{'form.serial'}.'.values'; |
} |
$value = $env{'form.values'}; |
if ($field=~m/newfield/) { |
$put_result = &Apache::lonnet::put('environment', |
my $item_num = $env{'form.serial'}; |
|
my $name = 'metadata.'.$item_num.'.type'; |
|
my $value = $env{'form.typenew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
$name = 'metadata.'.$item_num.'.values'; |
} else { |
$value = $env{'form.valuesnew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$name = 'metadata.'.$item_num.'.title'; |
|
$value = $env{'form.titlenew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
|
|
} |
|
|
foreach my $key (sort keys %env) { |
|
if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.\d+\.title$/) { |
} |
$key=~m/^course\.$env{'request.course.id'}\.metadata\.(\d+)\.title/; |
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
$item_num = $1; |
foreach my $key (sort keys %env) { |
if ($1 ge $next_meta) { |
if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.\d+\.title$/) { |
$next_meta = $1 + 1; |
$key=~m/(^course\.$env{'request.course.id'}\.metadata\.)(\d+)\.title/; |
} |
$key_base = $1; |
$output.='<tr><td>'.$env{$key}.'</td>'; |
$item_num = $2; |
$output.='<td>Select one: <input type="radio" name="type'.$item_num.'" value="one" /><br />'; |
if ($item_num ge $next_meta) { |
$output.='Select many: <input type="radio" name="type'.$item_num.'" value="many" /></td>'; |
$next_meta = $item_num + 1; |
$output.='<td><input name="values'.$item_num.'" type="text" value="'.$env{$key.'.values'}.'" /></td></tr>'; |
|
} |
} |
|
$output.='<tr><td>'.$env{$key}.'</td>'; |
|
$output.='<td>Select one: <input type="radio" name="type'.$item_num.'" value="one" /><br />'; |
|
$output.='Select many: <input type="radio" name="type'.$item_num.'" value="many" /></td>'; |
|
$output.='<td><input name="values'.$item_num.'" type="text" value="'.$env{$key_base.$item_num.'.values'}.'" /></td></tr>'; |
} |
} |
|
} |
$output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
$output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
$output.='<input type="text" name="newitem" /></td>'; |
$output.='<input type="text" name="titlenew" /></td>'; |
$output.='<td>Select one: <input type="radio" name="typenew" value="one" /><br />'; |
$output.='<td>Select one: <input type="radio" name="typenew" value="one" /><br />'; |
$output.='Select many: <input type="radio" name="typenew" value="many" /></td>'; |
$output.='Select many: <input type="radio" name="typenew" value="many" /></td>'; |
$output.='<td><input name="valuesnew" type="text" value="" /></td></tr>'; |
$output.='<td><input name="valuesnew" type="text" value="" /></td></tr>'; |
$output.='<td><input type="hidden" name="serial" value="'.$next_meta.'" /></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"> |
|
|
Line 2812 sub setinstmeta {
|
Line 2813 sub setinstmeta {
|
|
|
ENDenv |
ENDenv |
|
|
} |
|
$r->print('</body> |
$r->print('</body> |
</html>'); |
</html>'); |
return 'ok'; |
return 'ok'; |