[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm

raeburn raeburn at source.lon-capa.org
Wed Apr 1 19:42:06 EDT 2015


raeburn		Wed Apr  1 23:42:06 2015 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncommon.pm 
  Log:
  - For 2.11
    Backport 1.1210.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.88 loncom/interface/loncommon.pm:1.1075.2.89
--- loncom/interface/loncommon.pm:1.1075.2.88	Wed Mar 11 01:55:41 2015
+++ loncom/interface/loncommon.pm	Wed Apr  1 23:42:05 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1075.2.88 2015/03/11 01:55:41 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.89 2015/04/01 23:42:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7411,6 +7411,79 @@
 <meta http-equiv="pragma" content="no-cache" />
 <meta http-equiv="Refresh" content="$time; url=$url" />
 ADDMETA
+    } else {
+        unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) {
+            my $requrl = $env{'request.uri'};
+            if ($requrl eq '') {
+                $requrl = $ENV{'REQUEST_URI'};
+                $requrl =~ s/\?.+$//;
+            }
+            unless (($requrl =~ m{^/adm/(?:switchserver|login|authenticate|logout|groupsort|cleanup|helper|slotrequest|grades)(\?|$)}) ||
+                    (($requrl =~ m{^/res/}) && (($env{'form.submitted'} eq 'scantron') ||
+                     ($env{'form.grade_symb'}) || ($Apache::lonhomework::scantronmode)))) {
+                my $dom_in_use = $Apache::lonnet::perlvar{'lonDefDomain'};
+                unless (&Apache::lonnet::allowed('mau',$dom_in_use)) {
+                    my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use);
+                    if (ref($domdefs{'offloadnow'}) eq 'HASH') {
+                        my $lonhost = $Apache::lonnet::perlvar{'lonHostID'};
+                        if ($domdefs{'offloadnow'}{$lonhost}) {
+                            my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use);
+                            if (($newserver) && ($newserver ne $lonhost)) {
+                                my $numsec = 5;
+                                my $timeout = $numsec * 1000;
+                                my ($newurl,$locknum,%locks,$msg);
+                                if ($env{'request.role.adv'}) {
+                                    ($locknum,%locks) = &Apache::lonnet::get_locks();
+                                }
+                                my $disable_submit = 0;
+                                if ($requrl =~ /$LONCAPA::assess_re/) {
+                                    $disable_submit = 1;
+                                }
+                                if ($locknum) {
+                                    my @lockinfo = sort(values(%locks));
+                                    $msg = &mt('Once the following tasks are complete: ')."\\n".
+                                           join(", ",sort(values(%locks)))."\\n".
+                                           &mt('your session will be transferred to a different server, after you click "Roles".');
+                                } else {
+                                    if (($requrl =~ m{^/res/}) && ($env{'form.submitted'} =~ /^part_/)) {
+                                        $msg = &mt('Your LON-CAPA submission has been recorded')."\\n";
+                                    }
+                                    $msg .= &mt('Your current LON-CAPA session will be transferred to a different server in [quant,_1,second].',$numsec);
+                                    $newurl = '/adm/switchserver?otherserver='.$newserver;
+                                    if (($env{'request.role'}) && ($env{'request.role'} ne 'cm')) {
+                                        $newurl .= '&role='.$env{'request.role'};
+                                    }
+                                    if ($env{'request.symb'}) {
+                                        $newurl .= '&symb='.$env{'request.symb'};
+                                    } else {
+                                        $newurl .= '&origurl='.$requrl;
+                                    }
+                                }
+                                $result.=<<OFFLOAD
+<meta http-equiv="pragma" content="no-cache" />
+<script type="text/javascript">
+function LC_Offload_Now() {
+    var dest = "$newurl";
+    if (dest != '') {
+        window.location.href="$newurl";
+    }
+}
+window.alert('$msg');
+if ($disable_submit) {
+    \$(document).ready(function () {
+        \$(".LC_hwk_submit").prop("disabled", true);
+        \$( ".LC_textline" ).prop( "readonly", "readonly");
+    });
+}
+setTimeout('LC_Offload_Now()', $timeout);
+</script>
+OFFLOAD
+                            }
+                        }
+                    }
+                }
+            }
+        }
     }
     if (!defined($title)) {
 	$title = 'The LearningOnline Network with CAPA';




More information about the LON-CAPA-cvs mailing list