[LON-CAPA-cvs] cvs: loncom /interface lonblockingmenu.pm lonblockingstatus.pm loncommon.pm lonprintout.pm

raeburn raeburn at source.lon-capa.org
Sun Mar 22 14:39:05 EDT 2026


raeburn		Sun Mar 22 18:39:05 2026 EDT

  Modified files:              
    /loncom/interface	lonblockingmenu.pm lonblockingstatus.pm 
                     	loncommon.pm lonprintout.pm 
  Log:
  - Bug 6121 -- PDF Forms.
    Blocked actions during an exam or timed quiz can include submission of
    PDF forms.
  
  
-------------- next part --------------
Index: loncom/interface/lonblockingmenu.pm
diff -u loncom/interface/lonblockingmenu.pm:1.35 loncom/interface/lonblockingmenu.pm:1.36
--- loncom/interface/lonblockingmenu.pm:1.35	Wed Dec 24 18:36:07 2025
+++ loncom/interface/lonblockingmenu.pm	Sun Mar 22 18:39:05 2026
@@ -2,7 +2,7 @@
 # Routines for configuring blocking of access to collaborative functions, 
 # and specific resources during an exam
 #
-# $Id: lonblockingmenu.pm,v 1.35 2025/12/24 18:36:07 raeburn Exp $
+# $Id: lonblockingmenu.pm,v 1.36 2026/03/22 18:39:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -623,6 +623,7 @@
             '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".
             '<li>'.&mt('accessing content in LON-CAPA portfolios, blogs, or user information pages').'</li>'."\n".
             '<li>'.&mt("generating printouts of $lctype content").'</li>'.
+            '<li>'.&mt("generating or submitting fillable PDF forms").'</li>'.
             '<li>'.&mt("displaying the LON-CAPA gradebook in the $lctype").'</li>'.
             '<li>'.&mt("searching $lctype content by keyword").'</li>'.  
             '<li>'.&mt("displaying $lctype content indexed by keyword").'</li>'. 
@@ -1655,6 +1656,7 @@
         'about' => 'User Information',
         'docs' => 'Content',
         'printout' => 'Printouts',
+        'pdfforms' => 'PDF Forms',
         'passwd' => 'Change Password',
         'grades' => 'Gradebook',
         'search' => 'Content Search',
@@ -1662,7 +1664,7 @@
         'alert'  => 'Critical Alert',
         'reinit' => 'Course Re-init',
     );
-    my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','docs','grades','search','index','alert','reinit','passwd'];
+    my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','pdfforms','docs','grades','search','index','alert','reinit','passwd'];
     return ($typeorder,\%types);
 }
 
Index: loncom/interface/lonblockingstatus.pm
diff -u loncom/interface/lonblockingstatus.pm:1.24 loncom/interface/lonblockingstatus.pm:1.25
--- loncom/interface/lonblockingstatus.pm:1.24	Mon Jan  5 17:48:22 2026
+++ loncom/interface/lonblockingstatus.pm	Sun Mar 22 18:39:05 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # displays the blocking status table
 #
-# $Id: lonblockingstatus.pm,v 1.24 2026/01/05 17:48:22 raeburn Exp $
+# $Id: lonblockingstatus.pm,v 1.25 2026/03/22 18:39:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,7 +44,7 @@
     return OK if $r->header_only;
 
     my (%activities,$activity,$origurl,$origsymb);
