--- loncom/homework/lonhomework.pm 2008/07/01 11:01:30 1.294 +++ loncom/homework/lonhomework.pm 2009/02/17 15:25:18 1.302 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.294 2008/07/01 11:01:30 foxr Exp $ +# $Id: lonhomework.pm,v 1.302 2009/02/17 15:25:18 jms Exp $ # # Copyright Michigan State University Board of Trustees # @@ -209,58 +209,6 @@ sub proctor_checked_in { return 0; } -sub check_ip_acc { - my ($acc)=@_; - &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 $name; - foreach my $pattern (split(',',$acc)) { - $pattern =~ s/^\s*//; - $pattern =~ s/\s*$//; - if ($pattern =~ /\*$/) { - #35.8.* - $pattern=~s/\*//; - if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } - } elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) { - #35.8.3.[34-56] - my $low=$2; - my $high=$3; - $pattern=$1; - if ($ip =~ /^\Q$pattern\E/) { - my $last=(split(/\./,$ip))[3]; - if ($last <=$high && $last >=$low) { $allowed=1; } - } - } elsif ($pattern =~ /^\*/) { - #*.msu.edu - $pattern=~s/\*//; - if (!defined($name)) { - use Socket; - my $netaddr=inet_aton($ip); - ($name)=gethostbyaddr($netaddr,AF_INET); - } - if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } - } elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) { - #127.0.0.1 - if ($ip =~ /^\Q$pattern\E/) { $allowed=1; } - } else { - #some.name.com - if (!defined($name)) { - use Socket; - my $netaddr=inet_aton($ip); - ($name)=gethostbyaddr($netaddr,AF_INET); - } - if ($name =~ /\Q$pattern\E$/i) { $allowed=1; } - } - if ($allowed) { last; } - } - return $allowed; -} - sub check_slot_access { my ($id,$type)=@_; @@ -307,7 +255,7 @@ sub check_slot_access { &Apache::lonhomework::showhash(%slot); if ($slot{'starttime'} < time && $slot{'endtime'} > time && - &check_ip_acc($slot{'ip'})) { + &Apache::loncommon::check_ip_acc($slot{'ip'})) { &Apache::lonxml::debug("$slot is good"); $slotstatus='NEEDS_CHECKIN'; $returned_slot=\%slot; @@ -421,7 +369,7 @@ sub check_access { #if ($env{'request.state'} ne "construct" && $symb ne '') { if ($env{'request.state'} ne "construct") { my $idacc = &Apache::lonnet::EXT("resource.$id.acc"); - my $allowed=&check_ip_acc($idacc); + my $allowed=&Apache::loncommon::check_ip_acc($idacc); if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { $status='INVALID_ACCESS'; $date=&mt("can not be accessed from your location."); @@ -935,18 +883,11 @@ sub editxmlmode { my $js = &Apache::edit::js_change_detection(). &Apache::loncommon::resize_textarea_js(). - &Apache::structuretags::setmode_javascript(); + &Apache::structuretags::setmode_javascript(). + &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; - my $dragmath = < - function mathedit(textarea, doc) { - targetEntry = textarea; - targetDoc = doc; - newwin = window.open("/adm/dragmath/applet/EditMathPopup.html","","width=565,height=500,resizable"); - } - - -ENDDRAGMATH + my $dragmath_button = + &Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); my $start_page = &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, {'no_auto_mt_title' => 1, @@ -964,7 +905,7 @@ ENDDRAGMATH
'.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').' - '.&Apache::loncommon::helpLatexCheatsheet().' + '.&Apache::loncommon::helpLatexCheatsheet('Problem_LON-CAPA_Functions','Script Functions').'
@@ -974,11 +915,11 @@ ENDDRAGMATH 'onclick="javascript:setmode(this.form,'."'discard'".')" /> + '.$dragmath_button.'
- ' - .$dragmath.' +

'.&Apache::lonxml::message_location().'