Annotation of rat/lonpageflip.pm, revision 1.86

1.1       www         1: # The LearningOnline Network with CAPA
                      2: #
                      3: # Page flip handler
                      4: #
1.86    ! raeburn     5: # $Id: lonpageflip.pm,v 1.85 2014/05/20 20:40:46 musolffc Exp $
1.18      www         6: #
                      7: # Copyright Michigan State University Board of Trustees
                      8: #
                      9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     10: #
                     11: # LON-CAPA is free software; you can redistribute it and/or modify
                     12: # it under the terms of the GNU General Public License as published by
                     13: # the Free Software Foundation; either version 2 of the License, or
                     14: # (at your option) any later version.
                     15: #
                     16: # LON-CAPA is distributed in the hope that it will be useful,
                     17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19: # GNU General Public License for more details.
                     20: #
                     21: # You should have received a copy of the GNU General Public License
                     22: # along with LON-CAPA; if not, write to the Free Software
                     23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     24: #
                     25: # /home/httpd/html/adm/gpl.txt
                     26: #
                     27: # http://www.lon-capa.org/
                     28: #
1.1       www        29: 
1.76      jms        30: 
                     31: 
1.1       www        32: package Apache::lonpageflip;
                     33: 
                     34: use strict;
1.68      albertel   35: use LONCAPA;
1.4       www        36: use Apache::Constants qw(:common :http REDIRECT);
1.53      albertel   37: use Apache::lonnet;
1.70      albertel   38: use Apache::loncommon();
1.84      raeburn    39: use Apache::lonlocal;
1.1       www        40: use HTML::TokeParser;
                     41: use GDBM_File;
                     42: 
1.3       www        43: # ========================================================== Module Global Hash
                     44:   
1.1       www        45: my %hash;
1.34      www        46: 
                     47: sub cleanup {
                     48:     if (tied(%hash)){
                     49: 	&Apache::lonnet::logthis('Cleanup pageflip: hash');
                     50:         unless (untie(%hash)) {
                     51: 	    &Apache::lonnet::logthis('Failed cleanup pageflip: hash');
                     52:         }
                     53:     }
1.63      albertel   54:     return OK;
1.34      www        55: }
1.1       www        56: 
1.3       www        57: sub addrid {
1.4       www        58:     my ($current,$new,$condid)=@_;
                     59:     unless ($condid) { $condid=0; }
1.27      www        60: 
1.3       www        61: 	if ($current) {
1.5       www        62: 	    $current.=','.$new;
1.3       www        63:         } else {
1.5       www        64:             $current=''.$new;
1.3       www        65:         }
1.27      www        66: 
1.3       www        67:     return $current;
1.25      www        68: }
                     69: 
                     70: sub fullmove {
                     71:     my ($rid,$mapurl,$direction)=@_;
1.53      albertel   72:     if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.28      albertel   73:                         &GDBM_READER(),0640)) {
1.25      www        74: 	($rid,$mapurl)=&move($rid,$mapurl,$direction);
                     75:         untie(%hash);
                     76:     }
                     77:     return($rid,$mapurl);
1.1       www        78: }
                     79: 
1.50      albertel   80: sub hash_src {
                     81:     my ($id)=@_;
1.56      albertel   82:     my ($mapid,$resid)=split(/\./,$id);
                     83:     my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},
                     84: 					  $resid,$hash{'src_'.$id});
1.50      albertel   85:     if ($hash{'encrypted_'.$id}) {
1.56      albertel   86: 	return (&Apache::lonenc::encrypted($hash{'src_'.$id}),
                     87: 		&Apache::lonenc::encrypted($symb));
1.50      albertel   88:     }
1.56      albertel   89:     return ($hash{'src_'.$id},$symb);
1.50      albertel   90: }
                     91: 
