--- rat/lonpageflip.pm 2006/01/09 18:51:26 1.62 +++ rat/lonpageflip.pm 2006/03/06 23:41:07 1.66 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.62 2006/01/09 18:51:26 albertel Exp $ +# $Id: lonpageflip.pm,v 1.66 2006/03/06 23:41:07 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,7 @@ sub cleanup { &Apache::lonnet::logthis('Failed cleanup pageflip: hash'); } } + return OK; } sub addrid { @@ -83,6 +84,28 @@ sub hash_src { return ($hash{'src_'.$id},$symb); } +# Inputs are a url, adn a hash ref of +# form name => value pairs +# takes care of properly adding the form name elements and values to the +# the url doing proper escaping of the values and joining with ? or & as +# needed + +sub add_get_param { + my ($url,$form_data) = @_; + my $needs_question_mark = ($url !~ /\?/); + + while (my ($name,$value) = each(%$form_data)) { + if ($needs_question_mark) { + $url.='?'; + $needs_question_mark = 0; + } else { + $url.='&'; + } + $url.=$name.'='.&Apache::lonnet::escape($form_data->{$name}); + } + return $url; +} + sub move { my ($rid,$mapurl,$direction)=@_; my $startoutrid=$rid; @@ -97,9 +120,11 @@ sub move { $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}}; } foreach my $id (split(/\,/,$hash{'to_'.$rid})) { - my $thiscond= - &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}}); - if ($thiscond>=$mincond) { + my $condition= $hash{'conditions_'.$hash{'goesto_'.$id}}; + my $rescond = &Apache::lonnet::docondval($condition); + my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}}); + my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond; + if ($thiscond>=$mincond) { if ($posnext) { $posnext.=','.$id.':'.$thiscond; } else { @@ -137,8 +162,10 @@ sub move { $rid=$hash{'ids_'.$hash{'map_id_'.(split(/\./,$rid))[0]}}; } foreach my $id (split(/\,/,$hash{'from_'.$rid})) { - my $thiscond= - &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}}); + my $condition= $hash{'conditions_'.$hash{'comesfrom_'.$id}}; + my $rescond = &Apache::lonnet::docondval($condition); + my $linkcond = &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$id}}); + my $thiscond = ($rescond<$linkcond)?$rescond:$linkcond; if ($thiscond>=$mincond) { if ($posnext) { $posnext.=','.$id.':'.$thiscond; @@ -394,7 +421,7 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); my $url='http://'.$ENV{'HTTP_HOST'}.$redirecturl; - if ($redirectsymb ne '') { $url.='?symb='.&Apache::lonnet::escape($redirectsymb); } + $url = &add_get_param($url, { 'symb' => $redirectsymb}); $r->header_out(Location => $url); return REDIRECT; } else { @@ -428,8 +455,10 @@ ENDSTART foreach my $id (@possibilities) { $r->print( ''. + &add_get_param($multichoicehash{'src_'.$id}, + {'symb' => + $multichoicehash{'symb_'.$id}, + }).'">'. $multichoicehash{'title_'.$id}. ''.$multichoicehash{'type_'.$id}. '');