[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm /interface portfolio.pm

raeburn raeburn at source.lon-capa.org
Fri Jun 8 08:25:59 EDT 2012


raeburn		Fri Jun  8 12:25:59 2012 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
    /loncom/interface	portfolio.pm 
  Log:
  - Portfolio file selection for submission to a Bridge Task which includes IP 
    access control avoids blocking of portfolio access from exam blocks.
  
  
-------------- next part --------------
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.302 loncom/homework/inputtags.pm:1.303
--- loncom/homework/inputtags.pm:1.302	Sun Mar 11 20:17:10 2012
+++ loncom/homework/inputtags.pm	Fri Jun  8 12:25:54 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.302 2012/03/11 20:17:10 raeburn Exp $
+# $Id: inputtags.pm,v 1.303 2012/06/08 12:25:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -576,8 +576,20 @@
     if ( $which eq 'both') {
 	$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
     }
-    if ($which eq 'portfolioonly' || $which eq 'both') { 
-	$result.=$extratext.'<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&fieldname='.$env{'form.request.prefix'}.'HWPORT'.$jspart.'_'.$id.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
+    if ($which eq 'portfolioonly' || $which eq 'both') {
+        my $symb = $env{'request.symb'};
+        (undef,undef,my $res)=&Apache::lonnet::decode_symb($symb);
+        my $showsymb;
+        # If resource is a .task and URL is unencrypted, include symb in query string
+        # for url opened in portfolio file selection window. Can be used to override
+        # blocking of portfolio access resulting from an exam event in a different course. 
+        if ($res =~ /\.task$/i) {
+            my $encsymb = &Apache::lonenc::check_encrypt($symb);
+            if ($symb eq $encsymb) {
+                $showsymb = $symb;
+            }
+        }
+	$result.=$extratext.'<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&fieldname='.$env{'form.request.prefix'}.'HWPORT'.$jspart.'_'.$id.'&symb='.$showsymb.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
 	    &mt('Select Portfolio Files: (one or more files per submission)').'</a><br />'.
 	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
 	    '<br />';
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.234 loncom/interface/portfolio.pm:1.235
--- loncom/interface/portfolio.pm:1.234	Mon Apr 16 19:31:57 2012
+++ loncom/interface/portfolio.pm	Fri Jun  8 12:25:59 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # portfolio browser
 #
-# $Id: portfolio.pm,v 1.234 2012/04/16 19:31:57 raeburn Exp $
+# $Id: portfolio.pm,v 1.235 2012/06/08 12:25:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -122,6 +122,7 @@
                  .'<input name="uploaddoc" type="file" />'
                  .'<input type="hidden" name="currentpath" value="'.$current_path.'" />'
                  .'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'
+                 .'<input type="hidden" name="symb" value="'.$env{"form.symb"}.'" />'
                  .'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'
                  .'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'
                  .'<input type="submit" name="storeupl" value="'.$lt{'upload'}.'" />'
@@ -139,6 +140,7 @@
                  .'<input name="newdir" type="text" />'.$groupitem
                  .'<input type="hidden" name="currentpath" value="'.$current_path.'" />'
                  .'<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'
+                 .'<input type="hidden" name="symb" value="'.$env{"form.symb"}.'" />'
                  .'<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'
                  .'<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'
                  .'<input type="submit" name="createdir" value="'.$lt{'createdir'}.'" />'
@@ -155,6 +157,7 @@
         'selectfile'    => $port_path,
         'currentpath'   => '/',
         'mode'          => $env{"form.mode"},
+        'symb'          => $env{"form.symb"},
         'fieldname'     => $env{"form.fieldname"},
         'continue'      => $env{"form.continue"}
     );
@@ -168,6 +171,7 @@
                 'selectfile' => $tree[$i],
                 'currentpath' => $newCurrentPath,
                 'mode' => $env{"form.mode"},
+                'symb' => $env{"form.symb"},
                 'fieldname' => $env{"form.fieldname"},
                 'continue' => $env{"form.continue"}
             );
@@ -177,7 +181,7 @@
     $r->print('</span>');
     $r->print(&Apache::loncommon::help_open_topic('Portfolio ChangeDirectory'));
     &Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path);
-    $r->print('<br /><form method="post" action="'.$url.'?mode='.$env{"form.mode"}.'&fieldname='.$env{"form.fieldname"}.&group_args());
+    $r->print('<br /><form method="post" action="'.$url.'?mode='.$env{"form.mode"}.'&fieldname='.$env{"form.fieldname"}.'&symb='.$env{'form.symb'}.&group_args());
     $r->print('">'.
 	      &Apache::lonhtmlcommon::select_recent($namespace,'currentpath',
 						    'this.form.submit();'));
