Annotation of rat/lonpageflip.pm, revision 1.71

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

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