[LON-CAPA-cvs] cvs: loncom /interface lonrequestcourse.pm
raeburn
raeburn at source.lon-capa.org
Mon May 19 11:59:55 EDT 2014
raeburn Mon May 19 15:59:55 2014 EDT
Modified files:
/loncom/interface lonrequestcourse.pm
Log:
- Course creation can take some time if a course is being cloned.
- Display a message that processing is in progress, then flush the print
buffer. Hide messge when page loading completes.
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.83 loncom/interface/lonrequestcourse.pm:1.84
--- loncom/interface/lonrequestcourse.pm:1.83 Wed May 14 18:20:09 2014
+++ loncom/interface/lonrequestcourse.pm Mon May 19 15:59:55 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.83 2014/05/14 18:20:09 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.84 2014/05/19 15:59:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -311,6 +311,8 @@
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
if ($state eq 'courseinfo') {
$jscript .= &cloning_javascript();
+ } elsif ($state eq 'process') {
+ $jscript .= &processing_javascript();
}
}
}
@@ -413,7 +415,7 @@
for (var i=0; i<courseForm.cloning.length; i++) {
if (courseForm.cloning[i].checked) {
if (courseForm.cloning[i].value == 1) {
- document.getElementById('cloneoptions').style.display="block";;
+ document.getElementById('cloneoptions').style.display="block";
}
}
}
@@ -422,6 +424,17 @@
END
}
+sub processing_javascript {
+ return <<"END";
+function hideProcessing() {
+ if (document.getElementById('processing')) {
+ document.getElementById('processing').style.display="none";
+ }
+}
+
+END
+}
+
sub get_breadcrumbs {
my ($dom,$action,$state,$states,$trail) = @_;
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
@@ -697,6 +710,9 @@
if ($state eq 'courseinfo') {
$loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
}
+ if ($state eq 'process') {
+ $loaditems{'onload'} .= 'javascript:hideProcessing();';
+ }
}
return \%loaditems;
}
@@ -1550,7 +1566,7 @@
\%cat_order,\@code_order);
}
my $lonhost = $r->dir_config('lonHostID');
- my ($storeresult,$result) = &print_request_outcome($lonhost,$dom,\@codetitles,
+ my ($storeresult,$result) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
\@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
@@ -3359,7 +3375,7 @@
}
sub print_request_outcome {
- my ($lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;
+ my ($r,$lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;
my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
%sections,%crosslistings,%personnel, at baduname, at missingdom,%domconfig,
$uniquecode);
@@ -3604,13 +3620,13 @@
accessend => $accessend,
personnel => \%personnel,
};
- my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
+ my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
$req_notifylist,\@instsections,\%domconfig);
return ($result,$output);
}
sub process_request {
- my ($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
+ my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
$domconfig) = @_;
my (@inststatuses,$storeresult,$creationresult,$output);
my $val =
@@ -3740,6 +3756,10 @@
foreach my $role (@roles) {
$longroles{$role}=&Apache::lonnet::plaintext($role,$type);
}
+ $r->print('<div id="processing" style="display:block;">'."\n".
+ &mt('Your request is being processed; this page will update when processing is complete.').
+ '</div>');
+ $r->rflush();
my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
@@ -4782,7 +4802,11 @@
undef($clonedom);
}
}
- $r->print(&header('Course Creation'));
+ my $js = &processing_javascript();
+ my $loaditems = {
+ onload => 'javascript:hideProcessing();',
+ };
+ $r->print(&header('Course Creation',$js,$loaditems));
if (ref($can_request) eq 'HASH') {
unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
@@ -4821,7 +4845,8 @@
$details->{dateshift} = $env{'form.dateshift'};
}
my $lonhost = $r->dir_config('lonHostID');
- my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,'',
+ $r->rflush();
+ my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,'',
$req_notifylist,[],$domconfig);
$r->print($output);
if (&Apache::loncoursequeueadmin::author_prompt()) {
More information about the LON-CAPA-cvs
mailing list