--- loncom/homework/grades.pm 2011/10/10 18:27:34 1.596.2.5
+++ loncom/homework/grades.pm 2010/03/25 19:56:33 1.602
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.5 2011/10/10 18:27:34 raeburn Exp $
+# $Id: grades.pm,v 1.602 2010/03/25 19:56:33 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,10 +40,9 @@ use Apache::lonhomework;
use Apache::lonpickcode;
use Apache::loncoursedata;
use Apache::lonmsg();
-use Apache::Constants qw(:common :http);
+use Apache::Constants qw(:common);
use Apache::lonlocal;
use Apache::lonenc;
-use Apache::bridgetask();
use String::Similarity;
use LONCAPA;
@@ -97,6 +96,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) = @_;
@@ -122,13 +124,17 @@ sub getpartlist {
}
# --- 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));
+ $request->print(&mt("Unable to handle ambiguous references: [_1].",$url));
return ();
}
}
@@ -208,55 +214,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.="
'
- .&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();
@@ -272,13 +229,8 @@ sub reset_caches {
}
sub get_analyze {
- my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed)=@_;
+ my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_;
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') {
@@ -306,15 +258,9 @@ 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);
@@ -327,15 +273,15 @@ sub reset_caches {
}
sub get_order {
- my ($partid,$respid,$symb,$uname,$udom,$no_increment,$type,$trial,$rndseed)=@_;
- my $analyze = &get_analyze($symb,$uname,$udom,$no_increment,undef,$type,$trial,$rndseed);
+ my ($partid,$respid,$symb,$uname,$udom,$no_increment)=@_;
+ my $analyze = &get_analyze($symb,$uname,$udom,$no_increment);
return $analyze->{"$partid.$respid.shown"};
}
sub get_radiobutton_correct_foil {
- 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);
+ my ($partid,$respid,$symb,$uname,$udom)=@_;
+ my $analyze = &get_analyze($symb,$uname,$udom);
+ my $foils = &get_order($partid,$respid,$symb,$uname,$udom);
if (ref($foils) eq 'ARRAY') {
foreach my $foil (@{$foils}) {
if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') {
@@ -377,7 +323,7 @@ sub reset_caches {
# response types only.
sub cleanRecord {
my ($answer,$response,$symb,$partid,$respid,$record,$order,$version,
- $uname,$udom,$type,$trial,$rndseed) = @_;
+ $uname,$udom) = @_;
my $grayFont = '';
if ($response =~ /^(option|rank)$/) {
my %answer=&Apache::lonnet::str2hash($answer);
@@ -394,7 +340,7 @@ sub cleanRecord {
return '
'.
'
'.&mt('Answer').'
'.$toprow.'
'.
'
'.$grayFont.&mt('Option ID').'
'.
- $bottomrow.'
';
+ $grayFont.$bottomrow.''.'';
} elsif ($response eq 'match') {
my %answer=&Apache::lonnet::str2hash($answer);
my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"});
@@ -421,7 +367,7 @@ sub cleanRecord {
my %answer=&Apache::lonnet::str2hash($answer);
my ($toprow,$bottomrow);
my $correct =
- &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed);
+ &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom);
foreach my $foil (@$order) {
if (exists($answer{$foil})) {
if ($foil eq $correct) {
@@ -437,7 +383,7 @@ sub cleanRecord {
return '
'.
'
'.&mt('Answer').'
'.$toprow.'
'.
'
'.$grayFont.&mt('Option ID').'
'.
- $bottomrow.'
';
+ $bottomrow.''.'';
} elsif ($response eq 'essay') {
if (! exists ($env{'form.'.$symb})) {
my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
@@ -499,8 +445,7 @@ sub cleanRecord {
#-- A couple of common js functions
sub commonJSfunctions {
my $request = shift;
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(< 1) {
@@ -528,7 +473,6 @@ sub commonJSfunctions {
return selectOne.value;
}
}
-
COMMONJSFUNCTIONS
}
@@ -683,13 +627,13 @@ sub student_gradeStatus {
sub jscriptNform {
my ($symb) = @_;
my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status'));
- my $jscript=''."\n";
+ "\n");
$jscript.= '\n");
+}
+
#--- Check whether a receipt number is valid.---
sub verifyreceipt {
my $request = shift;
@@ -892,14 +846,15 @@ sub listStudents {
.&mt("$viewgrade Submissions for a Student or a Group of Students")
.'';
- 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.',
'single' => 'Please select the student before clicking on the Next button.',
);
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(<
LISTJAVASCRIPT
&commonJSfunctions($request);
@@ -937,7 +891,7 @@ LISTJAVASCRIPT
my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : '';
my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : '';
my $gradeTable='