--- loncom/homework/grades.pm 2010/04/06 14:56:37 1.605
+++ 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.605 2010/04/06 14:56:37 www Exp $
+# $Id: grades.pm,v 1.645 2011/02/07 19:16:28 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;
@@ -123,25 +125,6 @@ sub getpartlist {
return @stores;
}
-# --- 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(&mt("Unable to handle ambiguous references: [_1].",$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 {
@@ -156,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) = @_;
@@ -229,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') {
@@ -258,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);
@@ -273,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') {
@@ -323,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);
@@ -367,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) {
@@ -636,7 +631,6 @@ sub jscriptNform {
"\n");
$jscript.= '
\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) {
@@ -8955,22 +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.=(<
-
@@ -8995,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 ":"
@@ -9015,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".''.
"
'."\n";
- return $result.&show_grading_menu_form($symb);
+ $result.=''.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table();
+ return $result;
}
sub iclicker_eval {
@@ -9079,6 +9019,7 @@ sub iclicker_eval {
$id=~s/^[\#0]+//;
for (my $i=0;$i<$number;$i++) {
my $idx=3+$i*6;
+ $entries[$idx]=~s/[^a-zA-Z0-9\.\*\-\+]+//g;
push(@idresponses,$entries[$idx]);
}
$$responses{$id}=join(',',@idresponses);
@@ -9119,8 +9060,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;
@@ -9131,14 +9071,11 @@ sub assign_clicker_grades {
# FIXME: This should probably look for the first handgradeable part
my $part=$$partlist[0];
# Start screen output
- my $result='';
-
- 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().
+ '