[LON-CAPA-cvs] cvs: rat / lonratedt.pm lonuserstate.pm loncom/interface londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 02 Sep 2002 15:27:08 -0000


www		Mon Sep  2 11:27:08 2002 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
    /rat	lonratedt.pm lonuserstate.pm 
  Log:
  BUGFIX tmp file mechanism for lonratedt 
    - display right after "Save" and "Revert"
  
  Can override ratedt tmp-mechanism for coursedocs
  Does NAV as resource in coursemaps
  Start on showdoc mechanism for uploaded docs in main sequence
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.14 loncom/interface/londocs.pm:1.15
--- loncom/interface/londocs.pm:1.14	Fri Aug 30 20:43:12 2002
+++ loncom/interface/londocs.pm	Mon Sep  2 11:27:08 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.14 2002/08/31 00:43:12 www Exp $
+# $Id: londocs.pm,v 1.15 2002/09/02 15:27:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::loncommon;
 use Apache::lonratedt;
 use Apache::lonratsrv;
+use Apache::lonxml;
 
 my $iconpath;
 
@@ -54,7 +55,7 @@
     my ($coursenum,$coursedom,$map)=@_;
     return
       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
-                                $map);
+                                $map,1);
 }
 
 sub editor {
@@ -192,17 +193,31 @@
 
 # is this a standard course?
 
-    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']);
     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
-    my $forcestandard=($ENV{'form.folder'}=~/^default_/);
-    my $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
+    my $forcestandard;
+    my $forcesupplement;
+    my $script='';
+    my $allowed;
+    my $events='';
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+       ['folder','showdoc']);
+    unless ($ENV{'form.showdoc'}) { # got called from remote
+       $forcestandard=($ENV{'form.folder'}=~/^default_/);
+       $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
 
 # does this user have privileges to post, etc?
-    my $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
-    my $script='';
-    if ($allowed) { 
-       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
-       $script=&Apache::lonratedt::editscript('simple'); 
+       $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
+       if ($allowed) { 
+         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
+         $script=&Apache::lonratedt::editscript('simple'); 
+       }
+    } else { # got called in sequence from course
+       $allowed=0;
+       $forcestandard=1;
+       $forcesupplement=0;
+       $script=&Apache::&Apache::lonxml::registerurl(1,undef);
+       $events='onLoad="'.&Apache::lonxml::loadevents.
+           '" onUnload="'.&Apache::lonxml::unloadevents.'"';
     }
 
 # get course data
@@ -228,7 +243,7 @@
 <script>$script</script>
 </head>
 ENDDOCUMENT
-$r->print(&Apache::loncommon::bodytag('Course Documents'));
+$r->print(&Apache::loncommon::bodytag('Course Documents','',$events));
 # --------------------------------------------------0------ Standard documents
     if (($standard) && ($allowed) && (!$forcesupplement)) {
        $r->print('<h2>Main Course Documents</h2>');
@@ -276,6 +291,11 @@
 <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 <input name="newsyl" type="submit" value="Syllabus" />
+</form>
+<form action="/adm/coursedocs" method="post" name="newsyl">
+<input type=hidden name="importdetail" 
+value="Navigate Content=/adm/navmaps">
+<input name="newsyl" type="submit" value="Navigate Content" />
 </form>
 <form action="/adm/coursedocs" method="post" name="newaboutme">
 <input type=hidden name="importdetail" 
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.34 rat/lonratedt.pm:1.35
--- rat/lonratedt.pm:1.34	Fri Aug 30 20:42:30 2002
+++ rat/lonratedt.pm	Mon Sep  2 11:27:08 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.34 2002/08/31 00:42:30 www Exp $
+# $Id: lonratedt.pm,v 1.35 2002/09/02 15:27:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -331,10 +331,16 @@
 
 sub storemap {
     my $realfn=shift;
-    my $fn=$realfn.'.tmp';
-    unless (-e $fn) {
-	copy($realfn,$fn);
+    my $fn=$realfn;
+# unless this is forced to work from the original file, use a temporary file
+# instead
+    unless (shift) {
+       $fn=$realfn.'.tmp';
+       unless (-e $fn) {
+	  copy($realfn,$fn);
+       }
     }
+# store data either into tmp or real file
     &startfinish();
     my $output='graphdef<:>no';
     my $k=1;
@@ -474,10 +480,14 @@
        $targetmsg='<b>Saving ...</b><br>';
        copy($tmpfn,&Apache::lonnet::filelocation('',$url));
        unlink($tmpfn);
+       my ($errtext,$fatal)=
+                           &mapread(&Apache::lonnet::filelocation('',$url),'');
    }
    if ($ENV{'form.revert'}) {
        $targetmsg='<b>Reverting ...</b><br>';
        unlink($tmpfn);
+       my ($errtext,$fatal)=
+                           &mapread(&Apache::lonnet::filelocation('',$url),'');
    }
    if (-e $tmpfn) {
       $targetmsg=
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.39 rat/lonuserstate.pm:1.40
--- rat/lonuserstate.pm:1.39	Fri Aug 30 20:43:13 2002
+++ rat/lonuserstate.pm	Mon Sep  2 11:27:08 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.39 2002/08/31 00:43:13 www Exp $
+# $Id: lonuserstate.pm,v 1.40 2002/09/02 15:27:08 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,12 +118,19 @@
                     unless ($ispage) {
                         $turi=~/\.(\w+)$/;
                         my $embstyle=&Apache::loncommon::fileembstyle($1);
-                        if ($token->[2]->{'external'} eq 'true') {
+                        if ($token->[2]->{'external'} eq 'true') { # external
                             $turi=~s/^http\:\/\//\/adm\/wrapper\/ext\//;
-                        } else {
-                           my $embstyle=&Apache::loncommon::fileembstyle($1);
+                        } elsif ($turi=~/^\/*uploaded\//) { # uploaded
+			    if (($embstyle eq 'img') || ($embstyle eq 'emb')
+                             || ($embstyle eq 'ssi')) {
+                                $turi='/adm/wrapper'.$turi;
+                            } else {
+				$turi='/adm/coursedocs?showdoc='.$turi;
+                            }
+                        } else { # normal internal resource
                            if (($embstyle eq 'img') || ($embstyle eq 'emb')
-                          || ($turi=~/\/syllabus$/) || ($turi=~/\/aboutme$/)) {
+                          || ($turi=~/\/syllabus$/) || ($turi=~/\/aboutme$/)
+                          || ($turi=~/\/navmaps$/)) {
 			       $turi='/adm/wrapper'.$turi;
                            }
                         }