[LON-CAPA-cvs] cvs: loncom /imspackages imsimport.pm imsimportdocs.pm imsprocessor.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 08 Apr 2004 09:19:39 -0000


This is a MIME encoded message

--raeburn1081415979
Content-Type: text/plain

raeburn		Thu Apr  8 05:19:39 2004 EDT

  Modified files:              
    /loncom/imspackages	imsimportdocs.pm imsimport.pm imsprocessor.pm 
  Log:
  Set correct URL for inline images and linked files where IMS package import is via DOCS. Also fix some bugs in the parsing of Blackboard resource files.
  
  
--raeburn1081415979
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20040408051939.txt"

Index: loncom/imspackages/imsimportdocs.pm
diff -u loncom/imspackages/imsimportdocs.pm:1.5 loncom/imspackages/imsimportdocs.pm:1.6
--- loncom/imspackages/imsimportdocs.pm:1.5	Sun Mar 21 15:44:58 2004
+++ loncom/imspackages/imsimportdocs.pm	Thu Apr  8 05:19:39 2004
@@ -505,7 +505,6 @@
     my $timenow = time;
 
     my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow;
-    my $dirname = $cdom.'/'.$crs.'/'.$timenow;
     my $seqstem = "/uploaded/$cdom/$crs/$timenow";
     my $db_handling = '';
     my $user_handling = '';
@@ -567,7 +566,7 @@
         my @topurls = ();
         my @topnames = ();
 
-        &Apache::imsprocessor::process_resinfo($cms,$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$dirname,$seqstem,\@resrcfiles);
+        &Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles);
 
         &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);
  
Index: loncom/imspackages/imsimport.pm
diff -u loncom/imspackages/imsimport.pm:1.5 loncom/imspackages/imsimport.pm:1.6
--- loncom/imspackages/imsimport.pm:1.5	Tue Mar 16 14:20:58 2004
+++ loncom/imspackages/imsimport.pm	Thu Apr  8 05:19:39 2004
@@ -655,7 +655,7 @@
         my @topurls = ();
         my @topnames = ();
 
