--- loncom/imspackages/imsprocessor.pm 2005/10/27 17:07:23 1.31
+++ loncom/imspackages/imsprocessor.pm 2006/03/24 17:16:07 1.33
@@ -365,7 +365,7 @@ sub target_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') {
foreach my $key (sort keys %{$hrefs}) {
if (grep/^$key$/,@{$targets}) {
@@ -511,10 +511,10 @@ sub process_resinfo {
}
} elsif ($$resources{$key}{type} eq "resource/x-bb-staffinfo") {
%{$$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") {
%{$$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") {
%{$$resinfo{$key}} = ();
unless ($db_handling eq 'ignore') {
@@ -1205,12 +1205,12 @@ sub process_group {
# ---------------------------------------------------------------- Process Blackboard Staff
sub process_staff {
- my ($res,$docroot,$dirname,$destdir,$settings,$resrcfiles) = @_;
+ my ($res,$docroot,$destdir,$settings,$resrcfiles) = @_;
my $xmlfile = $docroot.'/'.$res.".dat";
my $filecount = 0;
my @state;
%{$$settings{name}} = ();
- %{$$settings{office}} = ();
+ %{$$settings{office}} = ();
my $p = HTML::Parser->new
(
@@ -1363,7 +1363,7 @@ sub process_staff {
|;
if ( defined($$settings{image}) ) {
$staffentry .= qq|
-
+
|;
}
$staffentry .= qq|
@@ -1386,7 +1386,7 @@ $staffentry
# ---------------------------------------------------------------- Process Blackboard Links
sub process_link {
- my ($res,$docroot,$dirname,$destdir,$settings,$resrcfiles) = @_;
+ my ($res,$docroot,$destdir,$settings,$resrcfiles) = @_;
my $xmlfile = $docroot.'/'.$res.".dat";
my @state = ();
my $p = HTML::Parser->new
@@ -2718,13 +2718,19 @@ sub build_problem_container {
sub write_bb5_questions {
my ($allids,$containerdir,$context,$settings,$dirname,$destdir,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum,$docroot) = @_;
my $qnum = 0;
+ my $pathstart;
+ if ($context eq 'CSTR') {
+ $pathstart = '../..';
+ } else {
+ $pathstart = $dirname;
+ }
foreach my $id (@{$allids}) {
if ($$settings{$id}{ishtml} eq 'true') {
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text});
}
if ($$settings{$id}{text} =~ m#]*>#) {
if (&retrieve_image($context,$res,$dirname,$cdom,$cnum,$docroot,$destdir,$1,$2) eq 'ok') {
- $$settings{$id}{text} =~ s#(]*>)#$1../../resfiles/$res/webimages/$3$4#g;
+ $$settings{$id}{text} =~ s#(]*>)#$1$pathstart/resfiles/$res/webimages/$3$4#g;
}
}
$$settings{$id}{text} =~ s#(]+)/*>#$1 />#gi;
@@ -2772,9 +2778,9 @@ sub write_bb5_questions {
my ($image,$imglink,$url);
if ( defined($$settings{$id}{image}) ) {
if ( $$settings{$id}{style} eq 'embed' ) {
- $image = qq|
|;
+ $image = qq|
|;
} else {
- $imglink = qq|
Link to file
|;
+ $imglink = qq|
Link to file
|;
}
}
if ( defined($$settings{$id}{url}) ) {
@@ -2819,9 +2825,9 @@ sub write_bb5_questions {
my ($ans_image,$ans_link);
if ( defined($$settings{$id}{$$allanswers{$id}[$k]}{image}) ) {
if ( $$settings{$id}{$$allanswers{$id}[$k]}{style} eq 'embed' ) {
- $ans_image .= qq|
|;
+ $ans_image .= qq|
|;
} else {
- $ans_link .= qq|
Link to file
|;
+ $ans_link .= qq|
Link to file
|;
}
}
$output .= $ans_image.$ans_link.''."\n";
@@ -3642,7 +3648,7 @@ sub write_bb6_questions {
|;
}
$$total{prob} ++;
- $questiontext .= &add_images_links('question',$settings,$id,$dirname,$res);
+ $questiontext .= &add_images_links('question',$context,$settings,$id,$dirname,$res);
if ($$settings{$id}{class} eq "Essay") {
if ($context eq 'CSTR') {
$output .= qq|$questiontext
@@ -3680,7 +3686,7 @@ sub write_bb6_questions {
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',$settings,$id,$dirname,$res);
+ $answer_text .= &add_images_links('response',$context,$settings,$id,$dirname,$res);
$output .= " ".$answer_text."\n";
@@ -3920,7 +3926,7 @@ sub write_bb6_questions {
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,$settings,$id,$dirname,$res);
+ $choice_text .= &add_images_links($choice_id,$context,$settings,$id,$dirname,$res);
push(@allmatchers,$choice_plaintext);
if ($context eq 'CSTR') {
$output .= qq|
@@ -3940,7 +3946,7 @@ sub write_bb6_questions {
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,$settings,$id,$dirname,$res);
+ $answer_text .= &add_images_links($answer_id,$context,$settings,$id,$dirname,$res);
if ($context eq 'CSTR') {
$output .= '
@@ -4005,7 +4011,6 @@ sub retrieve_image {
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;
@@ -4572,7 +4577,12 @@ $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);
@@ -4584,7 +4594,7 @@ sub process_html {
}
if ($$text =~ m#]*>#) {
if (&retrieve_image($context,$res,$dirname,$cdom,$cnum,$docroot,$destdir,$1,$2) eq 'ok') {
- $$text =~ s#(]*>)#$1../../resfiles/$res/webimages/$3$4#g;
+ $$text =~ s#(]*>)#$1$pathstart/resfiles/$res/webimages/$3$4#g;
}
}
$$text =~ s#(]+)/*>#$1 />#gi;
@@ -4593,13 +4603,18 @@ sub process_html {
}
sub add_images_links {
- my ($type,$settings,$id,$dirname,$res) = @_;
- my ($image,$imglink,$url);
+ 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|
|;
+ $image = qq|
|;
} else {
- $imglink = qq|
$$settings{$id}{$type}{label}
|;
+ $imglink = qq|
$$settings{$id}{$type}{label}
|;
}
}
if ((defined($$settings{$id}{$type}{link})) && ($$settings{$id}{$type}{link} ne '' )) {