version 1.31, 2007/07/11 23:51:02
|
version 1.41, 2011/07/04 09:25:17
|
Line 27
|
Line 27
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
|
|
|
|
|
package Apache::lonsequence; |
package Apache::lonsequence; |
|
|
use strict; |
use strict; |
Line 34 use Apache::lonnet;
|
Line 36 use Apache::lonnet;
|
use Apache::Constants qw(:common :http REDIRECT); |
use Apache::Constants qw(:common :http REDIRECT); |
use GDBM_File; |
use GDBM_File; |
use LONCAPA::map(); |
use LONCAPA::map(); |
|
use LONCAPA; |
use Apache::lonpageflip(); |
use Apache::lonpageflip(); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::groupsort(); |
use Apache::groupsort(); |
Line 46 my $successtied;
|
Line 49 my $successtied;
|
# ----------------------------------------- Attempt to read from resource space |
# ----------------------------------------- Attempt to read from resource space |
|
|
sub attemptread { |
sub attemptread { |
my $fn=shift; |
my ($fn,$unsorted)=@_; |
&Apache::lonnet::repcopy($fn); |
&Apache::lonnet::repcopy($fn); |
if (-e $fn) { |
if (-e $fn) { |
return &LONCAPA::map::attemptread($fn); |
return &LONCAPA::map::attemptread($fn,$unsorted); |
} else { |
} else { |
return (); |
return (); |
} |
} |
Line 100 ENDSCRIPT
|
Line 103 ENDSCRIPT
|
'<h1>'.$url.'</h1>'); |
'<h1>'.$url.'</h1>'); |
# ------------------ This is trying to select. Provide buttons and tie %selhash |
# ------------------ This is trying to select. Provide buttons and tie %selhash |
if ($env{'form.forceselect'}) { $r->print(<<ENDSELECT); |
if ($env{'form.forceselect'}) { $r->print(<<ENDSELECT); |
<form name=fileattr><input type=hidden name=acts value=''> |
<form name="fileattr"><input type="hidden" name="acts" value="" /> |
<input type="button" name="close" value='CLOSE' onClick="self.close()"> |
<input type="button" name="close" value="CLOSE" onClick="self.close()" /> |
<input type="button" name="groupimport" value='GROUP IMPORT' |
<input type="button" name="groupimport" value="GROUP IMPORT" |
onClick="javascript:select_group()"> |
onClick="javascript:select_group()" /> |
</form> |
</form> |
ENDSELECT |
ENDSELECT |
my $diropendb = |
my $diropendb = |
"/home/httpd/perl/tmp/$env{'user.domain'}\_$env{'user.name'}_sel_res.db"; |
LONCAPA::tempdir() . |
|
"$env{'user.domain'}\_$env{'user.name'}_sel_res.db"; |
if (tie(%selhash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
if (tie(%selhash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
if ($env{'form.launch'} eq '1') { |
if ($env{'form.launch'} eq '1') { |
&start_fresh_session(); |
&start_fresh_session(); |
Line 124 ENDSELECT
|
Line 128 ENDSELECT
|
# ----------------------------- successtied is now '1' if in working selectmode |
# ----------------------------- successtied is now '1' if in working selectmode |
my ($errtext,$fatal)=&mapread(&Apache::lonnet::filelocation('',$url),''); |
my ($errtext,$fatal)=&mapread(&Apache::lonnet::filelocation('',$url),''); |
if ($fatal==1) { |
if ($fatal==1) { |
$r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />'); |
$r->print('<p class="LC_warning">' |
|
.&mt('Map contents are not shown in order.') |
|
.'</p><br />'); |
} |
} |
my $idx=0; |
my $idx=0; |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
Line 147 ENDSELECT
|
Line 153 ENDSELECT
|
if ($successtied) { |
if ($successtied) { |
my $checked=''; |
my $checked=''; |
if ($selhash{'store_'.$url}) { |
if ($selhash{'store_'.$url}) { |
$checked=" checked"; |
$checked=' checked="checked"'; |
} |
} |
$selhash{"pre_${idx}_link"}=$url; |
$selhash{"pre_${idx}_link"}=$url; |
$selhash{"pre_${idx}_title"}=$title; |
$selhash{"pre_${idx}_title"}=$title; |
Line 166 ENDCHECKBOX
|
Line 172 ENDCHECKBOX
|
if ($successtied) { |
if ($successtied) { |
$r->print('</form>'); |
$r->print('</form>'); |
} else { |
} else { |
$r->print('<br>'); |
$r->print('<br />'); |
} |
} |
} |
} |
} |
} |
Line 213 sub handler {
|
Line 219 sub handler {
|
my $dismapid=''; |
my $dismapid=''; |
my $exitdisid = ''; |
my $exitdisid = ''; |
my $arrow_dir = ''; |
my $arrow_dir = ''; |
|
my $is_encrypted = ''; |
|
|
if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) { |
if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) { |
my $last; |
my $last; |
Line 243 sub handler {
|
Line 250 sub handler {
|
if (!$env{'request.role.adv'}) { |
if (!$env{'request.role.adv'}) { |
$randomout = $bighash{'randomout_'.$disid}; |
$randomout = $bighash{'randomout_'.$disid}; |
} |
} |
|
if (!$env{'request.role.adv'}) { |
|
$is_encrypted = $bighash{'encrypted_'.$disid}; |
|
} |
} elsif (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
} elsif (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', |
&GDBM_READER(),0640)) { |
&GDBM_READER(),0640)) { |
$last=$hash{'last_known'}; |
$last=$hash{'last_known'}; |
Line 262 sub handler {
|
Line 272 sub handler {
|
if (!$env{'request.role.adv'}) { |
if (!$env{'request.role.adv'}) { |
$randomout = $bighash{'randomout_'.$disid}; |
$randomout = $bighash{'randomout_'.$disid}; |
} |
} |
|
if (!$env{'request.role.adv'}) { |
|
$is_encrypted = $bighash{'encrypted_'.$disid}; |
|
} |
} |
} |
} |
} |
$exitdisid = $disid; |
$exitdisid = $disid; |
Line 275 sub handler {
|
Line 288 sub handler {
|
# now either disurl is set (going to first page), or we need another display |
# now either disurl is set (going to first page), or we need another display |
if ($disurl) { |
if ($disurl) { |
# -------------------------------------------------- Has first or last resource |
# -------------------------------------------------- Has first or last resource |
|
my $showdisurl = $disurl; |
|
if ($is_encrypted) { |
|
$showdisurl = &Apache::lonenc::encrypted($disurl); |
|
} |
&Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid], |
&Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid], |
'last_known' => [$disurl,$dismapid]); |
'last_known' => [$disurl,$dismapid]); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$disurl); |
$r->header_out(Location => &Apache::lonnet::absolute_url($ENV{'SERVER_NAME'}). |
|
$showdisurl); |
return REDIRECT; |
return REDIRECT; |
} else { |
} else { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 322 ENDNONE
|
Line 340 ENDNONE
|
1; |
1; |
__END__ |
__END__ |
|
|
|
=head1 NAME |
|
|
|
Apache::lonsequence |
|
|
|
=head1 SYNOPSIS |
|
|
|
Handler for showing sequence objects of |
|
educational resources. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 SUBROUTINES |
|
|
|
=over |
|
|
|
=item handler() |
|
|
|
=item viewmap() |
|
|
|
=item attemptread() |
|
|
|
=item mapread() |
|
|
|
=item start_fresh_session() |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
|