--- loncom/imspackages/imsprocessor.pm	2004/03/16 23:35:33	1.4
+++ loncom/imspackages/imsprocessor.pm	2004/04/08 09:19:39	1.7
@@ -366,7 +366,7 @@ sub process_coursefile {
 }
 
 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 @@ sub process_resinfo {
             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}} = ();
@@ -546,10 +546,7 @@ sub build_structure {
                 my $title = $$items{$contitem}{title};
                 $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom);
                 unless ($flag{$key}{page} == 1) {
-                    $seqtext{$key} .= qq|<resource id="$curr_id" src="$src" title="$title"|;
-                    unless ($cms eq 'bb5' && $key eq 'Top' && @{$announcements}) {
-                        $seqtext{$key} .= qq| type="start"|;
-                    }
+                    $seqtext{$key} .= qq|<resource id="$curr_id" src="$src" title="$title" type="start"|;
                     unless ($flag{$key}{seq} || $flag{$key}{board} || $flag{$key}{file}) {
                         $flag{$key}{page} = 1;
                     }
@@ -654,7 +651,7 @@ sub build_structure {
 
     my $filestem;
     if ($context eq 'DOCS') {
-        $filestem = "/uploaded/$cdom/$crs";
+        $filestem = "/uploaded/$cdom/$crs/$timenow";
     } elsif ($context eq 'CSTR') {
         $filestem = "/res/$udom/$uname/$newdir";
     }
@@ -849,13 +846,13 @@ sub process_user {
      [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};
@@ -893,7 +890,7 @@ sub process_user {
      end_h =>
      [sub {
         my ($tagname) = @_;
-        if (@state eq "USERS USER") {
+        if ("@state" eq "USERS USER") {
             $linknum = 0;
         }
         pop @state;
@@ -930,14 +927,14 @@ sub process_group {
      [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};
@@ -982,11 +979,11 @@ sub process_staff {
      [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};
@@ -1159,11 +1156,11 @@ sub process_link {
         [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};
@@ -1174,7 +1171,7 @@ sub process_link {
             } 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 =>
@@ -1859,7 +1856,7 @@ sub process_announce {
         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};
@@ -1932,10 +1929,14 @@ $$settings{text}
 
 # ---------------------------------------------------------------- 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;
@@ -1947,13 +1948,13 @@ sub process_content {
       [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};