[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm matchresponse.pm optionresponse.pm radiobuttonresponse.pm rankresponse.pm /interface lonpdfupload.pm

raeburn raeburn at source.lon-capa.org
Fri Feb 6 17:01:32 EST 2026


raeburn		Fri Feb  6 22:01:32 2026 EDT

  Modified files:              
    /loncom/homework	inputtags.pm matchresponse.pm optionresponse.pm 
                    	radiobuttonresponse.pm rankresponse.pm 
    /loncom/interface	lonpdfupload.pm 
  Log:
  - Bug 6121
    - Symbs for encrypted URLs should be encrypted in PDF Forms. 
    - Support processing of completed PDF Forms for problems added to course 
      via import of a published map.
  
  
-------------- next part --------------
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.372 loncom/homework/inputtags.pm:1.373
--- loncom/homework/inputtags.pm:1.372	Mon Aug 25 04:21:52 2025
+++ loncom/homework/inputtags.pm	Fri Feb  6 22:01:31 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input definitions
 #
-# $Id: inputtags.pm,v 1.372 2025/08/25 04:21:52 raeburn Exp $
+# $Id: inputtags.pm,v 1.373 2026/02/06 22:01:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -307,7 +307,15 @@
 	    $result.='\strut \\\\\strut \\\\\strut \\\\\strut \\\\}}}';
 	} else {
             if ($env{'form.pdfFormFields'} eq 'yes') {
-                my $fieldname = $env{'request.symb'}.
+                my $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+                $prefix =~ s{^/}{};
+                unless ($prefix =~ /^(uploaded|enc)/) {
+                    $prefix = 'res/'.$prefix;
+                }
+                unless ($env{'request.symb'} =~ /^uploaded/) {
+                    $prefix .= '&'.$env{'request.course.id'};
+                }
+                my $fieldname = $prefix.
                                 '&part_'. $Apache::inputtags::part.
                                 '&textresponse'.
                                 '&HWVAL_' . $Apache::inputtags::response['-1'];
@@ -528,7 +536,15 @@
 	if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
 	if ($env{'form.pdfFormFields'} eq 'yes'
             && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
-            my $fieldname = $env{'request.symb'}.
+            my $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+            $prefix =~ s{^/}{};
+            unless ($prefix =~ /^(uploaded|enc)/) {
+                $prefix = 'res/'.$prefix;
+            }
+            unless ($env{'request.symb'} =~ /^uploaded/) {
+                $prefix .= '&'.$env{'request.course.id'};
+            }
+            my $fieldname = $prefix.
                                  '&part_'. $Apache::inputtags::part.
                                  '&textresponse'.
                                  '&HWVAL_' . $Apache::inputtags::response['-1'];
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.97 loncom/homework/matchresponse.pm:1.98
--- loncom/homework/matchresponse.pm:1.97	Fri Feb 21 20:55:17 2025
+++ loncom/homework/matchresponse.pm	Fri Feb  6 22:01:31 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.97 2025/02/21 20:55:17 raeburn Exp $
+# $Id: matchresponse.pm,v 1.98 2026/02/06 22:01:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -679,6 +679,19 @@
         } else {
             $numrows = 1;
         }
+        my $prefix;
+        if (($Apache::lonhomework::type ne 'exam') &&
+            ($target eq 'tex' and $env{'form.pdfFormFields'} eq 'yes'
+             && $Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
+            $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+            $prefix =~ s{^/}{};
+            unless ($prefix =~ /^(uploaded|enc)/) {
+                $prefix = 'res/'.$prefix;
+            }
+            unless ($env{'request.symb'} =~ /^uploaded/) {
+                $prefix .= '&'.$env{'request.course.id'};
+            }
+        }
 	foreach my $name (@whichfoils) {
 	    my $lastopt=$lastresponse{$name};
 	    my $last_letter=$name_letter_map{$lastopt};
@@ -689,7 +702,7 @@
 		if ($Apache::lonhomework::type ne 'exam') {
                     if($env{'form.pdfFormFields'} eq 'yes'
                        && $Apache::inputtags::status['-1'] eq 'CAN_ANSWER') {
-                        my $fieldname = $env{'request.symb'} . '&part_'. $Apache::inputtags::part .'&matchresponse'. '&HWVAL_' . $Apache::inputtags::response['-1'] . ':' . $temp . '&submit_' . $Apache::inputtags::part . '&';
+                        my $fieldname = $prefix . '&part_'. $Apache::inputtags::part .'&matchresponse'. '&HWVAL_' . $Apache::inputtags::response['-1'] . ':' . $temp . '&submit_' . $Apache::inputtags::part . '&';
                         $optionlist = &Apache::lonxml::print_pdf_start_combobox($fieldname);
                     } else {
 
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.204 loncom/homework/optionresponse.pm:1.205
--- loncom/homework/optionresponse.pm:1.204	Fri Feb 21 20:55:17 2025
+++ loncom/homework/optionresponse.pm	Fri Feb  6 22:01:31 2026
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.204 2025/02/21 20:55:17 raeburn Exp $
+# $Id: optionresponse.pm,v 1.205 2026/02/06 22:01:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -735,6 +735,18 @@
                 ($checkboxchoices?&mt('Choices: ').'<b>'.$opt[0].','.$opt[1].'</b>. ':'').
                  &mt('Select all that are [_1].','<b>'.$checkboxopt.'</b>');
     }
+    my $prefix;
+    if ($target eq 'tex' and $env{'form.pdfFormFields'} eq 'yes'
+         && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+        $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+        $prefix =~ s{^/}{};
+        unless ($prefix =~ /^(uploaded|enc)/) {
+            $prefix = 'res/'.$prefix;
+        }
+        unless ($env{'request.symb'} =~ /^uploaded/) {
+            $prefix .= '&'.$env{'request.course.id'};
+        }
+    }
     foreach $name (@whichopt) {
       if ($target eq 'web') {
           $result.= '<div class="LC_optionfoil">';
@@ -750,7 +762,7 @@
 
       if($target eq 'tex' and $env{'form.pdfFormFields'} eq 'yes'
          && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
-          my $fieldname = $env{'request.symb'}.'&part_'.$Apache::inputtags::part.'&optionresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'].':'.$temp;
+          my $fieldname = $prefix.'&part_'.$Apache::inputtags::part.'&optionresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'].':'.$temp;
           $optionlist =  &Apache::lonxml::print_pdf_start_combobox($fieldname);
       }
 
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.163 loncom/homework/radiobuttonresponse.pm:1.164
--- loncom/homework/radiobuttonresponse.pm:1.163	Fri Feb  6 17:43:18 2026
+++ loncom/homework/radiobuttonresponse.pm	Fri Feb  6 22:01:31 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.163 2026/02/06 17:43:18 raeburn Exp $
+# $Id: radiobuttonresponse.pm,v 1.164 2026/02/06 22:01:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1129,11 +1129,19 @@
     my $temp = 0;
     my $result;
 
+    my $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+    $prefix =~ s{^/}{};
+    unless ($prefix =~ /^(uploaded|enc)/) {
+        $prefix = 'res/'.$prefix;
+    }
+    unless ($env{'request.symb'} =~ /^uploaded/) {
+        $prefix .= '&'.$env{'request.course.id'};
+    }
     $result .= "\\begin{$venv}";
     foreach my $name ( @{$whichfoils} ) {
 	
 	my $fieldname =
-	    $env{'request.symb'} 
+	    $prefix
 	. '&part_'
 	    . $Apache::inputtags::part
 	    . '&radiobuttonresponse'
Index: loncom/homework/rankresponse.pm
diff -u loncom/homework/rankresponse.pm:1.76 loncom/homework/rankresponse.pm:1.77
--- loncom/homework/rankresponse.pm:1.76	Mon Jan 27 14:46:20 2025
+++ loncom/homework/rankresponse.pm	Fri Feb  6 22:01:31 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # rank style response
 #
-# $Id: rankresponse.pm,v 1.76 2025/01/27 14:46:20 raeburn Exp $
+# $Id: rankresponse.pm,v 1.77 2026/02/06 22:01:31 raeburn Exp $
 # Copyright Michigan State University Board of Trustees
 #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -372,7 +372,7 @@
 	my $temp=1;
 	my $id=$Apache::inputtags::response[-1];
 	my $part=$Apache::inputtags::part;
-        my ($lastresponse,$newvariation);
+        my ($lastresponse,$newvariation,$prefix);
         if ((($Apache::lonhomework::history{"resource.$part.type"} eq 'randomizetry') ||
              ($Apache::lonhomework::type eq 'randomizetry')) &&
         ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
@@ -405,6 +405,14 @@
         }
         if($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes') {
             $result .= '\strut \\\\ \strut \\\\' ;
+            $prefix = &Apache::lonenc::check_encrypt($env{'request.symb'});
+            $prefix =~ s{^/}{};
+            unless ($prefix =~ /^(uploaded|enc)/) {
+                $prefix= 'res/'.$prefix;
+            }
+            unless ($env{'request.symb'} =~ /^uploaded/) {
+                $prefix .= '&'.$env{'request.course.id'};
+            }
         }
         foreach my $name (@whichfoils) {
 	    my $lastopt=$lastresponse{$name};
@@ -413,7 +421,7 @@
                 $optionlist = "<option value=\"\"></option>\n";
             } 
             if ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes') {
-                my $fieldname = $env{'request.symb'}.'&part_'.$Apache::inputtags::part.'&rankresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'].':'.$temp;
+                my $fieldname = $prefix.'&part_'.$Apache::inputtags::part.'&rankresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'].':'.$temp;
                 $optionlist =  &Apache::lonxml::print_pdf_start_combobox($fieldname);
             }
 	    my $option;
Index: loncom/interface/lonpdfupload.pm
diff -u loncom/interface/lonpdfupload.pm:1.27 loncom/interface/lonpdfupload.pm:1.28
--- loncom/interface/lonpdfupload.pm:1.27	Fri Feb  6 21:27:06 2026
+++ loncom/interface/lonpdfupload.pm	Fri Feb  6 22:01:32 2026
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # PDF Form Upload Handler
 #
-# $Id: lonpdfupload.pm,v 1.27 2026/02/06 21:27:06 raeburn Exp $
+# $Id: lonpdfupload.pm,v 1.28 2026/02/06 22:01:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use Apache::lonhtmlcommon();
 use Apache::loncommon();
 use Apache::lonnavmaps();
+use Apache::lonenc();
 use Apache::lonlocal;
 use File::MMagic;
 use CAM::PDF;
@@ -240,16 +241,31 @@
                       .'</p>';
             }
 
-        } elsif ($entry =~ /^upload.*/)  {
+        } elsif (($entry =~ m{^(uploaded|res)/}) || ($entry =~ m{^enc/\d+/}))  {
             $debug .= 'found: a problem -> '.$entry;
+            my ($cid, $part, $type, $HWVAL);
             my ($label, $value) = ($entry =~ /^([^?]*)\?(.*)/);
-            my ($symb, $part, $type, $HWVAL) = split('&', $label);
+            my ($symb, $rest) = split('&', $label, 2);
+            if ($symb =~ m{^enc/}) {
+                $symb = &Apache::lonenc::check_decrypt("/$symb");
+            } elsif ($symb =~ m{^res/}) {
+                $symb =~ s{^res/}{};
+            }
+            if ($symb =~ /^uploaded/) {
+                ($part, $type, $HWVAL) = split('&', $rest);
+            } else {
+                ($cid, $part, $type, $HWVAL) = split('&', $rest);
+            }
             my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symb);
             if ($map =~ m{^uploaded/($match_domain)/($match_courseid)/default(_?\d*)\.(page|sequence)}) {
                 my $mapcid = $1.'_'.$2;
                 if ($mapcid ne $env{'request.course.id'}) {
                     push(@{$foreigncourse{$mapcid}},$symb);
                 }
+            } elsif ($map =~ m{^($match_domain)/($match_username)/}) {
+                if ($cid ne $env{'request.course.id'}) {
+                    push(@{$foreigncourse{$cid}},$symb);
+                }
             }
             next unless (exists($restitles{$symb}));
             $value =~ s/(.*)\n/$1/; 


More information about the LON-CAPA-cvs mailing list