[LON-CAPA-cvs] cvs: loncom /homework externalresponse.pm

www www at source.lon-capa.org
Thu Aug 22 07:13:43 EDT 2013


www		Thu Aug 22 11:13:43 2013 EDT

  Modified files:              
    /loncom/homework	externalresponse.pm 
  Log:
  WIP
  
  
Index: loncom/homework/externalresponse.pm
diff -u loncom/homework/externalresponse.pm:1.21 loncom/homework/externalresponse.pm:1.22
--- loncom/homework/externalresponse.pm:1.21	Thu Aug 22 10:13:34 2013
+++ loncom/homework/externalresponse.pm	Thu Aug 22 11:13:43 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # external style responses
 #
-# $Id: externalresponse.pm,v 1.21 2013/08/22 10:13:34 kruse Exp $
+# $Id: externalresponse.pm,v 1.22 2013/08/22 11:13:43 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -245,12 +245,31 @@
                 }
             }
 	    my $response = &Apache::response::getresponse();
-            my $filestest;
-            my $fileshistory = $Apache::lonhomework::history{"resource.$part.$id.portfiles"};
-            $fileshistory .=   $Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
-            my $filesresults = $Apache::lonhomework::results{"resource.$part.$id.portfiles"};
-            $filesresults .=   $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"};
-	    if (( $response =~ /[^\s]/) ||  $filesresults || $fileshistory) {
+
+            my $filesresults=0;
+# Previously turned in files
+            my %previously_turned_in=();
+            foreach my $file (split(/\,/,$Apache::lonhomework::history{"resource.$part.$id.portfiles"}.','.
+                                         $Apache::lonhomework::history{"resource.$part.$id.uploadedurl"})) {
+               if ($file=~/\S/) {
+                  $previously_turned_in{'/uploaded/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/portfolio'.$file}=1;
+               }
+            }
+# Currently turned in files
+            my %currently_turned_in=();
+            foreach my $file (split(/\,/,$Apache::lonhomework::results{"resource.$part.$id.portfiles"}.','.
+                                         $Apache::lonhomework::results{"resource.$part.$id.uploadedurl"})) {
+               if ($file=~/\S/) {
+                  $filesresults=1;
+                  $currently_turned_in{'/uploaded/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/portfolio'.$file}=1;
+               }
+            }
+            my $filelinks=join(',',map{&escape($_)}(keys(%currently_turned_in)));
+            &Apache::lonnet::logthis("Previously: ".join("\n",sort(keys(%previously_turned_in))));
+            &Apache::lonnet::logthis("Currently: ".join("\n",sort(keys(%currently_turned_in))));
+            &Apache::lonnet::logthis("File flag: ".$filesresults);
+            &Apache::lonnet::logthis("Links String: ".$filelinks);
+	    if (( $response =~ /[^\s]/) ||  $filesresults ) {
 		my $url = &Apache::lonxml::get_param('url',$parstack,$safeeval);
 		my $answer = &Apache::lonxml::get_param('answer',$parstack,$safeeval);
 		my %form = &Apache::lonxml::get_param_var('form',$parstack,$safeeval);
@@ -258,8 +277,7 @@
 		$form{'LONCAPA_correct_answer'}=$answer;
 		$form{'LONCAPA_language'}=
 		    &Apache::lonnet::metadata($ENV{'REQUEST_URI'},'language');
-                $form{'LONCAPA_student_submitted_files_results'} = $filesresults;
-                $form{'LONCAPA_student_submitted_files_history'} = $fileshistory;
+                $form{'LONCAPA_student_submitted_files'} = $filelinks;
 		&Apache::lonxml::debug("Asking $url, with:");
 		&Apache::lonhomework::showhash(%form);
                 my $udom = &Apache::lonnet::EXT('user.domain');




More information about the LON-CAPA-cvs mailing list