--- loncom/homework/grades.pm 2009/12/27 01:25:26 1.586
+++ loncom/homework/grades.pm 2010/04/07 21:08:35 1.607
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.586 2009/12/27 01:25:26 raeburn Exp $
+# $Id: grades.pm,v 1.607 2010/04/07 21:08:35 droeschl 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'));
@@ -203,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.="
'."\n";
+ &mt('Verifying Receipt Number [_1]',$receipt).
+ ''."\n";
my ($string,$contents,$matches) = ('','',0);
my (undef,undef,$fullname) = &getclasslist('all','0');
@@ -869,21 +839,20 @@ sub listStudents {
my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'};
my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
my $viewgrade = $env{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
- $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ?
- &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
my $result='
'
.&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);
@@ -921,7 +889,7 @@ LISTJAVASCRIPT
my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : '';
my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : '';
my $gradeTable=''."\n";
+ ''."\n";
if ($ctr == 0) {
my $num_students=(scalar(keys(%$fullname)));
if ($num_students eq 0) {
@@ -1140,7 +1115,7 @@ LISTJAVASCRIPT
sub check_script {
my ($form, $type)=@_;
- my $chkallscript=''."\n";
+'."\n");
return $chkallscript;
}
@@ -1210,8 +1185,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 +1362,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 +1435,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("
';
return $result;
}
@@ -1949,7 +1912,8 @@ sub submission {
$udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student?
my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
$env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';
- my $symb = &get_symb($request);
+ my $symb = &get_symb($request);
+ my $probtitle=&Apache::lonnet::gettitle($symb);
if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }
if (!&canview($usec)) {
@@ -1973,13 +1937,10 @@ sub submission {
if ($counter == 0) {
&sub_page_js($request);
&sub_page_kw_js($request) if ($env{'form.handgrade'} eq 'yes');
- $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ?
- &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'};
if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) {
&download_all_link($request, $symb);
}
- $request->print('
'.&mt('Submission Record').'
'."\n".
- '
'.&mt('Resource: [_1]',$env{'form.probTitle'}).'
'."\n");
+ $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.
@@ -2010,7 +1971,7 @@ sub submission {
$env{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
$env{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
$env{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
- $keyhash{$symb.'_subject'} : $env{'form.probTitle'};
+ $keyhash{$symb.'_subject'} : $probtitle;
$env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
}
my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};
@@ -2020,7 +1981,6 @@ sub submission {
''."\n".
''."\n".
''."\n".
- ''."\n".
''."\n".
''."\n".
''."\n".
@@ -2066,7 +2026,7 @@ sub submission {
$request->print(<Keyword Options:
List
-Paste Selection to ListHighlight Attribute
KEYWORDS
@@ -2082,12 +2042,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') {
@@ -2111,20 +2090,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 = [];
@@ -2135,9 +2111,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
@@ -2147,10 +2123,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);
@@ -2177,7 +2155,7 @@ KEYWORDS
$lastsubonly.="\n".'
';
next;
@@ -2185,7 +2163,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'}){
@@ -2197,16 +2175,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);
@@ -2218,31 +2201,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,
@@ -2256,7 +2247,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') ||
@@ -2301,11 +2292,10 @@ KEYWORDS
my @gradePartRespid;
my @part_response_id = &flatten_responseType($responseType);
$request->print(
- '
'
- .'
'
- .&mt('Assign Grades').'
'
+ '
'
+ .'
'.&mt('Assign Grades').'
'
);
- $request->print(&gradeBox_start()); #
+ $request->print(&gradeBox_start());
foreach my $part_response_id (@part_response_id) {
my ($partid,$respid) = @{ $part_response_id };
my $part_resp = join('_',@{ $part_response_id });
@@ -2321,16 +2311,6 @@ KEYWORDS
$request->print('