-        &Apache::imsprocessor::process_resinfo($cms,$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles);
+        &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles);
    
         &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);
 
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.6 loncom/imspackages/imsprocessor.pm:1.7
--- loncom/imspackages/imsprocessor.pm:1.6	Sun Mar 21 15:44:58 2004
+++ loncom/imspackages/imsprocessor.pm	Thu Apr  8 05:19:39 2004
@@ -366,7 +366,7 @@
 }
 
 sub process_resinfo {
-    my ($cms,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles) = @_;
+    my ($cms,$context,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles) = @_;
     my $board_id = time;
     my $board_count = 0;
     my $announce_handling = 'include';
@@ -407,7 +407,7 @@
             if ($$resources{$key}{type} eq "resource/x-bb-document") {
                 unless ($$items{$$resources{$key}{revitm}}{filepath} eq 'Top') {
                     %{$$resinfo{$key}} = ();
-                    &process_content($key,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$resrcfiles);
+                    &process_content($key,$context,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$resrcfiles);
                 }
             } elsif ($$resources{$key}{type} eq "resource/x-bb-staffinfo") {
                 %{$$resinfo{$key}} = ();
@@ -846,13 +846,13 @@
      [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        if (@state eq "USERS USER") {
+        if ("@state" eq "USERS USER") {
             $userid = $attr->{value};
             %{$$settings{$userid}} = ();
             @{$$settings{$userid}{links}} = ();
-        } elsif (@state eq "USERS USER LOGINID") {  
+        } elsif ("@state" eq "USERS USER LOGINID") {  
             $$settings{$userid}{loginid} = $attr->{value};
-        } elsif (@state eq "USERS USER PASSPHRASE") {  
+        } elsif ("@state" eq "USERS USER PASSPHRASE") {  
             $$settings{$userid}{passphrase} = $attr->{value};
         } elsif ("@state" eq "USERS USER STUDENTID" ) {
             $$settings{$userid}{studentid} = $attr->{value};
@@ -890,7 +890,7 @@
      end_h =>
      [sub {
         my ($tagname) = @_;
-        if (@state eq "USERS USER") {
+        if ("@state" eq "USERS USER") {
             $linknum = 0;
         }
         pop @state;
@@ -927,14 +927,14 @@
      [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        if (@state eq "GROUPS GROUP") {
+        if ("@state" eq "GROUPS GROUP") {
             $grp = $attr->{id};
         }        
-        if (@state eq "GROUPS GROUP TITLE") {
+        if ("@state" eq "GROUPS GROUP TITLE") {
             $$settings{$grp}{title} = $attr->{value};
-        } elsif (@state eq "GROUPS GROUP FLAGS ISAVAILABLE") {  
+        } elsif ("@state" eq "GROUPS GROUP FLAGS ISAVAILABLE") {  
             $$settings{$grp}{isavailable} = $attr->{value};
-        } elsif (@state eq "GROUPS GROUP FLAGS HASCHATROOM") {  
+        } elsif ("@state" eq "GROUPS GROUP FLAGS HASCHATROOM") {  
             $$settings{$grp}{chat} = $attr->{value};
         } elsif ("@state" eq "GROUPS GROUP FLAGS HASDISCUSSIONBOARD") {
             $$settings{$grp}{discussion} = $attr->{value};
@@ -979,11 +979,11 @@
      [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        if (@state eq "STAFFINFO TITLE") {
+        if ("@state" eq "STAFFINFO TITLE") {
             $$settings{title} = $attr->{value};
-        } elsif (@state eq "STAFFINFO BIOGRAPHY TEXTCOLOR") {
+        } elsif ("@state" eq "STAFFINFO BIOGRAPHY TEXTCOLOR") {
             $$settings{textcolor} = $attr->{value};
-        } elsif (@state eq "STAFFINFO BIOGRAPHY FLAGS ISHTML") {
+        } elsif ("@state" eq "STAFFINFO BIOGRAPHY FLAGS ISHTML") {
             $$settings{ishtml} = $attr->{value};
         } elsif ("@state" eq "STAFFINFO FLAGS ISAVAILABLE" ) {
             $$settings{isavailable} = $attr->{value};
@@ -1156,11 +1156,11 @@
         [sub {
             my ($tagname, $attr) = @_;
             push @state, $tagname;
-            if (@state eq "EXTERNALLINK TITLE") {
+            if ("@state" eq "EXTERNALLINK TITLE") {
                 $$settings{title} = $attr->{value};
-            } elsif (@state eq "EXTERNALLINK TEXTCOLOR") {  
+            } elsif ("@state" eq "EXTERNALLINK TEXTCOLOR") {  
                 $$settings{textcolor} = $attr->{value};
-            } elsif (@state eq "EXTERNALLINK DESCRIPTION FLAGS ISHTML") {  
+            } elsif ("@state" eq "EXTERNALLINK DESCRIPTION FLAGS ISHTML") {  
                 $$settings{ishtml} = $attr->{value};                               
             } elsif ("@state" eq "EXTERNALLINK FLAGS ISAVAILABLE" ) {
                 $$settings{isavailable} = $attr->{value};
@@ -1171,7 +1171,7 @@
             } elsif ("@state" eq "EXTERNALLINK POSITION" ) {
                 $$settings{position} = $attr->{value};
             } elsif ("@state" eq "EXTERNALLINK URL" ) {
-              $$settings{url} = $attr->{value};
+                $$settings{url} = $attr->{value};
             }
         }, "tagname, attr"],
         text_h =>
@@ -1856,7 +1856,7 @@
         if ("@state" eq "ANNOUNCEMENT TITLE") {
             $$settings{title} = $attr->{value};
             $$settings{startassessment} = ();
-        } elsif (@state eq "ANNOUNCEMENT DESCRIPTION FLAGS ISHTML") {  
+        } elsif ("@state" eq "ANNOUNCEMENT DESCRIPTION FLAGS ISHTML") {  
             $$settings{ishtml} = $attr->{value};          
         } elsif ("@state" eq "ANNOUNCEMENT DESCRIPTION FLAGS ISNEWLINELITERAL" ) {
             $$settings{isnewline} = $attr->{value};
@@ -1929,10 +1929,14 @@
 
 # ---------------------------------------------------------------- Process Blackboard Content
 sub process_content {
-    my ($res,$docroot,$destdir,$settings,$dom,$user,$resrcfiles) = @_;
+    my ($res,$context,$docroot,$destdir,$settings,$dom,$user,$resrcfiles) = @_;
     my $xmlfile = $docroot.'/'.$res.".dat";
     my $destresdir = $destdir;
-    $destresdir =~ s|/home/$user/public_html/|/res/$dom/$user/|;
+    if ($context eq 'CSTR') {
+        $destresdir =~ s|/home/$user/public_html/|/res/$dom/$user/|;
+    } elsif ($context eq 'DOCS') {
+        $destresdir =~ s|^/home/httpd/html/userfiles|/uploaded|;
+    }
     my $filecount = 0;
     my @allrelfiles = ();
     my @state;
@@ -1944,13 +1948,13 @@
       [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        if (@state eq "CONTENT MAINDATA") {
+        if ("@state" eq "CONTENT MAINDATA") {
             %{$$settings{maindata}} = ();
-        } elsif (@state eq "CONTENT MAINDATA TEXTCOLOR") {
+        } elsif ("@state" eq "CONTENT MAINDATA TEXTCOLOR") {
             $$settings{maindata}{color} = $attr->{value};
-        } elsif (@state eq "CONTENT MAINDATA FLAGS ISHTML") {  
+        } elsif ("@state" eq "CONTENT MAINDATA FLAGS ISHTML") {  
             $$settings{maindata}{ishtml} = $attr->{value}; 
-        } elsif (@state eq "CONTENT MAINDATA FLAGS ISNEWLINELITERAL") {  
+        } elsif ("@state" eq "CONTENT MAINDATA FLAGS ISNEWLINELITERAL") {  
             $$settings{maindata}{isnewline} = $attr->{value};
         } elsif ("@state" eq "CONTENT FLAGS ISAVAILABLE" ) {
             $$settings{isavailable} = $attr->{value};

--raeburn1081415979--