@@ -447,6 +451,7 @@
                     'selectfile'    => $filename.'/',
                     'currentpath'   => $current_path.$filename.'/',
                     'mode'          => $env{"form.mode"},
+                    'symb'          => $env{"form.symb"},
                     'fieldname'     => $env{"form.fieldname"},
                     'continue'      => $env{"form.continue"}
                 );  
@@ -554,6 +559,7 @@
         $r->print('
             <input type="hidden" name="continue" value="true" />
             <input type="hidden" name="fieldname" value="'.$env{'form.fieldname'}.'" />
+            <input type="hidden" name="symb" value="'.$env{'form.symb'}.'" />
             <input type="hidden" name="mode" value="selectfile" />
             <p>
             <input type="submit" name="submit" value="'.&mt('Select checked files, and continue selecting').'" /><br />
@@ -641,6 +647,7 @@
         'showversions' => $env{'form.showversions'},
         'currentpath' => $env{'form.currentpath'},
         'fieldname' => $env{'form.fieldname'},
+        'symb'      => $env{'form.symb'},
         'mode'      => $env{'form.mode'}
     );
     my $result = '<h3>'.&make_anchor($url,\%anchor_fields,&mt($message)).'</h3>';
@@ -2090,6 +2097,7 @@
     }
     return <<END;
 <input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
+<input type="hidden" name="symb" value="$env{'form.symb'}" />
 <input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
 <input type="hidden" name="mode" value="$env{'form.mode'}" />
 <input type="hidden" name="showversions" value="$env{'form.showversions'}" />
@@ -2451,6 +2459,7 @@
     my ($container) = @_;
     my $state = <<STATE;
     <input type="hidden" name="currentpath" value="$env{'form.currentpath'}" />
+    <input type="hidden" name="symb" value="$env{'form.symb'}" />
     <input type="hidden" name="fieldname" value="$env{'form.fieldname'}" />
     <input type="hidden" name="mode" value="$env{'form.mode'}" />
     <input type="hidden" name="container" value="$container" />
@@ -2467,7 +2476,7 @@
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['selectfile','currentpath','meta','lockinfo','currentfile','action',
 	  'fieldname','mode','rename','continue','group','access','setnum',
-          'cnum','cdom','type','setroles','showversions','ref']);
+          'cnum','cdom','type','setroles','showversions','ref','symb']);
     my ($uname,$udom,$portfolio_root,$url,$caller,$title,$group,$grp_desc);
     if ($r->uri =~ m|^(/adm/)([^/]+)|) {
         $url = $1.$2;
@@ -2570,12 +2579,42 @@
         }
     }
     $r->rflush();
+    # Check if access to portfolio is blocked by one or more blocking events in courses.
     my ($blocked,$blocktext) = 
         &Apache::loncommon::blocking_status('port',$uname,$udom);
     if ($blocked) {
-         $r->print($blocktext);
-         $r->print(&Apache::loncommon::end_page());
-         return OK;
+        my $evade_block;
+        # If portfolio display is in a window popped up from a "Select Portfolio Files"
+        # link in a .task resource, check if access to the task included proctor validation
+        # of check-in to a slot limited by IP.
+        # If so, and the slot is between its open and close dates, override the block. 
+        if ($env{'request.course.id'} && $env{'form.symb'}) {
+            (undef,undef,my $res) = &Apache::lonnet::decode_symb($env{'form.symb'});
+            if ($res =~ /\.task$/i) {
+                my %history =
+                    &Apache::lonnet::restore($env{'form.symb'},$env{'request.course.id'},
+                                             $env{'user.domain'},$env{'user.name'});
+                my $version = $history{'resource.0.version'};
+                if ($history{'resource.'.$version.'.0.checkedin'}) {
+                    if ($history{'resource.'.$version.'.0.checkedin.slot'}) {
+                        my %slot = &Apache::lonnet::get_slot($history{'resource.'.$version.'.0.checkedin.slot'});
+                        if ($slot{'ip'}) {
+                            if (&Apache::loncommon::check_ip_acc($slot{'ip'})) {
+                                my $now = time;
+                                if (($slot{'slottime'} < $now) && ($slot{'endtime'} > $now)) {
+                                    $evade_block = 1;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        unless ($evade_block) {
+            $r->print($blocktext);
+            $r->print(&Apache::loncommon::end_page());
+            return OK;
+        }
     }
     if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
    	$r->print('<span class="LC_error">');


More information about the LON-CAPA-cvs mailing list