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

raeburn raeburn at source.lon-capa.org
Wed Feb 9 18:50:00 EST 2022


raeburn		Wed Feb  9 23:50:00 2022 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	grades.pm 
  Log:
  - For 2.11
    Backport 1.788
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.59 loncom/homework/grades.pm:1.596.2.12.2.60
--- loncom/homework/grades.pm:1.596.2.12.2.59	Fri Dec 17 20:20:14 2021
+++ loncom/homework/grades.pm	Wed Feb  9 23:50:00 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.596.2.12.2.59 2021/12/17 20:20:14 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.60 2022/02/09 23:50:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6667,9 +6667,12 @@
 }
 
 sub get_master_seq {
-    my ($resources,$master_seq,$symb_to_resource) = @_;
+    my ($resources,$master_seq,$symb_to_resource,$need_symb_in_map,$symb_for_examcode) = @_;
     return unless ((ref($resources) eq 'ARRAY') && (ref($master_seq) eq 'ARRAY') &&
                    (ref($symb_to_resource) eq 'HASH'));
+    if ($need_symb_in_map) {
+        return unless (ref($symb_for_examcode) eq 'HASH');
+    }
     my $resource_error;
     foreach my $resource (@{$resources}) {
         my $ressymb;
@@ -6677,6 +6680,14 @@
             $ressymb = $resource->symb();
             push(@{$master_seq},$ressymb);
             $symb_to_resource->{$ressymb} = $resource;
+            if ($need_symb_in_map) {
+                unless ($resource->is_map()) {
+                    my $map=(&Apache::lonnet::decode_symb($ressymb))[0];
+                    unless (exists($symb_for_examcode->{$map})) {
+                        $symb_for_examcode->{$map} = $ressymb;
+                    }
+                }
+            }
         } else {
             $resource_error = 1;
             last;
@@ -8493,6 +8504,17 @@
     if (ref($map)) {
         $randomorder = $map->randomorder();
         $randompick = $map->randompick();
+        unless ($randomorder || $randompick) {
+            foreach my $res ($navmap->retrieveResources($map,sub { $_[0]->is_map() },1,0,1)) {
+                if ($res->randomorder()) {
+                    $randomorder = 1;
+                }
+                if ($res->randompick()) {
+                    $randompick = 1;
+                }
+                last if ($randomorder || $randompick);
+            }
+        }
         if ($randomorder || $randompick) {
             $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource);
             if ($nav_error) {
@@ -8676,6 +8698,17 @@
     if (ref($map)) {
         $randomorder = $map->randomorder();
         $randompick = $map->randompick();
+        unless ($randomorder || $randompick) {
+            foreach my $res ($navmap->retrieveResources($map,sub { $_[0]->is_map() },1,0,1)) {
+                if ($res->randomorder()) {
+                    $randomorder = 1;
+                }
+                if ($res->randompick()) {
+                    $randompick = 1;
+                }
+                last if ($randomorder || $randompick);
+            }
+        }
         if ($randomorder || $randompick) {
             $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource);
             if ($nav_error) {
@@ -8817,10 +8850,21 @@
     }
     my $map=$navmap->getResourceByUrl($sequence);
     my ($randomorder,$randompick, at master_seq,%symb_to_resource,%grader_partids_by_symb,
-        %grader_randomlists_by_symb);
+        %grader_randomlists_by_symb,%symb_for_examcode);
     if (ref($map)) {
         $randomorder = $map->randomorder();
         $randompick = $map->randompick();
+        unless ($randomorder || $randompick) {
+            foreach my $res ($navmap->retrieveResources($map,sub { $_[0]->is_map() },1,0,1)) {
+                if ($res->randomorder()) {
+                    $randomorder = 1;
+                }
+                if ($res->randompick()) {
+                    $randompick = 1;
+                }
+                last if ($randomorder || $randompick);
+            }
+        }
     } else {
         $r->print(&navmap_errormsg());
         return '';
@@ -8828,7 +8872,7 @@
     my $nav_error;
     my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
     if ($randomorder || $randompick) {
-        $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource);
+        $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource,1,\%symb_for_examcode);
         if ($nav_error) {
             $r->print(&navmap_errormsg());
             return '';
@@ -8975,11 +9019,16 @@
         }
 
         if (($scancode) && ($randomorder || $randompick)) {
-            my $parmresult =
-                &Apache::lonparmset::storeparm_by_symb($symb,
-                                                       '0_examcode',2,$scancode,
-                                                       'string_examcode',$uname,
-                                                       $udom);
+            foreach my $key (keys(%symb_for_examcode)) {
+                my $symb_in_map = $symb_for_examcode{$key};
+                if ($symb_in_map ne '') {
+                    my $parmresult =
+                        &Apache::lonparmset::storeparm_by_symb($symb_in_map,
+                                                               '0_examcode',2,$scancode,
+                                                               'string_examcode',$uname,
+                                                               $udom);
+                }
+            }
         }
 	$completedstudents{$uname}={'line'=>$line};
         if ($env{'form.verifyrecord'}) {
@@ -9618,6 +9667,17 @@
     if (ref($map)) {
         $randomorder=$map->randomorder();
         $randompick=$map->randompick();
+        unless ($randomorder || $randompick) {
+            foreach my $res ($navmap->retrieveResources($map,sub { $_[0]->is_map() },1,0,1)) {
+                if ($res->randomorder()) {
+                    $randomorder = 1;
+                }
+                if ($res->randompick()) {
+                    $randompick = 1;
+                }
+                last if ($randomorder || $randompick);
+            }
+        }
     }
     my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
     my $nav_error = &get_master_seq(\@resources,\@master_seq,\%symb_to_resource);
@@ -11280,8 +11340,8 @@
          - missingbubble - array ref of the bubble lines that have missing
                            bubble errors
 
-   $randomorder - True if exam folder has randomorder set
-   $randompick  - True if exam folder has randompick set
+   $randomorder - True if exam folder (or a sub-folder) has randomorder set
+   $randompick  - True if exam folder (or a sub-folder) has randompick set
    $respnumlookup - Reference to HASH mapping question numbers in bubble lines
                      for current line to question number used for same question
                      in "Master Seqence" (as seen by Course Coordinator).




More information about the LON-CAPA-cvs mailing list