-    map { $activities{$_} = 1; } ('boards','chat','com','blogs','about','groups','port','printout','docs','grades','passwd','search','index','wishlist','annotate');
+    map { $activities{$_} = 1; } ('boards','chat','com','blogs','about','groups','port','printout','pdfforms','docs','grades','passwd','search','index','wishlist','annotate');
 
     # determine what kind of blocking we want details for
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['activity','url','symb']);
@@ -55,7 +55,8 @@
     if (($activity eq 'docs') || ($activity eq 'printout') ||
         ($activity eq 'grades') || ($activity eq 'passwd') ||
         ($activity eq 'search') || ($activity eq 'wishlist') ||
-        ($activity eq 'annotate') || ($activity eq 'index')) {
+        ($activity eq 'annotate') || ($activity eq 'index') ||
+        ($activity eq 'pdfforms')) {
         $title = 'Blocking Status Information';
         if ($activity eq 'docs') {
             $origurl = $env{'form.url'};
@@ -162,6 +163,7 @@
                    about      => 'User information pages',
                    groups     => 'Groups in this course',
                    printout   => 'Printout generation',
+                   pdfforms   => 'PDF Form generation or submission',
                    docs       => 'Course Content',
                    passwd     => 'Changing of passwords',
                    grades     => 'Course Gradebook',
@@ -204,7 +206,8 @@
         } elsif (($activity eq 'printout') || ($activity eq 'passwd') ||
                  ($activity eq 'grades') || ($activity eq 'search') ||
                  ($activity eq 'about') || ($activity eq 'wishlist') ||
-                 ($activity eq 'annotate') || ($activity eq 'index')) {
+                 ($activity eq 'annotate') || ($activity eq 'index') ||
+                 ($activity eq 'pdfforms')) {
             if ($by_ip) {
                 $output = mt( $description
                               . ' unavailable from your current IP address: [_1] '
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1509 loncom/interface/loncommon.pm:1.1510
--- loncom/interface/loncommon.pm:1.1509	Sun Feb  8 22:51:04 2026
+++ loncom/interface/loncommon.pm	Sun Mar 22 18:39:05 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1509 2026/02/08 22:51:04 raeburn Exp $
+# $Id: loncommon.pm,v 1.1510 2026/03/22 18:39:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6162,6 +6162,12 @@
         $class = '';
     } elsif ($activity eq 'printout') {
         $text = &mt('Printing Blocked');
+    } elsif ($activity eq 'pdfforms') {
+        if ($url eq '/adm/pdfupload') {
+            $text = &mt('PDF Forms Submission Blocked');
+        } else {
+            $text = &mt('PDF Forms Generation Blocked')
+        }
     } elsif ($activity eq 'passwd') {
         $text = &mt('Password Changing Blocked');
     } elsif ($activity eq 'grades') {
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.717 loncom/interface/lonprintout.pm:1.718
--- loncom/interface/lonprintout.pm:1.717	Sun Mar 22 18:10:45 2026
+++ loncom/interface/lonprintout.pm	Sun Mar 22 18:39:05 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.717 2026/03/22 18:10:45 raeburn Exp $
+# $Id: lonprintout.pm,v 1.718 2026/03/22 18:39:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2871,6 +2871,19 @@
     my @temporary_array=split /\|/,$format_from_helper;
     my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array;
 
+    if ($pdfFormFields eq 'yes') {
+        if (&can_use_pdfforms($helper)) {
+            if ($env{'request.course.id'}) {
+                my ($blocked) = &pdfforms_blocking();
+                if ($blocked) {
+                    undef($pdfFormFields);
+                }
+            }
+        } else {
+            undef($pdfFormFields);
+        }
+    }
+
     $laystyle = &map_laystyle($laystyle);
     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
     my $assignment =  $env{'form.assignment'};
@@ -3810,7 +3823,7 @@
 				"cgi.$identifier.courseid" => $cnum,
 				"cgi.$identifier.coursedom" => $cdom,
 				"cgi.$identifier.resources" => $resources_printed});
-    if (&can_use_pdfforms($helper) && $pdfFormFields) {
+    if ($pdfFormFields eq 'yes') {
         &Apache::lonnet::appenv({'cgi.'.$identifier.'.pdfFormFields' => $pdfFormFields});
     }
     my $end_page = &Apache::loncommon::end_page();
@@ -3850,6 +3863,28 @@
     return;
 }
 
+sub pdfforms_blocking {
+    my ($blocked,$blocktext);
+    if ($env{'request.course.id'}) {
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        my $clientip = &Apache::lonnet::get_requestor_ip();
+        ($blocked,$blocktext) =
+            &Apache::loncommon::blocking_status('pdfform',$clientip,$cnum,$cdom,'/adm/printout');
+        if ($blocked) {
+            my $checkrole = "cm./$cdom/$cnum";
+            if ($env{'request.course.sec'} ne '') {
+                $checkrole .= "/$env{'request.course.sec'}";
+            }
+            if ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) &&
+                ($env{'request.role'} !~ m{^st\./$cdom/$cnum})) {
+                undef($blocked);
+            }
+        }
+    }
+    return ($blocked,$blocktext);
+}
+
 sub get_CODE {
     my ($all_codes,$num,$seed,$size,$type)=@_;
     my $max='1'.'0'x$size;
@@ -5523,7 +5558,19 @@
         </select>
     </td>'."\n";
     if ($canuseforms) {
-        $result .= <<HTML;
+        my $blocked;
+        if ($env{'request.course.id'}) {
+            ($blocked,my $blocktext) = &Apache::lonprintout::pdfforms_blocking();
+            if ($blocked) {
+                $result .= <<HTML;
+        <td align='center'>
+        $blocktext
+        </td>
+HTML
+            }
+        }
+        unless ($blocked) {
+            $result .= <<HTML;
     <td align='center'>
         <select name='${var}.pdfFormFields'>
             <option selected="selected" value="no">$without</option>
@@ -5531,6 +5578,7 @@
         </select>
     </td>
 HTML
+        }
     }
     $result.=&Apache::loncommon::end_data_table_row()
             .&Apache::loncommon::end_data_table();


More information about the LON-CAPA-cvs mailing list