[LON-CAPA-cvs] cvs: modules /gerd/ct convert.pl

www lon-capa-cvs@mail.lon-capa.org
Thu, 01 Sep 2005 17:41:53 -0000


www		Thu Sep  1 13:41:53 2005 EDT

  Modified files:              
    /modules/gerd/ct	convert.pl 
  Log:
  Almost there interpreting all the data
  
  
Index: modules/gerd/ct/convert.pl
diff -u modules/gerd/ct/convert.pl:1.2 modules/gerd/ct/convert.pl:1.3
--- modules/gerd/ct/convert.pl:1.2	Thu Sep  1 12:17:20 2005
+++ modules/gerd/ct/convert.pl	Thu Sep  1 13:41:51 2005
@@ -33,10 +33,27 @@
 close(IN);
 for (my $i=0;$i<=$#ConceptTest;$i++) {
     if ($ConceptTest[$i]=~/\w+/) {
-        my $line=$ConceptTest[$i];
+	my $line="',".$ConceptTest[$i].",'";
+        my $image='';
+        my $answerimage='';
         $line=~s/\,(\d+)\,/\,\'$1\'\,/g;
-	my ($typeid,$intro,$postcomment,$imageid,$outro,$answertext,$answerimageid,$statusid)=split(/\'\,\'/,$line);
-        print "\n------\n".&htmlclean($intro);
+	my ($dummy,$typeid,$intro,$postcomment,$imageid,$outro,$answertext,$answerimageid,$statusid)=split(/\'\,\'/,$line);
+	if ($imageid) {
+           $image=$Image[$imageid];
+        }
+	if ($answerimageid) {
+           $answerimage=$Image[$answerimageid];
+        }
+        print "\n---\n".&htmlclean($intro)."\n".&htmlclean($postcomment);
+        for (my $k=0;$k<=$#CTChoices;$k++) {
+	    $line="',".$CTChoices[$k].",'";
+            unless ($line) { next; }
+	    $line=~s/\,(\d+)\,/\,\'$1\'\,/g;
+	    my ($dummy,$key,$text,$true)=split(/\'\,\'/,$line);
+            unless ($key==$i) { next; }
+            $CTChoices[$k]='';
+            print "\n- ".&htmlclean($text);
+	}
     }
 }
 
@@ -212,6 +229,8 @@
 sub htmlclean {
     my ($raw,$full,$blocklinefeed,$blockemptytags,$blocklowercasing,$blockdesymboling)=@_;
 # Take care of CRLF etc
+    $raw=~s/\\"/"/g;
+    $raw=~s/\\'/'/g;
     unless ($blocklinefeed) {
         $raw=~s/\\r/\r/g;
         $raw=~s/\\n/\n/g;
@@ -234,7 +253,7 @@
         foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
                  'table','tr','td','th','p','br','hr','img','embed','font',
                  'a','strong','center','title','basefont','li','ol','ul',
-                 'input','select','form','option','script','pre') {
+                 'input','select','form','option','script','pre','sub','sup') {
             $raw=~s/\<$_\s*\>/\<$_\>/gis;
             $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
             $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;