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

www www@source.lon-capa.org
Mon, 15 Mar 2010 07:54:05 -0000


This is a MIME encoded message

--www1268639645
Content-Type: text/plain

www		Mon Mar 15 07:54:05 2010 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Saving my work: cleaning up grading interface. Currently defunct.
  
  
--www1268639645
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20100315075405.txt"

Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.597 loncom/homework/grades.pm:1.598
--- loncom/homework/grades.pm:1.597	Thu Mar 11 16:29:42 2010
+++ loncom/homework/grades.pm	Mon Mar 15 07:54:04 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.597 2010/03/11 16:29:42 wenzelju Exp $
+# $Id: grades.pm,v 1.598 2010/03/15 07:54:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -96,6 +96,9 @@
 
 #
 # --- Retrieve the parts from the metadata file.---
+# Returns an array of everything that the resources stores away
+#
+
 sub getpartlist {
     my ($symb,$errorref) = @_;
 
@@ -121,13 +124,17 @@
 }
 
 # --- Get the symbolic name of a problem and the url
+# Generate an error message if symb could not be found unless silent flag is set
+# Takes $env{'form.symb'} by default; if not present, takes $env{'form.url'} and tries to get symb from that
+#
+ 
 sub get_symb {
     my ($request,$silent) = @_;
     (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
     my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
     if ($symb eq '') { 
 	if (!$silent) {
-	    $request->print("Unable to handle ambiguous references:$url:.");
+	    $request->print(&mt("Unable to handle ambiguous references: [_1].",$url));
 	    return ();
 	}
     }
@@ -209,52 +216,52 @@
 
 #--- 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>'
+#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;
-}
+#                    .&Apache::loncommon::end_data_table_row();
+#       }
+#    }
+#    $result.=&Apache::loncommon::end_data_table();
+#    return $result,$responseType,$hdgrade,$partlist,$handgrade;
+#}
 
 sub reset_caches {
     &reset_analyze_cache();
@@ -732,7 +739,7 @@
 
 # ignore empty submissions (occuring when only files are sent)
 
-    unless ($uessay=~/\w+/) { return ''; }
+    unless ($uessay=~/\w+/s) { return ''; }
 
 # these will be returned. Do not care if not at least 50 percent similar
     my $limit=0.6;
@@ -878,7 +885,10 @@
 	.&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 ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes'));
+    my ($partlist,$handgrade,$responseType) = &response_type($symb
+#,$res_error
+    );
 
     my %lt = &Apache::lonlocal::texthash (
 		'multiple' => 'Please select a student or group of students before clicking on the Next button.',
@@ -921,7 +931,7 @@
     my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : '';
     my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : '';
     my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'.
-	"\n".$table;
+	"\n";
 	
     $gradeTable .= &Apache::lonhtmlcommon::start_pick_box();
     $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text'))
@@ -2268,7 +2278,9 @@
 	}
 	$request->print($lastsubonly);
    } elsif ($env{'form.lastSub'} eq 'datesub') {
-	my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
+#	my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
+    my ($parts,$handgrade,$responseType) = &response_type($symb);
+
 	$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
     } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) {
 	$request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
@@ -2664,7 +2676,7 @@
 
 # Go directly to grade student - from submission or link from chart page
     if ($button eq 'Grade Student') {
-	(undef,undef,$env{'form.handgrade'},undef,undef) = &showResourceInfo($symb);
+#	(undef,undef,$env{'form.handgrade'},undef,undef) = &showResourceInfo($symb);
 	my $processUser = $env{'form.unamedom'.$env{'form.studentNo'}};
 	($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser);
 	$env{'form.fullname'} = $$fullname{$processUser};
@@ -3894,7 +3906,8 @@
 	$javascript=&csvupload_javascript_forward_associate();
     }
 
-    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+#    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+    my $result='';
     my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
     my $ignore=&mt('Ignore First Line');
     $symb = &Apache::lonenc::check_encrypt($symb);
@@ -3985,8 +3998,8 @@
     if (!$symb) {return '';}
     my $result=&checkforfile_js();
     $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
-    my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
-    $result.=$table;
+#    my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
+#    $result.=$table;
     $result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n";
     $result.='<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>'.&mt('Specify a file containing the class scores for current resource.').
@@ -8519,19 +8532,26 @@
     my ($symb)=&get_symb($request);
     if (!$symb) {return '';}
     my $probTitle = &Apache::lonnet::gettitle($symb);
-    my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle);
 
-    $request->print($table);
+#    $request->print($table);
     my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb),
-                  'handgrade'=>$hdgrade,
                   'probTitle'=>$probTitle,
-                  'command'=>'submit_options',
+                  'command'=>'individual',
                   'saveState'=>"",
                   'gradingMenu'=>1,
                   'showgrading'=>"yes");
     
-    my $url1 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
-    
+    my $url1a = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
+    $fields{'command'}='ungraded';
+    my $url1b=&Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
+    $fields{'command'}='table';
+    my $url1c=&Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
+    $fields{'command'}='all_for_one';
+    my $url1d=&Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
     $fields{'command'} = 'csvform';
     my $url2 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
     
@@ -8541,14 +8561,36 @@
     $fields{'command'} = 'scantron_selectphase';
     my $url4 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
     
