[LON-CAPA-cvs] cvs: loncom /automation batchcreatecourse.pm /html/adm/help/tex Batch_Creation.tex /interface loncommon.pm loncreatecourse.pm rat lonwrapper.pm

raeburn raeburn at source.lon-capa.org
Fri May 22 11:05:41 EDT 2020


raeburn		Fri May 22 15:05:41 2020 EDT

  Modified files:              
    /rat	lonwrapper.pm 
    /loncom/interface	loncreatecourse.pm loncommon.pm 
    /loncom/automation	batchcreatecourse.pm 
    /loncom/html/adm/help/tex	Batch_Creation.tex 
  Log:
  - "Open all assessments" option during course creation now allows the start 
    date to be chosen (default is current time) for the course-level opendate.
  
  
-------------- next part --------------
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.49.2.4 rat/lonwrapper.pm:1.49.2.4.4.1
--- rat/lonwrapper.pm:1.49.2.4	Tue Mar 14 04:12:10 2017
+++ rat/lonwrapper.pm	Tue Apr  7 20:39:03 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.49.2.4 2017/03/14 04:12:10 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.49.2.4.4.1 2020/04/07 20:39:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,10 +37,12 @@
 use Apache::loncommon();
 use Apache::lonhtmlcommon();
 use Apache::lonextresedit();
+use LONCAPA qw(:DEFAULT :match);
 
 # ================================================================ Main Handler
 sub wrapper {
-    my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$title) = @_;
+    my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,
+        $title,$width,$height) = @_;
 
     my $forcereg;
     unless ($env{'form.folderpath'}) {
@@ -82,7 +84,7 @@
     my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);
     my $endpage = &Apache::loncommon::end_page();
 
-    if ($env{'browser.mobile'}) {
+    if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) {
         my $output = $startpage;
         if ($is_pdf) {
             if ($title eq '') {
@@ -98,6 +100,46 @@
                 $output .= $title.'<br />';
             }
             $output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>';
+        } elsif (($exttool eq 'window') || ($exttool eq 'tab')) {
+            if ($linktext eq '') {
+                $linktext = &mt('Launch External Tool');
+            }
+            if ($exttool eq 'tab') {
+                $output .= '<div>'.
+                           '<a href="'.$url.'" target="LCExternalToolTab" style="padding:0;clear:both;margin:0;border:0">'.
+                           $linktext.'</a>'.
+                           '</div>';
+            } else {
+                $output .= <<"ENDLINK";
+<script type="text/javascript">
+// <![CDATA[
+var windowObjectReference = null;
+var PreviousUrl;
+
+function openSinglePopup(strUrl) {
+    if (windowObjectReference == null || windowObjectReference.closed) {
+        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+                                            "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
+    } else if(PreviousUrl != strUrl) {
+        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+                                            "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
+        windowObjectReference.focus();
+    } else {
+        windowObjectReference.focus();
+    };
+    PreviousUrl = strUrl;
+}
+// ]]>
+</script>
+<div>
+<a href="$url" target="LCExternalToolPopUp" onclick="openSinglePopup(this.href); return false;">
+$linktext</a>
+</div>
+ENDLINK
+            }
+            if ($explanation ne '') {
+                $output .= '<div>'.$explanation.'</div>';
+            }
         } else {
             $output .= '<div style="overflow:scroll; -webkit-overflow-scrolling:touch;">'."\n".
                        '<iframe src="'.$url.$anchor.'" height="100%" width="100%" frameborder="0">'."\n".
@@ -158,7 +200,8 @@
     return OK if $r->header_only;
 
     my $url = $r->uri;
-    my ($is_ext,$brcrum,$absolute,$is_pdf);
+    my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,
+        $linktext,$explanation,$width,$height);
 
     for ($url){
         s|^/adm/wrapper||;
@@ -169,9 +212,35 @@
 
     if ($url =~ /\.pdf$/i) {
         $is_pdf = 1;
+    } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
+        $cdom = $1;
+        $cnum = $2;
+        my $marker = $3;
+        $exttool = 'iframe';
+        my $exttoolremote;
+        my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'],
+                                            $cdom,$cnum);
+        if ($toolhash{'id'}) {
+            my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
+            if (ref($ltitools{$toolhash{'id'}}) eq 'HASH') {
+                $exttoolremote = $ltitools{$toolhash{'id'}}{'url'};
+            }
+        }
+        if ($toolhash{'target'} eq 'window') {
+            $exttool = 'window';
+            $width = $toolhash{'width'};
+            $height = $toolhash{'height'};
+        } elsif ($toolhash{'target'} eq 'tab') {
+            $exttool = 'tab';
+        }
+        if (($exttool eq 'window') || ($exttool eq 'tab')) {
+            $linktext = $toolhash{'linktext'};
+            $explanation = $toolhash{'explanation'};
+        } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
+            $exttool = 'tab';
+        }
     }