1.15      www        92: sub move {
1.72      albertel   93:     my ($next,$endupmap,$direction) = @_;
                     94:     my $safecount=0;
                     95:     my $allowed=0;
                     96:     do {
                     97: 	($next,$endupmap)=&get_next_possible_move($next,$endupmap,$direction);
                     98: 
                     99: 	my $url = $hash{'src_'.$next};
                    100: 	my ($mapid,$resid)=split(/\./,$next);
                    101: 	my $symb = &Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},
                    102: 						$resid,$url);
                    103: 	if ($url eq '' || $symb eq '') {
                    104: 	    $allowed = 0;
                    105: 	} else {
                    106: 	    my $priv = &Apache::lonnet::allowed('bre',$url,$symb);
                    107: 	    $allowed = (($priv eq 'F') || ($priv eq '2'));
                    108: 	}
                    109: 	$safecount++;
                    110:     } while (   ($next)
                    111: 	     && ($next!~/\,/)
                    112: 	     && (
                    113: 		    (!$hash{'src_'.$next})
                    114: 		 || (
                    115: 		        (!$env{'request.role.adv'})
                    116: 		     &&  $hash{'randomout_'.$next}
                    117: 		    )
                    118: 		 || (!$allowed)
                    119: 		)
                    120: 	     && ($safecount<10000));
                    121: 
                    122:     return ($next,$endupmap);
                    123: }
                    124: 
                    125: sub get_next_possible_move {
1.15      www       126:     my ($rid,$mapurl,$direction)=@_;
1.23      www       127:     my $startoutrid=$rid;
1.15      www       128: 
                    129:     my $next='';
                    130: 
                    131:               my $mincond=1;
                    132:               my $posnext='';
                    133:               if ($direction eq 'forward') {
                    134: # --------------------------------------------------------------------- Forward
1.33      www       135:                   while ($hash{'type_'.$rid} eq 'finish') {
                    136: 	             $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}};
1.15      www       137:                   }
1.61      albertel  138: 		  foreach my $id (split(/\,/,$hash{'to_'.$rid})) {
1.64      albertel  139: 		     my $condition= $hash{'conditions_'.$hash{'goesto_'.$id}};
                    140: 		     my $rescond  = &Apache::lonnet::docondval($condition);
                    141: 		     my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}});
                    142: 		     my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond;
                    143: 		     if ($thiscond>=$mincond) {
1.15      www       144: 		          if ($posnext) {
1.61      albertel  145: 		             $posnext.=','.$id.':'.$thiscond;
1.15      www       146:                           } else {
1.61      albertel  147:                              $posnext=$id.':'.$thiscond;
1.15      www       148: 		          }
                    149:                           if ($thiscond>$mincond) { $mincond=$thiscond; }
                    150: 	              }
1.61      albertel  151:                   } 
                    152: 		  foreach my $id (split(/\,/,$posnext))  {
                    153:                       my ($linkid,$condval)=split(/\:/,$id);
1.15      www       154:                       if ($condval>=$mincond) {
                    155: 		          $next=&addrid($next,$hash{'goesto_'.$linkid},
                    156:                                 $hash{'condid_'.$hash{'undercond_'.$linkid}});
                    157:                       }
1.61      albertel  158:                   }
1.15      www       159:                   if ($hash{'is_map_'.$next}) {
1.23      www       160: # This jumps to the beginning of a new map (going down level)
1.15      www       161:                       if (
                    162:       $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') {
                    163: 			  $mapurl=$hash{'src_'.$next};
                    164: 			  $next=$hash{'map_start_'.$hash{'src_'.$next}};
1.47      raeburn   165:                      } elsif (
                    166: # This jumps back up from an empty sequence, to a page up one level
                    167:                          $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') {
                    168:                          $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.15      www       169:                      }
1.23      www       170:                   } elsif 
                    171:                     ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) {
                    172: # This comes up from a map (coming up one level);
                    173: 		      $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.61      albertel  174: 		  }
1.15      www       175:               } elsif ($direction eq 'back') {
                    176: # ------------------------------------------------------------------- Backwards
1.33      www       177:                  while ($hash{'type_'.$rid} eq 'start') {
                    178: 	             $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}};
                    179: 		 }
1.62      albertel  180: 		 foreach my $id (split(/\,/,$hash{'from_'.$rid})) {
1.64      albertel  181: 		     my $condition= $hash{'conditions_'.$hash{'comesfrom_'.$id}};
                    182: 		     my $rescond  = &Apache::lonnet::docondval($condition);
                    183: 		     my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}});
                    184: 		     my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond;
