[LON-CAPA-cvs] cvs: modules /gerd/ct convert.pl
www
lon-capa-cvs@mail.lon-capa.org
Thu, 01 Sep 2005 20:32:07 -0000
www Thu Sep 1 16:32:07 2005 EDT
Modified files:
/modules/gerd/ct convert.pl
Log:
Making directory structure, finding dependencies
Index: modules/gerd/ct/convert.pl
diff -u modules/gerd/ct/convert.pl:1.3 modules/gerd/ct/convert.pl:1.4
--- modules/gerd/ct/convert.pl:1.3 Thu Sep 1 13:41:51 2005
+++ modules/gerd/ct/convert.pl Thu Sep 1 16:32:04 2005
@@ -1,5 +1,6 @@
use strict;
-
+use File::Copy;
+my @needtoget=();
my @ConceptTest;
my @CTStatus;
my @ImageType;
@@ -33,18 +34,31 @@
close(IN);
for (my $i=0;$i<=$#ConceptTest;$i++) {
if ($ConceptTest[$i]=~/\w+/) {
+ @needtoget=();
+ my $problem="<problem>\n";
my $line="',".$ConceptTest[$i].",'";
my $image='';
my $answerimage='';
$line=~s/\,(\d+)\,/\,\'$1\'\,/g;
my ($dummy,$typeid,$intro,$postcomment,$imageid,$outro,$answertext,$answerimageid,$statusid)=split(/\'\,\'/,$line);
if ($imageid) {
- $image=$Image[$imageid];
+ ($image)=($Image[$imageid]=~/\'([^\']+)\'/);
+ push @needtoget, $image;
+ push @needtoget,($Image[$imageid]=~/\'([^\']+)\'$/);
}
if ($answerimageid) {
- $answerimage=$Image[$answerimageid];
+ ($answerimage)=($Image[$answerimageid]=~/\'([^\']+)\'/);
+ push @needtoget, $answerimage;
+ push @needtoget,($Image[$answerimageid]=~/\'([^\']+)\'$/);
}
- print "\n---\n".&htmlclean($intro)."\n".&htmlclean($postcomment);
+ if ($intro) {
+ $problem.="\n<startouttext />".&htmlclean($intro)."<endouttext />\n";
+ }
+ if ($image) {
+ my ($relative)=($image=~/\/([^\/]+)$/);
+ $problem.="\n<img src='$relative' />\n";
+ }
+ $problem.="\n<radiobuttonresponse max='99' randomize='no'>\n<foilgroup>";
for (my $k=0;$k<=$#CTChoices;$k++) {
$line="',".$CTChoices[$k].",'";
unless ($line) { next; }
@@ -52,7 +66,33 @@
my ($dummy,$key,$text,$true)=split(/\'\,\'/,$line);
unless ($key==$i) { next; }
$CTChoices[$k]='';
- print "\n- ".&htmlclean($text);
+ $problem.="\n<foil name='$k' value='".($true==1?'true':'false')."'>\n<startouttext />".&htmlclean($text)."<endouttext />\n</foil>";
+ }
+ $problem.="\n</foilgroup>\n</radiobuttonresponse>";
+ if ($outro) {
+ $problem.="\n<startouttext />".&htmlclean($outro)."<endouttext />\n";
+ }
+ if (($answertext) || ($answerimage)) {
+ $problem.="\n<postanswerdate>\n";
+ if ($answertext) {
+ $problem.="\n<startouttext />".&htmlclean($answertext)."<endouttext />\n";
+ }
+ if ($answerimage) {
+ my ($relative)=($answerimage=~/\/([^\/]+)$/);
+ $problem.="\n<img src='$relative' />\n";
+ }
+ $problem.="\n</postanswerdate>\n";
+ }
+ $problem.="\n</problem>\n";
+ my $path='cts/';
+ my $nextpath=$i;
+ $nextpath=~s/(\d)/$1\//g;
+ $nextpath=~s/\d\/$//;
+ $path.=$nextpath.'/'.$i;
+ my $sofar='';
+ foreach (split(/\//,$path)) {
+ $sofar.=$_.'/';
+ mkdir $sofar;
}
}
}
@@ -263,6 +303,10 @@
unless ($blockdesymboling) {
$raw=&symbolfontreplace($raw);
}
+# Make relative URLs and set need to get
+ @needtoget=(@needtoget,($raw=~/src=[\"\']([^\"\']+)[\"\']/igs));
+ $raw=~s/src=[\"\']([^\"\']+)\/([^\"\'\/]+)[\"\']/src='$2'/igs;
+
return $raw;
}