- 
-    if ($is_ext) {
+    if (($is_ext) || ($exttool)) {
         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
             ['forceedit','register','folderpath','symb','idx','title','anchor']);
         if (($env{'form.forceedit'}) &&
@@ -188,10 +257,15 @@
                     $url .= '#'.$env{'form.anchor'};
                 }
             }
+            my $type = 'ext';
+            if ($exttool) {
+                $type = 'tool';
+            }
             $r->print(
                 &Apache::lonextresedit::display_editor($url,$env{'form.folderpath'},
                                                        $env{'form.symb'},
-                                                       $env{'form.idx'}));
+                                                       $env{'form.idx'},$type,$cdom,
+                                                       $cnum));
             return OK;
         } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
             my $crstype = &Apache::loncommon::course_type();
@@ -207,7 +281,7 @@
 #
 # Actual URL
 #
-    if ($url=~/$LONCAPA::assess_re/) {
+    if (($url=~/$LONCAPA::assess_re/) && (!$exttool)) {
 #
 # This is uploaded homework
 #
@@ -217,7 +291,7 @@
 #
 # This is not homework
 #
-        if ($is_ext) {
+        if (($is_ext) || ($exttool)) {
             $absolute = $env{'request.use_absolute'};
             $ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
             $ENV{'QUERY_STRING'} =~ s/\&$//;
@@ -228,9 +302,12 @@
         }
 
         # encrypt url if not external
-        &Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
+        unless ($is_ext) {
+            &Apache::lonenc::check_encrypt(\$url);
+        }
 
-        $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf) );
+        $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,
+                           $linktext,$explanation,undef,$width,$height) );
 
     } # not just the menu
     
@@ -257,7 +334,7 @@
 
 =over
 
-=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$title))
+=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title,$width,$height)
 
 =over
 
@@ -299,6 +376,22 @@
 
 true if URL is for a PDF (based on file extension).
 
+=item $exttool
+
+If URL is for an External Tool, will contain the target type: iframe, window or tab.
+
+=item $linktext
+
+optional. If URL is for an External Tool, and target type is window or tab,
+then the link text may be an option set in the course for each tool instance,
+or may be a default defined in the domain for all instances of the tool.
+
+=item $explanation
+
+optional. If URL is for an External Tool, and target type is window or tab,
+then the explanation is an option set in the course for each tool instance,
+or may be a default defined in the domain for all instances of the tool.
+
 =item $title
 
 optional. If wrapped item is a PDF, and $env{'browser.mobile'} 
@@ -307,6 +400,20 @@
 will be used, otherwise, the filename will be displayed (unless
 hidden URL set for the resource).
 
+=item $width
+
+optional. If URL is for an External Tool, and target type is window,
+then a default width may have been defined in the domain for all instances of
+the tool.  If so, that width will be used for the window opened (via a link)
+to launch the external tool.
+
+=item $height
+
+optional. If URL is for an External Tool, and target type is window,
+then a default height may have been defined in the domain for all instances of
+the tool.  If so, that height will be used for the window opened (via a link)
+to launch the external tool.
+
 =back
 
 Returns markup for the entire page.
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.172 loncom/interface/loncreatecourse.pm:1.173
--- loncom/interface/loncreatecourse.pm:1.172	Fri Jul 26 02:28:34 2019
+++ loncom/interface/loncreatecourse.pm	Fri May 22 15:05:30 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.172 2019/07/26 02:28:34 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.173 2020/05/22 15:05:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,6 +123,8 @@
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
     my $access_table = &Apache::lonuserutils::date_setting_table($starttime,
                                              $endtime,'create_defaultdates');
+    my $openallfrom =
+        &Apache::lonhtmlcommon::date_setter('ccrs','openallfrom',$starttime);
     if (($crstype eq 'Course') || ($crstype eq 'Placement')) {
         $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
                                               $endtime,'create_enrolldates');
@@ -192,6 +194,7 @@
                     'shd'  => 'Shift date parameters by number of days',
                     'assp' => "Assessment Parameters",
                     'oaas' => "Open all assessments",
+                    'sta'  => "starting from:",
                     'mssg' => "Messaging",
                     'scpf' => "Set course policy feedback to Course Coordinator",
                     'scfc' => "Set resource content feedback to Course Coordinator",
@@ -476,7 +479,10 @@
                  .&Apache::lonhtmlcommon::row_closure()
 
                  .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
-                 .'<input type="checkbox" name="openall" />'
+                 .'<span class="LC_nobreak">'
+                 .'<label><input type="radio" name="openall" value="0" checked="checked" />'.$lt{'no'}.'</label>'.(' 'x2)
+                 .'<label><input type="radio" name="openall" value="1" />'.$lt{'yes'}.'</label>'.', '
+                 .$lt{'sta'}.' '.$openallfrom
                  .&Apache::lonhtmlcommon::row_closure()
 
                  .&Apache::lonhtmlcommon::row_headline()
@@ -620,7 +626,7 @@
     my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
     my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
     my $crstype = 'Community';
