version 1.21, 2005/05/28 01:32:32
|
version 1.28, 2005/10/12 22:54:20
|
Line 1827 sub parse_bb5_assessment {
|
Line 1827 sub parse_bb5_assessment {
|
} |
} |
|
|
sub parse_bb6_assessment { |
sub parse_bb6_assessment { |
my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_; |
my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_; |
return; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
|
my @state = (); |
|
my $id; # the current question ID |
|
my $list; # the current list ID for multiple choice questions |
|
my $currtexttype; |
|
my $curr_outer_block; |
|
my $curr_inner_block; |
|
my $curr_shuffle; |
|
my $curr_class; |
|
my $curr_feedback_type; |
|
my $p = HTML::Parser->new |
|
( |
|
xml_mode => 1, |
|
start_h => |
|
[sub { |
|
my ($tagname, $attr) = @_; |
|
push @state, $tagname; |
|
if ("@state" eq "questestinterop assessment") { |
|
$$settings{title} = $attr->{title}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow") { |
|
$curr_outer_block = $attr->{class}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow") { |
|
$curr_inner_block = $attr->{class}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow material mat_extension mat_formatted_text") { |
|
$$settings{$id}{texttype} = $attr->{texttype}; |
|
$currtexttype = $attr->{texttype}; |
|
$curr_inner_block = $attr->{class}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow material matapplication") { |
|
$$settings{$id}{image} = $attr->{uri}; |
|
$$settings{$id}{style} = $attr->{embedded}; |
|
$$settings{$id}{label} = $attr->{label}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow material mattext") { |
|
$$settings{$id}{link} = $attr->{uri}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow response_lid render_choice") { |
|
$curr_shuffle = $attr->{shuffle}; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow response_lid render_choice flow response_label") { |
|
if ($$settings{$id}{class} eq 'Multiple Choice') { |
|
$curr_class = 'Multiple Choice'; |
|
$list = $attr->{ident}; |
|
push(@{$$settings{$id}{lists}},$list); |
|
$$settings{$id}{$list}{randomize} = $curr_shuffle; |
|
%{$$settings{$id}{$list}} = (); |
|
@{$$allanswers{$id}{$list}} = (); |
|
@{$$settings{$id}{$list}{correctanswer}} = (); |
|
} |
|
} |
|
if ("@state" eq "questestinterop section item itemfeedback") { |
|
$curr_feedback_type = $attr->{ident}; |
|
} |
|
if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material matapplication") { |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{filetype} = $attr->{'embedded'}; |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{label} = $attr->{label}; |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{uri} = $attr->{uri}; |
|
} |
|
if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mattext") { |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{link} = $attr->{uri}; |
|
} |
|
}, "tagname, attr"], |
|
text_h => |
|
[sub { |
|
my ($text) = @_; |
|
$text =~ s/^\s+//g; |
|
$text =~ s/\s+$//g; |
|
if ("@state" eq "questestinterop assessment rubric flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{description} = $text; |
|
} elsif ("@state" eq "questestinterop assessment presentation_material flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{instructions}{text} = $text; |
|
} |
|
if ("@state" eq "questestinterop assessment section item itemmetadata bbmd_asi_object_id") { |
|
$id = $text; |
|
push @{$allids}, $id; |
|
%{$$settings{$id}} = (); |
|
@{$$settings{$id}{lists}} = (); |
|
%{$$settings{$id}{correctfeedback}} = (); |
|
%{$$settings{$id}{incorrectfeedback}} = (); |
|
} |
|
if ("@state" eq "questestinterop assessment section item itemmetadata bbmd_questiontype") { |
|
$$settings{$id}{class} = $text; |
|
} |
|
if ("@state" eq "questestinterop assessment section item presentation flow flow flow material mat_extension mat_formatted_text") { |
|
$$settings{$id}{text} = $text; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow material mattext") { |
|
$$settings{$id}{linktext} = $text; |
|
} |
|
if ("@state" eq "questestinterop section item presentation flow flow flow response_lid render_choice flow response_label flow_mat material mat_extension mat_formatted_text") { |
|
$$settings{$id}{$list}{text} = $text; |
|
} |
|
if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varequal") { |
|
if ($curr_class eq 'Multiple Choice') { |
|
$$settings{$id}{$list}{correctanswer} = $text; |
|
} |
|
} |
|
if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{text} = $text; |
|
} |
|
if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mattext") { |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{linkname} = $text; |
|
} |
|
}, "dtext"], |
|
end_h => |
|
[sub { |
|
my ($tagname) = @_; |
|
pop @state; |
|
}, "tagname"], |
|
); |
|
$p->unbroken_text(1); |
|
$p->marked_sections(1); |
|
$p->parse_file($xmlfile); |
|
$p->eof; |
|
return; |
} |
} |
|
|
sub parse_webct4_assessment { |
sub parse_webct4_assessment { |
Line 2095 sub parse_webct4_questionDB {
|
Line 2212 sub parse_webct4_questionDB {
|
$$settings{$id}{$numid}{toltype} = $attr->{type}; |
$$settings{$id}{$numid}{toltype} = $attr->{type}; |
} |
} |
if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_unit") { |
if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_unit") { |
my $unitid = $attr->{ident}; |
$unitid = $attr->{ident}; |
%{$$settings{$id}{$numid}{$unitid}} = (); |
%{$$settings{$id}{$numid}{$unitid}} = (); |
push(@{$$settings{$id}{$numid}{units}},$unitid); |
push(@{$$settings{$id}{$numid}{units}},$unitid); |
$$settings{$id}{$numid}{$unitid}{value} = $attr->{value}; |
$$settings{$id}{$numid}{$unitid}{value} = $attr->{value}; |
Line 2864 sub write_webct4_questions {
|
Line 2981 sub write_webct4_questions {
|
$allfeedback .= $feedback; |
$allfeedback .= $feedback; |
} |
} |
if ($$settings{$id}{texttype} eq 'text/html') { |
if ($$settings{$id}{texttype} eq 'text/html') { |
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text}); |
$$settings{$id}{text} =~ s/(\&)(nbsp|gt|lt)(?!;)/$1$2;$3/gi; |
$$settings{$id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{text}); |
$$settings{$id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{text}); |
$$settings{$id}{text} =~ s#(<img src=["']?)([^>]+)(/?>)#$1../../resfiles/$2 />#gi; |
$$settings{$id}{text} =~ s#(<img src=["']?)([^>]+?)(/?>)#$1../../resfiles/$2 />#gi; |
$$settings{$id}{text} =~ s#<([bh])r>#<$1r />#g; |
$$settings{$id}{text} =~ s#<([bh])r>#<$1r />#g; |
# $$settings{$id}{text} =~ s#<p>#</p><p>#g; |
|
# $$settings{$id}{text} =~ s#</p></p>#</p>#; |
|
# $$settings{$id}{text} =~ s#<p></p>##g; |
|
$$settings{$id}{text} =~ s#<p>#<br /><br />#g; |
$$settings{$id}{text} =~ s#<p>#<br /><br />#g; |
$$settings{$id}{text} =~ s#</p>##g; |
$$settings{$id}{text} =~ s#</p>##g; |
} |
} |
Line 2893 sub write_webct4_questions {
|
Line 3007 sub write_webct4_questions {
|
$resourcedata{$symb.'randomize'} = 'yes'; |
$resourcedata{$symb.'randomize'} = 'yes'; |
$resourcedata{$symb.'maxfoils'} = 10; |
$resourcedata{$symb.'maxfoils'} = 10; |
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
$output = qq|<problem> |
unless ($$settings{$id}{class} eq 'numerical') { |
|
$output = qq|<problem> |
|; |
|; |
|
} |
} |
} |
$$total{prob} ++; |
$$total{prob} ++; |
if (exists($$settings{$id}{uri})) { |
if (exists($$settings{$id}{uri})) { |
Line 3058 sub write_webct4_questions {
|
Line 3174 sub write_webct4_questions {
|
} else { |
} else { |
$output .= qq| |
$output .= qq| |
<optionresponse max="10" randomize="yes"> |
<optionresponse max="10" randomize="yes"> |
<foilgroup options=$allmatchlist> |
<foilgroup options="$allmatchlist"> |
|; |
|; |
} |
} |
} else { |
} else { |
Line 3249 sub write_webct4_questions {
|
Line 3365 sub write_webct4_questions {
|
} |
} |
} |
} |
} elsif ($$settings{$id}{class} eq 'numerical') { |
} elsif ($$settings{$id}{class} eq 'numerical') { |
|
my %mathfns = ( |
|
'abs' => 'abs', |
|
'acos' => 'acos', |
|
'asin' => 'asin', |
|
'atan' => 'atan', |
|
'ceil' => 'ceil', |
|
'cos' => 'cos', |
|
'exp' => 'exp', |
|
'fact' => 'factorial', |
|
'floor' => 'floor', |
|
'int' => 'int', |
|
'ln' => 'log', |
|
'log' => 'log', |
|
'max' => 'max', |
|
'min' => 'min', |
|
'round' => 'roundto', |
|
'sin' => 'sin', |
|
'sqrt' => 'sqrt', |
|
'tan' => 'tan', |
|
); |
|
|
my $scriptblock = qq| |
my $scriptblock = qq| |
<script type="loncapa/perl"> |
<script type="loncapa/perl"> |
|; |
|; |
foreach my $numid (@{$$settings{$id}{numids}}) { |
foreach my $numid (@{$$settings{$id}{numids}}) { |
my $formula = $$settings{$id}{$numid}{formula}; |
my $formula = $$settings{$id}{$numid}{formula}; |
|
my $pattern = join('|',(sort (keys (%mathfns)))); |
|
$formula =~ s/($pattern)/\&$mathfns{$1}/g; |
foreach my $var (keys %{$$settings{$id}{$numid}{vars}}) { |
foreach my $var (keys %{$$settings{$id}{$numid}{vars}}) { |
my $decnum = $$settings{$id}{$numid}{vars}{$var}{dec}; |
my $decnum = $$settings{$id}{$numid}{vars}{$var}{dec}; |
my $increment = '0.'; |
my $increment = '0.'; |
Line 3267 sub write_webct4_questions {
|
Line 3406 sub write_webct4_questions {
|
} |
} |
$increment .= '1'; |
$increment .= '1'; |
} |
} |
$formula =~ s/{($var)}/\$$1/g; |
$formula =~ s/{($var)}/(\$$1)/g; |
$formula =~ s/ln\(?([^\)])\)?/ &log($1) /g; |
|
$formula =~ s/sqrt/\&sqrt/g; |
|
$scriptblock .= qq| |
$scriptblock .= qq| |
\$$var=&random($$settings{$id}{$numid}{vars}{$var}{min},$$settings{$id}{$numid}{vars}{$var}{max},$increment); |
\$$var=&random($$settings{$id}{$numid}{vars}{$var}{min},$$settings{$id}{$numid}{vars}{$var}{max},$increment); |
|; |
|; |
Line 3279 sub write_webct4_questions {
|
Line 3416 sub write_webct4_questions {
|
</script> |
</script> |
|; |
|; |
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
$output = $scriptblock.$output; |
$output = "<problem>\n".$scriptblock.$output; |
my $ansformat = ''; |
my $ansformat = ''; |
my $sigfig = '0,15'; |
my $sigfig = '0,15'; |
if ($$settings{$id}{$numid}{format} eq 'sig') { |
if ($$settings{$id}{$numid}{format} eq 'sig') { |
Line 3300 sub write_webct4_questions {
|
Line 3437 sub write_webct4_questions {
|
} |
} |
my $unitentry = ''; |
my $unitentry = ''; |
if ($unit ne '') { |
if ($unit ne '') { |
$unitentry = 'unit='.$unit; |
$unitentry = 'unit="'.$unit.'"'; |
} |
} |
$output .= qq| |
$output .= qq| |
<numericalresponse $unitentry $ansformat answer="\$answervar"> |
<numericalresponse $unitentry $ansformat answer="\$answervar"> |