--- rat/lonsequence.pm 2007/12/01 01:59:54 1.32 +++ rat/lonsequence.pm 2011/07/04 09:25:17 1.41 @@ -2,7 +2,7 @@ # # Sequence Handler # -# $Id: lonsequence.pm,v 1.32 2007/12/01 01:59:54 albertel Exp $ +# $Id: lonsequence.pm,v 1.41 2011/07/04 09:25:17 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,6 +27,8 @@ # http://www.lon-capa.org/ # + + package Apache::lonsequence; use strict; @@ -34,6 +36,7 @@ use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); use GDBM_File; use LONCAPA::map(); +use LONCAPA; use Apache::lonpageflip(); use Apache::loncommon(); use Apache::groupsort(); @@ -100,14 +103,15 @@ ENDSCRIPT '

'.$url.'

'); # ------------------ This is trying to select. Provide buttons and tie %selhash if ($env{'form.forceselect'}) { $r->print(< - - +
+ +
ENDSELECT 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 ($env{'form.launch'} eq '1') { &start_fresh_session(); @@ -124,7 +128,9 @@ ENDSELECT # ----------------------------- successtied is now '1' if in working selectmode my ($errtext,$fatal)=&mapread(&Apache::lonnet::filelocation('',$url),''); if ($fatal==1) { - $r->print('

'.&mt('Map contents are not shown in order.').'


'); + $r->print('

' + .&mt('Map contents are not shown in order.') + .'


'); } my $idx=0; foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { @@ -147,7 +153,7 @@ ENDSELECT if ($successtied) { my $checked=''; if ($selhash{'store_'.$url}) { - $checked=" checked"; + $checked=' checked="checked"'; } $selhash{"pre_${idx}_link"}=$url; $selhash{"pre_${idx}_title"}=$title; @@ -166,7 +172,7 @@ ENDCHECKBOX if ($successtied) { $r->print(''); } else { - $r->print('
'); + $r->print('
'); } } } @@ -213,6 +219,7 @@ sub handler { my $dismapid=''; my $exitdisid = ''; my $arrow_dir = ''; + my $is_encrypted = ''; if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) { my $last; @@ -243,6 +250,9 @@ sub handler { if (!$env{'request.role.adv'}) { $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', &GDBM_READER(),0640)) { $last=$hash{'last_known'}; @@ -262,6 +272,9 @@ sub handler { if (!$env{'request.role.adv'}) { $randomout = $bighash{'randomout_'.$disid}; } + if (!$env{'request.role.adv'}) { + $is_encrypted = $bighash{'encrypted_'.$disid}; + } } } $exitdisid = $disid; @@ -275,10 +288,15 @@ sub handler { # now either disurl is set (going to first page), or we need another display if ($disurl) { # -------------------------------------------------- Has first or last resource + my $showdisurl = $disurl; + if ($is_encrypted) { + $showdisurl = &Apache::lonenc::encrypted($disurl); + } &Apache::lonnet::symblist($requrl,$disurl => [$disurl,$dismapid], 'last_known' => [$disurl,$dismapid]); &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; } else { &Apache::loncommon::content_type($r,'text/html'); @@ -322,7 +340,35 @@ ENDNONE 1; __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