Annotation of rat/lonpageflip.pm, revision 1.90
1.1 www 1: # The LearningOnline Network with CAPA
2: #
3: # Page flip handler
4: #
1.90 ! raeburn 5: # $Id: lonpageflip.pm,v 1.89 2015/03/23 00:03:16 raeburn 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.87 raeburn 39: use Apache::lonuserstate;
1.84 raeburn 40: use Apache::lonlocal;
1.1 www 41: use HTML::TokeParser;
42: use GDBM_File;
43:
1.3 www 44: # ========================================================== Module Global Hash
45:
1.1 www 46: my %hash;
1.34 www 47:
48: sub cleanup {
49: if (tied(%hash)){
50: &Apache::lonnet::logthis('Cleanup pageflip: hash');
51: unless (untie(%hash)) {
52: &Apache::lonnet::logthis('Failed cleanup pageflip: hash');
53: }
54: }
1.63 albertel 55: return OK;
1.34 www 56: }
1.1 www 57:
1.3 www 58: sub addrid {
1.4 www 59: my ($current,$new,$condid)=@_;
60: unless ($condid) { $condid=0; }
1.27 www 61:
1.3 www 62: if ($current) {
1.5 www 63: $current.=','.$new;
1.3 www 64: } else {
1.5 www 65: $current=''.$new;
1.3 www 66: }
1.27 www 67:
1.3 www 68: return $current;
1.25 www 69: }
70:
71: sub fullmove {
72: my ($rid,$mapurl,$direction)=@_;
1.53 albertel 73: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.28 albertel 74: &GDBM_READER(),0640)) {
1.25 www 75: ($rid,$mapurl)=&move($rid,$mapurl,$direction);
76: untie(%hash);
77: }
78: return($rid,$mapurl);
1.1 www 79: }
80:
1.50 albertel 81: sub hash_src {
82: my ($id)=@_;
1.56 albertel 83: my ($mapid,$resid)=split(/\./,$id);
84: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},
85: $resid,$hash{'src_'.$id});
1.90 ! raeburn 86: my $anchor;
! 87: if ($hash{'ext_'.$id} eq 'true:') {
! 88: if ($hash{'src_'.$id} =~ /(\#.+)$/) {
! 89: $anchor = $1;
! 90: }
! 91: }
1.50 albertel 92: if ($hash{'encrypted_'.$id}) {
1.56 albertel 93: return (&Apache::lonenc::encrypted($hash{'src_'.$id}),
1.90 ! raeburn 94: &Apache::lonenc::encrypted($symb),
! 95: $hash{'encrypted_'.$id},$anchor);
1.50 albertel 96: }
1.90 ! raeburn 97: return ($hash{'src_'.$id},$symb,$hash{'encrypted_'.$id},$anchor);
1.50 albertel 98: }
99:
1.15 www 100: sub move {
1.72 albertel 101: my ($next,$endupmap,$direction) = @_;
102: my $safecount=0;
103: my $allowed=0;
104: do {
105: ($next,$endupmap)=&get_next_possible_move($next,$endupmap,$direction);
106:
107: my $url = $hash{'src_'.$next};
108: my ($mapid,$resid)=split(/\./,$next);
109: my $symb = &Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},
110: $resid,$url);
111: if ($url eq '' || $symb eq '') {
112: $allowed = 0;
113: } else {
114: my $priv = &Apache::lonnet::allowed('bre',$url,$symb);
115: $allowed = (($priv eq 'F') || ($priv eq '2'));
116: }
117: $safecount++;
118: } while ( ($next)
119: && ($next!~/\,/)
120: && (
121: (!$hash{'src_'.$next})
122: || (
123: (!$env{'request.role.adv'})
124: && $hash{'randomout_'.$next}
125: )
126: || (!$allowed)
127: )
128: && ($safecount<10000));
129:
130: return ($next,$endupmap);
131: }
132:
133: sub get_next_possible_move {
1.15 www 134: my ($rid,$mapurl,$direction)=@_;
1.23 www 135: my $startoutrid=$rid;
1.15 www 136:
137: my $next='';
138:
139: my $mincond=1;
140: my $posnext='';
141: if ($direction eq 'forward') {
142: # --------------------------------------------------------------------- Forward
1.33 www 143: while ($hash{'type_'.$rid} eq 'finish') {
144: $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}};
1.15 www 145: }
1.61 albertel 146: foreach my $id (split(/\,/,$hash{'to_'.$rid})) {
1.64 albertel 147: my $condition= $hash{'conditions_'.$hash{'goesto_'.$id}};
148: my $rescond = &Apache::lonnet::docondval($condition);
149: my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}});
150: my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond;
151: if ($thiscond>=$mincond) {
1.15 www 152: if ($posnext) {
1.61 albertel 153: $posnext.=','.$id.':'.$thiscond;
1.15 www 154: } else {
1.61 albertel 155: $posnext=$id.':'.$thiscond;
1.15 www 156: }
157: if ($thiscond>$mincond) { $mincond=$thiscond; }
158: }
1.61 albertel 159: }
160: foreach my $id (split(/\,/,$posnext)) {
161: my ($linkid,$condval)=split(/\:/,$id);
1.15 www 162: if ($condval>=$mincond) {
163: $next=&addrid($next,$hash{'goesto_'.$linkid},
164: $hash{'condid_'.$hash{'undercond_'.$linkid}});
165: }
1.61 albertel 166: }
1.15 www 167: if ($hash{'is_map_'.$next}) {
1.23 www 168: # This jumps to the beginning of a new map (going down level)
1.15 www 169: if (
170: $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') {
171: $mapurl=$hash{'src_'.$next};
172: $next=$hash{'map_start_'.$hash{'src_'.$next}};
1.47 raeburn 173: } elsif (
174: # This jumps back up from an empty sequence, to a page up one level
175: $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') {
176: $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.15 www 177: }
1.23 www 178: } elsif
179: ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) {
180: # This comes up from a map (coming up one level);
181: $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.61 albertel 182: }
1.15 www 183: } elsif ($direction eq 'back') {
184: # ------------------------------------------------------------------- Backwards
1.33 www 185: while ($hash{'type_'.$rid} eq 'start') {
186: $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}};
187: }
1.62 albertel 188: foreach my $id (split(/\,/,$hash{'from_'.$rid})) {
1.64 albertel 189: my $condition= $hash{'conditions_'.$hash{'comesfrom_'.$id}};
190: my $rescond = &Apache::lonnet::docondval($condition);
191: my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}});
192: my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond;
1.62 albertel 193: if ($thiscond>=$mincond) {
194: if ($posnext) {
195: $posnext.=','.$id.':'.$thiscond;
196: } else {
197: $posnext=$id.':'.$thiscond;
198: }
199: if ($thiscond>$mincond) { $mincond=$thiscond; }
200: }
201: }
202: foreach my $id (split(/\,/,$posnext)) {
203: my ($linkid,$condval)=split(/\:/,$id);
204: if ($condval>=$mincond) {
205: $next=&addrid($next,$hash{'comesfrom_'.$linkid},
206: $hash{'condid_'.$hash{'undercond_'.$linkid}});
207: }
208: }
1.15 www 209: if ($hash{'is_map_'.$next}) {
1.24 www 210: # This jumps to the end of a new map (going down one level)
1.15 www 211: if (
212: $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'sequence') {
213: $mapurl=$hash{'src_'.$next};
214: $next=$hash{'map_finish_'.$hash{'src_'.$next}};
1.47 raeburn 215: } elsif (
216: $hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$next}}} eq 'page') {
217: # This jumps back up from an empty sequence, to a page up one level
218: $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
219: }
1.24 www 220: } elsif
221: ((split(/\./,$startoutrid))[0]!=(split(/\./,$next))[0]) {
222: # This comes back up from a map (going up one level);
223: $mapurl=$hash{'map_id_'.(split(/\./,$next))[0]};
1.15 www 224: }
225: }
226: return ($next,$mapurl);
227: }
228:
1.69 www 229: sub first_accessible_resource {
230: my $furl;
231: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
232: &GDBM_READER(),0640)) {
233: $furl=$hash{'first_url'};
1.74 albertel 234: my %args;
235: my ($url,$args) = split(/\?/,$furl);
236: foreach my $pair (split(/\&/,$args)) {
237: my ($name,$value) = split(/=/,$pair);
238: $args{&unescape($name)} = &unescape($value);
239: }
240: if (!&Apache::lonnet::allowed('bre',$url,$args{'symb'})) {
1.69 www 241: # Wow, we cannot see this ... move forward to the next one that we can see
242: my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward');
243: # Build the new URL
1.73 albertel 244: my ($newmapid,$newresid)=split(/\./,$newrid);
1.69 www 245: my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid});
246: $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb });
247: if ($hash{'encrypted_'.$newrid}) {
248: $furl=&Apache::lonenc::encrypted($furl);
249: }
250: }
251: untie(%hash);
252: return $furl;
253: } else {
254: return '/adm/navmaps';
255: }
256: }
257:
1.1 www 258: # ================================================================ Main Handler
259:
260: sub handler {
1.2 www 261: my $r=shift;
1.1 www 262:
263: # ------------------------------------------- Set document type for header only
264:
1.2 www 265: if ($r->header_only) {
1.51 albertel 266: &Apache::loncommon::content_type($r,'text/html');
267: $r->send_http_header;
268: return OK;
1.2 www 269: }
270:
1.5 www 271: my %cachehash=();
272: my $multichoice=0;
273: my %multichoicehash=();
1.90 ! raeburn 274: my ($redirecturl,$redirectsymb,$enc,$anchor);
1.4 www 275: my $next='';
276: my @possibilities=();
1.37 www 277: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
1.53 albertel 278: if (($env{'form.postdata'})&&($env{'request.course.fn'})) {
1.88 raeburn 279: my ($direction,$currenturl) = ($env{'form.postdata'}=~/(\w+)\:(.*)/);
1.89 raeburn 280: if ($currenturl=~m|^/enc/|) {
281: $currenturl=&Apache::lonenc::unencrypted($currenturl);
282: }
283: $currenturl=~s/\.\d+\.(\w+)$/\.$1/;
284: $currenturl=~s/^https?\:\/\///;
285: $currenturl=~s/^[^\/]+//;
286: my ($preupdatepos,$last,$reinitcheck);
287: if ($direction eq 'return') {
288: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
289: &GDBM_READER(),0640)) {
290: $last=$hash{'last_known'};
291: untie(%hash);
292: }
293: }
1.87 raeburn 294: if ($env{'request.course.id'}) {
295: # Check if course needs to be re-initialized
296: my $loncaparev = $r->dir_config('lonVersion');
1.89 raeburn 297: ($reinitcheck,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
298: if ($reinitcheck eq 'switch') {
1.87 raeburn 299: &Apache::loncommon::content_type($r,'text/html');
300: $r->send_http_header;
301: $r->print(&Apache::loncommon::check_release_result(@reinit));
302: return OK;
1.89 raeburn 303: } elsif ($reinitcheck eq 'update') {
1.87 raeburn 304: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
305: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.89 raeburn 306: $preupdatepos = &Apache::lonnet::symbread($currenturl);
307: unless ($direction eq 'return') {
308: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
309: &GDBM_READER(),0640)) {
310: $last=$hash{'last_known'};
311: untie(%hash);
312: }
313: }
1.87 raeburn 314: my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
315: if ($ferr) {
316: my $requrl = $r->uri;
317: $env{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
318: $env{'user.reinit'} = 1;
319: return HTTP_NOT_ACCEPTABLE;
1.89 raeburn 320: } else {
321: if ($last) {
322: my ($murl,$id,$fn)=&Apache::lonnet::decode_symb($last);
323: unless (&Apache::lonnet::symbverify($last,$fn)) {
324: undef($last);
325: }
326: }
1.87 raeburn 327: }
328: }
329: }
1.54 albertel 330: if ($direction eq 'firstres') {
1.69 www 331: my $furl=&first_accessible_resource();
1.54 albertel 332: &Apache::loncommon::content_type($r,'text/html');
333: $r->header_out(Location =>
1.71 albertel 334: &Apache::lonnet::absolute_url().$furl);
1.54 albertel 335:
336: return REDIRECT;
337: }
1.89 raeburn 338: if ($direction eq 'return') {
1.10 www 339: # -------------------------------------------------------- Return to last known
340: my $newloc;
1.53 albertel 341: if (($last) && (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36 www 342: &GDBM_READER(),0640))) {
1.52 albertel 343: my ($murl,$id,$fn)=&Apache::lonnet::decode_symb($last);
1.50 albertel 344: $id=$hash{'map_pc_'.&Apache::lonnet::clutter($murl)}.'.'.$id;
345: $newloc=$hash{'src_'.$id};
346: if ($newloc) {
347: if ($hash{'encrypted_'.$id}) { $newloc=&Apache::lonenc::encrypted($newloc); }
348: } else {
1.57 www 349: $newloc='/adm/navmaps';
1.50 albertel 350: }
1.36 www 351: untie %hash;
1.10 www 352: } else {
1.57 www 353: $newloc='/adm/navmaps';
1.89 raeburn 354: }
355: &Apache::loncommon::content_type($r,'text/html');
356: $r->header_out(Location =>
357: &Apache::lonnet::absolute_url().$newloc);
1.54 albertel 358:
1.89 raeburn 359: return REDIRECT;
1.10 www 360: }
1.35 www 361: #
362: # Is the current URL on the map? If not, start with last known URL
363: #
1.89 raeburn 364:
1.35 www 365: unless (&Apache::lonnet::is_on_map($currenturl)) {
1.89 raeburn 366: if ($preupdatepos) {
367: undef($preupdatepos);
368: } elsif (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
369: &GDBM_READER(),0640)) {
370: $last=$hash{'last_known'};
1.7 www 371: untie(%hash);
372: }
1.89 raeburn 373: my $newloc;
1.7 www 374: if ($last) {
1.52 albertel 375: $currenturl=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($last))[2]);
1.7 www 376: } else {
1.89 raeburn 377: &Apache::loncommon::content_type($r,'text/html');
378: $r->header_out(Location =>
379: &Apache::lonnet::absolute_url().
380: '/adm/navmaps');
381: return REDIRECT;
1.7 www 382: }
383: }
1.3 www 384: # ------------------------------------------- Do we have any idea where we are?
385: my $position;
1.89 raeburn 386: if ($preupdatepos) {
387: $position = $preupdatepos;
388: } else {
389: $position=Apache::lonnet::symbread($currenturl);
390: }
391: if ($position) {
1.3 www 392: # ------------------------------------------------------------------------- Yes
1.41 www 393: my ($startoutmap,$mapnum,$thisurl)=&Apache::lonnet::decode_symb($position);
1.52 albertel 394: $cachehash{$startoutmap}{$thisurl}=[$thisurl,$mapnum];
1.23 www 395: $cachehash{$startoutmap}{'last_known'}=
1.52 albertel 396: [&Apache::lonnet::declutter($currenturl),$mapnum];
1.20 albertel 397:
1.5 www 398: # ============================================================ Tie the big hash
1.53 albertel 399: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.28 albertel 400: &GDBM_READER(),0640)) {
1.29 www 401: my $rid=$hash{'map_pc_'.&Apache::lonnet::clutter($startoutmap)}.
402: '.'.$mapnum;
1.14 www 403:
1.15 www 404: # ------------------------------------------------- Move forward, backward, etc
1.22 www 405: my $endupmap;
406: ($next,$endupmap)=&move($rid,$startoutmap,$direction);
1.15 www 407: # -------------------------------------- Do we have one and only one empty URL?
1.22 www 408: # We are now at at least one non-empty URL
1.4 www 409: # ----------------------------------------------------- Check out possibilities
410: if ($next) {
411: @possibilities=split(/\,/,$next);
412: if ($#possibilities==0) {
1.5 www 413: # ---------------------------------------------- Only one possibility, redirect
1.90 ! raeburn 414: ($redirecturl,$redirectsymb,$enc,$anchor)=&hash_src($next);
1.52 albertel 415: $cachehash{$endupmap}{$redirecturl}=
416: [$redirecturl,(split(/\./,$next))[1]];
1.4 www 417: } else {
1.5 www 418: # ------------------------ There are multiple possibilities for a next resource
419: $multichoice=1;
1.62 albertel 420: foreach my $id (@possibilities) {
421: $multichoicehash{'src_'.$id}=$hash{'src_'.$id};
422: $multichoicehash{'title_'.$id}=$hash{'title_'.$id};
423: $multichoicehash{'type_'.$id}=$hash{'type_'.$id};
424: (my $first, my $second) = $id =~ /(\d+).(\d+)/;
425: my $symbSrc = Apache::lonnet::declutter($hash{'src_'.$id});
426: $multichoicehash{'symb_'.$id} =
1.32 bowersj2 427: Apache::lonnet::declutter($hash{'map_id_'.$first}.'___'.
428: $second.'___'.$symbSrc);
429:
1.62 albertel 430: my ($choicemap,$choiceres)=split(/\./,$id);
1.52 albertel 431: my $map=&Apache::lonnet::declutter($hash{'src_'.$choicemap});
1.62 albertel 432: my $url=$multichoicehash{'src_'.$id};
1.52 albertel 433: $cachehash{$map}{$url}=[$url,$choiceres];
1.62 albertel 434: }
1.4 www 435: }
1.5 www 436: } else {
437: # -------------------------------------------------------------- No place to go
438: $multichoice=-1;
1.4 www 439: }
1.5 www 440: # ----------------- The program must come past this point to untie the big hash
1.3 www 441: untie(%hash);
1.5 www 442: # --------------------------------------------------------- Store position info
1.52 albertel 443: $cachehash{$startoutmap}{'last_direction'}=[$direction,'notasymb'];
1.86 raeburn 444: foreach my $thismap (keys(%cachehash)) {
1.52 albertel 445: my $mapnum=$cachehash{$thismap}->{'mapnum'};
446: delete($cachehash{$thismap}->{'mapnum'});
447: &Apache::lonnet::symblist($thismap,
448: %{$cachehash{$thismap}});
1.19 www 449: }
1.5 www 450: # ============================================== Do not return before this line
1.4 www 451: if ($redirecturl) {
1.5 www 452: # ----------------------------------------------------- There is a URL to go to
1.38 www 453: if ($direction eq 'forward') {
454: &Apache::lonnet::linklog($currenturl,$redirecturl);
455: }
456: if ($direction eq 'back') {
457: &Apache::lonnet::linklog($redirecturl,$currenturl);
458: }
1.85 musolffc 459: # ------------------------------------- Check for and display critical messages
460: my ($redirect, $url) = &Apache::loncommon::critical_redirect(300);
1.89 raeburn 461: unless ($redirect) {
1.85 musolffc 462: $url=&Apache::lonnet::absolute_url().$redirecturl;
1.90 ! raeburn 463: my $addanchor;
! 464: if (($anchor ne '') && (!$enc || $env{'request.role.adv'})) {
! 465: $addanchor = 1;
! 466: $url =~ s/\#.+$//;
! 467: }
1.89 raeburn 468: $url = &add_get_param($url, { 'symb' => $redirectsymb});
1.90 ! raeburn 469: if ($addanchor) {
! 470: $url .= $anchor;
! 471: }
1.85 musolffc 472: }
1.89 raeburn 473: &Apache::loncommon::content_type($r,'text/html');
1.56 albertel 474: $r->header_out(Location => $url);
1.4 www 475: return REDIRECT;
1.5 www 476: } else {
477: # --------------------------------------------------------- There was a problem
1.51 albertel 478: &Apache::loncommon::content_type($r,'text/html');
1.8 www 479: $r->send_http_header;
1.59 www 480: my %lt=&Apache::lonlocal::texthash('title' => 'End of Sequence',
481: 'explain' =>
482: 'You have reached the end of the sequence of materials.',
483: 'back' => 'Go Back',
1.83 raeburn 484: 'nav' => 'Course Contents',
1.59 www 485: 'wherenext' =>
486: 'There are several possibilities of where to go next',
487: 'pick' =>
488: 'Please click on the the resource you intend to access',
489: 'titleheader' => 'Title',
1.89 raeburn 490: 'type' => 'Type',
491: 'update' => 'Content updated',
492: 'expupdate' => 'As a result of a recent update to the sequence of materials, it is not possible to complete the page flip.',
493: 'gonav' => 'Go to the Contents page to select a resource to display.');
1.83 raeburn 494: if (&Apache::loncommon::course_type() eq 'Community') {
495: $lt{'nav'} = &mt('Community Contents');
496: }
1.8 www 497: if ($#possibilities>0) {
1.67 albertel 498: my $start_page=
499: &Apache::loncommon::start_page('Multiple Resources');
1.8 www 500: $r->print(<<ENDSTART);
1.67 albertel 501: $start_page
1.59 www 502: <h3>$lt{'wherenext'}</h3>
1.8 www 503: <p>
1.59 www 504: $lt{'pick'}:
1.8 www 505: <p>
1.79 bisitz 506: <table border="2">
1.59 www 507: <tr><th>$lt{'titleheader'}</th><th>$lt{'type'}</th></tr>
1.8 www 508: ENDSTART
1.62 albertel 509: foreach my $id (@possibilities) {
1.8 www 510: $r->print(
511: '<tr><td><a href="'.
1.66 albertel 512: &add_get_param($multichoicehash{'src_'.$id},
513: {'symb' =>
514: $multichoicehash{'symb_'.$id},
515: }).'">'.
1.62 albertel 516: $multichoicehash{'title_'.$id}.
517: '</a></td><td>'.$multichoicehash{'type_'.$id}.
1.8 www 518: '</td></tr>');
1.26 www 519: }
1.59 www 520: $r->print('</table>');
1.8 www 521: } else {
1.89 raeburn 522: if ($reinitcheck) {
523: if (&Apache::loncommon::course_type() eq 'Community') {
524: $r->print(
525: &Apache::loncommon::start_page('Community Contents Updated'));
526: } else {
527: $r->print(
528: &Apache::loncommon::start_page('Course Contents Updated'));
529: }
530: $r->print('<h2>'.$lt{'update'}.'</h2>'
531: .'<p>'.$lt{'expupdate'}.'<br />'
532: .$lt{'gonav'}.'</p>');
533: } else {
534: $r->print(
535: &Apache::loncommon::start_page('No Resource')
536: .'<h2>'.$lt{'title'}.'</h2>'
537: .'<p>'.$lt{'explain'}.'</p>');
538: }
539: }
540: if ((!@possibilities) && ($reinitcheck)) {
541: $r->print(
542: &Apache::lonhtmlcommon::actionbox(
543: ['<a href="/adm/navmaps">'.$lt{'nav'}.'</a></li>'
544: ]));
545: } else {
1.82 bisitz 546: $r->print(
1.89 raeburn 547: &Apache::lonhtmlcommon::actionbox(
548: ['<a href="/adm/flip?postdata=return:">'.$lt{'back'}.'</a></li>',
549: '<a href="/adm/navmaps">'.$lt{'nav'}.'</a></li>'
550: ]));
1.82 bisitz 551: }
1.89 raeburn 552: $r->print(&Apache::loncommon::end_page());
553:
1.59 www 554: return OK;
555: }
1.5 www 556: } else {
557: # ------------------------------------------------- Problem, could not tie hash
1.53 albertel 558: $env{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing";
1.5 www 559: return HTTP_NOT_ACCEPTABLE;
1.3 www 560: }
1.5 www 561: } else {
562: # ---------------------------------------- No, could not determine where we are
1.42 albertel 563: $r->internal_redirect('/adm/ambiguous');
1.81 raeburn 564: return OK;
1.2 www 565: }
1.5 www 566: } else {
1.2 www 567: # -------------------------- Class was not initialized or page fliped strangely
1.53 albertel 568: $env{'user.error.msg'}="/adm/flip:bre:0:0:Choose Course";
1.2 www 569: return HTTP_NOT_ACCEPTABLE;
570: }
1.1 www 571: }
572:
573: 1;
574: __END__
575:
1.77 jms 576: =pod
577:
578: =head1 NAME
579:
580: Apache::lonpageflip
581:
582: =head1 SYNOPSIS
583:
584: Deals with forward, backward, and other page flips.
585:
586: This is part of the LearningOnline Network with CAPA project
587: described at http://www.lon-capa.org.
588:
589: =head1 OVERVIEW
590:
591: (empty)
592:
593: =head1 SUBROUTINES
594:
595: =over cleanup()
596:
597: =item addrid()
598:
599: =item fullmove()
600:
601: =item hash_src()
602:
603: =item move()
604:
605: =item get_next_possible_move()
606:
607: =item first_accessible_resource()
608:
609: =item handler()
610:
611: =back
612:
613: =cut
1.1 www 614:
615:
616:
617:
618:
619:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>