--- loncom/homework/response.pm 2003/09/23 01:52:57 1.82.2.1
+++ loncom/homework/response.pm 2003/08/11 19:56:45 1.83
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.82.2.1 2003/09/23 01:52:57 albertel Exp $
+# $Id: response.pm,v 1.83 2003/08/11 19:56:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -278,6 +278,24 @@ sub end_dataresponse {
return $result;
}
+sub decide_package {
+ my ($tagstack)=@_;
+ my $package;
+ if ($$tagstack[-1] eq 'parameter') {
+ $package='part';
+ } else {
+ my $i=-1;
+ while (defined($$tagstack[$i])) {
+ if ($$tagstack[$i] =~ /(response|hint)$/) {
+ $package=$$tagstack[$i];
+ last;
+ }
+ $i--;
+ }
+ }
+ return $package;
+}
+
sub start_responseparam {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
@@ -288,6 +306,19 @@ sub start_responseparam {
$token->[2]->{'description'});
} elsif ($target eq 'edit') {
$result.=&Apache::edit::tag_start($target,$token);
+ my $optionlist;
+ my $package=&decide_package($tagstack);
+ foreach my $key (sort(keys(%Apache::lonnet::packagetab))) {
+ if ($key =~ /^\Q$package\E&(.*)&display$/) {
+ $optionlist.='';
+ }
+ }
+ if (defined($optionlist)) {
+ $result.='Use template:
';
+ }
$result.=&Apache::edit::text_arg('Name:','name',$token).
&Apache::edit::text_arg('Type:','type',$token).
&Apache::edit::text_arg('Description:','description',$token).
@@ -295,9 +326,22 @@ sub start_responseparam {
"";
$result.=&Apache::edit::end_table;
} elsif ($target eq 'modified') {
- my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,
- 'name','type','description',
- 'default');
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,
+ $safeeval,'name','type',
+ 'description','default');
+ my $element=&Apache::edit::html_element_name('parameter_package');
+ if (defined($ENV{"form.$element"}) && $ENV{"form.$element"} ne '') {
+ my $name=$ENV{"form.$element"};
+ my $tag=&decide_package($tagstack);
+ $token->[2]->{'name'}=$name;
+ $token->[2]->{'type'}=
+ $Apache::lonnet::packagetab{"$tag&$name&type"};
+ $token->[2]->{'description'}=
+ $Apache::lonnet::packagetab{"$tag&$name&display"};
+ $token->[2]->{'default'}=
+ $Apache::lonnet::packagetab{"$tag&$name&default"};
+ $constructtag=1;
+ }
if ($constructtag) {
$result = &Apache::edit::rebuild_tag($token);
$result.=&Apache::edit::handle_insert();
@@ -512,14 +556,6 @@ sub whichorder {
return @whichopt;
}
-sub show_answer {
- my $part = $Apache::inputtags::part;
- my $award = $Apache::lonhomework::history{"resource.$part.solved"};
- my $status = $Apache::inputtags::status[-1];
- return ( ($award =~ /^correct/
- && lc($Apache::lonhomework::problemstatus) ne 'no')
- || $status eq "SHOW_ANSWER");
-}
1;
__END__