[LON-CAPA-cvs] cvs: rat / lonpageflip.pm loncom/interface lonnavdisplay.pm lonquickgrades.pm
raeburn
raeburn at source.lon-capa.org
Thu Nov 16 08:42:01 EST 2017
raeburn Thu Nov 16 13:42:01 2017 EDT
Modified files:
/loncom/interface lonquickgrades.pm lonnavdisplay.pm
/rat lonpageflip.pm
Log:
- If user's course session is stale, and needs updating when page flip,
student's view of grades or course contents page were requested, show
message and "indeterminate" progressbar until reinitialization complete.
-------------- next part --------------
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.110 loncom/interface/lonquickgrades.pm:1.111
--- loncom/interface/lonquickgrades.pm:1.110 Mon Jun 26 01:56:58 2017
+++ loncom/interface/lonquickgrades.pm Thu Nov 16 13:41:56 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Quick Student Grades Display
#
-# $Id: lonquickgrades.pm,v 1.110 2017/06/26 01:56:58 raeburn Exp $
+# $Id: lonquickgrades.pm,v 1.111 2017/11/16 13:41:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,6 +77,11 @@
}
my $cangrade=&Apache::lonnet::allowed('mgr');
+ my $showPoints =
+ (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard')
+ || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'));
+
+ my $reinitresult;
unless ($cangrade) {
# Check for critical messages and redirect if present.
@@ -89,22 +94,46 @@
# Check if course needs to be re-initialized
my $loncaparev = $r->dir_config('lonVersion');
- my ($result, at reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
+ ($reinitresult,my @reinit) = &Apache::loncommon::needs_coursereinit($loncaparev);
- if ($result eq 'switch') {
+ if ($reinitresult eq 'switch') {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
$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'};
+ } elsif ($reinitresult eq 'update') {
+ 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,$showPoints);
+ 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>';
+ %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");
+ &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished'));
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ my $closure = <<ENDCLOSE;
+<script type="text/javascript">
+// <![CDATA[
+\$("#LC_update_$cid").hide('slow');
+// ]]>
+</script>
+ENDCLOSE
if ($ferr) {
+ $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;
+ } else {
+ $r->print($closure);
}
} elsif ((&Apache::loncommon::course_type() eq 'Placement') &&
(!$env{'request.role.adv'})) {
@@ -115,27 +144,13 @@
}
}
- # Send header, don't cache this page
- &Apache::loncommon::no_cache($r);
- $r->send_http_header;
-
- my $showPoints =
- (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard')
- || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'));
- my $notshowSPRSlink =
- (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external')
- || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'));
- my $notshowTotals=
- $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
- my $showCategories=
- $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';
-
-
- my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";
- my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];
- $r->print(&Apache::loncommon::start_page($title,undef,
- {'bread_crumbs' => $brcrum})
- );
+ unless ($reinitresult eq 'update') {
+ # Send header, don't cache this page
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+ &startpage($r,$showPoints);
+ }
+ $r->rflush();
&startGradeScreen($r,'quick');
@@ -204,6 +219,14 @@
}
$r->rflush();
+ my $notshowSPRSlink =
+ (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external')
+ || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'));
+ my $notshowTotals=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals';
+ my $showCategories=
+ $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';
+
my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=
&getData($showPoints,$uname,$udom);
@@ -248,6 +271,14 @@
}
}
+sub startpage {
+ my ($r,$showPoints) = @_;
+ my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";
+ my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];
+ $r->print(&Apache::loncommon::start_page($title,undef,
+ {'bread_crumbs' => $brcrum})
+ );
+}
sub startGradeScreen {
my ($r,$mode)=@_;
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.34 loncom/interface/lonnavdisplay.pm:1.35
--- loncom/interface/lonnavdisplay.pm:1.34 Mon Jun 26 01:56:58 2017
+++ loncom/interface/lonnavdisplay.pm Thu Nov 16 13:41:56 2017
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Display Handler
#
-# $Id: lonnavdisplay.pm,v 1.34 2017/06/26 01:56:58 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.35 2017/11/16 13:41:56 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;
@@ -86,52 +114,47 @@
my $course_type = &Apache::loncommon::course_type();
if (($course_type eq 'Placement') && (!$env{'request.role.adv'})) {
my $furl = &Apache::lonpageflip::first_accessible_resource();
- &Apache::loncommon::content_type($r,'text/html');
- $r->header_out(Location => $furl);
- return REDIRECT;
+ if ($result eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print($closure.&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $furl);
+ return REDIRECT;
+ }
}
# Create the nav map
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">'."\n".
- '// <![CDATA['."\n".
- 'window.focus();'."\n".
- '// ]]>'."\n".
- '</script>');
+
&startContentScreen($r,'navmaps');
- $r->rflush();
+ unless ($result eq 'update') {
+ $r->rflush();
+ }
# Check that it's defined
if (!($navmap->courseMapDefined())) {
@@ -316,6 +339,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)=@_;
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.96 rat/lonpageflip.pm:1.97
--- rat/lonpageflip.pm:1.96 Mon Jun 26 01:57:11 2017
+++ rat/lonpageflip.pm Thu Nov 16 13:42:01 2017
@@ -2,7 +2,7 @@
#
# Page flip handler
#
-# $Id: lonpageflip.pm,v 1.96 2017/06/26 01:57:11 raeburn Exp $
+# $Id: lonpageflip.pm,v 1.97 2017/11/16 13:42:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -299,6 +299,28 @@
return $usehttp;
}
+sub reinited_js {
+ my ($url,$cid,$timeout) = @_;
+ if (!$timeout) {
+ $timeout = 0;
+ }
+ return <<"END";
+<script type="text/javascript">
+// <![CDATA[
+setTimeout(function() {
+ var newurl = '$url';
+ if (document.getElementById('LC_update_$cid')) {
+ document.getElementById('LC_update_$cid').style.display = 'none';
+ }
+ if ((newurl !== null) && (newurl !== '') && (newurl !== 'undefined')) {
+ window.location.href = "$url";
+ }
+}, $timeout);
+// ]]>
+</script>
+END
+}
+
# ================================================================ Main Handler
sub handler {
@@ -315,6 +337,7 @@
my %cachehash=();
my $multichoice=0;
my %multichoicehash=();
+ my %prog_state=();
my ($redirecturl,$redirectsymb,$enc,$anchor);
my $next='';
my $hostname = $r->hostname();
@@ -372,8 +395,20 @@
untie(%hash);
}
}
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ $r->print(&Apache::loncommon::start_page('Content Changed'));
+ my $preamble = '<div id="LC_update_'.$env{'request.course.id'}.'" 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>';
+ %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);
+ &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Updating course'));
my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+ &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Finished'));
if ($ferr) {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
my $requrl = $r->uri;
$env{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
$env{'user.reinit'} = 1;
@@ -396,9 +431,16 @@
} else {
$furl=&Apache::lonnet::absolute_url().$furl;
}
- &Apache::loncommon::content_type($r,'text/html');
- $r->header_out(Location => $furl);
- return REDIRECT;
+ if ($reinitcheck eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print(&reinited_js($furl,$env{'request.course.id'},100));
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $furl);
+ return REDIRECT;
+ }
}
if ($direction eq 'return') {
# -------------------------------------------------------- Return to last known
@@ -427,9 +469,15 @@
} else {
$newloc=&Apache::lonnet::absolute_url().$newloc
}
- &Apache::loncommon::content_type($r,'text/html');
- $r->header_out(Location => $newloc);
- return REDIRECT;
+ if ($reinitcheck eq 'update') {
+ $r->print(&reinited_js($newloc,$env{'request.course.id'},100));
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $newloc);
+ return REDIRECT;
+ }
}
#
# Is the current URL on the map? If not, start with last known URL
@@ -447,11 +495,18 @@
if ($last) {
$currenturl=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($last))[2]);
} else {
- &Apache::loncommon::content_type($r,'text/html');
- $r->header_out(Location =>
- &Apache::lonnet::absolute_url().
- '/adm/navmaps');
- return REDIRECT;
+ my $newloc = &Apache::lonnet::absolute_url().
+ '/adm/navmaps';
+ if ($reinitcheck eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print(&reinited_js($newloc,$env{'request.course.id'},100));
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $newloc);
+ return REDIRECT;
+ }
}
}
# ------------------------------------------- Do we have any idea where we are?
@@ -548,9 +603,16 @@
$url .= $anchor;
}
}
- &Apache::loncommon::content_type($r,'text/html');
- $r->header_out(Location => $url);
- return REDIRECT;
+ if ($reinitcheck eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print(&reinited_js($url,$env{'request.course.id'},100));
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ } else {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $url);
+ return REDIRECT;
+ }
} else {
# --------------------------------------------------------- There was a problem
&Apache::loncommon::content_type($r,'text/html');
@@ -653,12 +715,23 @@
}
} else {
# ------------------------------------------------- Problem, could not tie hash
+ if ($reinitcheck eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print(&Apache::loncommon::end_page());
+ }
$env{'user.error.msg'}="/adm/flip:bre:0:1:Course Data Missing";
return HTTP_NOT_ACCEPTABLE;
}
} else {
# ---------------------------------------- No, could not determine where we are
- $r->internal_redirect('/adm/ambiguous');
+ my $newloc = '/adm/ambiguous';
+ if ($reinitcheck eq 'update') {
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ $r->print(&reinited_js($newloc,$env{'request.course.id'},100));
+ $r->print(&Apache::loncommon::end_page());
+ } else {
+ $r->internal_redirect($newloc);
+ }
return OK;
}
} else {
More information about the LON-CAPA-cvs
mailing list