--- loncom/homework/grades.pm 2010/04/22 13:00:24 1.630
+++ loncom/homework/grades.pm 2011/02/07 19:16:28 1.645
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.630 2010/04/22 13:00:24 www Exp $
+# $Id: grades.pm,v 1.645 2011/02/07 19:16:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,6 +44,7 @@ use Apache::Constants qw(:common);
use Apache::lonlocal;
use Apache::lonenc;
use Apache::lonstathelpers;
+use Apache::lonquickgrades;
use String::Similarity;
use LONCAPA;
@@ -212,8 +213,13 @@ sub reset_caches {
}
sub get_analyze {
- my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_;
+ my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed)=@_;
my $key = "$symb\0$uname\0$udom";
+ if ($type eq 'randomizetry') {
+ if ($trial ne '') {
+ $key .= "\0".$trial;
+ }
+ }
if (exists($analyze_cache{$key})) {
my $getupdate = 0;
if (ref($add_to_hash) eq 'HASH') {
@@ -241,9 +247,15 @@ sub reset_caches {
'grade_courseid' => $env{'request.course.id'},
'grade_username' => $uname,
'grade_noincrement' => $no_increment);
+ if ($type eq 'randomizetry') {
+ $form{'grade_questiontype'} = $type;
+ if ($rndseed ne '') {
+ $form{'grade_rndseed'} = $rndseed;
+ }
+ }
if (ref($add_to_hash)) {
%form = (%form,%{$add_to_hash});
- }
+ }
my $subresult=&ssi_with_retries($url, $ssi_retries,%form);
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
my %analyze=&Apache::lonnet::str2hash($subresult);
@@ -256,15 +268,15 @@ sub reset_caches {
}
sub get_order {
- my ($partid,$respid,$symb,$uname,$udom,$no_increment)=@_;
- my $analyze = &get_analyze($symb,$uname,$udom,$no_increment);
+ my ($partid,$respid,$symb,$uname,$udom,$no_increment,$type,$trial,$rndseed)=@_;
+ my $analyze = &get_analyze($symb,$uname,$udom,$no_increment,undef,$type,$trial,$rndseed);
return $analyze->{"$partid.$respid.shown"};
}
sub get_radiobutton_correct_foil {
- my ($partid,$respid,$symb,$uname,$udom)=@_;
- my $analyze = &get_analyze($symb,$uname,$udom);
- my $foils = &get_order($partid,$respid,$symb,$uname,$udom);
+ my ($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed)=@_;
+ my $analyze = &get_analyze($symb,$uname,$udom,undef,undef,$type,$trial,$rndseed);
+ my $foils = &get_order($partid,$respid,$symb,$uname,$udom,undef,$type,$trial,$rndseed);
if (ref($foils) eq 'ARRAY') {
foreach my $foil (@{$foils}) {
if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') {
@@ -306,7 +318,7 @@ sub reset_caches {
# response types only.
sub cleanRecord {
my ($answer,$response,$symb,$partid,$respid,$record,$order,$version,
- $uname,$udom) = @_;
+ $uname,$udom,$type,$trial,$rndseed) = @_;
my $grayFont = '';
if ($response =~ /^(option|rank)$/) {
my %answer=&Apache::lonnet::str2hash($answer);
@@ -350,7 +362,7 @@ sub cleanRecord {
my %answer=&Apache::lonnet::str2hash($answer);
my ($toprow,$bottomrow);
my $correct =
- &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom);
+ &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed);
foreach my $foil (@$order) {
if (exists($answer{$foil})) {
if ($foil eq $correct) {
@@ -820,9 +832,7 @@ sub listStudents {
$submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
}
- my $result=' '
- .&mt("View/Grade/Regrade Submissions for a Student or a Group of Students")
- .'
';
+ my $result='';
my $res_error;
my ($partlist,$handgrade,$responseType) = &response_type($symb,\$res_error);
@@ -1269,12 +1279,6 @@ sub sub_page_js {
}
}
- if (val == "Grade Student") {
- if (formname.Status.value == "") {
- formname.Status.value = "Active";
- }
- formname.studentNo.value = total;
- }
formname.submit();
}
@@ -1913,7 +1917,6 @@ sub submission {
if ($counter == 0) {
&sub_page_js($request);
&sub_page_kw_js($request);
- $request->print(' '.&mt('Submission Record').'
');
# option to display problem, only once else it cause problems
# with the form later since the problem has a form.
@@ -2141,6 +2144,12 @@ KEYWORDS
my ($ressub,$hide,$subval) = split(/:/,$submission,3);
# Similarity check
my $similar='';
+ my ($type,$trial,$rndseed);
+ if ($hide eq 'rand') {
+ $type = 'randomizetry';
+ $trial = $record{"resource.$partid.tries"};
+ $rndseed = $record{"resource.$partid.rndseed"};
+ }
if($env{'form.checkPlag'}){
my ($oname,$odom,$ocrsid,$oessay,$osim)=
&most_similar($uname,$udom,$subval,\%old_essays);
@@ -2150,7 +2159,7 @@ KEYWORDS
&Apache::lonnet::coursedescription($ocrsid,
{'one_time' => 1});
- if ($hide) {
+ if ($hide eq 'anon') {
$similar='
'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'
'.
&mt('As the current submission is for an anonymous survey, no other details are available.').'
';
} else {
@@ -2167,7 +2176,8 @@ KEYWORDS
}
}
}
- my $order=&get_order($partid,$respid,$symb,$uname,$udom);
+ my $order=&get_order($partid,$respid,$symb,$uname,$udom,
+ undef,$type,$trial,$rndseed);
if ($env{'form.lastSub'} eq 'lastonly' ||
($env{'form.lastSub'} eq 'hdgrade' &&
$$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
@@ -2179,7 +2189,7 @@ KEYWORDS
' ';
my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
if (@$files) {
- if ($hide) {
+ if ($hide eq 'anon') {
$lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files}));
} else {
$lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
';
@@ -2190,12 +2200,12 @@ KEYWORDS
}
$lastsubonly.='
';
}
- if ($hide) {
+ if ($hide eq 'anon') {
$lastsubonly.=''.&mt('Anonymous Survey').'';
} else {
$lastsubonly.=''.&mt('Submitted Answer:').' '.
&cleanRecord($subval,$responsetype,$symb,$partid,
- $respid,\%record,$order,undef,$uname,$udom);
+ $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed);
}
if ($similar) {$lastsubonly.="
$similar\n";}
$lastsubonly.='';
@@ -2217,13 +2227,8 @@ KEYWORDS
$request->print(''."\n");
# return if view submission with no grading option
-# FIXME: the logic seems off here. Why show the grade button if you cannot grade?
if (!&canmodify($usec)) {
- my $toGrade.=' '."\n" if (&canmodify($usec));
- $toGrade.=''."\n";
- $request->print($toGrade);
+ $request->print('
'.&mt('No grading privileges').'
'); return; } else { $request->print(''."\n"); @@ -2344,7 +2349,7 @@ sub check_collaborators { (split(/[,;\s]+/,$record->{'resource.'.$part.'.collaborators'})) { $possible_collaborator =~ s/[\$\^\(\)]//g; next if ($possible_collaborator eq ''); - my ($co_name,$co_dom) = split(/\@|:/,$possible_collaborator); + my ($co_name,$co_dom) = split(/:/,$possible_collaborator); $co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i); next if ($co_name eq $uname && $co_dom eq $udom); # Doing this grep allows 'fuzzy' specification @@ -2399,35 +2404,51 @@ sub get_last_submission { &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'}); } } - my %typeparts; + my (%typeparts,%randombytry); my $showsurv = &Apache::lonnet::allowed('vas',$env{'request.course.id'}); foreach my $key (sort(keys(%lasthash))) { if ($key =~ /\.type$/) { if (($lasthash{$key} eq 'anonsurvey') || - ($lasthash{$key} eq 'anonsurveycred')) { + ($lasthash{$key} eq 'anonsurveycred') || + ($lasthash{$key} eq 'randomizetry')) { my ($ign,@parts) = split(/\./,$key); pop(@parts); - unless ($showsurv) { - my $id = join(',',@parts); - $typeparts{$ign.'.'.$id} = $lasthash{$key}; + my $id = join('.',@parts); + if ($lasthash{$key} eq 'randomizetry') { + $randombytry{$ign.'.'.$id} = $lasthash{$key}; + } else { + unless ($showsurv) { + $typeparts{$ign.'.'.$id} = $lasthash{$key}; + } } delete($lasthash{$key}); } } } my @hidden = keys(%typeparts); + my @randomize = keys(%randombytry); foreach my $key (keys(%lasthash)) { next if ($key !~ /\.submission$/); my $hide; if (@hidden) { foreach my $id (@hidden) { if ($key =~ /^\Q$id\E/) { - $hide = 1; + $hide = 'anon'; last; } } } + unless ($hide) { + if (@randomize) { + foreach my $id (@hidden) { + if ($key =~ /^\Q$id\E/) { + $hide = 'rand'; + last; + } + } + } + } my ($partid,$foo) = split(/submission$/,$key); my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ? 'Draft Copy ' : ''; @@ -2596,16 +2617,6 @@ sub processHandGrade { return ''; } -# Go directly to grade student - from submission or link from chart page -# FIXME: looks like reading off the button label! - if ($button eq 'Grade Student') { - my $processUser = $env{'form.unamedom'.$env{'form.studentNo'}}; - ($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser); - $env{'form.fullname'} = $$fullname{$processUser}; - &submission($request,0,0,$symb); - return ''; - } - # Get the next/previous one or group of students my $firststu = $env{'form.unamedom0'}; my $laststu = $env{'form.unamedom'.($ngrade-1)}; @@ -2693,9 +2704,7 @@ sub processHandGrade { $ctr++; } if ($total < 0) { - my $the_end = '