[LON-CAPA-cvs] cvs: rat / lonratedt.pm lonsequence.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 23 May 2002 10:19:30 -0000
www Thu May 23 06:19:30 2002 EDT
Modified files:
/rat lonratedt.pm lonsequence.pm
Log:
Selection of resources from sequences for RAT should be done out of
resource space - moved code for that from lonratedt
Starting to work on viewing of sequences out of course context
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.27 rat/lonratedt.pm:1.28
--- rat/lonratedt.pm:1.27 Wed May 22 16:39:59 2002
+++ rat/lonratedt.pm Thu May 23 06:19:30 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.27 2002/05/22 20:39:59 www Exp $
+# $Id: lonratedt.pm,v 1.28 2002/05/23 10:19:30 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -129,7 +129,9 @@
}
# ---------------------------------------------- Read a map as well as possible
-
+# Also used by the sequence handler
+# Call lonsequence::attemptread to read from resource space
+#
sub attemptread {
my $fn=shift;
@@ -263,7 +265,6 @@
# ---------------------------------------------------------------- Make buttons
sub buttons {
- if ($ENV{'form.forceselect'}) { return ''; }
my $adv=shift;
my $output='<form method=post>';
if ($adv==1) {
@@ -765,41 +766,7 @@
sub viewmap {
my ($r,$url,$adv,$errtext)=@_;
- $r->print('<html>');
- if ($ENV{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
-<script>
-
-function select_group() {
- window.location="/adm/groupsort?catalogmode=groupimport&mode=rat&acts="+document.forms.fileattr.acts.value;
-}
-
-function queue(val) {
- if (eval("document.forms."+val+".filelink.checked")) {
- var l=val.length;
- var v=val.substring(4,l);
- document.forms.fileattr.acts.value+='1a'+v+'b';
- }
- else {
- var l=val.length;
- var v=val.substring(4,l);
- document.forms.fileattr.acts.value+='0a'+v+'b';
- }
-}
-
-
-
-</script>
-ENDSCRIPT
- }
- $r->print('<body bgcolor="#FFFFFF">'.&buttons($adv));
- if ($ENV{'form.forceselect'}) { $r->print(<<ENDSELECT);
-<form name=fileattr><input type=hidden name=acts value=''>
-<input type="button" name="close" value='CLOSE' onClick="self.close()">
-<input type="button" name="groupimport" value='GROUP IMPORT'
-onClick="javascript:select_group()">
-</form>
-ENDSELECT
- }
+ $r->print('<html><body bgcolor="#FFFFFF">'.&buttons($adv));
if ($errtext) {
$r->print($errtext.'<hr>');
}
@@ -807,31 +774,17 @@
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
if (defined($_)) {
$idx++;
- if ($ENV{'form.forceselect'}) {
- $r->print('<form name="form'.$idx.'">');
- }
my ($title,$url)=split(/\:/,$_);
$title=~s/\&colon\;/\:/g;
$url=~s/\&colon\;/\:/g;
unless ($title) { $title=(split(/\//,$url))[-1] };
unless ($title) { $title='<i>Empty</i>'; }
if ($url) {
- if ($ENV{'form.forceselect'}) {
- $r->print(<<ENDCHECKBOX);
-<input type='checkbox' name='filelink'
-value='$url' onClick='javascript:queue("form$idx")' >
-<input type='hidden' name='title' value='$title'>
-ENDCHECKBOX
- }
$r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');
}
$r->print(&Apache::lonratsrv::qtescape($title));
if ($url) { $r->print('</a>'); }
- if ($ENV{'form.forceselect'}) {
- $r->print('</form>');
- } else {
- $r->print('<br>');
- }
+ $r->print('<br>');
}
}
$r->print('</body></html>');
@@ -845,9 +798,6 @@
$r->send_http_header;
return OK if $r->header_only;
-
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['forceselect']);
my $url=$r->uri;
my $fn=&Apache::lonnet::filelocation('',$url);
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.7 rat/lonsequence.pm:1.8
--- rat/lonsequence.pm:1.7 Tue Apr 2 16:17:34 2002
+++ rat/lonsequence.pm Thu May 23 06:19:30 2002
@@ -2,7 +2,7 @@
#
# Sequence Handler
#
-# $Id: lonsequence.pm,v 1.7 2002/04/02 21:17:34 www Exp $
+# $Id: lonsequence.pm,v 1.8 2002/05/23 10:19:30 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,8 @@
use Apache::lonnet;
use Apache::Constants qw(:common :http REDIRECT);
use GDBM_File;
-
+use Apache::lonratedt;
+use Apache::lonratsrv;
# ----------------------------------------------------------- Could not resolve
@@ -56,6 +57,95 @@
'</body></html>');
}
+
+# ----------------------------------------- Attempt to read from resource space
+
+sub attemptread {
+ my $fn=shift;
+ &Apache::lonnet::repcopy($fn);
+ if (-e $fn) {
+ return &Apache::lonratedt::attemptread($fn);
+ } else {
+ return ();
+ }
+}
+
+# ---------------------------------------------------------------- View Handler
+
+sub viewmap {
+ my ($r,$url,$adv,$errtext)=@_;
+ $r->print('<html>');
+ if ($ENV{'form.forceselect'}) { $r->print(<<ENDSCRIPT);
+<script>
+
+function select_group() {
+ window.location="/adm/groupsort?catalogmode=groupimport&mode=rat&acts="+document.forms.fileattr.acts.value;
+}
+
+function queue(val) {
+ if (eval("document.forms."+val+".filelink.checked")) {
+ var l=val.length;
+ var v=val.substring(4,l);
+ document.forms.fileattr.acts.value+='1a'+v+'b';
+ }
+ else {
+ var l=val.length;
+ var v=val.substring(4,l);
+ document.forms.fileattr.acts.value+='0a'+v+'b';
+ }
+}
+
+
+
+</script>
+ENDSCRIPT
+ }
+ $r->print('<body bgcolor="#FFFFFF">'.&buttons($adv));
+ if ($ENV{'form.forceselect'}) { $r->print(<<ENDSELECT);
+<form name=fileattr><input type=hidden name=acts value=''>
+<input type="button" name="close" value='CLOSE' onClick="self.close()">
+<input type="button" name="groupimport" value='GROUP IMPORT'
+onClick="javascript:select_group()">
+</form>
+ENDSELECT
+ }
+ if ($errtext) {
+ $r->print($errtext.'<hr>');
+ }
+ my $idx=0;
+ foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
+ if (defined($_)) {
+ $idx++;
+ if ($ENV{'form.forceselect'}) {
+ $r->print('<form name="form'.$idx.'">');
+ }
+ my ($title,$url)=split(/\:/,$_);
+ $title=~s/\&colon\;/\:/g;
+ $url=~s/\&colon\;/\:/g;
+ unless ($title) { $title=(split(/\//,$url))[-1] };
+ unless ($title) { $title='<i>Empty</i>'; }
+ if ($url) {
+ if ($ENV{'form.forceselect'}) {
+ $r->print(<<ENDCHECKBOX);
+<input type='checkbox' name='filelink'
+value='$url' onClick='javascript:queue("form$idx")' >
+<input type='hidden' name='title' value='$title'>
+ENDCHECKBOX
+ }
+ $r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');
+ }
+ $r->print(&Apache::lonratsrv::qtescape($title));
+ if ($url) { $r->print('</a>'); }
+ if ($ENV{'form.forceselect'}) {
+ $r->print('</form>');
+ } else {
+ $r->print('<br>');
+ }
+ }
+ }
+ $r->print('</body></html>');
+}
+
# ================================================================ Main Handler
sub handler {
@@ -66,6 +156,9 @@
$r->send_http_header;
return OK;
}
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['forceselect']);
my %hash;
my %bighash;