--- loncom/homework/grades.pm 2009/12/27 01:49:32 1.587
+++ loncom/homework/grades.pm 2010/03/19 21:22:34 1.599
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.587 2009/12/27 01:49:32 raeburn Exp $
+# $Id: grades.pm,v 1.599 2010/03/19 21:22:34 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -96,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) = @_;
@@ -121,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("Unable to handle ambiguous references:$url:.");
+ $request->print(&mt("Unable to handle ambiguous references: [_1].",$url));
return ();
}
}
@@ -160,6 +167,10 @@ sub response_type {
return;
}
my $res = $navmap->getBySymb($symb);
+ unless (ref($res)) {
+ $$response_error = 1;
+ return;
+ }
my $partlist = $res->parts();
my %vPart =
map { $_ => 1 } (&Apache::loncommon::get_env_multiple('form.vPart'));
@@ -205,52 +216,52 @@ sub get_display_part {
#--- 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.="
';
+ $bottomrow.''.'';
} elsif ($response eq 'essay') {
if (! exists ($env{'form.'.$symb})) {
my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
@@ -483,8 +494,7 @@ sub cleanRecord {
#-- A couple of common js functions
sub commonJSfunctions {
my $request = shift;
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(< 1) {
@@ -512,7 +522,6 @@ sub commonJSfunctions {
return selectOne.value;
}
}
-
COMMONJSFUNCTIONS
}
@@ -667,13 +676,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";
if ($ctr == 0) {
my $num_students=(scalar(keys(%$fullname)));
if ($num_students eq 0) {
@@ -1140,7 +1158,7 @@ LISTJAVASCRIPT
sub check_script {
my ($form, $type)=@_;
- my $chkallscript=''."\n";
+'."\n");
return $chkallscript;
}
@@ -1210,8 +1228,7 @@ sub processGroup {
sub sub_page_js {
my $request = shift;
my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = ');
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(<
SUBJAVASCRIPT
}
@@ -1389,8 +1405,7 @@ sub sub_page_kw_js {
my $iconpath = $request->dir_config('lonIconsURL');
&commonJSfunctions($request);
- my $inner_js_msg_central=<
+ my $inner_js_msg_central= &Apache::lonhtmlcommon::scripttag(<
INNERJS
- my $inner_js_highlight_central=<
+ my $inner_js_highlight_central= &Apache::lonhtmlcommon::scripttag(<
INNERJS
my $start_page_msg_central =
@@ -1466,8 +1478,7 @@ INNERJS
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
$docopen=~s/^document\.//;
my $alertmsg = &mt('Please select a word or group of words from document and then click this link.');
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(<");
pDoc.write("<\\/td><\\/tr><\\/table> ");
- pDoc.write(" ");
- pDoc.write("
'.&mt('Grade Status').': '.
''.
''.
@@ -3381,7 +3433,7 @@ sub viewgrades {
$result.=&Apache::loncommon::end_data_table()."\n".
'';
$result.='';
+ 'onclick="javascript:resetEntry('.$ctsparts.');" />';
#table listing all the students in a section/class
#header of table
@@ -3445,7 +3497,7 @@ sub viewgrades {
$result.=&Apache::loncommon::end_data_table();
$result.=''."\n";
$result.=''."\n";
+ 'onclick="javascript:submit();" target="_self" />'."\n";
if (scalar(%$fullname) eq 0) {
my $colspan=3+scalar(@parts);
my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
@@ -3497,7 +3549,7 @@ sub viewstudentgrade {
'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
$result.='
'."\n";
} elsif ($type eq 'solved') {
my ($status,$foo)=split(/_/,$score,2);
@@ -3506,7 +3558,7 @@ sub viewstudentgrade {
$part.'_solved_s" value="'.$status.'" />'."\n";
$result.=' '."\n";
+ 'onchange="javascript:changeOneScore(\''.$part.'\',\''.$student.'\')" >'."\n";
$result.= (($status eq 'excused') ? ''
: '')."\n";
$result.='';
@@ -3544,6 +3596,7 @@ sub editgrades {
'incorrect'=>'incorrect_by_override',
'excused' =>'excused',
'ungraded' =>'ungraded_attempted',
+ 'credited' =>'credit_attempted',
'nothing' => '',
);
my ($classlist,undef,$fullname) = &getclasslist($env{'form.section'},'0');
@@ -3853,7 +3906,8 @@ sub csvuploadmap_header {
$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);
@@ -3866,7 +3920,7 @@ $result
Total number of records found in file: $distotal
Enter as many fields as you can. The system will inform you and bring you back
to this page if the data selected is insufficient to run your class.
-
+
@@ -3880,10 +3934,8 @@ to this page if the data selected is ins
-
ENDPICK
+ $request->print(&Apache::lonhtmlcommon::scripttag($javascript));
return '';
}
@@ -3921,15 +3973,14 @@ sub csvuploadmap_footer {
-
+
ENDPICK
}
sub checkforfile_js {
my $alertmsg = &mt('Please use the browse button to select a file from your local directory.');
- my $result =<
+ my $result = &Apache::lonhtmlcommon::scripttag(<
CSVFORMJS
return $result;
}
@@ -3948,8 +3998,8 @@ sub upcsvScores_form {
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.='