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

www www@source.lon-capa.org
Thu, 25 Mar 2010 19:56:34 -0000


www		Thu Mar 25 19:56:34 2010 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Work in progress: cleaning up grades.pm
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.601 loncom/homework/grades.pm:1.602
--- loncom/homework/grades.pm:1.601	Sun Mar 21 18:31:45 2010
+++ loncom/homework/grades.pm	Thu Mar 25 19:56:33 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.601 2010/03/21 18:31:45 www Exp $
+# $Id: grades.pm,v 1.602 2010/03/25 19:56:33 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -214,55 +214,6 @@
     return $display;
 }
 
-#--- Show resource title
-#--- and parts and response type
-#sub showResourceInfo {
-#    my ($symb,$probTitle,$checkboxes,$res_error) = @_;
-#    my $result = '<h3>'.&mt('Current Resource').': '.$probTitle.'</h3>'."\n";
-#    my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error);
-#    if (ref($res_error)) {
-#        if ($$res_error) {
-#            return;
-#        }
-#    }
-#    $result.=&Apache::loncommon::start_data_table()
-#            .&Apache::loncommon::start_data_table_header_row();
-#    if ($checkboxes) {
-#        $result.='<th>&nbsp;</th>';
-#    }
-#    $result.='<th>'.&mt('Problem Part').'</th>'
-#            .'<th>'.&mt('Res. ID').'</th>'
-#            .'<th>'.&mt('Type').'</th>'
-#            .&Apache::loncommon::end_data_table_header_row();
-#    my %resptype = ();
-#    my $hdgrade='no';
-#    my %partsseen;
-#    foreach my $partID (sort(keys(%$responseType))) {
-#        foreach my $resID (sort(keys(%{ $responseType->{$partID} }))) {
-#            my $handgrade=$$handgrade{$partID.'_'.$resID};
-#            my $responsetype = $responseType->{$partID}->{$resID};
-#            $hdgrade = $handgrade if ($handgrade eq 'yes');
-#            $result.=&Apache::loncommon::start_data_table_row();
-#            if ($checkboxes) {
-#                if (exists($partsseen{$partID})) {
-#                    $result.="<td>&nbsp;</td>";
-#                } else {
-#                    $result.="<td><input type='checkbox' name='vPart' value='$partID' checked='checked' /></td>";
-#                }
-#                $partsseen{$partID}=1;
-#            }
-#            my $display_part=&get_display_part($partID,$symb);
-#            $result.='<td>'.$display_part.'</td>'
-#                    .'<td>'.'<span class="LC_internal_info">'.$resID.'</span></td>'
-#                    .'<td>'.&mt($responsetype).'</td>'
-#                   .'<td>'.&mt('<b>Handgrade: </b>[_1]',$handgrade).'</td>'
-#                    .&Apache::loncommon::end_data_table_row();
-#       }
-#    }
-#    $result.=&Apache::loncommon::end_data_table();
-#    return $result,$responseType,$hdgrade,$partlist,$handgrade;
-#}
-
 sub reset_caches {
     &reset_analyze_cache();
     &reset_perm();
@@ -776,6 +727,16 @@
 
 #------------------------------------ Receipt Verification Routines
 #
+
+sub initialverifyreceipt {
+   my $request = shift;
+   &commonJSfunctions($request);
+   $request->print('<form name="gradingMenu"><input type="submit" value="'.&mt('Verify Receipt No.').'" />'.
+        &Apache::lonnet::recprefix($env{'request.course.id'}).
+        '-<input type="text" name="receipt" size="4" />'.
+        "</form>\n");
+}
+
 #--- Check whether a receipt number is valid.---
 sub verifyreceipt {
     my $request  = shift;
@@ -885,7 +846,6 @@
 	.&mt("$viewgrade Submissions for a Student or a Group of Students")
 	.'</span></h3>';
 
-#    my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes'));
     my ($partlist,$handgrade,$responseType) = &response_type($symb
 #,$res_error
     );
@@ -8521,7 +8481,6 @@
     if (!$symb) {return '';}
     my $probTitle = &Apache::lonnet::gettitle($symb);
 
-#    $request->print($table);
     my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb),
                   'probTitle'=>$probTitle,
                   'command'=>'individual',
@@ -8547,6 +8506,9 @@
     
     $fields{'command'} = 'scantron_selectphase';
     my $url4 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
+    $fields{'command'} = 'initialverifyreceipt';
+    my $url5 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
     
     my @menu = ({	categorytitle=>'Hand Grading',
             items =>[
@@ -8595,69 +8557,27 @@
                     		permission => 'F',
                     		icon => 'stat.png',
                     		linktitle => 'Grade scantron exams, upload/download scantron data files, and review previously graded scantron exams.'
-                	    }
+                	    },
+                            {   linktext => 'Verify Receipt No.',
+                                url => $url5,
+                                permission => 'F',
+                                icon => 'edit-find-replace.png',
+                                linktitle => 'Verify a system-generated receipt number for correct problem solution.'
+                            }
+
                     ]
             });
 