1.62      albertel  185: 		     if ($thiscond>=$mincond) {
                    186: 			 if ($posnext) {
                    187: 		             $posnext.=','.$id.':'.$thiscond;
                    188: 			 } else {
                    189:                              $posnext=$id.':'.$thiscond;
                    190: 			 }
                    191: 			 if ($thiscond>$mincond) { $mincond=$thiscond; }
                    192: 		     }
                    193: 		 } 
                    194: 		 foreach my $id (split(/\,/,$posnext)) {
                    195: 		     my ($linkid,$condval)=split(/\:/,$id);
                    196: 		     if ($condval>=$mincond) {
                    197: 			 $next=&addrid($next,$hash{'comesfrom_'.$linkid},
                    198: 				       $hash{'condid_'.$hash{'undercond_'.$linkid}});
                    199: 		     }
                    200: 		 }
1.15      www       201:                   if ($hash{'is_map_'.$next}) {
1.24      www       202: # This jumps to the end of a new map (going down one level)
1.15      www       203:                       if (
                    204:       $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') {
                    205: 			  $mapurl=$hash{'src_'.$next};
                    206: 			  $next=$hash{'map_finish_'.$hash{'src_'.$next}};
1.47      raeburn   207:                       } elsif (
                    208:       $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') {
                    209: # This jumps back up from an empty sequence, to a page up one level
                    210:                           $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
                    211:                       }
1.24      www       212:                   } elsif 
                    213:                     ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) {
                    214: # This comes back up from a map (going up one level);
                    215: 		      $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.15      www       216:                   }
                    217: 	      }
                    218:               return ($next,$mapurl);
                    219: }
                    220: 
1.69      www       221: sub first_accessible_resource {
                    222:     my $furl;
                    223:     if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
                    224: 	    &GDBM_READER(),0640)) {
                    225: 	$furl=$hash{'first_url'};
1.74      albertel  226: 	my %args;
                    227: 	my ($url,$args) = split(/\?/,$furl);
                    228: 	foreach my $pair (split(/\&/,$args)) {
                    229: 	    my ($name,$value) = split(/=/,$pair);
                    230: 	    $args{&unescape($name)} = &unescape($value);
                    231: 	}
                    232:         if (!&Apache::lonnet::allowed('bre',$url,$args{'symb'})) {
1.69      www       233: # Wow, we cannot see this ... move forward to the next one that we can see
                    234: 	    my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward');
                    235: # Build the new URL
1.73      albertel  236: 	    my ($newmapid,$newresid)=split(/\./,$newrid);
1.69      www       237: 	    my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid});
                    238: 	    $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb });
                    239: 	    if ($hash{'encrypted_'.$newrid}) {
                    240: 		$furl=&Apache::lonenc::encrypted($furl);
                    241: 	    }
                    242: 	}
                    243: 	untie(%hash);
                    244: 	return $furl;
                    245:     } else {
                    246: 	return '/adm/navmaps';
                    247:     }
                    248: }
                    249: 
1.1       www       250: # ================================================================ Main Handler
                    251: 
                    252: sub handler {
1.2       www       253:    my $r=shift;
1.1       www       254: 
                    255: # ------------------------------------------- Set document type for header only
                    256: 
1.2       www       257:   if ($r->header_only) {
1.51      albertel  258:       &Apache::loncommon::content_type($r,'text/html');
                    259:       $r->send_http_header;
                    260:       return OK;
1.2       www       261:   }
                    262: 
1.5       www       263:   my %cachehash=(); 
                    264:   my $multichoice=0;
                    265:   my %multichoicehash=();
1.56      albertel  266:   my ($redirecturl,$redirectsymb);
1.4       www       267:   my $next='';
                    268:   my @possibilities=();
1.37      www       269:    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
1.53      albertel  270:   if (($env{'form.postdata'})&&($env{'request.course.fn'})) {
                    271:       $env{'form.postdata'}=~/(\w+)\:(.*)/;
1.2       www       272:       my $direction=$1;
1.40      www       273:       my $currenturl=$2;
1.50      albertel  274:       if ($currenturl=~m|^/enc/|) {
                    275: 	  $currenturl=&Apache::lonenc::unencrypted($currenturl);
                    276:       }
1.46      www       277:       $currenturl=~s/\.\d+\.(\w+)$/\.$1/;
1.54      albertel  278:       if ($direction eq 'firstres') {
1.69      www       279: 	  my $furl=&first_accessible_resource();
1.54      albertel  280: 	  &Apache::loncommon::content_type($r,'text/html');
                    281: 	  $r->header_out(Location => 
1.71      albertel  282: 			 &Apache::lonnet::absolute_url().$furl);
1.54      albertel  283: 	     
                    284: 	  return REDIRECT;
                    285:       }
1.80      droeschl  286:       if ($direction eq 'return') {
1.10      www       287: # -------------------------------------------------------- Return to last known
                    288:          my $last;
1.53      albertel  289:          if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
1.28      albertel  290:                     &GDBM_READER(),0640)) {
1.10      www       291: 	     $last=$hash{'last_known'};
                    292:              untie(%hash);
                    293:          }
                    294:          my $newloc;
1.53      albertel  295:          if (($last) && (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36      www       296:                         &GDBM_READER(),0640))) {
1.52      albertel  297:             my ($murl,$id,$fn)=&Apache::lonnet::decode_symb($last);
1.50      albertel  298: 	    $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id;
                    299: 	    $newloc=$hash{'src_'.$id};
                    300: 	    if ($newloc) {
                    301: 		if ($hash{'encrypted_'.$id}) { $newloc=&Apache::lonenc::encrypted($newloc); }
                    302: 			      
                    303: 	    } else {
1.57      www       304: 		$newloc='/adm/navmaps';
1.50      albertel  305: 	    }
1.36      www       306:             untie %hash;
1.10      www       307:          } else {
1.57      www       308: 	    $newloc='/adm/navmaps';
1.10      www       309:          }  
1.54      albertel  310: 	     &Apache::loncommon::content_type($r,'text/html');
                    311: 	     $r->header_out(Location => 
1.71      albertel  312: 			    &Apache::lonnet::absolute_url().$newloc);
1.54      albertel  313: 	     
                    314: 	     return REDIRECT;
