--- loncom/homework/grades.pm 2009/12/09 17:53:55 1.582
+++ 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.582 2009/12/09 17:53:55 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,45 +216,52 @@ sub get_display_part {
#--- Show resource title
#--- and parts and response type
-sub showResourceInfo {
- my ($symb,$probTitle,$checkboxes,$res_error) = @_;
- my $col=3;
- if ($checkboxes) { $col=4; }
- 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 .='
';
- 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.='
';
- if ($checkboxes) {
- if (exists($partsseen{$partID})) {
- $result.="
';
+ $bottomrow.''.'';
} elsif ($response eq 'essay') {
if (! exists ($env{'form.'.$symb})) {
my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
@@ -476,8 +494,7 @@ sub cleanRecord {
#-- A couple of common js functions
sub commonJSfunctions {
my $request = shift;
- $request->print(<
+ $request->print(&Apache::lonhtmlcommon::scripttag(< 1) {
@@ -505,7 +522,6 @@ sub commonJSfunctions {
return selectOne.value;
}
}
-
COMMONJSFUNCTIONS
}
@@ -660,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) {
@@ -1130,7 +1158,7 @@ LISTJAVASCRIPT
sub check_script {
my ($form, $type)=@_;
- my $chkallscript=''."\n";
+'."\n");
return $chkallscript;
}
@@ -1200,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
}
@@ -1379,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 =
@@ -1456,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("
'
+ .&Apache::loncommon::end_data_table_header_row()
+ );
+}
+
+sub gradeBox_end {
+ return (
+ &Apache::loncommon::end_data_table()
+ );
+}
#--- displays the grading box, used in essay type problem and grading by page/sequence
sub gradeBox {
my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
@@ -1720,7 +1759,7 @@ sub gradeBox {
if ($last_resets{$partid}) {
$aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
}
- $result.='
';
+ $result.=&Apache::loncommon::start_data_table_row();
my $ctr = 0;
my $thisweight = 0;
my $increment = &get_increment();
@@ -1728,7 +1767,7 @@ sub gradeBox {
my $radio.='
'."\n"; # display radio buttons in a nice table 10 across
while ($thisweight<=$wgt) {
$radio.= '
\n";
$radio.=(($ctr+1)%10 == 0 ? '
' : '');
@@ -1739,13 +1778,13 @@ sub gradeBox {
my $line.=''."\n";
$line.='
KEYWORDS
@@ -2053,12 +2089,31 @@ KEYWORDS
}
# This is where output for one specific student would start
- my $add_class = ($counter%2) ? 'LC_grade_show_user_odd_row' : '';
- $request->print("\n\n".
- '
'
+ ."\n"
+ );
+ # Show additional functions if allowed
+ if ($perm{'vgr'}) {
+ $request->print(
+ &Apache::loncommon::track_student_link(
+ &mt('View recent activity'),
+ $uname,$udom,'check')
+ .' '
+ );
+ }
+ if ($perm{'opa'}) {
+ $request->print(
+ &Apache::loncommon::pprmlink(
+ &mt('Set/Change parameters'),
+ $uname,$udom,$symb,'check'));
+ }
+
+ # Show Problem
if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') {
my $mode;
if ($env{'form.vProb'} eq 'all' && $env{'form.vAns'} eq 'all') {
@@ -2082,20 +2137,17 @@ KEYWORDS
# Display student info
$request->print(($counter == 0 ? '' : ' '));
- my $result='
';
-
- $result.='
';
- $result.= &mt('Submissions');
+
+ my $result='
'
+ .'
'.&mt('Submissions').'
';
$result.=''."\n";
+ '" value="'.$env{'form.fullname'}.'" />'."\n";
if ($env{'form.handgrade'} eq 'no') {
- $result.=''.
- &mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)."\n";
-
+ $result.='
'
+ .&mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)
+ ."
\n";
}
-
-
# If any part of the problem is an essay-response (handgraded), then check for collaborators
my $fullname;
my $col_fullnames = [];
@@ -2106,9 +2158,9 @@ KEYWORDS
$result.=$sub_result;
}
$request->print($result."\n");
- $request->print('
'."\n");
+
# print student answer/submission
- # Options are (1) Handgaded submission only
+ # Options are (1) Handgraded submission only
# (2) Last submission, includes submission that is not handgraded
# (for multi-response type part)
# (3) Last submission plus the parts info
@@ -2118,10 +2170,12 @@ KEYWORDS
my $lastsubonly;
- if ($$timestamp eq '') {
- $lastsubonly.='
'.$$string[0].'
';
- } else {
- $lastsubonly = '
Date Submitted: '.$$timestamp."\n";
+ if ($$timestamp eq '') {
+ $lastsubonly.='
'.$$string[0].'
';
+ } else {
+ $lastsubonly =
+ '
'
+ .''.&mt('Date Submitted:').' '.$$timestamp."\n";
my %seenparts;
my @part_response_id = &flatten_responseType($responseType);
@@ -2148,7 +2202,7 @@ KEYWORDS
$lastsubonly.="\n".'
';
next;
@@ -2156,7 +2210,7 @@ KEYWORDS
foreach my $submission (@$string) {
my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; }
- my ($ressub,$subval) = split(/:/,$submission,2);
+ my ($ressub,$hide,$subval) = split(/:/,$submission,3);
# Similarity check
my $similar='';
if($env{'form.checkPlag'}){
@@ -2168,16 +2222,21 @@ KEYWORDS
&Apache::lonnet::coursedescription($ocrsid,
{'one_time' => 1});
- $similar="
".
- &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])',
- $osim,
- &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')',
- $old_course_desc{'description'},
- $old_course_desc{'num'},
- $old_course_desc{'domain'}).
- '
'.
- &keywords_highlight($oessay).
- '
';
+ if ($hide) {
+ $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 {
+ $similar="
".
+ &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])',
+ $osim,
+ &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')',
+ $old_course_desc{'description'},
+ $old_course_desc{'num'},
+ $old_course_desc{'domain'}).
+ '
'.
+ &keywords_highlight($oessay).
+ '
';
+ }
}
}
my $order=&get_order($partid,$respid,$symb,$uname,$udom);
@@ -2189,31 +2248,39 @@ KEYWORDS
''.&mt('Part: [_1]',$display_part).''.
' '.
'('.&mt('Part ID: [_1]',$respid).')'.
- ' ';
+ ' ';
my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
if (@$files) {
- $lastsubonly.=' '.&mt('Like all files provided by users, this file may contain viruses').' ';
- my $file_counter = 0;
- foreach my $file (@$files) {
- $file_counter++;
- &Apache::lonnet::allowuploaded('/adm/grades',$file);
- $lastsubonly.=' '.$file.'';
- }
+ if ($hide) {
+ $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').' ';
+ foreach my $file (@$files) {
+ &Apache::lonnet::allowuploaded('/adm/grades',$file);
+ $lastsubonly.=' '.$file.'';
+ }
+ }
$lastsubonly.=' ';
}
- $lastsubonly.=''.&mt('Submitted Answer:').' '.
- &cleanRecord($subval,$responsetype,$symb,$partid,
- $respid,\%record,$order,undef,$uname,$udom);
+ if ($hide) {
+ $lastsubonly.=''.&mt('Anonymous Survey').'';
+ } else {
+ $lastsubonly.=''.&mt('Submitted Answer:').' '.
+ &cleanRecord($subval,$responsetype,$symb,$partid,
+ $respid,\%record,$order,undef,$uname,$udom);
+ }
if ($similar) {$lastsubonly.="
$similar\n";}
$lastsubonly.='
';
}
}
}
- $lastsubonly.='
'."\n";
+ $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body
}
$request->print($lastsubonly);
} elsif ($env{'form.lastSub'} eq 'datesub') {
- my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
+# my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
+ my ($parts,$handgrade,$responseType) = &response_type($symb);
+
$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
} elsif ($env{'form.lastSub'} =~ /^(last|all)$/) {
$request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
@@ -2227,7 +2294,7 @@ KEYWORDS
# return if view submission with no grading option
if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) {
my $toGrade.=' '."\n" if (&canmodify($usec));
$toGrade.='
'."\n";
if (($env{'form.command'} eq 'submission') ||
@@ -2271,11 +2338,11 @@ KEYWORDS
my @partlist;
my @gradePartRespid;
my @part_response_id = &flatten_responseType($responseType);
- $request->print('