[LON-CAPA-cvs] cvs: rat / lonratsrv.pm loncom/interface londocs.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 19 Aug 2002 21:15:08 -0000
www Mon Aug 19 17:15:08 2002 EDT
Modified files:
/loncom/interface londocs.pm
/rat lonratsrv.pm
Log:
Further work toward having uploaded maps as standard course maps, and
londocs as editor for that.
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.6 loncom/interface/londocs.pm:1.7
--- loncom/interface/londocs.pm:1.6 Thu Aug 1 11:26:23 2002
+++ loncom/interface/londocs.pm Mon Aug 19 17:15:08 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.6 2002/08/01 15:26:23 www Exp $
+# $Id: londocs.pm,v 1.7 2002/08/19 21:15:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,6 +32,43 @@
use Apache::Constants qw(:common);
use Apache::lonnet;
use Apache::loncommon;
+use Apache::lonratedt;
+use Apache::lonratsrv;
+
+
+# Mapread read maps into lonratedt::global arrays
+# @links and @resources, determines status
+# sets @order - pointer to resources in right order
+# sets @resources - array with the resources with correct idx
+#
+
+sub mapread {
+ my ($coursenum,$coursedom,$map)=@_;
+ return
+ &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map);
+}
+
+sub storemap {
+ my ($coursenum,$coursedom,$map)=@_;
+ return
+ &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map);
+}
+
+sub editor {
+ my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
+ my ($errtext,$fatal)=
+ &mapread($coursenum,$coursedom,$folder.'.sequence');
+ if ($fatal) {
+ $r->print('<p><font color="red">'.$errtext.'</font></p>');
+ } else {
+# ------------------------------------------------------------ Process commands
+ if ($allowed) {
+ }
+# ---------------------------------------------------------------- Print screen
+ }
+}
sub handler {
my $r = shift;
@@ -39,12 +76,19 @@
$r->send_http_header;
return OK if $r->header_only;
+# 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'}=~/^supplement_/);
+
# does this user have privileges to post, etc?
my $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
if ($allowed) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['remove'])
+ ['remove']);
}
# get course data
@@ -87,6 +131,21 @@
<body bgcolor="#FFFFFF">
<h1>Course Documents</h1>
ENDDOCUMENT
+# --------------------------------------------------0------ Standard documents
+ if (($standard) && ($allowed) && (!$forcesupplement)) {
+ $r->print('<h2>Main Course Documents</h2>');
+ my $folder=$ENV{'form.folder'};
+ unless ($folder) { $folder='default'; }
+ &editor($r,$coursenum,$coursedom,$folder,$allowed);
+ $r->print('<hr />');
+ }
+# ----------------------------------------------------- Supplemental documents
+ if (!$forcestandard) {
+ $r->print('<h2>Supplemental Course Documents</h2>');
+ my $folder=$ENV{'form.folder'};
+ unless ($folder) { $folder='supplemental'; }
+ &editor($r,$coursenum,$coursedom,$folder,$allowed);
+ }
# ------------------------------------------------------- Print headers to docs
my %currentdocs=&Apache::lonnet::dump('coursedocs',$coursedom,$coursenum);
foreach (sort keys (%currentdocs)) {
@@ -118,6 +177,11 @@
</form>
ENDFORM
}
+
+ foreach (@Apache::lonratedt::resources) {
+ $r->print($_.'<br>');
+ }
+
$r->print('</body></html>');
return OK;
}
Index: rat/lonratsrv.pm
diff -u rat/lonratsrv.pm:1.20 rat/lonratsrv.pm:1.21
--- rat/lonratsrv.pm:1.20 Thu Jun 27 13:00:12 2002
+++ rat/lonratsrv.pm Mon Aug 19 17:15:08 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Server for RAT Maps
#
-# $Id: lonratsrv.pm,v 1.20 2002/06/27 17:00:12 albertel Exp $
+# $Id: lonratsrv.pm,v 1.21 2002/08/19 21:15:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,15 +69,20 @@
sub loadmap {
my ($fn,$errtext)=@_;
my $outstr='';
- my @content=();
my @obj=();
my @links=();
- if (-e $fn) {
+ my $instr='';
+ if ($fn=~/^\/*uploaded\//) {
+ $instr=&Apache::lonnet::getfile($fn);
+ } elsif (-e $fn) {
+ my @content=();
{
my $fh=Apache::File->new($fn);
@content=<$fh>;
}
- my $instr=join('',@content);
+ $instr=join('',@content);
+ }
+ if ($instr) {
my $parser = HTML::TokeParser->new(\$instr);
my $token;
my $graphmode=0;
@@ -286,7 +291,14 @@
}
} @tags;
$outstr.="</map>\n";
- {
+ if ($fn=~/^\/*uploaded\//) {
+ $ENV{'form.output'}=$outstr;
+ &Apache::lonnet::finishuserfileupload(
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.home'},
+ 'output',(split(/\//,$fn))[-1]);
+ } else {
my $fh;
if ($fh=Apache::File->new(">$fn")) {
print $fh $outstr;