version 1.33, 2001/08/04 19:19:17
|
version 1.41, 2001/08/07 23:17:36
|
Line 3
|
Line 3
|
|
|
# 11/23,11/24,11/28 Gerd Kortemeyer |
# 11/23,11/24,11/28 Gerd Kortemeyer |
# Guy Albertelli |
# Guy Albertelli |
# 08/04 Gerd Kortemeyer |
# 08/04,08/07 Gerd Kortemeyer |
|
|
package Apache::response; |
package Apache::response; |
use strict; |
use strict; |
Line 13 sub BEGIN {
|
Line 13 sub BEGIN {
|
} |
} |
|
|
sub start_response { |
sub start_response { |
my ($parstack,$safeeval)=@_; |
my ($parstack,$safeeval)=@_; |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
push (@Apache::inputtags::response,$id); |
push (@Apache::inputtags::response,$id); |
Line 28 sub end_response {
|
Line 28 sub end_response {
|
return ''; |
return ''; |
} |
} |
|
|
|
sub start_hintresponse { |
|
my ($parstack,$safeeval)=@_; |
|
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
|
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
|
push (@Apache::inputtags::response,$id); |
|
return $id; |
|
} |
|
|
|
sub end_hintresponse { |
|
pop @Apache::inputtags::response; |
|
return ''; |
|
} |
|
|
# used by response to set the non-safe space random number generator to something |
# used by response to set the non-safe space random number generator to something |
# that is stable and unique based on the part number and response number |
# that is stable and unique based on the part number and response number |
sub setrandomnumber { |
sub setrandomnumber { |
Line 35 sub setrandomnumber {
|
Line 48 sub setrandomnumber {
|
&Apache::lonxml::debug("randseed $rndseed"); |
&Apache::lonxml::debug("randseed $rndseed"); |
# $rndseed=unpack("%32i",$rndseed); |
# $rndseed=unpack("%32i",$rndseed); |
$rndseed=$rndseed |
$rndseed=$rndseed |
+(&Apache::lonnet::numval($Apache::inputtags::part) << 10) |
+(&Apache::lonnet::numval($Apache::inputtags::part) << 10); |
|
if (defined($Apache::inputtags::response['-1'])) { |
|
$rndseed=$rndseed |
+&Apache::lonnet::numval($Apache::inputtags::response['-1']); |
+&Apache::lonnet::numval($Apache::inputtags::response['-1']); |
|
} |
srand($rndseed); |
srand($rndseed); |
&Apache::lonxml::debug("randseed $rndseed"); |
&Apache::lonxml::debug("randseed $rndseed"); |
return ''; |
return ''; |
Line 44 sub setrandomnumber {
|
Line 60 sub setrandomnumber {
|
|
|
sub meta_parameter_write { |
sub meta_parameter_write { |
my ($name,$type,$default,$display)=@_; |
my ($name,$type,$default,$display)=@_; |
return '<parameter part="'.$Apache::inputtags::part. |
my $partref=$Apache::inputtags::part; |
'" name="'.$name. |
my $result='<parameter part="'.$Apache::inputtags::part.'"'; |
'" type="'.$type. |
if (defined($Apache::inputtags::response[-1])) { |
'" default="'.$default. |
$result.= ' id="'.$Apache::inputtags::response[-1].'"'; |
'" display="'.$display. |
$partref.='_'.$Apache::inputtags::response[-1]; |
' [Part: '.$Apache::inputtags::part.']"></parameter>' |
} |
."\n"; |
$result.= ' name="'.$name.'"'. |
|
' type="'.$type.'"'. |
|
($default?' default="'.$default.'"':''). |
|
($display?' display="'.$display.' [Part: '.$partref.']"':'') |
|
.'></parameter>' |
|
."\n"; |
|
return $result; |
} |
} |
|
|
sub meta_package_write { |
sub meta_package_write { |
my $name=shift; |
my $name=shift; |
return '<parameter part="'.$Apache::inputtags::part. |
my $result = '<parameter part="'.$Apache::inputtags::part.'"'; |
'" package="'.$name.'"></parameter>' |
if(defined($Apache::inputtags::response[-1])) { |
."\n"; |
$result.= ' id="'.$Apache::inputtags::response[-1].'"'; |
|
} |
|
$result.=' package="'.$name.'"></parameter>'."\n"; |
|
return $result; |
} |
} |
|
|
sub meta_stores_write { |
sub meta_stores_write { |
my ($name,$type,$display)=@_; |
my ($name,$type,$display)=@_; |
return '<stores part="'.$Apache::inputtags::part. |
my $partref=$Apache::inputtags::part; |
'" name="'.$name. |
my $result = '<stores part="'.$Apache::inputtags::part.'"'; |
'" type="'.$type. |
if (defined($Apache::inputtags::response[-1])) { |
'" display="'.$display. |
$result.= ' id="'.$Apache::inputtags::response[-1].'"'; |
' [Part: '.$Apache::inputtags::part.']"></stores>' |
$partref.='_'.$Apache::inputtags::response[-1]; |
."\n"; |
} |
|
$result.= ' name="'.$name.'"'. |
|
' type="'.$type.'"'. |
|
' display="'.$display.' [Part: '.$partref.']"'. |
|
"></stores>\n"; |
} |
} |
|
|
sub mandatory_part_meta { |
sub mandatory_part_meta { |
Line 78 sub mandatory_part_meta {
|
Line 107 sub mandatory_part_meta {
|
# of each part |
# of each part |
# |
# |
return |
return |
&meta_parameter_write('opendate','date_start','', |
# &meta_parameter_write('opendate','date_start','', |
'Opening Date'). |
# 'Opening Date'). |
&meta_parameter_write('duedate','date_end','', |
# &meta_parameter_write('duedate','date_end','', |
'Due Date'). |
# 'Due Date'). |
&meta_parameter_write('answerdate','date_start','', |
# &meta_parameter_write('answerdate','date_start','', |
'Show Answer Date'). |
# 'Show Answer Date'). |
&meta_parameter_write('weight','int_zeropos','', |
# &meta_parameter_write('weight','int_zeropos','', |
'Available Points'). |
# 'Available Points'). |
&meta_parameter_write('maxtries','int_pos','', |
# &meta_parameter_write('maxtries','int_pos','', |
'Maximum Number of Tries'). |
# 'Maximum Number of Tries'). |
|
&meta_package_write('part'). |
&meta_stores_write('solved','string', |
&meta_stores_write('solved','string', |
'Problem Status'). |
'Problem Status'). |
&meta_stores_write('tries','int_zeropos', |
&meta_stores_write('tries','int_zeropos', |
Line 148 sub start_numericalresponse {
|
Line 177 sub start_numericalresponse {
|
require Apache::caparesponse; |
require Apache::caparesponse; |
import Apache::caparesponse; |
import Apache::caparesponse; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
return &Apache::caparesponse::start_numericalresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
return &Apache::caparesponse::start_numericalresponse |
|
($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
} |
} |
|
|
sub start_radiobuttonresponse { |
sub start_radiobuttonresponse { |
Line 184 sub start_responseparam {
|
Line 214 sub start_responseparam {
|
if ($target eq 'grade' || $target eq 'web') { |
if ($target eq 'grade' || $target eq 'web') { |
my $default= &Apache::lonxml::get_param('default',$parstack,$safeeval); |
my $default= &Apache::lonxml::get_param('default',$parstack,$safeeval); |
my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval); |
&Apache::lonxml::debug("looking for resource.$Apache::inputtags::part.$name"); |
my $entry= 'resource.'.$Apache::inputtags::part; |
my $value = &Apache::lonnet::EXT("resource.$Apache::inputtags::part.$name"); |
if (defined($Apache::inputtags::response[-1])) { |
|
$entry.='_'.$Apache::inputtags::response[-1]; |
|
} |
|
$entry.='.'.$name; |
|
&Apache::lonxml::debug("looking for $entry"); |
|
my $value = &Apache::lonnet::EXT("$entry"); |
&Apache::lonxml::debug("$name has value :$value: and default :$default:"); |
&Apache::lonxml::debug("$name has value :$value: and default :$default:"); |
if ($value eq '' || $value eq 'con_lost') { |
if ($value eq '' || $value eq 'con_lost' || $value =~ /^error:/) { |
&Apache::lonxml::debug("defaulting"); |
&Apache::lonxml::debug("defaulting"); |
$Apache::inputtags::params{$name}=$default; |
$Apache::inputtags::params{$name}=$default; |
} else { |
} else { |