[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm

raeburn raeburn at source.lon-capa.org
Mon Jul 1 18:51:46 EDT 2024


raeburn		Mon Jul  1 22:51:46 2024 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	grades.pm 
  Log:
  - For 2.11
    Backport 1.791, 1.792, 1.794, 1.795
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.60 loncom/homework/grades.pm:1.596.2.12.2.61
--- loncom/homework/grades.pm:1.596.2.12.2.60	Wed Feb  9 23:50:00 2022
+++ loncom/homework/grades.pm	Mon Jul  1 22:51:46 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.596.2.12.2.60 2022/02/09 23:50:00 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.61 2024/07/01 22:51:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2178,7 +2178,7 @@
         my ($uname,$udom,$fullname) = split(/:/,$student);
         my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
 					      $udom,$uname);
-        my ($string,$timestamp)= &get_last_submission(\%record);
+        my ($string)= &get_last_submission(\%record);
         foreach my $submission (@$string) {
             my ($partid,$respid) =
 		($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
@@ -2523,16 +2523,29 @@
     #             (3) All transactions (by date)
     #             (4) The whole record (with detailed information for all transactions)
 
-    my ($string,$timestamp)= &get_last_submission(\%record);
+    my ($string,$timestamp,$lastgradetime,$lastsubmittime) =
+        &get_last_submission(\%record);
 
     my $lastsubonly;
 
-    if ($$timestamp eq '') {
-        $lastsubonly.='<div class="LC_grade_submissions_body">'.$$string[0].'</div>'; 
+    if ($timestamp eq '') {
+        $lastsubonly.='<div class="LC_grade_submissions_body">'.$string->[0].'</div>'; 
     } else {
+        my ($shownsubmdate,$showngradedate);
+        if ($lastsubmittime && $lastgradetime) {
+            $shownsubmdate = &Apache::lonlocal::locallocaltime($lastsubmittime);
+            if ($lastgradetime > $lastsubmittime) {
+                 $showngradedate = &Apache::lonlocal::locallocaltime($lastgradetime);
+             }
+        } else {
+            $shownsubmdate = $timestamp;
+        }
         $lastsubonly =
             '<div class="LC_grade_submissions_body">'
-           .'<b>'.&mt('Date Submitted:').'</b> '.$$timestamp."\n";
+           .'<b>'.&mt('Date Submitted:').'</b> '.$shownsubmdate."\n";
+        if ($showngradedate) {
+            $lastsubonly .= '<br /><b>'.&mt('Date Graded:').'</b> '.$showngradedate."\n";
+        }
 
 	my %seenparts;
 	my @part_response_id = &flatten_responseType($responseType);
@@ -2857,18 +2870,51 @@
 #--- Retrieve the last submission for all the parts
 sub get_last_submission {
     my ($returnhash)=@_;
-    my (@string,$timestamp,%lasthidden);
+    my (@string,$timestamp,$lastgradetime,$lastsubmittime);
     if ($$returnhash{'version'}) {
 	my %lasthash=();
-	my ($version);
+        my %prevsolved=();
+        my %solved=();
+	my $version;
 	for ($version=1;$version<=$$returnhash{'version'};$version++) {
+            my %handgraded = ();
 	    foreach my $key (sort(split(/\:/,
 					$$returnhash{$version.':keys'}))) {
 		$lasthash{$key}=$$returnhash{$version.':'.$key};
-		$timestamp = 
-		    &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'});
+                if ($key =~ /\.([^.]+)\.regrader$/) {
+                    $handgraded{$1} = 1;
+                } elsif ($key =~ /\.portfiles$/) {
+                    if (($$returnhash{$version.':'.$key} ne '') &&
+                        ($$returnhash{$version.':'.$key} !~ /\.\d+\.\w+$/)) {
+                        $lastsubmittime = $$returnhash{$version.':timestamp'};
+                    }
+                } elsif ($key =~ /\.submission$/) {
+                    if ($$returnhash{$version.':'.$key} ne '') {
+                        $lastsubmittime = $$returnhash{$version.':timestamp'};
+                    }
+                } elsif ($key =~ /\.([^.]+)\.solved$/) {
+                    $prevsolved{$1} = $solved{$1};
+                    $solved{$1} = $lasthash{$key};
+                }
 	    }
+            foreach my $partid (keys(%handgraded)) {
+                if (($prevsolved{$partid} eq 'ungraded_attempted') &&
+                    (($solved{$partid} eq 'incorrect_by_override') ||
+                     ($solved{$partid} eq 'correct_by_override'))) {
+                    $lastgradetime = $$returnhash{$version.':timestamp'};
+                }
+                if ($solved{$partid} ne '') {
+                    $prevsolved{$partid} = $solved{$partid};
+                }
+            }
 	}
+#
+# Timestamp is for last transaction for this resource, which does not
+# necessarily correspond to the time of last submission for problem (or part).
+#
+        if ($lasthash{'timestamp'} ne '') {
+            $timestamp = &Apache::lonlocal::locallocaltime($lasthash{'timestamp'});
+        }
         my (%typeparts,%randombytry);
         my $showsurv = 
             &Apache::lonnet::allowed('vas',$env{'request.course.id'});
@@ -2925,7 +2971,7 @@
 	$string[0] =
 	    '<span class="LC_warning">'.&mt('Nothing submitted - no attempts.').'</span>';
     }
-    return (\@string,\$timestamp);
+    return (\@string,$timestamp,$lastgradetime,$lastsubmittime);
 }
 
 #--- High light keywords, with style choosen by user.
@@ -3760,8 +3806,8 @@
             $$record{$key} = join(',', at versioned_portfiles);
             push(@returned_keys,$key);
         }
-    } 
-    return (@returned_keys);   
+    }
+    return (@returned_keys);
 }
 
 sub get_next_version {




More information about the LON-CAPA-cvs mailing list