-    my ($enrollstart,$enrollend,$startaccess,$endaccess);
+    my ($enrollstart,$enrollend,$startaccess,$endaccess,$openallfrom);
     my %domdefaults = 
         &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
 
@@ -633,6 +639,7 @@
     }
     $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
     $endaccess   = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
+    $openallfrom = &Apache::lonhtmlcommon::get_date_from_form('openallfrom');
 
     my $autharg;
     my $authtype;
@@ -698,6 +705,7 @@
                disresdis => $env{'form.disresdis'},
                disablechat => $env{'form.disablechat'},
                openall => $env{'form.openall'},
+               openallfrom => $openallfrom,
                firstres => $env{'form.firstres'}
                };
 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1340 loncom/interface/loncommon.pm:1.1341
--- loncom/interface/loncommon.pm:1.1340	Sun Mar 15 23:04:15 2020
+++ loncom/interface/loncommon.pm	Fri May 22 15:05:30 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1340 2020/03/15 23:04:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1341 2020/05/22 15:05:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -16326,12 +16326,17 @@
 # Open all assignments
 #
     if ($args->{'openall'}) {
+       my $opendate = time;
+       if ($args->{'openallfrom'} =~ /^\d+$/) {
+           $opendate = $args->{'openallfrom'};
+       }
        my $storeunder=$$crsudom.'_'.$$crsunum.'.0.opendate';
-       my %storecontent = ($storeunder         => time,
+       my %storecontent = ($storeunder         => $opendate,
                            $storeunder.'.type' => 'date_start');
-       
-       $outcome .= &mt('Opening all assignments').': '.&Apache::lonnet::cput
-                 ('resourcedata',\%storecontent,$$crsudom,$$crsunum).$linefeed;
+       $outcome .= &mt('All assignments open starting [_1]',
+                       &Apache::lonlocal::locallocaltime($opendate)).': '.
+                   &Apache::lonnet::cput
+                       ('resourcedata',\%storecontent,$$crsudom,$$crsunum).$linefeed;
    }
 #
 # Set first page
Index: loncom/automation/batchcreatecourse.pm
diff -u loncom/automation/batchcreatecourse.pm:1.43 loncom/automation/batchcreatecourse.pm:1.44
--- loncom/automation/batchcreatecourse.pm:1.43	Fri Jul 26 02:28:28 2019
+++ loncom/automation/batchcreatecourse.pm	Fri May 22 15:05:36 2020
@@ -1,5 +1,5 @@
 #
-# $Id: batchcreatecourse.pm,v 1.43 2019/07/26 02:28:28 raeburn Exp $
+# $Id: batchcreatecourse.pm,v 1.44 2020/05/22 15:05:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,6 +89,7 @@
 # <disresdis>1</disresdis>
 # <disablechat>1</disablechat>
 # <openall></openall>
+# <openallfrom></openallfrom>
 # <notify_dc>1</notify_dc>
 # <notify_owner>1</notify_owner>
 # <owner>
@@ -272,7 +273,7 @@
     my $role = '';
     my @items = ('title','optional_id','coursecode','defaultcredits','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','showphotos','setpolicy','setcontent','setcomment','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota','uniquecode');
     my @possroles = qw(st ad ep ta in cc co);
-    my @dateitems = ('enrollstart','enrollend','accessstart','accessend');
+    my @dateitems = ('enrollstart','enrollend','accessstart','accessend','openallfrom');
     my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID');
     my $p = HTML::Parser->new
     (
@@ -551,6 +552,7 @@
                disresdis => $details->{'disresdis'},
                disablechat => $details->{'disablechat'},
                openall => $details->{'openall'},
+               openallfrom => $details->{'openallfrom'},
                firstres => $firstres
                };
         if ($details->{'textbook'}) {
Index: loncom/html/adm/help/tex/Batch_Creation.tex
diff -u loncom/html/adm/help/tex/Batch_Creation.tex:1.7 loncom/html/adm/help/tex/Batch_Creation.tex:1.8
--- loncom/html/adm/help/tex/Batch_Creation.tex:1.7	Thu Aug 25 22:33:10 2016
+++ loncom/html/adm/help/tex/Batch_Creation.tex	Fri May 22 15:05:41 2020
@@ -45,6 +45,7 @@
 <disresdis>1</disresdis>
 <disablechat>1</disablechat>
 <openall></openall>
+<openallfrom></openallfrom>
 <notify_dc>1</notify_dc>
 <notify_owner>1</notify_owner>
 <owner>
@@ -120,6 +121,10 @@
 
 Dates are in the format YYYY:MM:DD:HH:MM:SS (:separators required)
 
+If openall has a value of 1, but openallfrom is blank, then the opendate
+set at a course-level will be the time the batch creation of the course occurs,
+otherwise the date specified for openallfrom will be the date used. 
+
 firstres can be nav, syl, or blank for ``Navigate Contents'',
 Syllabus, or no entry respectively. 
 


More information about the LON-CAPA-cvs mailing list