[LON-CAPA-cvs] cvs: loncom /homework hint.pm response.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 16 Mar 2004 22:00:51 -0000
albertel Tue Mar 16 17:00:51 2004 EDT
Modified files:
/loncom/homework hint.pm response.pm
Log:
- make hinttries work beter in CSTR
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.51 loncom/homework/hint.pm:1.52
--- loncom/homework/hint.pm:1.51 Tue Mar 16 14:47:47 2004
+++ loncom/homework/hint.pm Tue Mar 16 17:00:51 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# implements the tags that control the hints
#
-# $Id: hint.pm,v 1.51 2004/03/16 19:47:47 albertel Exp $
+# $Id: hint.pm,v 1.52 2004/03/16 22:00:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,13 +47,7 @@
my $id=$Apache::inputtags::part;
my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
if ( $numtries eq '') { $numtries = 0; }
- my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");
- if ($ENV{'request.state'} eq 'construct' &&
- defined($Apache::inputtags::params{'hinttries'})) {
- $hinttries=$Apache::inputtags::params{'hinttries'};
- }
-
- if ( $hinttries eq '') { $hinttries = 1; }
+ my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
my $gradestatus=$Apache::lonhomework::history{"resource.$id.solved"};
if ( $numtries < $hinttries || $gradestatus =~ /^correct/) {
@@ -75,8 +69,7 @@
my $id=$Apache::inputtags::part;
my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
if ( $numtries eq '') { $numtries = 0; }
- my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");
- if ( $hinttries eq '') { $hinttries = 1; }
+ my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
my $hinttext=&Apache::lonxml::endredirection;
if ($Apache::lonhomework::type ne 'exam' &&
@@ -158,7 +151,8 @@
my $response = $Apache::lonhomework::history{
"resource.$partid.$submitid.submission"};
&Apache::lonxml::debug("hintgroup is using $response<br />\n");
- my $hideunit=&Apache::lonnet::EXT('resource.'.$submitid.'_'.$id.'.turnoffunit');
+ my $hideunit=&Apache::response::get_response_param($submitid.'_'.$id,
+ 'turnoffunit');
my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
$$args_ref{'response'}=$response;
#need to get all possible parms
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.94 loncom/homework/response.pm:1.95
--- loncom/homework/response.pm:1.94 Fri Mar 12 13:41:43 2004
+++ loncom/homework/response.pm Tue Mar 16 17:00:51 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.94 2004/03/12 18:41:43 albertel Exp $
+# $Id: response.pm,v 1.95 2004/03/16 22:00:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -632,6 +632,20 @@
}
+sub get_response_param {
+ my ($id,$name,$default)=@_;
+ my $parameter;
+ if ($ENV{'request.state'} eq 'construct' &&
+ defined($Apache::inputtags::params{$name})) {
+ $parameter=$Apache::inputtags::params{$name};
+ } else {
+ $parameter=&Apache::lonnet::EXT("resource.$id.$name");
+ }
+ if (!defined($parameter) || $parameter eq '') {
+ $parameter = $default;
+ }
+ return $parameter;
+}
1;
__END__