-    my @menu = ({	categorytitle=>'Course Grading',
+    my @menu = ({	categorytitle=>'Hand Grading',
             items =>[
-                        {	linktext => 'Manual Grading/View Submissions',
-                    		url => $url1,
+                        {	linktext => 'Select individual students to grade',
+                    		url => $url1a,
                     		permission => 'F',
                     		icon => 'edit-find-replace.png',
-                    		linktitle => 'Start the process of hand grading submissions.'
+                    		linktitle => 'Grade current resource for a selection of students.'
+                        }, 
+                        {       linktext => 'Grade ungraded submissions.',
+                                url => $url1b,
+                                permission => 'F',
+                                icon => 'edit-find-replace.png',
+                                linktitle => 'Grade all submissions that have not been graded yet.'
                         },
+
+                        {       linktext => 'Grading table',
+                                url => $url1c,
+                                permission => 'F',
+                                icon => 'edit-find-replace.png',
+                                linktitle => 'Grade current resource for all students.'
+                        },
+                        {       linktext => 'Grade complete page/sequence/folder for one student.',
+                                url => $url1d,
+                                permission => 'F',
+                                icon => 'edit-find-replace.png',
+                                linktitle => 'Grade all resources in current page/sequence/folder for one student.'
+                        }]},
+                         { categorytitle=>'Automated Grading',
+               items =>[
+
                 	    {	linktext => 'Upload Scores',
                     		url => $url2,
                     		permission => 'F',
@@ -8579,7 +8621,7 @@
     $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="handgrade"   value="'.$hdgrade.'" />'."\n".
 	'<input type="hidden" name="probTitle"   value="'.$probTitle.'" />'."\n".
 	'<input type="hidden" name="saveState"   value="" />'."\n".
 	'<input type="hidden" name="gradingMenu" value="1" />'."\n".
@@ -8633,6 +8675,26 @@
     return $Str;    
 }
 
+sub individual {
+    my ($request)=@_;
+    &submit_options($request);
+}
+
+sub ungraded {
+    my ($request)=@_;
+    &submit_options($request);
+}
+
+sub table {
+    my ($request)=@_;
+    &submit_options($request);
+}
+
+sub all_for_one {
+    my ($request)=@_;
+    &submit_options($request);
+}
+
 
 #--- Displays the submissions first page -------
 sub submit_options {
@@ -8677,7 +8739,7 @@
     }
 GRADINGMENUJS
     &commonJSfunctions($request);
-    my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle);
+#    my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle);
     my $result;
     my (undef,$sections) = &getclasslist('all','0');
     my $savedState = &savedState();
@@ -8697,7 +8759,7 @@
 
     $result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".
 	'<input type="hidden" name="symb"        value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
-	'<input type="hidden" name="handgrade"   value="'.$hdgrade.'" />'."\n".
+#	'<input type="hidden" name="handgrade"   value="'.$hdgrade.'" />'."\n".
 	'<input type="hidden" name="probTitle"   value="'.$probTitle.'" />'."\n".
 	'<input type="hidden" name="command"     value="" />'."\n".
 	'<input type="hidden" name="saveState"   value="" />'."\n".
@@ -8708,9 +8770,6 @@
 <h2>
   '.&mt('Grade Current Resource').'
 </h2>
-<div>
-  '.$table.'
-</div>
 
 <div class="LC_columnSection">
   
@@ -8884,8 +8943,8 @@
     if (!$symb) {return '';}
     my $result=&checkforfile_js();
     $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
-    my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
-    $result.=$table;
+#    my ($table) = &showResourceInfo($symb,$env{'form.probTitle'});
+#    $result.=$table;
     $result.='<br /><table width="100%" border="0"><tr><td bgcolor="#777777">'."\n";
     $result.='<table width="100%" border="0"><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>'.&mt('Specify a file containing the clicker information for this resource.').
@@ -8994,8 +9053,8 @@
     my %Saveable_Parameters=&clicker_grading_parameters();
     &Apache::loncommon::store_course_settings('grades_clicker',
                                               \%Saveable_Parameters);
-
-    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+    my $result='';
+#    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
     if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) {
 	$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>';
 	return $result.&show_grading_menu_form($symb);
@@ -9234,7 +9293,8 @@
 # FIXME: This should probably look for the first handgradeable part
     my $part=$$partlist[0];
 # Start screen output
-    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+    my $result='';
+#    my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
 
     my $heading=&mt('Assigning grades based on clicker file');
     $result.=(<<ENDHEADER);
@@ -9404,8 +9464,14 @@
 	    &processGroup($request);
 	} elsif ($command eq 'gradingmenu' && $perm{'vgr'}) {
 	    $request->print(&grading_menu($request));
-	} elsif ($command eq 'submit_options' && $perm{'vgr'}) {
-	    $request->print(&submit_options($request));
+	} elsif ($command eq 'individual' && $perm{'vgr'}) {
+	    $request->print(&individual($request));
+        } elsif ($command eq 'ungraded' && $perm{'vgr'}) {
+            $request->print(&submit_options($request));
+        } elsif ($command eq 'table' && $perm{'vgr'}) {
+            $request->print(&submit_options($request));
+        } elsif ($command eq 'all_for_one' && $perm{'vgr'}) {
+            $request->print(&submit_options($request));
 	} elsif ($command eq 'viewgrades' && $perm{'vgr'}) {
 	    $request->print(&viewgrades($request));
 	} elsif ($command eq 'handgrade' && $perm{'mgr'}) {

--www1268639645--