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

raeburn raeburn at source.lon-capa.org
Mon Sep 10 19:11:27 EDT 2018


raeburn		Mon Sep 10 23:11:27 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonnavdisplay.pm 
  Log:
  - For 2.11
    Backport 1.35
  
  
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.22.4.7 loncom/interface/lonnavdisplay.pm:1.22.4.8
--- loncom/interface/lonnavdisplay.pm:1.22.4.7	Sun Apr  2 13:35:30 2017
+++ loncom/interface/lonnavdisplay.pm	Mon Sep 10 23:11:26 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Display Handler
 #
-# $Id: lonnavdisplay.pm,v 1.22.4.7 2017/04/02 13:35:30 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.22.4.8 2018/09/10 23:11:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -62,9 +62,15 @@
         return REDIRECT;
     }
 
+# ------------------------------------------------------------ Get query string
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sort',
+                                                                  'showOnlyHomework',
+                                                                  'postsymb','register']);
     # Check if course needs to be re-initialized
     my $loncaparev = $r->dir_config('lonVersion');
     my ($result, at reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
+    my %prog_state=();
+    my $closure;
 
     if ($result eq 'switch') {
         &Apache::loncommon::content_type($r,'text/html');
@@ -72,10 +78,32 @@
         $r->print(&Apache::loncommon::check_release_result(@reinit));
         return OK;
     } elsif ($result eq 'update') {
-        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-        my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+        my $cid = $env{'request.course.id'};
+        my $cnum = $env{'course.'.$cid.'.num'};
+        my $cdom = $env{'course.'.$cid.'.domain'};
+        &Apache::loncommon::content_type($r,'text/html');
+        $r->send_http_header;
+        &startpage($r);
+        my $preamble = '<div id="LC_update_'.$cid.'" class="LC_info">'.
+                       '<br />'.
+                       &mt('Your course session is being updated because of recent changes by course personnel.').
+                       ' '.&mt('Please be patient.').'<br /></div>'.
+                       '<div style="padding:0;clear:both;margin:0;border:0"></div>';
+        $closure = <<ENDCLOSE;
+<script type="text/javascript">
+// <![CDATA[
+\$("#LC_update_$cid").hide('slow');
+// ]]>
+</script>
+ENDCLOSE
+        %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);
+        &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Updating course'));
+        $r->rflush();
+        my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum",\%prog_state,$r);
+        &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished'));
         if ($ferr) {
+            &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+            $r->print($closure.&Apache::loncommon::end_page());
             my $requrl = $r->uri;
             $env{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
             $env{'user.reinit'} = 1;
@@ -87,39 +115,32 @@
     my $navmap = Apache::lonnavmaps::navmap->new();
 
     if (!defined($navmap)) {
+        if ($result eq 'update') {
+            &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+            $r->print($closure.&Apache::loncommon::end_page());
+        }
         my $requrl = $r->uri;
         $env{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
         $env{'user.reinit'} = 1;
         return HTTP_NOT_ACCEPTABLE;
     }
 
-    # Send header, don't cache this page
-    &Apache::loncommon::content_type($r,'text/html');
-    $r->send_http_header;
-
-# ------------------------------------------------------------ Get query string
-    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sort','showOnlyHomework','postsymb','register']);
-    
-# ----------------------------------------------------- Force menu registration
-    # Header
-    my $course_type = &Apache::loncommon::course_type();
-    my $title = $course_type . ' Contents';
-    my ($start_page,$args);
-    if ($env{'form.register'}) {
-        $args = {'force_register' => $env{'form.register'}};
-        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+    if ($result eq 'update') {
+        $r->rflush();
+        &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+        $r->print($closure);
+        $r->rflush();
     } else {
-        my $brcrum = [{href => '/adm/navmaps',
-                       text => &mt($course_type . ' Contents'),
-                       no_mt => 1},
-                     ];
-        $args = {'bread_crumbs' => $brcrum};
-        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+        # Send header, don't cache this page
+        &Apache::loncommon::content_type($r,'text/html');
+        $r->send_http_header;
+        &startpage($r);
     }
-    $r->print($start_page.
-              '<script type="text/javascript">window.focus();</script>');
+
     &startContentScreen($r,'navmaps');
-    $r->rflush();
+    unless ($result eq 'update') {
+        $r->rflush();
+    }
 
     # Check that it's defined
     if (!($navmap->courseMapDefined())) {
@@ -304,6 +325,33 @@
     return OK;
 }
 
+sub startpage {
+    my ($r) = @_;
+# ----------------------------------------------------- Force menu registration
+    # Header
+    my $course_type = &Apache::loncommon::course_type();
+    my $title = $course_type . ' Contents';
+    my ($start_page,$args);
+    if ($env{'form.register'}) {
+        $args = {'force_register' => $env{'form.register'}};
+        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+    } else {
+        my $brcrum = [{href => '/adm/navmaps',
+                       text => &mt($course_type . ' Contents'),
+                       no_mt => 1},
+                     ];
+        $args = {'bread_crumbs' => $brcrum};
+        $start_page = &Apache::loncommon::start_page($title,undef,$args);
+    }
+    $r->print($start_page.
+              '<script type="text/javascript">'."\n".
+              '// <![CDATA['."\n".
+              'window.focus();'."\n".
+              '// ]]>'."\n".
+              '</script>');
+    return;
+}
+
 sub startContentScreen {
     my ($r,$mode)=@_;
 




More information about the LON-CAPA-cvs mailing list