-    #$fields{'command'} = 'verify';
-    #$url = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    #
     # Create the menu
     my $Str;
-    # $Str .= '<h2>'.&mt('Please select a grading task').'</h2>';
     $Str .= '<form method="post" action="" name="gradingMenu">';
     $Str .= '<input type="hidden" name="command" value="" />'.
     	'<input type="hidden" name="symb"        value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
-#	'<input type="hidden" name="handgrade"   value="'.$hdgrade.'" />'."\n".
 	'<input type="hidden" name="probTitle"   value="'.$probTitle.'" />'."\n".
 	'<input type="hidden" name="gradingMenu" value="1" />'."\n".
 	'<input type="hidden" name="showgrading" value="yes" />'."\n";
 
-    $Str .= Apache::lonhtmlcommon::generate_menu(@menu);
-    #$menudata->{'jscript'}
-    $Str .='<hr /><input type="button" value="'.&mt('Verify Receipt No.').'" '.
-        ' onclick="javascript:checkChoice(document.forms.gradingMenu,\'5\',\'verify\')" '.
-        ' /> '.
-        &Apache::lonnet::recprefix($env{'request.course.id'}).
-        '-<input type="text" name="receipt" size="4" onchange="javascript:checkReceiptNo(this.form,\'OK\')" />';
-
-    $Str .="</form>\n";
-    my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box.");
-    $request->print(&Apache::lonhtmlcommon::scripttag(<<GRADINGMENUJS));
-    function checkChoice(formname,val,cmdx) {
-	if (val <= 2) {
-	    var cmd = radioSelection(formname.radioChoice);
-	    var cmdsave = cmd;
-	} else {
-	    cmd = cmdx;
-	    cmdsave = 'submission';
-	}
-	formname.command.value = cmd;
-	if (val < 5) formname.submit();
-	if (val == 5) {
-	    if (!checkReceiptNo(formname,'notOK')) { 
-	        return false;
-	    } else {
-	        formname.submit();
-	    }
-	}
-    }
-
-    function checkReceiptNo(formname,nospace) {
-	var receiptNo = formname.receipt.value;
-	var checkOpt = false;
-	if (nospace == "OK" && isNaN(receiptNo)) {checkOpt = true;}
-	if (nospace == "notOK" && (isNaN(receiptNo) || receiptNo == "")) {checkOpt = true;}
-	if (checkOpt) {
-	    alert("$receiptalert");
-	    formname.receipt.value = "";
-	    formname.receipt.focus();
-	    return false;
-	}
-	return true;
-    }
-GRADINGMENUJS
-    &commonJSfunctions($request);
+    $Str .= &Apache::lonhtmlcommon::generate_menu(@menu);
     return $Str;    
 }
 
@@ -9399,6 +9319,8 @@
 	    $request->print(&processHandGrade($request));
 	} elsif ($command eq 'editgrades' && $perm{'mgr'}) {
 	    $request->print(&editgrades($request));
+        } elsif ($command eq 'initialverifyreceipt' && $perm{'vgr'}) {
+            $request->print(&initialverifyreceipt($request));
 	} elsif ($command eq 'verify' && $perm{'vgr'}) {
 	    $request->print(&verifyreceipt($request));
         } elsif ($command eq 'processclicker' && $perm{'mgr'}) {