version 1.19, 2005/04/07 06:56:22
|
version 1.28, 2005/10/12 22:54:20
|
Line 24
|
Line 24
|
package Apache::imsprocessor; |
package Apache::imsprocessor; |
|
|
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncleanup; |
|
use LWP::UserAgent; |
|
use HTTP::Request::Common; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
use strict; |
use strict; |
|
|
Line 1724 sub parse_bb5_assessment {
|
Line 1727 sub parse_bb5_assessment {
|
$id = $attr->{id}; |
$id = $attr->{id}; |
} elsif ( ($state[0] eq $toptag{$container}) && ($state[1] =~ m/^QUESTION_(\w+)$/) && ($state[2] eq "BODY") && ($state[3] eq "FLAGS") ) { |
} elsif ( ($state[0] eq $toptag{$container}) && ($state[1] =~ m/^QUESTION_(\w+)$/) && ($state[2] eq "BODY") && ($state[3] eq "FLAGS") ) { |
if ($state[4] eq "ISHTML") { |
if ($state[4] eq "ISHTML") { |
$$settings{$id}{html} = $attr->{value}; |
$$settings{$id}{ishtml} = $attr->{value}; |
} elsif ($state[4] eq "ISNEWLINELITERAL") { |
} elsif ($state[4] eq "ISNEWLINELITERAL") { |
$$settings{$id}{newline} = $attr->{value}; |
$$settings{$id}{newline} = $attr->{value}; |
} |
} |
Line 1824 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 2092 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 2342 sub process_assessment {
|
Line 2462 sub process_assessment {
|
if (!-e "$destdir/problems/$seqname") { |
if (!-e "$destdir/problems/$seqname") { |
mkdir("$destdir/problems/$seqname",0755); |
mkdir("$destdir/problems/$seqname",0755); |
} |
} |
my $newdir = "$destdir/problems/$seqname"; |
$newdir = "$destdir/problems/$seqname"; |
my $dbcontainerdir; |
my $dbcontainerdir; |
&build_problem_container($cms,$seqname,$destdir,'database',$seqname,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@{$$catinfo{$category}{contents}},$udom,$uname,$dirname,\$dbcontainerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
&build_problem_container($cms,$seqname,$destdir,'database',$seqname,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@{$$catinfo{$category}{contents}},$udom,$uname,$dirname,\$dbcontainerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
} |
} |
Line 2370 sub process_assessment {
|
Line 2490 sub process_assessment {
|
if (!-e "$destdir/problems/$dirtitle") { |
if (!-e "$destdir/problems/$dirtitle") { |
mkdir("$destdir/problems/$dirtitle",0755); |
mkdir("$destdir/problems/$dirtitle",0755); |
} |
} |
my $newdir = "$destdir/problems/$dirtitle"; |
$newdir = "$destdir/problems/$dirtitle"; |
} |
} |
|
|
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
if ($cms eq 'webct4') { |
|
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
|
} else { |
|
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$settings); |
|
} |
if ($cms eq 'bb5') { |
if ($cms eq 'bb5') { |
&write_bb5_questions(\@allids,$containerdir,$context,$settings,$dirname,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); |
&write_bb5_questions(\@allids,$containerdir,$context,$settings,$dirname,$destdir,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot); |
} elsif ($cms eq 'bb6') { |
} elsif ($cms eq 'bb6') { |
&write_bb6_questions(\@allids,$containerdir,$context,$settings,$dirname,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); |
&write_bb6_questions(\@allids,$containerdir,$context,$settings,$dirname,$destdir,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); |
} |
} |
} |
} |
|
|
Line 2411 sub build_problem_container {
|
Line 2535 sub build_problem_container {
|
my $probsrc = "/res/lib/templates/simpleproblem.problem"; |
my $probsrc = "/res/lib/templates/simpleproblem.problem"; |
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
foreach my $id (@{$allids}) { |
foreach my $id (@{$allids}) { |
$probtitle{$id} = $$settings{$id}{title}; |
if ($cms eq 'webct4') { |
|
$probtitle{$id} = $$settings{$id}{title}; |
|
} else { |
|
$probtitle{$id} = $$settings{title}; |
|
} |
$probtitle{$id} =~ s/\s/_/g; |
$probtitle{$id} =~ s/\s/_/g; |
$probtitle{$id} =~ s/\W//g; |
$probtitle{$id} =~ s/\W//g; |
$probtitle{$id} .= '_'.$id; |
$probtitle{$id} .= '_'.$id; |
Line 2423 sub build_problem_container {
|
Line 2551 sub build_problem_container {
|
$probdir =~ s/\W//g; |
$probdir =~ s/\W//g; |
$probsrc = "$dirname/problems/$probdir/$probtitle{$$allids[0]}.problem"; |
$probsrc = "$dirname/problems/$probdir/$probtitle{$$allids[0]}.problem"; |
} else { |
} else { |
$probsrc="$dirname/problems/$dirtitle/$$allids[0].problem"; |
$probsrc="$dirname/problems/$dirtitle/$probtitle{$$allids[0]}.problem"; |
} |
} |
} |
} |
print $fh qq|<resource id="1" src="$probsrc" type="start" title="question_0001"></resource>|; |
print $fh qq|<resource id="1" src="$probsrc" type="start" title="question_0001"></resource>|; |
Line 2447 sub build_problem_container {
|
Line 2575 sub build_problem_container {
|
$probdir =~ s/\W//g; |
$probdir =~ s/\W//g; |
$probsrc = "$dirname/problems/$probdir/$probtitle{$$allids[$j]}.problem"; |
$probsrc = "$dirname/problems/$probdir/$probtitle{$$allids[$j]}.problem"; |
} else { |
} else { |
$probsrc = "$dirname/problems/$dirtitle/$$allids[$j].problem"; |
$probsrc = "$dirname/problems/$dirtitle/$probtitle{$$allids[$j]}.problem"; |
} |
} |
} |
} |
print $fh qq| |
print $fh qq| |
Line 2465 sub build_problem_container {
|
Line 2593 sub build_problem_container {
|
} |
} |
|
|
sub write_bb5_questions { |
sub write_bb5_questions { |
my ($allids,$containerdir,$context,$settings,$dirname,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum) = @_; |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot) = @_; |
my $qnum = 0; |
my $qnum = 0; |
foreach my $id (@{$allids}) { |
foreach my $id (@{$allids}) { |
|
if ($$settings{$id}{ishtml} eq 'true') { |
|
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text}); |
|
} |
|
if ($$settings{$id}{text} =~ m#<img src=['"]?(https?://[^\s]+/)([^/\s\'"]+)['"]?[^>]*>#) { |
|
if (&retrieve_image($context,$res,$dirname,$cdom,$cnum,$docroot,$destdir,$1,$2) eq 'ok') { |
|
$$settings{$id}{text} =~ s#(<img src=['"]?)(https?://[^\s]+/)([^/\s'"]+)(['"]?[^>]*>)#$1../../resfiles/$res/webimages/$3$4#g; |
|
} |
|
} |
|
$$settings{$id}{text} =~ s#(<img src=[^>]+)/*>#$1 />#gi; |
|
$$settings{$id}{text} =~ s#<br>#<br />#g; |
$qnum ++; |
$qnum ++; |
my $output; |
my $output; |
my $permcontainer = $containerdir; |
my $permcontainer = $containerdir; |
Line 2811 sub write_bb5_questions {
|
Line 2949 sub write_bb5_questions {
|
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
$output .= qq|</problem> |
$output .= qq|</problem> |
|; |
|; |
open(PROB,">$newdir/problems/$id.problem"); |
my $title = $$settings{title}; |
|
$title =~ s/\s/_/g; |
|
$title =~ s/\W//g; |
|
$title .= '_'.$id; |
|
open(PROB,">:utf8", "$newdir/$title.problem"); |
print PROB $output; |
print PROB $output; |
close PROB; |
close PROB; |
} else { |
} else { |
Line 2839 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::lonxml::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#<hr>#<hr />#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; |
} |
} |
if ($$settings{$id}{class} eq 'numerical') { |
if ($$settings{$id}{class} eq 'numerical') { |
foreach my $numid (@{$$settings{$id}{numids}}) { |
foreach my $numid (@{$$settings{$id}{numids}}) { |
Line 2868 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 2930 sub write_webct4_questions {
|
Line 3071 sub write_webct4_questions {
|
} |
} |
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::lonxml::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
|
|
Line 2972 sub write_webct4_questions {
|
Line 3113 sub write_webct4_questions {
|
} |
} |
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::lonxml::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
|
|
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
Line 3004 sub write_webct4_questions {
|
Line 3145 sub write_webct4_questions {
|
|
|
$$settings{$id}{$grp}{$answer_id}{text} = &HTML::Entities::decode($$settings{$id}{$grp}{$answer_id}{text}); |
$$settings{$id}{$grp}{$answer_id}{text} = &HTML::Entities::decode($$settings{$id}{$grp}{$answer_id}{text}); |
$test_for_html = &test_for_html($$settings{$id}{$grp}{$answer_id}{text}); |
$test_for_html = &test_for_html($$settings{$id}{$grp}{$answer_id}{text}); |
$$settings{$id}{$grp}{$answer_id}{text} = &Apache::lonxml::chtmlclean($$settings{$id}{$grp}{$answer_id}{text}); |
$$settings{$id}{$grp}{$answer_id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$grp}{$answer_id}{text}); |
$$settings{$id}{$grp}{$answer_id}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$grp}{$answer_id}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$grp}{$answer_id}{text} =~ s#</?p>##g; |
$$settings{$id}{$grp}{$answer_id}{text} =~ s#</?p>##g; |
} |
} |
Line 3033 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 3067 sub write_webct4_questions {
|
Line 3208 sub write_webct4_questions {
|
for (my $k=0; $k<@{$$allchoices{$id}}; $k++) { |
for (my $k=0; $k<@{$$allchoices{$id}}; $k++) { |
if ($$settings{$id}{$$allchoices{$id}[$k]}{texttype} eq 'text/html') { |
if ($$settings{$id}{$$allchoices{$id}[$k]}{texttype} eq 'text/html') { |
$$settings{$id}{$$allchoices{$id}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$$allchoices{$id}[$k]}{text}); |
$$settings{$id}{$$allchoices{$id}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$$allchoices{$id}[$k]}{text}); |
$$settings{$id}{$$allchoices{$id}[$k]}{text} = &Apache::lonxml::htmlclean($$settings{$id}{$$allchoices{$id}[$k]}{text}); |
$$settings{$id}{$$allchoices{$id}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$$allchoices{$id}[$k]}{text}); |
$$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#</?p>##g; |
$$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#</?p>##g; |
} |
} |
Line 3224 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 3242 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 3254 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 3275 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"> |
Line 3332 sub test_for_html {
|
Line 3494 sub test_for_html {
|
} |
} |
|
|
sub write_bb6_questions { |
sub write_bb6_questions { |
my ($allids,$containerdir,$context,$settings,$dirname,$res,$allanswers,$allchoices) = @_; |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices) = @_; |
|
} |
|
|
|
sub retrieve_image { |
|
my ($context,$res,$dirname,$cdom,$cname,$docroot,$destdir,$urlpath,$filename) = @_; |
|
my $contents; |
|
my $url = $urlpath.$filename; |
|
my $ua=new LWP::UserAgent; |
|
my $request=new HTTP::Request('GET',$url); |
|
my $response=$ua->request($request); |
|
if ($response->is_success) { |
|
$contents = $response->content; |
|
if (!-e "$docroot/$res") { |
|
mkdir("$docroot/$res",0755); |
|
} |
|
if (!-e "$docroot/$res/webimages") { |
|
mkdir("$docroot/$res/webimages",0755); |
|
} |
|
open(my $fh,">$docroot/$res/webimages/$filename"); |
|
print $fh $contents; |
|
close($fh); |
|
if ($context eq 'DOCS') { |
|
my $chome = &Apache::lonnet::homeserver($cname,$cdom); |
|
my $copyfile = $dirname.'/'.$filename; |
|
my $source = "$docroot/$res/webimages/$filename"; |
|
my $fileresult; |
|
if (-e $source) { |
|
$fileresult = &Apache::lonnet::process_coursefile('copy',$cname,$cdom,$chome,$copyfile,$source); |
|
} |
|
return $fileresult; |
|
} elsif ($context eq 'CSTR') { |
|
if (!-e "$destdir/resfiles/$res") { |
|
mkdir("$destdir/resfiles/$res",0755); |
|
} |
|
if (!-e "$destdir/resfiles/$res/webimages") { |
|
mkdir("$destdir/resfiles/$res/webimages",0755); |
|
} |
|
rename("$docroot/$res/webimages/$filename","$destdir/resfiles/$res/webimages/$filename"); |
|
return 'ok'; |
|
} |
|
} else { |
|
return -1; |
|
} |
} |
} |
|
|
# ---------------------------------------------------------------- Process Blackboard Announcements |
# ---------------------------------------------------------------- Process Blackboard Announcements |