--- loncom/homework/grades.pm 2010/03/11 16:29:42 1.597
+++ loncom/homework/grades.pm 2011/01/23 01:04:21 1.643
@@ -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.643 2011/01/23 01:04:21 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,6 +43,8 @@ use Apache::lonmsg();
use Apache::Constants qw(:common);
use Apache::lonlocal;
use Apache::lonenc;
+use Apache::lonstathelpers;
+use Apache::lonquickgrades;
use String::Similarity;
use LONCAPA;
@@ -96,6 +98,9 @@ sub ssi_print_error {
#
# --- Retrieve the parts from the metadata file.---
+# Returns an array of everything that the resources stores away
+#
+
sub getpartlist {
my ($symb,$errorref) = @_;
@@ -120,21 +125,6 @@ sub getpartlist {
return @stores;
}
-# --- Get the symbolic name of a problem and the url
-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:.");
- return ();
- }
- }
- &Apache::lonenc::check_decrypt(\$symb);
- return ($symb);
-}
-
#--- Format fullname, username:domain if different for display
#--- Use anywhere where the student names are listed
sub nameUserString {
@@ -149,6 +139,7 @@ sub nameUserString {
#--- Get the partlist and the response type for a given problem. ---
#--- Indicate if a response type is coded handgraded or not. ---
+#--- Sets response_error pointer to "1" if navmaps object broken ---
sub response_type {
my ($symb,$response_error) = @_;
@@ -207,55 +198,6 @@ sub get_display_part {
return $display;
}
-#--- Show resource title
-#--- and parts and response type
-sub showResourceInfo {
- my ($symb,$probTitle,$checkboxes,$res_error) = @_;
- my $result = '
'.&mt('Current Resource').': '.$probTitle.'
'."\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.='
';
- }
- $result.='
'.&mt('Problem Part').'
'
- .'
'.&mt('Res. ID').'
'
- .'
'.&mt('Type').'
'
- .&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.="
'."\n";
+ &mt('Verifying Receipt Number [_1]',$receipt).
+ ''."\n";
my ($string,$contents,$matches) = ('','',0);
my (undef,undef,$fullname) = &getclasslist('all','0');
@@ -854,7 +814,7 @@ sub verifyreceipt {
$contents.
&Apache::loncommon::end_data_table()."\n";
}
- return $string.&show_grading_menu_form($symb);
+ return $string;
}
#--- This is called by a number of programs.
@@ -862,23 +822,19 @@ sub verifyreceipt {
#--- Also called directly when one clicks on the subm button
# on the problem page.
sub listStudents {
- my ($request) = shift;
+ my ($request,$symb,$submitonly) = @_;
- my ($symb) = &get_symb($request);
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'};
- my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
- my $viewgrade = $env{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
- $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ?
- &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
-
- my $result='
'
- .&mt("$viewgrade Submissions for a Student or a Group of Students")
- .'
';
+ unless ($submitonly) {
+ $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
+ }
- my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes'));
+ my $result='';
+ my $res_error;
+ 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.',
@@ -918,10 +874,8 @@ LISTJAVASCRIPT
&commonJSfunctions($request);
$request->print($result);
- my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : '';
- my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : '';
my $gradeTable='';
+ return $result;
}
+sub submit_options_download {
+ my ($request,$symb) = @_;
+ if (!$symb) {return '';}
+
+ &commonJSfunctions($request);
+
+ my $result='
'."\n".
+ ''."\n";
+ $result.='
+
+ '.&mt('Select Students for Which to Download Submissions').'
+
'.&selectfield(1).'
+
+
+
+
+
+
+
';
+ return $result;
+}
#--- Displays the submissions first page -------
sub submit_options {
- my ($request) = @_;
- my ($symb)=&get_symb($request);
+ my ($request,$symb) = @_;
if (!$symb) {return '';}
- my $probTitle = &Apache::lonnet::gettitle($symb);
- my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box.");
- $request->print(&Apache::lonhtmlcommon::scripttag(<'.$section.''."\n";
- }
- }
$result.='
\n";
# Attempt to restore parameters from last session, set defaults if not present
my %Saveable_Parameters=&clicker_grading_parameters();
&Apache::loncommon::restore_course_settings('grades_clicker',
@@ -8907,7 +8738,7 @@ sub process_clicker {
}
}
- my $upload=&mt("Upload File");
+ my $upload=&mt("Evaluate File");
my $type=&mt("Type");
my $attendance=&mt("Award points just for participation");
my $personnel=&mt("Correctness determined from response by course personnel");
@@ -8917,8 +8748,8 @@ sub process_clicker {
my $pcorrect=&mt("Percentage points for correct solution");
my $pincorrect=&mt("Percentage points for incorrect solution");
my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
- ('iclicker' => 'i>clicker',
- 'interwrite' => 'interwrite PRS'));
+ {'iclicker' => 'i>clicker',
+ 'interwrite' => 'interwrite PRS'});
$symb = &Apache::lonenc::check_encrypt($symb);
$result.= &Apache::lonhtmlcommon::scripttag(<
-
-
-
+ENDUPFORM
+ $result.='
'."\n";
- $result.=&show_grading_menu_form($symb);
+ENDPERCFORM
+ $result.=''.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table();
return $result;
}
sub process_clicker_file {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
my %Saveable_Parameters=&clicker_grading_parameters();
&Apache::loncommon::store_course_settings('grades_clicker',
\%Saveable_Parameters);
-
- my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+ my $result='';
if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) {
$result.=''.&mt('You need to specify a clicker ID for the correct answer').'';
- return $result.&show_grading_menu_form($symb);
+ return $result;
}
if (($env{'form.gradingmechanism'} eq 'given') && ($env{'form.givenanswer'}!~/\S/)) {
$result.=''.&mt('You need to specify the correct answer').'';
- return $result.&show_grading_menu_form($symb);
+ return $result;
}
my $foundgiven=0;
if ($env{'form.gradingmechanism'} eq 'given') {
@@ -9049,7 +8882,7 @@ sub process_clicker_file {
$result.="\n";
if ($number==0) {
$result.=''.&mt('No IDs found to determine correct answer').'';
- return $result.&show_grading_menu_form($symb);
+ return $result;
}
}
if (length($env{'form.upfile'}) < 2) {
@@ -9057,23 +8890,22 @@ sub process_clicker_file {
'',
'',
''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'');
- return $result.&show_grading_menu_form($symb);
+ return $result;
}
# Were able to get all the info needed, now analyze the file
$result.=&Apache::loncommon::studentbrowser_javascript();
$symb = &Apache::lonenc::check_encrypt($symb);
- my $heading=&mt('Scanning clicker file');
- $result.=(<
-
-
@@ -9098,7 +8930,7 @@ ENDHEADER
' ';
if (($env{'form.gradingmechanism'} eq 'given') && ($number!=$foundgiven)) {
$result.=''.&mt('Number of given answers does not agree with number of questions in file.').'';
- return $result.&show_grading_menu_form($symb);
+ return $result;
}
# Remember Question Titles
# FIXME: Possibly need delimiter other than ":"
@@ -9118,7 +8950,9 @@ ENDHEADER
} elsif ($clicker_ids{$id}) {
if ($clicker_ids{$id}=~/\,/) {
# More than one user with the same clicker!
- $result.="\n".&mt('Clicker registered more than once').": ".$id." ";
+ $result.="".&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::start_data_table_row()."
".
+ &mt('Clicker registered more than once').": ".$id." ";
$result.="\n".''.
"
'.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table();
+ return $result;
}
sub iclicker_eval {
@@ -9222,8 +9059,7 @@ sub interwrite_eval {
}
sub assign_clicker_grades {
- my ($r)=@_;
- my ($symb)=&get_symb($r);
+ my ($r,$symb)=@_;
if (!$symb) {return '';}
# See which part we are saving to
my $res_error;
@@ -9234,14 +9070,11 @@ sub assign_clicker_grades {
# 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 $heading=&mt('Assigning grades based on clicker file');
- $result.=(<
-
-$heading
-ENDHEADER
+ my $result=&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
';
# Get correct result
# FIXME: Possibly need delimiter other than ":"
my @correct=();
@@ -9276,6 +9109,7 @@ ENDHEADER
my $pcorrect=$env{'form.pcorrect'};
my $pincorrect=$env{'form.pincorrect'};
my $storecount=0;
+ my %users=();
foreach my $key (keys(%env)) {
my $user='';
if ($key=~/^form\.student\:(.*)$/) {
@@ -9289,7 +9123,13 @@ ENDHEADER
$user=$env{'form.multi'.$id};
}
}
- if ($user) {
+ if ($user) {
+ if ($users{$user}) {
+ $result.=' '.
+ &mt("More than one entry found for [_1]!",$user).
+ ' ';
+ }
+ $users{$user}=1;
my @answer=split(/\,/,$env{$key});
my $sum=0;
my $realnumber=$number;
@@ -9329,9 +9169,10 @@ ENDHEADER
}
# We are done
$result.=' '.&mt('Successfully stored grades for [quant,_1,student].',$storecount).
- '