--- loncom/homework/grades.pm	2012/12/18 18:05:35	1.683
+++ loncom/homework/grades.pm	2013/06/01 00:22:42	1.689
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.683 2012/12/18 18:05:35 raeburn Exp $
+# $Id: grades.pm,v 1.689 2013/06/01 00:22:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3101,7 +3101,7 @@ sub handback_files {
                         &Apache::lonnet::dirlist($portfolio_root.$portfolio_path,
                                                  $domain,$stuname,$getpropath);
 		    my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
-                    # fix file name
+                    # fix filename
                     my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
                     my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
             	                                $newflg.'_'.$part_resp.'_returndoc'.$counter,
@@ -3120,7 +3120,7 @@ sub handback_files {
                         $$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name;
 			$file_msg.= '<span class="LC_filename"><a href="/uploaded/'."$domain/$stuname/".$save_file_name.'">'.$save_file_name."</a></span> <br />";
                     }
-                    $request->print('<br />'.&mt('[_1] will be the uploaded file name [_2]','<span class="LC_info">'.$fname.'</span>','<span class="LC_filename">'.$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter}.'</span>'));
+                    $request->print('<br />'.&mt('[_1] will be the uploaded filename [_2]','<span class="LC_info">'.$fname.'</span>','<span class="LC_filename">'.$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter}.'</span>'));
                 }
             }
         }
@@ -7006,7 +7006,7 @@ sub scantron_validate_sequence {
 	    $r->print(
                 '<p class="LC_warning">'
                .&mt('Some resources in the sequence currently are not set to'
-                   .' exam mode. Grading these resources currently may not'
+                   .' bubblesheet exam mode. Grading these resources currently may not'
                    .' work correctly.')
                .'</p>'
             );
@@ -7140,7 +7140,7 @@ sub scantron_get_correction {
 	$r->print(&Apache::loncommon::selectstudent_link('scantronupload',
 				       'scantron_username','scantron_domain'));
 	$r->print(": <input type='text' name='scantron_username' value='' />");
-	$r->print("\n@".
+	$r->print("\n:\n".
 		 &Apache::loncommon::select_dom_form($env{'request.role.domain'},'scantron_domain'));
 
 	$r->print('</li>');
@@ -7400,7 +7400,16 @@ sub prompt_for_corrections {
             ($responsetype_per_response{$question-1} eq 'imageresponse') ||
             ($responsetype_per_response{$question-1} eq 'reactionresponse') ||
             ($responsetype_per_response{$question-1} eq 'organicresponse')) {
-            $r->print(&mt("Although this particular question type requires handgrading, the instructions for this question in the exam directed students to leave [quant,_1,line] blank on their bubblesheets.",$lines).'<br /><br />'.&mt('A non-zero score can be assigned to the student during bubblesheet grading by selecting a bubble in at least one line.').'<br />'.&mt('The score for this question will be a sum of the numeric values for the selected bubbles from each line, where A=1 point, B=2 points etc.').'<br />'.&mt("To assign a score of zero for this question, mark all lines as 'No bubble'.").'<br /><br />');
+            $r->print(
+                &mt("Although this particular question type requires handgrading, the instructions for this question in the bubblesheet exam directed students to leave [quant,_1,line] blank on their bubblesheets.",$lines)
+               .'<br /><br />'
+               .&mt('A non-zero score can be assigned to the student during bubblesheet grading by selecting a bubble in at least one line.')
+               .'<br />'
+               .&mt('The score for this question will be a sum of the numeric values for the selected bubbles from each line, where A=1 point, B=2 points etc.')
+               .'<br />'
+               .&mt("To assign a score of zero for this question, mark all lines as 'No bubble'.")
+               .'<br /><br />'
+            );
         } else {
             $r->print(&mt("Select at most one bubble in a single line and select 'No Bubble' in all the other lines. ")."<br />");
         }
@@ -7914,9 +7923,10 @@ sub scantron_process_students {
         return '';
     }  
     my $map=$navmap->getResourceByUrl($sequence);
-    my $randomorder;
+    my ($randomorder,$randompick);
     if (ref($map)) {
         $randomorder = $map->randomorder();
+        $randompick = $map->randompick();
     }
     my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
     my (%grader_partids_by_symb,%grader_randomlists_by_symb,%ordered);
@@ -8025,7 +8035,7 @@ SCANTRONFORM
         }
 
         my @mapresources = @resources;
-        if ($randomorder) {
+        if ($randomorder || $randompick) {
             @mapresources = 
                 &users_order($user,$scancode,$sequence,\@master_seq,\%ordered,
                              \%symb_to_resource);
@@ -8205,7 +8215,7 @@ sub users_order  {
         my $actual_seq =
             &Apache::lonprintout::master_seq_to_person_seq($mapurl,
                                                            $master_seq,
-                                                           $user,$scancode);
+                                                           $user,$scancode,1);
         if (ref($actual_seq) eq 'ARRAY') {
             @{$ordered->{$scancode}} =
                 map { $symb_to_resource->{$_}; } @{$actual_seq};
@@ -8216,7 +8226,7 @@ sub users_order  {
         my $actual_seq =
             &Apache::lonprintout::master_seq_to_person_seq($mapurl,
                                                            $master_seq,
-                                                           $user);
+                                                           $user,undef,1);
         if (ref($actual_seq) eq 'ARRAY') {
             @mapresources = 
                 map { $symb_to_resource->{$_}; } @{$actual_seq};
@@ -8480,7 +8490,7 @@ sub scantron_download_scantron_data {
     if (! &valid_file($file)) {
 	$r->print('
 	<p>
-	    '.&mt('The requested file name was invalid.').'
+	    '.&mt('The requested filename was invalid.').'
         </p>
 ');
 	return;
@@ -8530,9 +8540,10 @@ sub checkscantron_results {
         return '';
     }
     my $map=$navmap->getResourceByUrl($sequence);
-    my ($randomorder,@master_seq,%symb_to_resource);
+    my ($randomorder,$randompick,@master_seq,%symb_to_resource);
     if (ref($map)) { 
         $randomorder=$map->randomorder();
+        $randompick=$map->randompick();
     }
     my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
     foreach my $resource (@resources) {
@@ -8610,7 +8621,7 @@ sub checkscantron_results {
         }
 
         my @mapresources = @resources;
-        if ($randomorder) {
+        if ($randomorder || $randompick) {
             @mapresources =
                 &users_order($user,$scancode,$sequence,\@master_seq,\%ordered,
                              \%symb_to_resource);
@@ -9748,6 +9759,7 @@ sub handler {
         }
     } elsif (!%perm) {
         $request->internal_redirect('/adm/quickgrades');
+        return OK;
     }
     &Apache::loncommon::content_type($request,'text/html');
     $request->send_http_header;