--- loncom/interface/loncommon.pm 2014/11/08 18:26:06 1.1199 +++ loncom/interface/loncommon.pm 2014/12/20 15:35:40 1.1203 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1199 2014/11/08 18:26:06 raeburn Exp $ +# $Id: loncommon.pm,v 1.1203 2014/12/20 15:35:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3837,7 +3837,8 @@ sub get_previous_attempt { } } elsif ($data eq 'regrader') { if (($identifier ne '') && (@parts)) { - $regraded{$parts[-1]} = 1; + my $id = join(',',@parts); + $regraded{$ign.'.'.$id} = 1; } } } else { @@ -3851,16 +3852,18 @@ sub get_previous_attempt { $prevattempts.=&end_data_table_header_row(); if ($getattempt eq '') { my (%solved,%resets,%probstatus); - for ($version=1;$version<=$returnhash{'version'};$version++) { - if ($identifier ne '') { - foreach my $part (keys(%regraded)) { - if (($returnhash{$version.':resource.'.$part.'.regrader'}) && - ($returnhash{$version.':resource.'.$part.'.tries'} eq '') && - ($returnhash{$version.':resource.'.$part.'.award'} eq '')) { - push(@{$resets{$part}},$version); + if (($identifier ne '') && (keys(%regraded) > 0)) { + for ($version=1;$version<=$returnhash{'version'};$version++) { + foreach my $id (keys(%regraded)) { + if (($returnhash{$version.':'.$id.'.regrader'}) && + ($returnhash{$version.':'.$id.'.tries'} eq '') && + ($returnhash{$version.':'.$id.'.award'} eq '')) { + push(@{$resets{$id}},$version); } } } + } + for ($version=1;$version<=$returnhash{'version'};$version++) { my (@hidden,@unsolved); if (%typeparts) { foreach my $id (keys(%typeparts)) { @@ -3871,7 +3874,7 @@ sub get_previous_attempt { unless (($returnhash{$version.':'.$id.'.type'} eq 'survey') || ($returnhash{$version.':'.$id.'.type'} eq 'surveycred') || ($hidestatus{$id})) { - next if ((ref($resets{$id}) eq 'ARRAY') && grep(/^\Q$id\E$/,@{$resets{$id}})); + next if ((ref($resets{$id}) eq 'ARRAY') && grep(/^\Q$version\E$/,@{$resets{$id}})); if ($returnhash{$version.':'.$id.'.solved'} eq 'correct_by_student') { push(@{$solved{$id}},$version); } elsif (($returnhash{$version.':'.$id.'.solved'} ne '') && @@ -4736,13 +4739,13 @@ END_BLOCK ############################################### sub check_ip_acc { - my ($acc)=@_; + my ($acc,$clientip)=@_; &Apache::lonxml::debug("acc is $acc"); if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { return 1; } my $allowed=0; - my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; + my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'} || $clientip; my $name; foreach my $pattern (split(',',$acc)) { @@ -7730,10 +7733,12 @@ function set_wishlistlink(title, path) { title = title.replace(/^LON-CAPA /,''); } title = encodeURIComponent(title); + title = title.replace("'","\\\'"); if (!path) { path = location.pathname; } path = encodeURIComponent(path); + path = path.replace("'","\\\'"); Win = window.open('/adm/wishlist?mode=newLink&setTitle='+title+'&setPath='+path, 'wishlistNewLink','width=560,height=350,scrollbars=0'); } @@ -7776,6 +7781,7 @@ var modalWindow = { }; var openMyModal = function(source,width,height,scrolling,transparency,style) { + source = source.replace("'","'"); modalWindow.windowId = "myModal"; modalWindow.width = width; modalWindow.height = height; @@ -8383,7 +8389,7 @@ role status: active, previous or future. sub check_user_status { my ($udom,$uname,$cdom,$crs,$role,$sec) = @_; my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname); - my @uroles = keys %userinfo; + my @uroles = keys(%userinfo); my $srchstr; my $active_chk = 'none'; my $now = time; @@ -14549,7 +14555,7 @@ sub escape_url { my ($url) = @_; my @urlslices = split(/\//, $url,-1); my $lastitem = &escape(pop(@urlslices)); - return join('/',@urlslices).'/'.$lastitem; + return &HTML::Entities::encode(join('/',@urlslices),"'").'/'.$lastitem; } sub compare_arrays { @@ -15323,7 +15329,6 @@ sub search_courses { return %courses; } - =pod =back