[LON-CAPA-cvs] cvs: modules /gerd/ct convert.pl
www
lon-capa-cvs@mail.lon-capa.org
Mon, 02 Jan 2006 20:25:40 -0000
www Mon Jan 2 15:25:40 2006 EDT
Modified files:
/modules/gerd/ct convert.pl
Log:
Stylefile format
Index: modules/gerd/ct/convert.pl
diff -u modules/gerd/ct/convert.pl:1.7 modules/gerd/ct/convert.pl:1.8
--- modules/gerd/ct/convert.pl:1.7 Thu Sep 22 11:21:01 2005
+++ modules/gerd/ct/convert.pl Mon Jan 2 15:25:38 2006
@@ -10,6 +10,7 @@
my @Image;
my @ConceptTestType;
my @CTCopyright;
+print "Starting\n";
open(IN,'ct.sql');
while (my $line=<IN>) {
if ($line=~/^INSERT INTO (\w+) VALUES \((\d+)\,(.*)\)\;$/) {
@@ -41,10 +42,13 @@
$CTCopyright[$1]=$line;
}
close(IN);
+print "Starting Conversion\n";
for (my $i=0;$i<=$#ConceptTest;$i++) {
+ print "\nDoing ".$i;
if ($ConceptTest[$i]=~/\w+/) {
@needtoget=();
my $problem="<problem>\n";
+ $problem.='<parserlib>../../../../../../ct.sty</parserlib>';
my $line="',".$ConceptTest[$i].",'";
my $image='';
my $answerimage='';
@@ -61,13 +65,16 @@
push @needtoget,($Image[$answerimageid]=~/\'([^\']+)\'$/);
}
if ($intro) {
- $problem.="\n<startouttext />".&htmlclean($intro)."<endouttext />\n";
+ $problem.="\n<ctintro>".&htmlclean($intro)."</ctintro>\n";
}
if ($image) {
my ($relative)=($image=~/\/([^\/]+)$/);
- $problem.="\n<img src='$relative' />\n";
+ $problem.="\n<ctimage src='$relative' />\n";
}
- $problem.="\n<radiobuttonresponse max='99' randomize='no'>\n<foilgroup>";
+ if ($postcomment) {
+ $problem.="\n<ctpostcomment>".&htmlclean($postcomment)."</ctpostcomment>\n";
+ }
+ $problem.="\n<ctchoices>";
for (my $k=0;$k<=$#CTChoices;$k++) {
$line="',".$CTChoices[$k].",'";
unless ($line) { next; }
@@ -75,22 +82,22 @@
my ($dummy,$key,$text,$true)=split(/\'\,\'/,$line);
unless ($key==$i) { next; }
$CTChoices[$k]='';
- $problem.="\n<foil name='$k' value='".($true==1?'true':'false')."'>\n<startouttext />".&htmlclean($text)."<endouttext />\n</foil>";
+ $problem.="\n<ctchoice name='$k' value='".($true==1?'true':'false')."'>\n".&htmlclean($text)."\n</ctchoice>\n";
}
- $problem.="\n</foilgroup>\n</radiobuttonresponse>";
+ $problem.="\n</ctchoices>";
if ($outro) {
- $problem.="\n<startouttext />".&htmlclean($outro)."<endouttext />\n";
+ $problem.="\n<ctoutro>".&htmlclean($outro)."<ctoutro>\n";
}
if (($answertext) || ($answerimage)) {
- $problem.="\n<postanswerdate>\n";
+ $problem.="\n<ctanswer>\n";
if ($answertext) {
- $problem.="\n<startouttext />".&htmlclean($answertext)."<endouttext />\n";
+ $problem.="\n<ctanswertext>".&htmlclean($answertext)."</ctanswertext>\n";
}
if ($answerimage) {
my ($relative)=($answerimage=~/\/([^\/]+)$/);
- $problem.="\n<img src='$relative' />\n";
+ $problem.="\n<ctanswerimage src='$relative' />\n";
}
- $problem.="\n</postanswerdate>\n";
+ $problem.="\n</ctanswer>\n";
}
$problem.="\n</problem>\n";
my $path='cts/';
@@ -110,18 +117,22 @@
my $meta='';
my ($dummy,$dummy2,$copyid,$author,$email,$inst,$year)=split(/\,/,$CTCopyright[$i]);
$year=~s/\W//gs;
- if ($author) {
- my $customrights=$author.$copyid;
- $customrights=~s/\W//g;
- open (OUT,">cts/$customrights.rights");
- print OUT '<accessrule effect="deny" realm="" role="" />'."\n";
- close(OUT);
- $meta.='<author>'.$author.'</author>'."\n".
- '<copyright>custom</copyright>'."\n".
- "<customdistributionfile>/res/harvard/cts/$customrights.rights</customdistributionfile>\n";
- } else {
- $meta.="<copyright>default</copyright>\n";
+ if ($author) {
+ $meta.='<author>'.$author.'</author>'."\n";
+ if (($author!~/mazur/i) && ($copyid)) {
+ my $customrights=$author.$copyid;
+ $customrights=~s/\W//g;
+ open (OUT,">cts/$customrights.rights");
+ print OUT '<accessrule effect="deny" realm="" role="" />'."\n";
+ close(OUT);
+ $meta.=
+ '<copyright>custom</copyright>'."\n".
+ "<customdistributionfile>/res/harvard/cts/$customrights.rights</customdistributionfile>\n";
+ } else {
+ $meta.="<copyright>default</copyright>\n";
+ }
}
+ $meta.='<title>ConceptTest '.$i.'</title>'."\n";
$meta.='<notes>';
if ($inst) { $meta.=$inst.", "; }
if ($year) { $meta.=$year.", "; }
@@ -135,6 +146,7 @@
foreach my $url (@needtoget) {
unless ($url) { next; }
my ($relative)=($url=~/\/([^\/]+)$/);
+ if (-e "$path/$relative") { next; }
unless ($url=~/^http\:/) {
$url='http://www.deas.harvard.edu/galileo/images/ctimages/'.$url;
}