[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm

raeburn raeburn at source.lon-capa.org
Fri Jan 23 18:32:03 EST 2015


raeburn		Fri Jan 23 23:32:03 2015 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncommon.pm 
  Log:
  - For 2.11
    - Backport 1.1199, 1.1200.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.85 loncom/interface/loncommon.pm:1.1075.2.86
--- loncom/interface/loncommon.pm:1.1075.2.85	Sun Dec 21 17:29:44 2014
+++ loncom/interface/loncommon.pm	Fri Jan 23 23:32:02 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1075.2.85 2014/12/21 17:29:44 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.86 2015/01/23 23:32:02 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3677,7 +3677,7 @@
 =over 4
 
 =item * &get_previous_attempt($symb, $username, $domain, $course,
-    $getattempt, $regexp, $gradesub)
+    $getattempt, $regexp, $gradesub, $usec, $identifier)
 
 Return string with previous attempt on problem. Arguments:
 
@@ -3699,6 +3699,11 @@
 
 =item * $gradesub: routine that processes the string if it matches $regexp
 
+=item * $usec: section of the desired student
+
+=item * $identifier: counter for student (multiple students one problem) or
+    problem (one student; whole sequence).
+
 =back
 
 The output string is a table containing all desired attempts, if any.
@@ -3706,7 +3711,7 @@
 =cut
 
 sub get_previous_attempt {
-  my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_;
+  my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub,$usec,$identifier)=@_;
   my $prevattempts='';
   no strict 'refs';
   if ($symb) {
@@ -3722,7 +3727,7 @@
       }
       $prevattempts=&start_data_table().&start_data_table_header_row();
       $prevattempts.='<th>'.&mt('History').'</th>';
-      my (%typeparts,%lasthidden);
+      my (%typeparts,%lasthidden,%regraded,%hidestatus);
       my $showsurv=&Apache::lonnet::allowed('vas',$env{'request.course.id'});
       foreach my $key (sort(keys(%lasthash))) {
 	my ($ign, at parts) = split(/\./,$key);
@@ -3739,6 +3744,18 @@
                       $lasthidden{$ign.'.'.$id} = 1;
                   }
               }
+              if ($identifier ne '') {
+                  my $id = join(',', at parts);
+                  if (&Apache::lonnet::EXT("resource.$id.problemstatus",$symb,
+                                               $domain,$username,$usec,undef,$course) =~ /^no/) {
+                      $hidestatus{$ign.'.'.$id} = 1;
+                  }
+              }
+          } elsif ($data eq 'regrader') {
+              if (($identifier ne '') && (@parts)) {
+                  my $id = join(',', at parts);
+                  $regraded{$ign.'.'.$id} = 1;
+              }
           } 
 	} else {
 	  if ($#parts == 0) {
@@ -3750,17 +3767,60 @@
       }
       $prevattempts.=&end_data_table_header_row();
       if ($getattempt eq '') {
+        my (%solved,%resets,%probstatus);
+        if (($identifier ne '') && (keys(%regraded) > 0)) {
+            for ($version=1;$version<=$returnhash{'version'};$version++) {
+                foreach my $id (keys(%regraded)) {
+                    if (($returnhash{$version.':'.$id.'.regrader'}) &&
+                        ($returnhash{$version.':'.$id.'.tries'} eq '') &&
+                        ($returnhash{$version.':'.$id.'.award'} eq '')) {
+                        push(@{$resets{$id}},$version);
+                    }
+                }
+            }
+        }
 	for ($version=1;$version<=$returnhash{'version'};$version++) {
-            my @hidden;
+            my (@hidden, at unsolved);
             if (%typeparts) {
                 foreach my $id (keys(%typeparts)) {
-                    if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') || ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
+                    if (($returnhash{$version.':'.$id.'.type'} eq 'anonsurvey') ||
+                        ($returnhash{$version.':'.$id.'.type'} eq 'anonsurveycred')) {
                         push(@hidden,$id);
+                    } elsif ($identifier ne '') {
+                        unless (($returnhash{$version.':'.$id.'.type'} eq 'survey') ||
+                                ($returnhash{$version.':'.$id.'.type'} eq 'surveycred') ||
+                                ($hidestatus{$id})) {
+                            next if ((ref($resets{$id}) eq 'ARRAY') && grep(/^\Q$version\E$/,@{$resets{$id}}));
+                            if ($returnhash{$version.':'.$id.'.solved'} eq 'correct_by_student') {
+                                push(@{$solved{$id}},$version);
+                            } elsif (($returnhash{$version.':'.$id.'.solved'} ne '') &&
+                                     (ref($solved{$id}) eq 'ARRAY')) {
+                                my $skip;
+                                if (ref($resets{$id}) eq 'ARRAY') {
+                                    foreach my $reset (@{$resets{$id}}) {
+                                        if ($reset > $solved{$id}[-1]) {
+                                            $skip=1;
+                                            last;
+                                        }
+                                    }
+                                }
+                                unless ($skip) {
+                                    my ($ign,$partslist) = split(/\./,$id,2);
+                                    push(@unsolved,$partslist);
+                                }
+                            }
+                        }
                     }
                 }
             }
             $prevattempts.=&start_data_table_row().
-                           '<td>'.&mt('Transaction [_1]',$version).'</td>';
+                           '<td>'.&mt('Transaction [_1]',$version);
+            if (@unsolved) {
+                $prevattempts .= '<span class="LC_nobreak"><label>'.
+                                 '<input type="checkbox" name="HIDE'.$identifier.'" value="'.$version.':'.join('_', at unsolved).'" />'.
+                                 &mt('Hide').'</label></span>';
+            }
+            $prevattempts .= '</td>';
             if (@hidden) {
                 foreach my $key (sort(keys(%lasthash))) {
                     next if ($key =~ /\.foilorder$/);




More information about the LON-CAPA-cvs mailing list