version 1.27, 2005/07/20 05:13:46
|
version 1.34, 2006/03/24 17:36:27
|
Line 44 sub ims_config {
|
Line 44 sub ims_config {
|
survey => 'assessment/x-bb-survey', |
survey => 'assessment/x-bb-survey', |
users => 'course/x-bb-user', |
users => 'course/x-bb-user', |
); |
); |
%{$$cmsmap{bb6}} = %{$$cmsmap{bb5}}; |
%{$$cmsmap{bb6}} = ( |
|
announce => 'resource/x-bb-announcement', |
|
board => 'resource/x-bb-discussionboard', |
|
doc => 'resource/x-bb-document', |
|
extlink => 'resource/x-bb-externallink', |
|
pool => 'assessment/x-bb-qti-pool', |
|
quiz => 'assessment/x-bb-qti-test', |
|
staff => 'resource/x-bb-staffinfo', |
|
survey => 'assessment/x-bb-survey', |
|
users => 'course/x-bb-user', |
|
); |
$$cmsmap{bb6}{conference} = 'resource/x-bb-conference'; |
$$cmsmap{bb6}{conference} = 'resource/x-bb-conference'; |
%{$$cmsmap{angel}} = ( |
%{$$cmsmap{angel}} = ( |
board => 'BOARD', |
board => 'BOARD', |
Line 54 sub ims_config {
|
Line 64 sub ims_config {
|
survey => 'FORM', |
survey => 'FORM', |
); |
); |
@{$$cmsmap{angel}{doc}} = ('FILE','PAGE'); |
@{$$cmsmap{angel}{doc}} = ('FILE','PAGE'); |
%{$$cmsmap{webct4}} = ( |
%{$$cmsmap{webctce4}} = ( |
quiz => 'webctquiz', |
quiz => 'webctquiz', |
survey => 'webctsurvey', |
survey => 'webctsurvey', |
doc => 'webcontent' |
doc => 'webcontent' |
Line 148 sub process_manifest {
|
Line 158 sub process_manifest {
|
bb6 => 'organization', |
bb6 => 'organization', |
bb5 => 'tableofcontents', |
bb5 => 'tableofcontents', |
angel => 'organization', |
angel => 'organization', |
webct4 => 'organization', |
webctce4 => 'organization', |
); |
); |
my %contents = (); |
my %contents = (); |
my @state = (); |
my @state = (); |
Line 192 sub process_manifest {
|
Line 202 sub process_manifest {
|
%{$$items{$itm}} = (); |
%{$$items{$itm}} = (); |
$$items{$itm}{contentscount} = 0; |
$$items{$itm}{contentscount} = 0; |
@{$$items{$itm}{contents}} = (); |
@{$$items{$itm}{contents}} = (); |
if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { |
if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webctce4') { |
$$items{$itm}{resnum} = $attr->{identifierref}; |
$$items{$itm}{resnum} = $attr->{identifierref}; |
if ($cms eq 'bb5') { |
if ($cms eq 'bb5') { |
$$items{$itm}{title} = $attr->{title}; |
$$items{$itm}{title} = $attr->{title}; |
Line 246 sub process_manifest {
|
Line 256 sub process_manifest {
|
$lastitem = $itm; |
$lastitem = $itm; |
} |
} |
} |
} |
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
if (($state[-1] eq "webct:properties") && (@state > 4)) { |
if (($state[-1] eq "webct:properties") && (@state > 4)) { |
$$items{$itm}{properties} = $attr->{identifierref}; |
$$items{$itm}{properties} = $attr->{identifierref}; |
} |
} |
Line 257 sub process_manifest {
|
Line 267 sub process_manifest {
|
if ($cms eq 'bb5' || $cms eq 'bb6') { |
if ($cms eq 'bb5' || $cms eq 'bb6') { |
$$resources{$identifier}{file} = $attr->{file}; |
$$resources{$identifier}{file} = $attr->{file}; |
$$resources{$identifier}{type} = $attr->{type}; |
$$resources{$identifier}{type} = $attr->{type}; |
} elsif ($cms eq 'webct4') { |
} elsif ($cms eq 'webctce4') { |
$$resources{$identifier}{type} = $attr->{type}; |
$$resources{$identifier}{type} = $attr->{type}; |
$$resources{$identifier}{file} = $attr->{href}; |
$$resources{$identifier}{file} = $attr->{href}; |
} elsif ($cms eq 'angel') { |
} elsif ($cms eq 'angel') { |
Line 270 sub process_manifest {
|
Line 280 sub process_manifest {
|
} |
} |
} elsif ("@state" eq "manifest resources resource file") { |
} elsif ("@state" eq "manifest resources resource file") { |
if ($$includedres{$identifier} || $phase ne 'build') { |
if ($$includedres{$identifier} || $phase ne 'build') { |
if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { |
if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webctce4') { |
push @{$$hrefs{$identifier}},$attr->{href}; |
push @{$$hrefs{$identifier}},$attr->{href}; |
} elsif ($cms eq 'angel') { |
} elsif ($cms eq 'angel') { |
if ($attr->{href} =~ m/^_assoc\\$identifier\\(.+)$/) { |
if ($attr->{href} =~ m/^_assoc\\$identifier\\(.+)$/) { |
Line 293 sub process_manifest {
|
Line 303 sub process_manifest {
|
if ($cms eq 'angel' || $cms eq 'bb6') { |
if ($cms eq 'angel' || $cms eq 'bb6') { |
$$items{$itm}{title} = $text; |
$$items{$itm}{title} = $text; |
} |
} |
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
$$items{$itm}{title} = $text; |
$$items{$itm}{title} = $text; |
$$items{$itm}{title} =~ s/(<[^>]*>)//g; |
$$items{$itm}{title} =~ s/(<[^>]*>)//g; |
} |
} |
Line 355 sub target_resources {
|
Line 365 sub target_resources {
|
} |
} |
|
|
sub copy_resources { |
sub copy_resources { |
my ($context,$cms,$hrefs,$tempdir,$targets,$url,$crs,$cdom,$chome,$destdir,$timenow) = @_; |
my ($context,$cms,$hrefs,$tempdir,$targets,$url,$crs,$cdom,$destdir,$timenow) = @_; |
if ($context eq 'DOCS') { |
if ($context eq 'DOCS') { |
foreach my $key (sort keys %{$hrefs}) { |
foreach my $key (sort keys %{$hrefs}) { |
if (grep/^$key$/,@{$targets}) { |
if (grep/^$key$/,@{$targets}) { |
%{$$url{$key}} = (); |
%{$$url{$key}} = (); |
foreach my $file (@{$$hrefs{$key}}) { |
foreach my $file (@{$$hrefs{$key}}) { |
my $source = $tempdir.'/'.$key.'/'.$file; |
my $source = $tempdir.'/'.$key.'/'.$file; |
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
$source = $tempdir.'/'.$file; |
$source = $tempdir.'/'.$file; |
} |
} |
my $filename = ''; |
my $filename = ''; |
Line 374 sub copy_resources {
|
Line 384 sub copy_resources {
|
} |
} |
$file =~ s-\\-/-g; |
$file =~ s-\\-/-g; |
my $copyfile = $file; |
my $copyfile = $file; |
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
if ($file =~ m-/my_files/(.+)$-) { |
if ($file =~ m-/my_files/(.+)$-) { |
$copyfile = $1; |
$copyfile = $1; |
} |
} |
} |
} |
unless (($cms eq 'webct4') && ($copyfile =~ m/questionDB\.xml$/ || $copyfile =~ m/quiz_QIZ_\d+\.xml$/ || $copyfile =~ m/properties_QIZ_\d+\.xml$/)) { |
unless (($cms eq 'webctce4') && ($copyfile =~ m/questionDB\.xml$/ || $copyfile =~ m/quiz_QIZ_\d+\.xml$/ || $copyfile =~ m/properties_QIZ_\d+\.xml$/)) { |
$copyfile = $fpath.$copyfile; |
$copyfile = $fpath.$copyfile; |
my $fileresult; |
my $fileresult; |
if (-e $source) { |
if (-e $source) { |
$fileresult = &Apache::lonnet::process_coursefile('copy',$crs,$cdom,$chome,$copyfile,$source); |
$fileresult = &Apache::lonnet::process_coursefile('copy',$crs,$cdom,$copyfile,$source); |
} |
} |
} |
} |
} |
} |
Line 417 sub copy_resources {
|
Line 427 sub copy_resources {
|
} elsif ($cms eq 'bb5' || $cms eq 'bb6') { |
} elsif ($cms eq 'bb5' || $cms eq 'bb6') { |
rename("$tempdir/$key/$file","$destdir/resfiles/$key/$file"); |
rename("$tempdir/$key/$file","$destdir/resfiles/$key/$file"); |
} |
} |
} elsif ($cms eq 'webct4') { |
} elsif ($cms eq 'webctce4') { |
if ($file =~ m-/my_files/(.+)$-) { |
if ($file =~ m-/my_files/(.+)$-) { |
my $copyfile = $1; |
my $copyfile = $1; |
if ($copyfile =~ m-^[^/]+/[^/]+-) { |
if ($copyfile =~ m-^[^/]+/[^/]+-) { |
Line 501 sub process_resinfo {
|
Line 511 sub process_resinfo {
|
} |
} |
} elsif ($$resources{$key}{type} eq "resource/x-bb-staffinfo") { |
} elsif ($$resources{$key}{type} eq "resource/x-bb-staffinfo") { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
&process_staff($key,$docroot,$dirname,$destdir,\%{$$resinfo{$key}},$resrcfiles); |
&process_staff($key,$docroot,$destdir,\%{$$resinfo{$key}},$resrcfiles); |
} elsif ($$resources{$key}{type} eq "resource/x-bb-externallink") { |
} elsif ($$resources{$key}{type} eq "resource/x-bb-externallink") { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
&process_link($key,$docroot,$dirname,$destdir,\%{$$resinfo{$key}},$resrcfiles); |
&process_link($key,$docroot,$destdir,\%{$$resinfo{$key}},$resrcfiles); |
} elsif ($$resources{$key}{type} eq "resource/x-bb-discussionboard") { |
} elsif ($$resources{$key}{type} eq "resource/x-bb-discussionboard") { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
unless ($db_handling eq 'ignore') { |
unless ($db_handling eq 'ignore') { |
Line 514 sub process_resinfo {
|
Line 524 sub process_resinfo {
|
$board_id ++; |
$board_id ++; |
$board_count ++; |
$board_count ++; |
} |
} |
} elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") { |
} elsif ($$resources{$key}{type} =~/assessment\/x\-bb\-(qti\-)?pool/) { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
&process_assessment($cms,$context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
&process_assessment($cms,$context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
push @{$pools}, $key; |
push @{$pools}, $key; |
} elsif ($$resources{$key}{type} eq "assessment/x-bb-quiz") { |
} elsif ($$resources{$key}{type} =~ /assessment\/x\-bb\-(qti\-)?quiz/) { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
&process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
&process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
push @{$quizzes}, $key; |
push @{$quizzes}, $key; |
} elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") { |
} elsif ($$resources{$key}{type} =~ /assessment\/x\-bb\-(qti\-)?survey/) { |
%{$$resinfo{$key}} = (); |
%{$$resinfo{$key}} = (); |
&process_assessment($cms,$context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
&process_assessment($cms,$context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs); |
push @{$surveys}, $key; |
push @{$surveys}, $key; |
Line 559 sub process_resinfo {
|
Line 569 sub process_resinfo {
|
if (@{$pools}) { |
if (@{$pools}) { |
$$items{'Top'}{'contentscount'} ++; |
$$items{'Top'}{'contentscount'} ++; |
} |
} |
} elsif ($cms eq 'webct4') { |
} elsif ($cms eq 'webctce4') { |
foreach my $key (sort keys %{$resources}) { |
foreach my $key (sort keys %{$resources}) { |
if (grep/^$key$/,@{$targets}) { |
if (grep/^$key$/,@{$targets}) { |
if ($$resources{$key}{type} eq "webcontent") { |
if ($$resources{$key}{type} eq "webcontent") { |
Line 639 sub build_structure {
|
Line 649 sub build_structure {
|
my $resnum = $$items{$key}{resnum}; |
my $resnum = $$items{$key}{resnum}; |
my $type = $$resources{$resnum}{type}; |
my $type = $$resources{$resnum}{type}; |
my $contentscount = $$items{$key}{'contentscount'}; |
my $contentscount = $$items{$key}{'contentscount'}; |
if (($cms eq 'angel' && $type eq "FOLDER") || (($cms eq 'bb5' || $cms eq 'bb6') && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) || ($cms eq 'webct4' && $contentscount > 0)) { |
if (($cms eq 'angel' && $type eq "FOLDER") || (($cms eq 'bb5' || $cms eq 'bb6') && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) || ($cms eq 'webctce4' && $contentscount > 0)) { |
unless (($cms eq 'bb5') && $key eq 'Top') { |
unless (($cms eq 'bb5') && $key eq 'Top') { |
$seqtext{$key} = "<map>\n"; |
$seqtext{$key} = "<map>\n"; |
} |
} |
Line 877 sub build_structure {
|
Line 887 sub build_structure {
|
sub make_structure { |
sub make_structure { |
my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$randompick) = @_; |
my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$randompick) = @_; |
my $src =''; |
my $src =''; |
if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && (($$resinfo{$res}{'isfolder'} eq 'true') || $key eq 'Top')) || ($cms eq 'webct4' && $contitemcount > 0)) { |
if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && (($$resinfo{$res}{'isfolder'} eq 'true') || $key eq 'Top')) || ($cms eq 'webctce4' && $contitemcount > 0)) { |
$src = $srcstem.'/sequences/'.$contitem.'.sequence'; |
$src = $srcstem.'/sequences/'.$contitem.'.sequence'; |
$$flag{$key}{page} = 0; |
$$flag{$key}{page} = 0; |
$$flag{$key}{seq} = 1; |
$$flag{$key}{seq} = 1; |
$$count{$key}{seq} ++; |
$$count{$key}{seq} ++; |
} elsif ($cms eq 'webct4' && $randompick) { |
} elsif ($cms eq 'webctce4' && $randompick) { |
$src = $srcstem.'/sequences/'.$res.'.sequence'; |
$src = $srcstem.'/sequences/'.$res.'.sequence'; |
$$flag{$key}{page} = 0; |
$$flag{$key}{page} = 0; |
$$flag{$key}{seq} = 1; |
$$flag{$key}{seq} = 1; |
Line 930 sub make_structure {
|
Line 940 sub make_structure {
|
} |
} |
$$flag{$key}{seq} = 0; |
$$flag{$key}{seq} = 0; |
} |
} |
} elsif ($cms eq 'webct4') { |
} elsif ($cms eq 'webctce4') { |
if ($type eq 'webctquiz') { |
if ($type eq 'webctquiz') { |
$src = $srcstem.'/pages/'.$res.'.page'; |
$src = $srcstem.'/pages/'.$res.'.page'; |
$$count{$key}{page} ++; |
$$count{$key}{page} ++; |
Line 1195 sub process_group {
|
Line 1205 sub process_group {
|
|
|
# ---------------------------------------------------------------- Process Blackboard Staff |
# ---------------------------------------------------------------- Process Blackboard Staff |
sub process_staff { |
sub process_staff { |
my ($res,$docroot,$dirname,$destdir,$settings,$resrcfiles) = @_; |
my ($res,$docroot,$destdir,$settings,$resrcfiles) = @_; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
my $filecount = 0; |
my $filecount = 0; |
my @state; |
my @state; |
%{$$settings{name}} = (); |
%{$$settings{name}} = (); |
%{$$settings{office}} = (); |
%{$$settings{office}} = (); |
|
|
my $p = HTML::Parser->new |
my $p = HTML::Parser->new |
( |
( |
Line 1353 sub process_staff {
|
Line 1363 sub process_staff {
|
|; |
|; |
if ( defined($$settings{image}) ) { |
if ( defined($$settings{image}) ) { |
$staffentry .= qq| |
$staffentry .= qq| |
<img src="$dirname/resfiles/$res/$$settings{image}"> |
<img src="$res/$$settings{image}"> |
|; |
|; |
} |
} |
$staffentry .= qq| |
$staffentry .= qq| |
Line 1376 $staffentry
|
Line 1386 $staffentry
|
|
|
# ---------------------------------------------------------------- Process Blackboard Links |
# ---------------------------------------------------------------- Process Blackboard Links |
sub process_link { |
sub process_link { |
my ($res,$docroot,$dirname,$destdir,$settings,$resrcfiles) = @_; |
my ($res,$docroot,$destdir,$settings,$resrcfiles) = @_; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
my @state = (); |
my @state = (); |
my $p = HTML::Parser->new |
my $p = HTML::Parser->new |
Line 1827 sub parse_bb5_assessment {
|
Line 1837 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,$allids) = @_; |
return; |
my $xmlfile = $docroot.'/'.$res.".dat"; |
|
my @state = (); |
|
my $id; # the current question ID |
|
my $response; # the current response ID |
|
my $foil; # the current foil ID |
|
my $numchoice; # the current right match choice; |
|
my $labelcount; # the current count of choices for a matching item. |
|
my $curr_shuffle; |
|
my $curr_class; # the current question type |
|
my $curr_matchitem; |
|
my $curr_block_type; # the current block type |
|
my $curr_flow; # the current flow class attribute |
|
my $curr_flow_mat; # the current flow_mat class attribute |
|
my $curr_feedback_type; # the current feedback type |
|
my $numorder; # counter for ordering type questions |
|
|
|
my $itemfrag = "questestinterop assessment section item"; |
|
my $presfrag = "$itemfrag presentation flow flow"; |
|
my $blockflow = 'flow'; |
|
my $responselid; |
|
my $instructionfrag = "questestinterop assessment presentation_material flow_mat material"; |
|
my $feedbackfrag = "$itemfrag itemfeedback"; |
|
my $feedback_tag = ''; |
|
my $responselid; |
|
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 assessment rubric flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{description}{texttype} = $attr->{type}; |
|
} |
|
if ("@state" eq $presfrag) { |
|
if ($attr->{class} eq 'QUESTION_BLOCK') { |
|
$curr_block_type = 'question'; |
|
} elsif ($attr->{class} eq 'RESPONSE_BLOCK') { |
|
$curr_block_type = 'response'; |
|
if ($curr_class eq 'Matching') { |
|
$responselid = 'flow response_lid'; |
|
} else { |
|
$responselid = 'response_lid'; |
|
} |
|
} elsif (($attr->{class} eq 'RIGHT_MATCH_BLOCK')) { |
|
$numchoice = 0; |
|
$curr_block_type = 'rightmatch'; |
|
} |
|
} |
|
if ("@state" eq "$presfrag flow") { |
|
if (($curr_block_type =~ /^rightmatch/) && ($attr->{class} eq 'Block')) { |
|
$curr_block_type = 'rightmatch'.$numchoice; |
|
$numchoice ++; |
|
} |
|
} |
|
if ($state[-1] eq 'flow') { |
|
$curr_flow = $attr->{class}; |
|
} |
|
if ($state[-1] eq 'flow_mat') { |
|
$curr_flow_mat = $attr->{class}; |
|
} |
|
if ("@state" eq "$presfrag $blockflow material mat_extension mat_formattedtext") { |
|
$$settings{$id}{$curr_block_type}{texttype} = $attr->{texttype}; |
|
} |
|
if ("@state" eq "$presfrag $blockflow material matapplication") { |
|
$$settings{$id}{$curr_block_type}{image} = $attr->{uri}; |
|
$$settings{$id}{$curr_block_type}{style} = $attr->{embedded}; |
|
$$settings{$id}{$curr_block_type}{label} = $attr->{label}; |
|
} |
|
if ("@state" eq "$presfrag $blockflow material mattext") { |
|
$$settings{$id}{$curr_block_type}{link} = $attr->{uri}; |
|
} |
|
if ("@state" eq "$presfrag $responselid") { |
|
$response = $attr->{ident}; |
|
$labelcount = 0; |
|
if ($curr_class eq 'Matching') { |
|
push(@{$$settings{$id}{answers}},$response); |
|
%{$$settings{$id}{$response}} = (); |
|
foreach my $key (keys(%{$$settings{$id}{$curr_block_type}})) { |
|
$$settings{$id}{$response}{$key} = $$settings{$id}{$curr_block_type}{$key}; |
|
} |
|
%{$$settings{$id}{$curr_block_type}} = (); |
|
} |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice") { |
|
$curr_shuffle = $attr->{shuffle}; |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice flow_label response_label") { |
|
$foil = $attr->{ident}; |
|
%{$$settings{$id}{$foil}} = (); |
|
$$settings{$id}{$foil}{randomize} = $curr_shuffle; |
|
unless ($curr_class eq 'Essay'){ |
|
if ($curr_class eq 'Matching') { |
|
push(@{$$settings{$id}{$response}{items}},$foil); |
|
$$settings{$id}{$foil}{order} = $labelcount; |
|
$labelcount ++; |
|
} else { |
|
push(@{$$settings{$id}{answers}},$foil); |
|
@{$$settings{$id}{correctanswer}} = (); |
|
} |
|
} |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice flow_label response_label flow_mat material matapplication") { |
|
$$settings{$id}{$foil}{filetype} = $attr->{embedded}; |
|
$$settings{$id}{$foil}{label} = $attr->{label}; |
|
$$settings{$id}{$foil}{uri} = $attr->{uri}; |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice flow_label response_label flow_mat material mattext") { |
|
$$settings{$id}{$foil}{link} = $attr->{uri}; |
|
} |
|
if ("@state" eq "questestinterop assessment section item resprocessing") { |
|
if ($curr_class eq 'Matching') { |
|
$$settings{$id}{allchoices} = $numchoice; |
|
} |
|
} |
|
if ("@state" eq "questestinterop assessment section item resprocessing respcondition conditionvar varequal") { |
|
if ($curr_class eq 'Matching') { |
|
$curr_matchitem = $attr->{respident}; |
|
} |
|
} |
|
if ("@state" eq $feedbackfrag) { |
|
$curr_feedback_type = $attr->{ident}; |
|
$feedback_tag = ""; |
|
} |
|
if ("@state" eq "$feedbackfrag solution") { |
|
$curr_feedback_type = 'solution'; |
|
$feedback_tag = "solution solutionmaterial"; |
|
} |
|
if ("@state" eq "$feedbackfrag $feedback_tag 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 "$feedbackfrag $feedback_tag 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} = $text; |
|
} |
|
if ("@state" eq "questestinterop assessment rubric flow_mat material mattext") { |
|
$$settings{description}{text} = $text; |
|
} |
|
if ("@state" eq "$instructionfrag mat_extension mat_formattedtext") { |
|
$$settings{instructions}{text} = $text; |
|
} |
|
if ("@state" eq "$instructionfrag mattext") { |
|
$$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}{answers}} = (); |
|
%{$$settings{$id}{question}} = (); |
|
%{$$settings{$id}{correctfeedback}} = (); |
|
%{$$settings{$id}{incorrectfeedback}} = (); |
|
%{$$settings{$id}{solutionfeedback}} = (); |
|
} |
|
if ("@state" eq "questestinterop assessment section item itemmetadata bbmd_questiontype") { |
|
$$settings{$id}{class} = $text; |
|
$curr_class = $text; |
|
if ($curr_class eq 'Matching') { |
|
$blockflow = 'flow flow'; |
|
} else { |
|
$blockflow = 'flow'; |
|
} |
|
} |
|
if ("@state" eq "$presfrag $blockflow material mat_extension mat_formattedtext") { |
|
$$settings{$id}{$curr_block_type}{text} = $text; |
|
} |
|
if ("@state" eq "$presfrag $blockflow material mattext") { |
|
if ($curr_flow eq 'LINK_BLOCK') { |
|
$$settings{$id}{$curr_block_type}{linkname} = $text; |
|
} elsif ($curr_flow eq 'FORMATTED_TEXT_BLOCK') { |
|
$$settings{$id}{$curr_block_type}{text} = $text; |
|
} |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice flow_label response_label flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{$id}{$foil}{text} = $text; |
|
} |
|
if ("@state" eq "$presfrag $responselid render_choice flow_label response_label flow_mat material mattext") { |
|
if ($curr_flow_mat eq 'LINK_BLOCK') { |
|
$$settings{$id}{$foil}{linkname} = $text; |
|
} else { |
|
$$settings{$id}{$foil}{text} = $text; |
|
} |
|
} |
|
if ("@state" eq "questestinterop assessment section item resprocessing respcondition conditionvar varequal") { |
|
if ($curr_class eq 'Matching') { |
|
$$settings{$id}{$curr_matchitem}{correctanswer} = $text; |
|
} else { |
|
push(@{$$settings{$id}{correctanswer}},$text); |
|
} |
|
} |
|
if ("@state" eq "questestinterop assessment section item resprocessing respcondition conditionvar") { |
|
$numorder = 0; |
|
} |
|
if ("@state" eq "questestinterop assessment section item resprocessing respcondition conditionvar and varequal") { |
|
push(@{$$settings{$id}{correctanswer}},$text); |
|
if ($curr_class eq 'Ordering') { |
|
$numorder ++; |
|
$$settings{$id}{$text}{order} = $numorder; |
|
} |
|
} |
|
if ("@state" eq "$feedbackfrag $feedback_tag flow_mat flow_mat material mat_extension mat_formattedtext") { |
|
$$settings{$id}{$curr_feedback_type.'feedback'}{text} = $text; |
|
} |
|
if ("@state" eq "$feedbackfrag $feedback_tag 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 2299 sub process_assessment {
|
Line 2539 sub process_assessment {
|
if ($cms eq 'bb5') { |
if ($cms eq 'bb5') { |
&parse_bb5_assessment($res,$docroot,$container,$settings,\%allanswers,\%allchoices,\@allids); |
&parse_bb5_assessment($res,$docroot,$container,$settings,\%allanswers,\%allchoices,\@allids); |
} elsif ($cms eq 'bb6') { |
} elsif ($cms eq 'bb6') { |
&parse_bb6_assessment($res,$docroot,$container,$settings,\%allanswers,\%allchoices,\@allids); |
&parse_bb6_assessment($res,$docroot,$container,$settings,\@allids); |
} elsif ($cms eq 'webct4') { |
} elsif ($cms eq 'webctce4') { |
unless($$dbparse) { |
unless($$dbparse) { |
&parse_webct4_questionDB($docroot,$$resources{$res}{file},$catinfo,$qzdbsettings,\%alldbanswers,\%alldbchoices,\@alldbquestids); |
&parse_webct4_questionDB($docroot,$$resources{$res}{file},$catinfo,$qzdbsettings,\%alldbanswers,\%alldbchoices,\@alldbquestids); |
if (!-e "$destdir/sequences") { |
if (!-e "$destdir/sequences") { |
Line 2363 sub process_assessment {
|
Line 2603 sub process_assessment {
|
} |
} |
} |
} |
my $dirtitle; |
my $dirtitle; |
unless ($cms eq 'webct4') { |
unless ($cms eq 'webctce4') { |
$dirtitle = $$settings{'title'}; |
$dirtitle = $$settings{'title'}; |
$dirtitle =~ s/\W//g; |
$dirtitle =~ s/\W//g; |
$dirtitle .= '_'.$res; |
$dirtitle .= '_'.$res; |
Line 2376 sub process_assessment {
|
Line 2616 sub process_assessment {
|
$newdir = "$destdir/problems/$dirtitle"; |
$newdir = "$destdir/problems/$dirtitle"; |
} |
} |
|
|
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$qzdbsettings); |
} else { |
} else { |
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$settings); |
&build_problem_container($cms,$dirtitle,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,$cid,$cdom,$cnum,$catinfo,$settings); |
Line 2384 sub process_assessment {
|
Line 2624 sub process_assessment {
|
if ($cms eq 'bb5') { |
if ($cms eq 'bb5') { |
&write_bb5_questions(\@allids,$containerdir,$context,$settings,$dirname,$destdir,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot); |
&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,$destdir,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); |
&write_bb6_questions(\@allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$total,$newdir,$cid,$cdom,$cnum,$docroot); |
} |
} |
} |
} |
|
|
Line 2418 sub build_problem_container {
|
Line 2658 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}) { |
if ($cms eq 'webct4') { |
if ($cms eq 'webctce4') { |
$probtitle{$id} = $$settings{$id}{title}; |
$probtitle{$id} = $$settings{$id}{title}; |
} else { |
} else { |
$probtitle{$id} = $$settings{title}; |
$probtitle{$id} = $$settings{title}; |
Line 2427 sub build_problem_container {
|
Line 2667 sub build_problem_container {
|
$probtitle{$id} =~ s/\W//g; |
$probtitle{$id} =~ s/\W//g; |
$probtitle{$id} .= '_'.$id; |
$probtitle{$id} .= '_'.$id; |
} |
} |
if ($cms eq 'webct4' && $container ne 'database') { |
if ($cms eq 'webctce4' && $container ne 'database') { |
my $catid = $$settings{$$allids[0]}{category}; |
my $catid = $$settings{$$allids[0]}{category}; |
my $probdir = $$catinfo{$catid}{title}.'_'.$catid; |
my $probdir = $$catinfo{$catid}{title}.'_'.$catid; |
$probdir =~ s/\s/_/g; |
$probdir =~ s/\s/_/g; |
Line 2451 sub build_problem_container {
|
Line 2691 sub build_problem_container {
|
$curr_id = $j; |
$curr_id = $j; |
$next_id = $curr_id + 1; |
$next_id = $curr_id + 1; |
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
if ($cms eq 'webct4' && $container ne 'database') { |
if ($cms eq 'webctce4' && $container ne 'database') { |
my $catid = $$settings{$$allids[$j]}{category}; |
my $catid = $$settings{$$allids[$j]}{category}; |
my $probdir = $$catinfo{$catid}{title}.'_'.$catid; |
my $probdir = $$catinfo{$catid}{title}.'_'.$catid; |
$probdir =~ s/\s/_/g; |
$probdir =~ s/\s/_/g; |
Line 2478 sub build_problem_container {
|
Line 2718 sub build_problem_container {
|
sub write_bb5_questions { |
sub write_bb5_questions { |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot) = @_; |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot) = @_; |
my $qnum = 0; |
my $qnum = 0; |
|
my $pathstart; |
|
if ($context eq 'CSTR') { |
|
$pathstart = '../..'; |
|
} else { |
|
$pathstart = $dirname; |
|
} |
foreach my $id (@{$allids}) { |
foreach my $id (@{$allids}) { |
if ($$settings{$id}{ishtml} eq 'true') { |
if ($$settings{$id}{ishtml} eq 'true') { |
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text}); |
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text}); |
} |
} |
if ($$settings{$id}{text} =~ m#<img src=['"]?(https?://[^\s]+/)([^/\s\'"]+)['"]?[^>]*>#) { |
if ($$settings{$id}{text} =~ m#<img src=['"]?(https?://[^\s]+/)([^/\s\'"]+)['"]?[^>]*>#) { |
if (&retrieve_image($context,$res,$dirname,$cdom,$cnum,$docroot,$destdir,$1,$2) eq 'ok') { |
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=['"]?)(https?://[^\s]+/)([^/\s'"]+)(['"]?[^>]*>)#$1$pathstart/resfiles/$res/webimages/$3$4#g; |
} |
} |
} |
} |
$$settings{$id}{text} =~ s#(<img src=[^>]+)/*>#$1 />#gi; |
$$settings{$id}{text} =~ s#(<img src=[^>]+)/*>#$1 />#gi; |
Line 2532 sub write_bb5_questions {
|
Line 2778 sub write_bb5_questions {
|
my ($image,$imglink,$url); |
my ($image,$imglink,$url); |
if ( defined($$settings{$id}{image}) ) { |
if ( defined($$settings{$id}{image}) ) { |
if ( $$settings{$id}{style} eq 'embed' ) { |
if ( $$settings{$id}{style} eq 'embed' ) { |
$image = qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{image}" /><br />|; |
$image = qq|<br /><img src="$pathstart/resfiles/$res/$$settings{$id}{image}" /><br />|; |
} else { |
} else { |
$imglink = qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{image}">Link to file</a><br />|; |
$imglink = qq|<br /><a href="$pathstart/resfiles/$res/$$settings{$id}{image}">Link to file</a><br />|; |
} |
} |
} |
} |
if ( defined($$settings{$id}{url}) ) { |
if ( defined($$settings{$id}{url}) ) { |
Line 2579 sub write_bb5_questions {
|
Line 2825 sub write_bb5_questions {
|
my ($ans_image,$ans_link); |
my ($ans_image,$ans_link); |
if ( defined($$settings{$id}{$$allanswers{$id}[$k]}{image}) ) { |
if ( defined($$settings{$id}{$$allanswers{$id}[$k]}{image}) ) { |
if ( $$settings{$id}{$$allanswers{$id}[$k]}{style} eq 'embed' ) { |
if ( $$settings{$id}{$$allanswers{$id}[$k]}{style} eq 'embed' ) { |
$ans_image .= qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{$$allanswers{$id}[$k]}{image}" /><br />|; |
$ans_image .= qq|<br /><img src="$pathstart/resfiles/$res/$$settings{$id}{$$allanswers{$id}[$k]}{image}" /><br />|; |
} else { |
} else { |
$ans_link .= qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{$$allanswers{$id}[$k]}{image}" />Link to file</a><br/>|; |
$ans_link .= qq|<br /><a href="$pathstart/resfiles/$res/$$settings{$id}{$$allanswers{$id}[$k]}{image}" />Link to file</a><br/>|; |
} |
} |
} |
} |
$output .= $ans_image.$ans_link.'<endouttext /></foil>'."\n"; |
$output .= $ans_image.$ans_link.'<endouttext /></foil>'."\n"; |
Line 3377 sub test_for_html {
|
Line 3623 sub test_for_html {
|
} |
} |
|
|
sub write_bb6_questions { |
sub write_bb6_questions { |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices) = @_; |
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$total,$newdir,$cid,$cdom,$cnum,$docroot) = @_; |
|
my $qnum = 0; |
|
foreach my $id (@{$allids}) { |
|
my $questiontext = $$settings{$id}{question}{text}; |
|
my $question_texttype = $$settings{$id}{question}{texttype}; |
|
&process_html(\$questiontext,'bb6',$question_texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$qnum ++; |
|
my $output; |
|
my $permcontainer = $containerdir; |
|
$permcontainer =~ s#/home/httpd/html/userfiles#uploaded#; |
|
my $symb = $cid.'.'.$permcontainer.'___'.$qnum.'___lib/templates/simpleproblem.problem.0.'; |
|
my %resourcedata = (); |
|
for (my $i=0; $i<10; $i++) { |
|
my $iter = $i+1; |
|
$resourcedata{$symb.'text'.$iter} = ""; |
|
$resourcedata{$symb.'value'.$iter} = "unused"; |
|
$resourcedata{$symb.'position'.$iter} = "random"; |
|
} |
|
$resourcedata{$symb.'randomize'} = 'yes'; |
|
$resourcedata{$symb.'maxfoils'} = 10; |
|
if ($context eq 'CSTR') { |
|
$output = qq|<problem> |
|
|; |
|
} |
|
$$total{prob} ++; |
|
$questiontext .= &add_images_links('question',$context,$settings,$id,$dirname,$res); |
|
if ($$settings{$id}{class} eq "Essay") { |
|
if ($context eq 'CSTR') { |
|
$output .= qq|<startouttext />$questiontext<endouttext /> |
|
<essayresponse> |
|
<textfield></textfield> |
|
</essayresponse> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'questiontext'} = $questiontext; |
|
$resourcedata{$symb.'hiddenparts'} = '!essay'; |
|
$resourcedata{$symb.'questiontype'} = 'essay'; |
|
} |
|
} else { |
|
if ($context eq 'CSTR') { |
|
$output .= qq|<startouttext />$questiontext\n<endouttext />|; |
|
} else { |
|
$resourcedata{$symb.'questiontext'} = $questiontext; |
|
} |
|
my $numfoils = @{$$settings{$id}{answers}}; |
|
if (($$settings{$id}{class} eq 'Multiple Choice') || |
|
($$settings{$id}{class} eq 'True/False')) { |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<radiobuttonresponse max="$numfoils" randomize="yes"> |
|
<foilgroup> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'hiddenparts'} = '!radio'; |
|
$resourcedata{$symb.'questiontype'} = 'radio'; |
|
$resourcedata{$symb.'maxfoils'} = $numfoils; |
|
} |
|
for (my $k=0; $k<$numfoils; $k++) { |
|
my $iter = $k+1; |
|
my $answer_id = $$settings{$id}{answers}[$k]; |
|
my $answer_text = $$settings{$id}{$answer_id}{text}; |
|
my $texttype = $$settings{$id}{$answer_id}{texttype}; |
|
&process_html(\$answer_text,'bb6',$texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$answer_text .= &add_images_links('response',$context,$settings,$id,$dirname,$res); |
|
$output .= " <foil name=\"foil".$k."\" value=\""; |
|
if (grep/^$answer_id$/,@{$$settings{$id}{correctanswer}}) { |
|
$output .= "true\" location=\""; |
|
$resourcedata{$symb.'value'.$iter} = "true"; |
|
} else { |
|
$output .= "false\" location=\""; |
|
$resourcedata{$symb.'value'.$iter} = "false"; |
|
} |
|
if (lc ($$settings{$id}{$answer_id}{text}) =~ m/^\s?([Aa]ll)|([Nn]one)\s(of\s)?the\sabove\.?/) { |
|
$output .= "bottom\""; |
|
$resourcedata{$symb.'position'.$iter} = "bottom"; |
|
} else { |
|
$output .= "random\""; |
|
} |
|
$output .= '\><startouttext />'.$answer_text. |
|
'<endouttext /></foil>'."\n"; |
|
$resourcedata{$symb.'text'.$iter} = $answer_text; |
|
} |
|
if ($context eq 'CSTR') { |
|
chomp($output); |
|
$output .= qq| |
|
</foilgroup> |
|
<hintgroup showoncorrect="no"> |
|
<radiobuttonhint> |
|
</radiobuttonhint> |
|
<hintpart on="default"> |
|
<startouttext/><endouttext /> |
|
</hintpart> |
|
</hintgroup> |
|
</radiobuttonresponse> |
|
|; |
|
} |
|
} elsif ($$settings{$id}{class} eq 'Multiple Answer') { |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<optionresponse max="$numfoils" randomize="yes"> |
|
<foilgroup options="('True','False')"> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'newopt'} = ''; |
|
$resourcedata{$symb.'delopt'} = ''; |
|
$resourcedata{$symb.'options'} = "('True','False')"; |
|
$resourcedata{$symb.'hiddenparts'} = '!option'; |
|
$resourcedata{$symb.'questiontype'} = 'option'; |
|
$resourcedata{$symb.'maxfoils'} = $numfoils; |
|
} |
|
for (my $k=0; $k<$numfoils; $k++) { |
|
my $iter = $k+1; |
|
my $answer_id = $$settings{$id}{answers}[$k]; |
|
my $answer_text = $$settings{$id}{$answer_id}{text}; |
|
my $texttype = $$settings{$id}{$answer_id}{texttype}; |
|
&process_html(\$answer_text,'bb6',$texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$answer_text .= &add_images_links('response',$context,$settings,$id,$dirname,$res); |
|
|
|
$output .= " <foil name=\"foil".$k."\" value=\""; |
|
if (grep/^$answer_id$/,@{$$settings{$id}{correctanswer}}) { |
|
$output .= "True\""; |
|
$resourcedata{$symb.'value'.$iter} = "True"; |
|
} else { |
|
$output .= "False\""; |
|
$resourcedata{$symb.'value'.$iter} = "False"; |
|
} |
|
$output .= "\><startouttext />".$answer_text."<endouttext /></foil>\n"; |
|
$resourcedata{$symb.'text'.$iter} = $answer_text; |
|
} |
|
if ($context eq 'CSTR') { |
|
chomp($output); |
|
$output .= qq| |
|
</foilgroup> |
|
<hintgroup showoncorrect="no"> |
|
<optionhint> |
|
</optionhint> |
|
<hintpart on="default"> |
|
<startouttext/><endouttext /> |
|
</hintpart> |
|
</hintgroup> |
|
</optionresponse> |
|
|; |
|
} |
|
} elsif ($$settings{$id}{class} eq 'Ordering') { |
|
my @allorder = (); |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<rankresponse max="$numfoils" randomize="yes"> |
|
<foilgroup> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'newopt'} = ''; |
|
$resourcedata{$symb.'delopt'} = ''; |
|
$resourcedata{$symb.'hiddenparts'} = '!option'; |
|
$resourcedata{$symb.'questiontype'} = 'option'; |
|
$resourcedata{$symb.'maxfoils'} = $numfoils; |
|
} |
|
for (my $k=0; $k<$numfoils; $k++) { |
|
my $answer_id = $$settings{$id}{answers}[$k]; |
|
my $answer_text = $$settings{$id}{$answer_id}{text}; |
|
my $texttype = $$settings{$id}{$answer_id}{texttype}; |
|
&process_html(\$answer_text,'bb6',$texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$answer_text .= &add_images_links('response',$context,$settings,$id,$dirname,$res); |
|
my $iter = $k+1; |
|
if ($context eq 'CSTR') { |
|
$output .= " <foil location=\"random\" name=\"foil".$k."\" value=\"".$$settings{$id}{$answer_id}{order}."\"><startouttext />".$answer_text."<endouttext /></foil>\n"; |
|
} else { |
|
$resourcedata{$symb.'text'.$iter} = $answer_text; |
|
$resourcedata{$symb.'value'.$iter} = $$settings{$id}{$answer_id}{order}; |
|
if (!grep/^$$settings{$id}{$answer_id}{order}$/,@allorder) { |
|
push(@allorder,$$settings{$id}{$answer_id}{order}); |
|
} |
|
} |
|
} |
|
if ($context eq 'CSTR') { |
|
chomp($output); |
|
$output .= qq| |
|
</foilgroup> |
|
</rankresponse> |
|
|; |
|
} else { |
|
@allorder = sort {$a <=> $b} @allorder; |
|
$resourcedata{$symb.'options'} = "('".join("','",@allorder)."')"; |
|
} |
|
} elsif ($$settings{$id}{class} eq 'Fill in the Blank') { |
|
my $numerical = 1; |
|
if ($context eq 'DOCS') { |
|
$numerical = 0; |
|
} else { |
|
for (my $k=0; $k<@{$$settings{$id}{correctanswer}}; $k++) { |
|
if ($$settings{$id}{correctanswer}[$k] =~ m/([^\d\.]|\.\.)/) { |
|
$numerical = 0; |
|
} |
|
} |
|
} |
|
if ($numerical) { |
|
my $numans; |
|
my $tol; |
|
if (@{$$settings{$id}{correctanswer}} == 1) { |
|
$tol = 5; |
|
$numans = $$settings{$id}{correctanswer}[0]; |
|
} else { |
|
my $min = $$settings{$id}{correctanswer}[0];; |
|
my $max = $min; |
|
for (my $k=1; $k<@{$$settings{$id}{correctanswer}}; $k++) { |
|
if ($$settings{$id}{correctanswer}[$k] <= $min) { |
|
$min = $$settings{$id}{correctanswer}[$k]; |
|
} |
|
if ($$settings{$id}{correctanswer}[$k] >= $max) { |
|
$max = $$settings{$id}{correctanswer}[$k]; |
|
} |
|
} |
|
$numans = ($max + $min)/2; |
|
$tol = 100*($max - $min)/($numans*2); |
|
$tol = 5; |
|
} |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<numericalresponse answer="$numans"> |
|
<responseparam type="tolerance" default="$tol%" name="tol" description="Numerical Tolerance" /> |
|
<responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" |
|
/> |
|
<textline /> |
|
</numericalresponse> |
|
<hintgroup showoncorrect="no"> |
|
<numericalhint> |
|
</numericalhint> |
|
<hintpart on="default"> |
|
<startouttext/><endouttext /> |
|
</hintpart> |
|
</hintgroup> |
|
|; |
|
} |
|
} else { |
|
if ($context eq 'DOCS') { |
|
$resourcedata{$symb.'hiddenparts'} = '!string'; |
|
$resourcedata{$symb.'questiontype'} = 'string'; |
|
$resourcedata{$symb.'maxfoils'} = 1; |
|
$resourcedata{$symb.'hiddenparts'} = '!string'; |
|
$resourcedata{$symb.'stringtype'} = 'ci'; |
|
$resourcedata{$symb.'stringanswer'} = $$settings{$id}{correctanswer}[0]; |
|
} else { |
|
if (@{$$settings{$id}{correctanswer}} == 1) { |
|
$output .= qq| |
|
<stringresponse answer="$$settings{$id}{correctanswer}[0];" type="ci"> |
|
<textline> |
|
</textline> |
|
</stringresponse> |
|
<hintgroup showoncorrect="no"> |
|
<stringhint type="cs"> |
|
</stringhint> |
|
<hintpart on="default"> |
|
<startouttext/><endouttext /> |
|
</hintpart> |
|
</hintgroup> |
|
|; |
|
} else { |
|
my @answertext = (); |
|
for (my $k=0; $k<@{$$settings{$id}{correctanswer}}; $k++) { |
|
my $answer_text = $$settings{$id}{correctanswer}[$k]; |
|
$answer_text =~ s/\|/\|/g; |
|
push @answertext, $answer_text; |
|
} |
|
my $regexpans = join('|',@answertext); |
|
$regexpans = '/^('.$regexpans.')\b/'; |
|
$output .= qq| |
|
<stringresponse answer="$regexpans" type="re"> |
|
<textline> |
|
</textline> |
|
</stringresponse> |
|
<hintgroup showoncorrect="no"> |
|
<stringhint type="cs"> |
|
</stringhint> |
|
<hintpart on="default"> |
|
<startouttext/><endouttext /> |
|
</hintpart> |
|
</hintgroup> |
|
|; |
|
} |
|
} |
|
} |
|
} elsif ($$settings{$id}{class} eq "Matching") { |
|
my @allmatchers = (); |
|
my %matchtext = (); |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<matchresponse max="10" randomize="yes"> |
|
<foilgroup> |
|
<itemgroup> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'newopt'} = ''; |
|
$resourcedata{$symb.'delopt'} = ''; |
|
$resourcedata{$symb.'hiddenparts'} = '!option'; |
|
$resourcedata{$symb.'questiontype'} = 'option'; |
|
$resourcedata{$symb.'maxfoils'} = $numfoils; |
|
} |
|
for (my $k=0; $k<$$settings{$id}{allchoices}; $k++) { |
|
my $choice_id = 'rightmatch'.$k; |
|
my $choice_text = $$settings{$id}{$choice_id}{text}; |
|
my $texttype = $$settings{$id}{$choice_id}{texttype}; |
|
my $choice_plaintext = &remove_html($choice_text); |
|
&process_html(\$choice_text,'bb6',$texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$choice_text .= &add_images_links($choice_id,$context,$settings,$id,$dirname,$res); |
|
push(@allmatchers,$choice_plaintext); |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
<item name="$choice_id"> |
|
<startouttext />$choice_text<endouttext /> |
|
</item> |
|
|; |
|
} |
|
} |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
</itemgroup> |
|
|; |
|
} |
|
for (my $k=0; $k<$numfoils; $k++) { |
|
my $answer_id = $$settings{$id}{answers}[$k]; |
|
my $answer_text = $$settings{$id}{$answer_id}{text}; |
|
my $texttype = $$settings{$id}{$answer_id}{texttype}; |
|
&process_html(\$answer_text,'bb6',$texttype,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir); |
|
$answer_text .= &add_images_links($answer_id,$context,$settings,$id,$dirname,$res); |
|
if ($context eq 'CSTR') { |
|
$output .= ' |
|
<foil location="random" value="rightmatch'.$$settings{$id}{$$settings{$id}{$answer_id}{correctanswer}}{order}.'" name="'.$answer_id.'"> |
|
<startouttext />'.$answer_text.'<endouttext /> |
|
</foil> |
|
'; |
|
} else { |
|
my $iter = $k+1; |
|
$resourcedata{$symb.'value'.$iter} = "$allmatchers[$$settings{$id}{$$settings{$id}{$answer_id}{correctanswer}}{order}]"; |
|
$resourcedata{$symb.'text'.$iter} = $answer_text; |
|
} |
|
} |
|
if ($context eq 'CSTR') { |
|
$output .= qq| |
|
</foilgroup> |
|
</matchresponse> |
|
|; |
|
} else { |
|
$resourcedata{$symb.'options'} = "('".join("','",@allmatchers)."')"; |
|
} |
|
} |
|
} |
|
if ($context eq 'CSTR') { |
|
|
|
$output .= qq| |
|
<postanswerdate> |
|
$$settings{$id}{solutionfeedback}{text} |
|
</postanswerdate> |
|
</problem> |
|
|; |
|
my $title = $$settings{title}; |
|
$title =~ s/\s/_/g; |
|
$title =~ s/\W//g; |
|
$title .= '_'.$id; |
|
open(PROB,">:utf8", "$newdir/$title.problem"); |
|
print PROB $output; |
|
close PROB; |
|
} else { |
|
# put %resourcedata; |
|
my $reply=&Apache::lonnet::cput |
|
('resourcedata',\%resourcedata,$cdom,$cnum); |
|
} |
|
} |
} |
} |
|
|
sub retrieve_image { |
sub retrieve_image { |
Line 3399 sub retrieve_image {
|
Line 4011 sub retrieve_image {
|
print $fh $contents; |
print $fh $contents; |
close($fh); |
close($fh); |
if ($context eq 'DOCS') { |
if ($context eq 'DOCS') { |
my $chome = &Apache::lonnet::homeserver($cname,$cdom); |
|
my $copyfile = $dirname.'/'.$filename; |
my $copyfile = $dirname.'/'.$filename; |
my $source = "$docroot/$res/webimages/$filename"; |
my $source = "$docroot/$res/webimages/$filename"; |
my $fileresult; |
my $fileresult; |
if (-e $source) { |
if (-e $source) { |
$fileresult = &Apache::lonnet::process_coursefile('copy',$cname,$cdom,$chome,$copyfile,$source); |
$fileresult = &Apache::lonnet::process_coursefile('copy',$cname,$cdom,$copyfile,$source); |
} |
} |
return $fileresult; |
return $fileresult; |
} elsif ($context eq 'CSTR') { |
} elsif ($context eq 'CSTR') { |
Line 3964 $linktag
|
Line 4575 $linktag
|
} |
} |
} |
} |
|
|
|
sub process_html { |
|
my ($text,$caller,$html_cond,$context,$res,$dirname,$cdom,$cnum,$docroot,$destdir) = @_; |
|
my $pathstart; |
|
if ($context eq 'CSTR') { |
|
$pathstart = '../..'; |
|
} else { |
|
$pathstart = $dirname; |
|
} |
|
if ($caller eq 'bb5') { |
|
if ($html_cond eq 'true') { |
|
$$text = &HTML::Entities::decode($$text); |
|
} |
|
} elsif ($caller eq 'bb6') { |
|
if ($html_cond eq 'HTML') { |
|
$$text = &HTML::Entities::decode($$text); |
|
} |
|
} |
|
if ($$text =~ m#<img src=['"]?(https?://[^\s]+/)([^/\s\'"]+)['"]?[^>]*>#) { |
|
if (&retrieve_image($context,$res,$dirname,$cdom,$cnum,$docroot,$destdir,$1,$2) eq 'ok') { |
|
$$text =~ s#(<img src=['"]?)(https?://[^\s]+/)([^/\s'"]+)(['"]?[^>]*>)#$1$pathstart/resfiles/$res/webimages/$3$4#g; |
|
} |
|
} |
|
$$text =~ s#(<img src=[^>]+)/*>#$1 />#gi; |
|
$$text =~ s#<br>#<br />#g; |
|
return; |
|
} |
|
|
|
sub add_images_links { |
|
my ($type,$context,$settings,$id,$dirname,$res) = @_; |
|
my ($image,$imglink,$url,$pathstart); |
|
if ($context eq 'CSTR') { |
|
$pathstart = '../..'; |
|
} else { |
|
$pathstart = $dirname; |
|
} |
|
if ((defined($$settings{$id}{$type}{image})) && ($$settings{$id}{$type}{image} ne '')) { |
|
if ( $$settings{$id}{$type}{style} eq 'Inline' ) { |
|
$image = qq|<br /><img src="$pathstart/resfiles/$res/$$settings{$id}{$type}{image}" alt="$$settings{$id}{$type}{label}"/><br />|; |
|
} else { |
|
$imglink = qq|<br /><a href="$pathstart/resfiles/$res/$$settings{$id}{$type}{image}">$$settings{$id}{$type}{label}</a><br />|; |
|
} |
|
} |
|
if ((defined($$settings{$id}{$type}{link})) && ($$settings{$id}{$type}{link} ne '' )) { |
|
$url = qq|<br /><a href="$$settings{$id}{$type}{link}">$$settings{$id}{$type}{linkname}</a><br />|; |
|
} |
|
return $image.$imglink.$url; |
|
} |
|
|
|
sub remove_html { |
|
my ($choice_text) = @_; |
|
return $choice_text; |
|
} |
|
|
|
|
1; |
1; |
__END__ |
__END__ |