1.10      www       315:       }
1.78      raeburn   316:       $currenturl=~s/^https?\:\/\///;
1.2       www       317:       $currenturl=~s/^[^\/]+//;
1.35      www       318: #
                    319: # Is the current URL on the map? If not, start with last known URL
                    320: #
                    321:       unless (&Apache::lonnet::is_on_map($currenturl)) {
1.7       www       322: 	 my $last;
1.53      albertel  323:          if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
1.28      albertel  324:                     &GDBM_READER(),0640)) {
1.7       www       325: 	     $last=$hash{'last_known'};
                    326:              untie(%hash);
                    327:          }
                    328:          if ($last) {
1.52      albertel  329: 	     $currenturl=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($last))[2]);
1.7       www       330: 	 } else {
1.54      albertel  331: 		 &Apache::loncommon::content_type($r,'text/html');
                    332: 		 $r->header_out(Location => 
1.71      albertel  333: 				&Apache::lonnet::absolute_url().
1.70      albertel  334: 				'/adm/noidea.html');
1.54      albertel  335: 		 return REDIRECT;
1.7       www       336:          }
                    337:       }
1.3       www       338: # ------------------------------------------- Do we have any idea where we are?
                    339:       my $position;
                    340:       if ($position=Apache::lonnet::symbread($currenturl)) {
                    341: # ------------------------------------------------------------------------- Yes
1.41      www       342: 	  my ($startoutmap,$mapnum,$thisurl)=&Apache::lonnet::decode_symb($position);
1.52      albertel  343:           $cachehash{$startoutmap}{$thisurl}=[$thisurl,$mapnum];
1.23      www       344:           $cachehash{$startoutmap}{'last_known'}=
1.52      albertel  345:                              [&Apache::lonnet::declutter($currenturl),$mapnum];
1.20      albertel  346: 
1.5       www       347: # ============================================================ Tie the big hash
1.53      albertel  348:           if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.28      albertel  349:                         &GDBM_READER(),0640)) {
1.29      www       350:               my $rid=$hash{'map_pc_'.&Apache::lonnet::clutter($startoutmap)}.
                    351:                       '.'.$mapnum;
1.14      www       352: 
1.15      www       353: # ------------------------------------------------- Move forward, backward, etc
1.22      www       354:               my $endupmap;
                    355:               ($next,$endupmap)=&move($rid,$startoutmap,$direction);
1.15      www       356: # -------------------------------------- Do we have one and only one empty URL?
1.22      www       357: # We are now at at least one non-empty URL
1.4       www       358: # ----------------------------------------------------- Check out possibilities
                    359:               if ($next) {
                    360:                   @possibilities=split(/\,/,$next);
                    361:                   if ($#possibilities==0) {
1.5       www       362: # ---------------------------------------------- Only one possibility, redirect
1.56      albertel  363: 	              ($redirecturl,$redirectsymb)=&hash_src($next);
1.52      albertel  364:                       $cachehash{$endupmap}{$redirecturl}=
                    365: 			  [$redirecturl,(split(/\./,$next))[1]];
1.4       www       366:                   } else {
1.5       www       367: # ------------------------ There are multiple possibilities for a next resource
                    368:                       $multichoice=1;
1.62      albertel  369: 		      foreach my $id (@possibilities) {
                    370: 			  $multichoicehash{'src_'.$id}=$hash{'src_'.$id};
                    371:                           $multichoicehash{'title_'.$id}=$hash{'title_'.$id};
                    372:                           $multichoicehash{'type_'.$id}=$hash{'type_'.$id};
                    373:                           (my $first, my $second) = $id =~ /(\d+).(\d+)/;
                    374:                           my $symbSrc = Apache::lonnet::declutter($hash{'src_'.$id});
                    375:                           $multichoicehash{'symb_'.$id} = 
1.32      bowersj2  376:                               Apache::lonnet::declutter($hash{'map_id_'.$first}.'___'.
                    377:                                                         $second.'___'.$symbSrc);
                    378:                                                          
1.62      albertel  379:                           my ($choicemap,$choiceres)=split(/\./,$id);
1.52      albertel  380: 			  my $map=&Apache::lonnet::declutter($hash{'src_'.$choicemap});
1.62      albertel  381: 			  my $url=$multichoicehash{'src_'.$id};
1.52      albertel  382:                           $cachehash{$map}{$url}=[$url,$choiceres];
1.62      albertel  383:                       }
1.4       www       384:                   }
1.5       www       385: 	      } else {
                    386: # -------------------------------------------------------------- No place to go
                    387:                   $multichoice=-1;
1.4       www       388:               }
1.5       www       389: # ----------------- The program must come past this point to untie the big hash
1.3       www       390: 	      untie(%hash);
1.5       www       391: # --------------------------------------------------------- Store position info
1.52      albertel  392:               $cachehash{$startoutmap}{'last_direction'}=[$direction,'notasymb'];
1.86    ! raeburn   393:               foreach my $thismap (keys(%cachehash)) {
1.52      albertel  394: 		  my $mapnum=$cachehash{$thismap}->{'mapnum'};
                    395: 		  delete($cachehash{$thismap}->{'mapnum'});
                    396: 		  &Apache::lonnet::symblist($thismap,
                    397: 					    %{$cachehash{$thismap}});
1.19      www       398: 	      }
1.5       www       399: # ============================================== Do not return before this line
1.4       www       400:               if ($redirecturl) {
1.5       www       401: # ----------------------------------------------------- There is a URL to go to
1.38      www       402: 		  if ($direction eq 'forward') {
                    403:                      &Apache::lonnet::linklog($currenturl,$redirecturl);
                    404: 		  }
                    405: 		  if ($direction eq 'back') {
                    406:                      &Apache::lonnet::linklog($redirecturl,$currenturl);
                    407: 		  }
1.85      musolffc  408: # ------------------------------------- Check for and display critical messages
                    409:                   my ($redirect, $url) = &Apache::loncommon::critical_redirect(300);
                    410:                   unless ($redirect) { 
                    411:                       $url=&Apache::lonnet::absolute_url().$redirecturl;
                    412: 		      $url = &add_get_param($url, { 'symb' => $redirectsymb});
                    413:                   }
1.51      albertel  414: 		  &Apache::loncommon::content_type($r,'text/html');
1.56      albertel  415:                   $r->header_out(Location => $url);
1.4       www       416:                   return REDIRECT;
1.5       www       417: 	      } else {
                    418: # --------------------------------------------------------- There was a problem
1.51      albertel  419:                   &Apache::loncommon::content_type($r,'text/html');
1.8       www       420:                   $r->send_http_header;
1.59      www       421: 		  my %lt=&Apache::lonlocal::texthash('title' => 'End of Sequence',
                    422: 						     'explain' =>
                    423: 						     'You have reached the end of the sequence of materials.',
                    424: 						     'back' => 'Go Back',
1.83      raeburn   425: 						     'nav' => 'Course Contents',
1.59      www       426: 						     'wherenext' =>
                    427: 						     'There are several possibilities of where to go next',
                    428: 						     'pick' =>
                    429: 						     'Please click on the the resource you intend to access',
                    430: 						     'titleheader' => 'Title',
                    431: 						     'type' => 'Type');
1.83      raeburn   432:                   if (&Apache::loncommon::course_type() eq 'Community') {
                    433:                       $lt{'nav'} = &mt('Community Contents');
                    434:                   }
1.8       www       435:                   if ($#possibilities>0) {
1.67      albertel  436: 		      my $start_page=
                    437: 			  &Apache::loncommon::start_page('Multiple Resources');
1.8       www       438:                      $r->print(<<ENDSTART);
1.67      albertel  439: $start_page
1.59      www       440: <h3>$lt{'wherenext'}</h3>
1.8       www       441: <p>
1.59      www       442: $lt{'pick'}:
1.8       www       443: <p>
1.79      bisitz    444: <table border="2">
1.59      www       445: <tr><th>$lt{'titleheader'}</th><th>$lt{'type'}</th></tr>
1.8       www       446: ENDSTART
1.62      albertel  447:                      foreach my $id (@possibilities) {
1.8       www       448:                         $r->print(
                    449:                               '<tr><td><a href="'.
1.66      albertel  450: 				  &add_get_param($multichoicehash{'src_'.$id},
                    451: 						 {'symb' =>
                    452: 						      $multichoicehash{'symb_'.$id},
                    453: 						  }).'">'.
1.62      albertel  454:                               $multichoicehash{'title_'.$id}.
                    455:                               '</a></td><td>'.$multichoicehash{'type_'.$id}.
1.8       www       456: 			      '</td></tr>');
1.26      www       457:                      }
1.59      www       458:                      $r->print('</table>');
1.8       www       459:                   } else {
1.82      bisitz    460:                       $r->print(
                    461:                           &Apache::loncommon::start_page('No Resource')
                    462:                          .'<h2>'.$lt{'title'}.'</h2>'
                    463:                          .'<p>'.$lt{'explain'}.'</p>');
                    464:                   }
                    465:                   $r->print(
                    466:                       &Apache::lonhtmlcommon::actionbox(
                    467:                           ['<a href="/adm/flip?postdata=return:">'.$lt{'back'}.'</a></li>',
                    468:                            '<a href="/adm/navmaps">'.$lt{'nav'}.'</a></li>'
                    469:                           ])
                    470:                      .&Apache::loncommon::end_page());
1.59      www       471:                   return OK;
                    472: 	      }
1.5       www       473: 	  } else {
                    474: # ------------------------------------------------- Problem, could not tie hash
1.53      albertel  475:               $env{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing";
1.5       www       476:               return HTTP_NOT_ACCEPTABLE; 
1.3       www       477:           }
1.5       www       478:       } else {
                    479: # ---------------------------------------- No, could not determine where we are
1.42      albertel  480: 	  $r->internal_redirect('/adm/ambiguous');
1.81      raeburn   481:           return OK;
1.2       www       482:       }
1.5       www       483:   } else {
1.2       www       484: # -------------------------- Class was not initialized or page fliped strangely
1.53      albertel  485:       $env{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
1.2       www       486:       return HTTP_NOT_ACCEPTABLE; 
                    487:   } 
1.1       www       488: }
                    489: 
                    490: 1;
                    491: __END__
                    492: 
1.77      jms       493: =pod
                    494: 
                    495: =head1 NAME
                    496: 
                    497: Apache::lonpageflip
                    498: 
                    499: =head1 SYNOPSIS
                    500: 
                    501: Deals with forward, backward, and other page flips.
                    502: 
                    503: This is part of the LearningOnline Network with CAPA project
                    504: described at http://www.lon-capa.org.
                    505: 
                    506: =head1 OVERVIEW
                    507: 
                    508: (empty)
                    509: 
                    510: =head1 SUBROUTINES
                    511: 
                    512: =over cleanup()
                    513: 
                    514: =item addrid()
                    515: 
                    516: =item fullmove()
                    517: 
                    518: =item hash_src()
                    519: 
                    520: =item move()
                    521: 
                    522: =item get_next_possible_move()
                    523: 
                    524: =item first_accessible_resource()
                    525: 
                    526: =item handler()
                    527: 
                    528: =back
                    529: 
                    530: =cut
1.1       www       531: 
                    532: 
                    533: 
                    534: 
                    535: 
                    536: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>