'
.&mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)
."
\n";
}
- # If any part of the problem is an essayresponse, then check for collaborators
+ # If any part of the problem is an essay-response (handgraded), then check for collaborators
my $fullname;
my $col_fullnames = [];
- if ($numessay) {
+# if ($env{'form.handgrade'} eq 'yes') {
+ if (1) {
(my $sub_result,$fullname,$col_fullnames)=
&check_collaborators($symb,$uname,$udom,\%record,$handgrade,
$counter);
$result.=$sub_result;
}
$request->print($result."\n");
-
+
# print student answer/submission
- # Options are (1) Last submission only
- # (2) Last submission (with detailed information for that submission)
- # (3) All transactions (by date)
- # (4) The whole record (with detailed information for all transactions)
-
- my ($lastsubonly,$partinfo) =
- &show_last_submission($uname,$udom,$symb,$essayurl,$responseType,$env{'form.lastSub'},
- $is_tool,$fullname,\%record,\%coursedesc_by_cid);
- $request->print($partinfo);
- $request->print($lastsubonly);
+ # 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
+ # (4) The whole record for this student
+
+ my ($string,$timestamp)= &get_last_submission(\%record);
+
+ my $lastsubonly;
+
+ if ($$timestamp eq '') {
+ $lastsubonly.=''
.'
'.&mt('Assign Grades').'
'
@@ -2631,6 +2385,8 @@ sub submission {
my $part_resp = join('_',@{ $part_response_id });
next if ($seen{$partid} > 0);
$seen{$partid}++;
+ next if ($$handgrade{$part_resp} ne 'yes'
+ && $env{'form.lastSub'} eq 'hdgrade');
push(@partlist,$partid);
push(@gradePartRespid,$partid.'.'.$respid);
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -2686,186 +2442,6 @@ sub submission {
return '';
}
-sub show_last_submission {
- my ($uname,$udom,$symb,$essayurl,$responseType,$viewtype,$is_tool,$fullname,
- $record,$coursedesc_by_cid) = @_;
- my ($string,$timestamp,$lastgradetime,$lastsubmittime) =
- &get_last_submission($record,$is_tool);
-
- my ($lastsubonly,$partinfo);
- if ($timestamp eq '') {
- $lastsubonly.='
'.$string->[0].'
';
- } elsif ($is_tool) {
- $lastsubonly =
- '
'
- .''.&mt('Date Grade Passed Back:').' '.$timestamp."
\n";
- } else {
- my ($shownsubmdate,$showngradedate);
- if ($lastsubmittime && $lastgradetime) {
- $shownsubmdate = &Apache::lonlocal::locallocaltime($lastsubmittime);
- if ($lastgradetime > $lastsubmittime) {
- $showngradedate = &Apache::lonlocal::locallocaltime($lastgradetime);
- }
- } else {
- $shownsubmdate = $timestamp;
- }
- $lastsubonly =
- '
'
- .'
'.&mt('Date Submitted:').' '.$shownsubmdate."\n";
- if ($showngradedate) {
- $lastsubonly .= '
'.&mt('Date Graded:').' '.$showngradedate."\n";
- }
-
- my %seenparts;
- my @part_response_id = &flatten_responseType($responseType);
- foreach my $part (@part_response_id) {
- my ($partid,$respid) = @{ $part };
- my $display_part=&get_display_part($partid,$symb);
- if ($env{"form.$uname:$udom:$partid:submitted_by"}) {
- if (exists($seenparts{$partid})) { next; }
- $seenparts{$partid}=1;
- $partinfo .=
- '
'.&mt('Part: [_1]',$display_part).''.
- '
'.&mt('Collaborative submission by: [_1]',
- ''.
- $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'').
- '
';
- next;
- }
- my $responsetype = $responseType->{$partid}->{$respid};
- if (!exists($record->{"resource.$partid.$respid.submission"})) {
- $lastsubonly.="\n".''.
- ''.&mt('Part: [_1]',$display_part).''.
- ' '.
- '('.&mt('Response ID: [_1]',$respid).')'.
- ' '.
- ''.&mt('Nothing submitted - no attempts.').'
';
- next;
- }
- foreach my $submission (@$string) {
- my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
- if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; }
- my ($ressub,$hide,$draft,$subval) = split(/:/,$submission,4);
- # Similarity check
- my $similar='';
- my ($type,$trial,$rndseed);
- if ($hide eq 'rand') {
- $type = 'randomizetry';
- $trial = $record->{"resource.$partid.tries"};
- $rndseed = $record->{"resource.$partid.rndseed"};
- }
- if ($env{'form.checkPlag'}) {
- my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$symb,$subval);
- if ($osim) {
- $osim=int($osim*100.0);
- if ($hide eq 'anon') {
- $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='
';
- if ($essayurl eq 'lib/templates/simpleproblem.problem') {
- $similar .= ''.
- &mt('Essay is [_1]% similar to an essay by [_2]',
- $osim,
- &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')').
- '
';
- } else {
- my %old_course_desc;
- if ($ocrsid ne '') {
- if (ref($coursedesc_by_cid->{$ocrsid}) eq 'HASH') {
- %old_course_desc = %{$coursedesc_by_cid->{$ocrsid}};
- } else {
- my $args;
- if ($ocrsid ne $env{'request.course.id'}) {
- $args = {'one_time' => 1};
- }
- %old_course_desc =
- &Apache::lonnet::coursedescription($ocrsid,$args);
- $coursedesc_by_cid->{$ocrsid} = \%old_course_desc;
- }
- $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'}).
- '
';
- } else {
- $similar .=
- ''.
- &mt('Essay is [_1]% similar to an essay by [_2] in an unknown course',
- $osim,
- &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')').
- '
';
- }
- }
- $similar .= ''.
- &keywords_highlight($oessay).
- '
';
- }
- }
- }
- my $order=&get_order($partid,$respid,$symb,$uname,$udom,
- undef,$type,$trial,$rndseed);
- if (($viewtype eq 'lastonly') ||
- ($viewtype eq 'datesub') ||
- ($viewtype =~ /^(last|all)$/)) {
- my $display_part=&get_display_part($partid,$symb);
- $lastsubonly.=''.
- '
'.&mt('Part: [_1]',$display_part).''.
- '
'.
- '('.&mt('Response ID: [_1]',$respid).')'.
- ' ';
- my $files=&get_submitted_files($udom,$uname,$partid,$respid,$record);
- if (@$files) {
- if ($hide eq 'anon') {
- $lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files}));
- } else {
- $lastsubonly.='
'.'
'.&mt('Submitted Files:').''
- .'
';
- if(@$files == 1) {
- $lastsubonly .= &mt('Like all files provided by users, this file may contain viruses!');
- } else {
- $lastsubonly .= &mt('Like all files provided by users, these files may contain viruses!');
- }
- $lastsubonly .= '';
- foreach my $file (@$files) {
- &Apache::lonnet::allowuploaded('/adm/grades',$file);
- $lastsubonly.='
'.$file.'';
- }
- }
- $lastsubonly.='
';
- }
- if ($hide eq 'anon') {
- $lastsubonly.='
'.&mt('Anonymous Survey').'';
- } else {
- $lastsubonly.='
'.&mt('Submitted Answer:').' ';
- if ($draft) {
- $lastsubonly.= '
'.&mt('Draft Copy').'';
- }
- $subval =
- &cleanRecord($subval,$responsetype,$symb,$partid,
- $respid,$record,$order,undef,$uname,$udom,$type,$trial,$rndseed);
- if ($responsetype eq 'essay') {
- $subval =~ s{\n}{
}g;
- }
- $lastsubonly.=$subval."\n";
- }
- if ($similar) {$lastsubonly.="
$similar\n";}
- $lastsubonly.='
';
- }
- }
- }
- $lastsubonly.=''."\n"; # End: LC_grade_submissions_body
- }
- return ($lastsubonly,$partinfo);
-}
-
sub check_collaborators {
my ($symb,$uname,$udom,$record,$handgrade,$counter) = @_;
my ($result,@col_fullnames);
@@ -2924,46 +2500,18 @@ sub check_collaborators {
#--- Retrieve the last submission for all the parts
sub get_last_submission {
- my ($returnhash,$is_tool)=@_;
- my (@string,$timestamp,$lastgradetime,$lastsubmittime);
+ my ($returnhash)=@_;
+ my (@string,$timestamp,%lasthidden);
if ($$returnhash{'version'}) {
my %lasthash=();
- my %prevsolved=();
- my %solved=();
- my $version;
+ my ($version);
for ($version=1;$version<=$$returnhash{'version'};$version++) {
- my %handgraded = ();
foreach my $key (sort(split(/\:/,
$$returnhash{$version.':keys'}))) {
$lasthash{$key}=$$returnhash{$version.':'.$key};
- if ($key =~ /\.([^.]+)\.regrader$/) {
- $handgraded{$1} = 1;
- } elsif ($key =~ /\.portfiles$/) {
- if (($$returnhash{$version.':'.$key} ne '') &&
- ($$returnhash{$version.':'.$key} !~ /\.\d+\.\w+$/)) {
- $lastsubmittime = $$returnhash{$version.':timestamp'};
- }
- } elsif ($key =~ /\.submission$/) {
- if ($$returnhash{$version.':'.$key} ne '') {
- $lastsubmittime = $$returnhash{$version.':timestamp'};
- }
- } elsif ($key =~ /\.([^.]+)\.solved$/) {
- $prevsolved{$1} = $solved{$1};
- $solved{$1} = $lasthash{$key};
- }
- }
- foreach my $partid (keys(%handgraded)) {
- if (($prevsolved{$partid} eq 'ungraded_attempted') &&
- (($solved{$partid} eq 'incorrect_by_override') ||
- ($solved{$partid} eq 'correct_by_override'))) {
- $lastgradetime = $$returnhash{$version.':timestamp'};
- }
- if ($solved{$partid} ne '') {
- $prevsolved{$partid} = $solved{$partid};
- }
- }
- $timestamp =
- &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'});
+ $timestamp =
+ &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'});
+ }
}
my (%typeparts,%randombytry);
my $showsurv =
@@ -3018,16 +2566,10 @@ sub get_last_submission {
}
}
if (!@string) {
- my $msg;
- if ($is_tool) {
- $msg = &mt('No grade passed back.');
- } else {
- $msg = &mt('Nothing submitted - no attempts.');
- }
$string[0] =
- '
'.$msg.'';
+ '
'.&mt('Nothing submitted - no attempts.').'';
}
- return (\@string,$timestamp,$lastgradetime,$lastsubmittime);
+ return (\@string,\$timestamp);
}
#--- High light keywords, with style choosen by user.
@@ -3057,11 +2599,12 @@ sub show_previous_task_version {
my ($uname,$udom) = ($env{'form.student'},$env{'form.userdom'});
my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
if (!&canview($usec)) {
- $request->print('
'.
- &mt('Unable to view previous version for requested student.').
- ' '.&mt('([_1] in section [_2] in course id [_3])',
- $uname.':'.$udom,$usec,$env{'request.course.id'}).
- '');
+ $request->print(
+ '
'.
+ &mt('Unable to view previous version for requested student.').
+ ' '.&mt('([_1] in section [_2] in course id [_3])',
+ $uname.':'.$udom,$usec,$env{'request.course.id'}).
+ '');
return;
}
my $mode = 'both';
@@ -3233,37 +2776,19 @@ sub processHandGrade {
my $ntstu = $env{'form.NTSTU'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my ($res_error,%queueable);
- my ($partlist,$handgrade,$responseType,$numresp,$numessay) = &response_type($symb,\$res_error);
- if ($res_error) {
- $request->print(&navmap_errormsg());
- return;
- } else {
- foreach my $part (@{$partlist}) {
- if (ref($responseType->{$part}) eq 'HASH') {
- foreach my $id (keys(%{$responseType->{$part}})) {
- if (($responseType->{$part}->{$id} eq 'essay') ||
- (lc($handgrade->{$part.'_'.$id}) eq 'yes')) {
- $queueable{$part} = 1;
- last;
- }
- }
- }
- }
- }
if ($button eq 'Save & Next') {
my $ctr = 0;
while ($ctr < $ngrade) {
my ($uname,$udom) = split(/:/,$env{'form.unamedom'.$ctr});
my ($errorflag,$pts,$wgt,$numhidden) =
- &saveHandGrade($request,$symb,$uname,$udom,$ctr,undef,undef,\%queueable);
+ &saveHandGrade($request,$symb,$uname,$udom,$ctr);
if ($errorflag eq 'no_score') {
$ctr++;
next;
}
if ($errorflag eq 'not_allowed') {
- $request->print(
+ $request->print(
'
'
.&mt('Not allowed to modify grades for [_1]',"$uname:$udom")
.'');
@@ -3312,7 +2837,7 @@ sub processHandGrade {
foreach my $collaborator (@collaborators) {
my ($errorflag,$pts,$wgt) =
&saveHandGrade($request,$symb,$collaborator,$udom,$ctr,
- $env{'form.unamedom'.$ctr},$part,\%queueable);
+ $env{'form.unamedom'.$ctr},$part);
if ($errorflag eq 'not_allowed') {
$request->print("
".&mt('Not allowed to modify grades for [_1]',"$collaborator:$udom")."");
next;
@@ -3334,12 +2859,13 @@ sub processHandGrade {
}
}
- my %keyhash = ();
- if ($numessay) {
+# if ($env{'form.handgrade'} eq 'yes') {
+ if (1) {
# Keywords sorted in alphabatical order
my $loginuser = $env{'user.name'}.':'.$env{'user.domain'};
+ my %keyhash = ();
$env{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
- $env{'form.keywords'} =~ s/^\s+|\s+$//g;
+ $env{'form.keywords'} =~ s/^\s+|\s+$//;
my (@keywords) = sort(split(/\s+/,$env{'form.keywords'}));
$env{'form.keywords'} = join(' ',@keywords);
$keyhash{$symb.'_keywords'} = $env{'form.keywords'};
@@ -3347,9 +2873,7 @@ sub processHandGrade {
$keyhash{$loginuser.'_kwclr'} = $env{'form.kwclr'};
$keyhash{$loginuser.'_kwsize'} = $env{'form.kwsize'};
$keyhash{$loginuser.'_kwstyle'} = $env{'form.kwstyle'};
- }
- if ($env{'form.compmsg'}) {
# message center - Order of message gets changed. Blank line is eliminated.
# New messages are saved in env for the next student.
# All messages are saved in nohist_handgrade.db
@@ -3372,12 +2896,9 @@ sub processHandGrade {
}
$env{'form.savemsgN'} = --$idx;
$keyhash{$symb.'_savemsgN'} = $env{'form.savemsgN'};
- }
- if (($numessay) || ($env{'form.compmsg'})) {
my $putresult = &Apache::lonnet::put
('nohist_handgrade',\%keyhash,$cdom,$cnum);
}
-
# Called by Save & Refresh from Highlight Attribute Window
my (undef,undef,$fullname) = &getclasslist($env{'form.section'},'1');
if ($env{'form.refresh'} eq 'on') {
@@ -3417,6 +2938,7 @@ sub processHandGrade {
}
return $a cmp $b;
} (keys(%$fullname))) {
+# FIXME: this is fishy, looks like the button label
if ($nextflg == 1 && $button =~ /Next$/) {
push(@parsedlist,$item);
}
@@ -3427,7 +2949,14 @@ sub processHandGrade {
}
}
$ctr = 0;
+# FIXME: this is fishy, looks like the button label
@parsedlist = reverse @parsedlist if ($button eq 'Previous');
+ my $res_error;
+ my ($partlist) = &response_type($symb,\$res_error);
+ if ($res_error) {
+ $request->print(&navmap_errormsg());
+ return;
+ }
foreach my $student (@parsedlist) {
my $submitonly=$env{'form.submitonly'};
my ($uname,$udom) = split(/:/,$student);
@@ -3477,7 +3006,7 @@ sub processHandGrade {
$ctr++;
}
if ($total < 0) {
- my $the_end.='
'.&mt('[_1]Message:[_2] No more students for this section or class.','','').'
'."\n";
+ my $the_end.='
'.&mt('[_1]Message:[_2] No more students for this section or class.','','').'
'."\n";
$request->print($the_end);
}
return '';
@@ -3485,7 +3014,7 @@ sub processHandGrade {
#---- Save the score and award for each student, if changed
sub saveHandGrade {
- my ($request,$symb,$stuname,$domain,$newflg,$submitter,$part,$queueable) = @_;
+ my ($request,$symb,$stuname,$domain,$newflg,$submitter,$part) = @_;
my @version_parts;
my $usec = &Apache::lonnet::getsection($domain,$stuname,
$env{'request.course.id'});
@@ -3597,7 +3126,7 @@ sub saveHandGrade {
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
&check_and_remove_from_queue(\@parts,\%record,\%newrecord,$symb,
- $cdom,$cnum,$domain,$stuname,$queueable);
+ $cdom,$cnum,$domain,$stuname);
}
if ($aggregateflag) {
&Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
@@ -3637,7 +3166,7 @@ sub makehidden {
}
sub check_and_remove_from_queue {
- my ($parts,$record,$newrecord,$symb,$cdom,$cnum,$domain,$stuname,$queueable) = @_;
+ my ($parts,$record,$newrecord,$symb,$cdom,$cnum,$domain,$stuname) = @_;
my @ungraded_parts;
foreach my $part (@{$parts}) {
if ( $record->{ 'resource.'.$part.'.awarded'} eq ''
@@ -3645,9 +3174,7 @@ sub check_and_remove_from_queue {
&& $newrecord->{'resource.'.$part.'.awarded'} eq ''
&& $newrecord->{'resource.'.$part.'.solved' } ne 'excused'
) {
- if ($queueable->{$part}) {
- push(@ungraded_parts, $part);
- }
+ push(@ungraded_parts, $part);
}
}
if ( !@ungraded_parts ) {
@@ -3673,19 +3200,19 @@ sub handback_files {
my $part_resp = join('_',@{ $part_response_id });
if (($env{'form.'.$newflg.'_'.$part_resp.'_countreturndoc'} =~ /^\d+$/) & ($new_part eq $part_id)) {
for (my $counter=1; $counter<=$env{'form.'.$newflg.'_'.$part_resp.'_countreturndoc'}; $counter++) {
- # if multiple files are uploaded names will be 'returndoc2','returndoc3'
- if ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$counter}) {
+ # if multiple files are uploaded names will be 'returndoc2','returndoc3'
+ if ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$counter}) {
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$counter.'.filename'};
my ($directory,$answer_file) =
($env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter} =~ /^(.*?)([^\/]*)$/);
my ($answer_name,$answer_ver,$answer_ext) =
- &file_name_version_ext($answer_file);
+ &Apache::lonnet::file_name_version_ext($answer_file);
my ($portfolio_path) = ($directory =~ /^.+$stuname\/portfolio(.*)/);
my $getpropath = 1;
- my ($dir_list,$listerror) =
+ my ($dir_list,$listerror) =
&Apache::lonnet::dirlist($portfolio_root.$portfolio_path,
$domain,$stuname,$getpropath);
- my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
+ my $version = &Apache::lonnet::get_next_version($answer_name,$answer_ext,$dir_list);
# fix filename
my ($save_file_name) = (($directory.$answer_name.".$version.".$answer_ext) =~ /^.+\/${stuname}\/(.*)/);
my $result=&Apache::lonnet::finishuserfileupload($stuname,$domain,
@@ -3703,8 +3230,7 @@ sub handback_files {
$$newrecord{"resource.$new_part.$resp_id.handback"}.=',';
}
$$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name;
- $file_msg.='
'.$save_file_name." ";
-
+ $file_msg.= '
'.$save_file_name." ";
}
$request->print('
'.&mt('[_1] will be the uploaded filename [_2]','
'.$fname.'','
'.$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$counter}.''));
}
@@ -3715,7 +3241,7 @@ sub handback_files {
$request->print('
');
my @what = ($symb,$env{'request.course.id'},'handback');
&Apache::lonnet::mark_as_readonly($domain,$stuname,\@handedback,\@what);
- my $user_lh = &Apache::loncommon::user_lang($stuname,$domain,$env{'request.course.id'});
+ my $user_lh = &Apache::loncommon::user_lang($stuname,$domain,$env{'request.course.id'});
my ($subject,$message);
if (scalar(@handedback) == 1) {
$subject = &mt_user($user_lh,'File Handed Back by Instructor');
@@ -3835,29 +3361,14 @@ sub version_portfiles {
my $version_parts = join('|',@$v_flag);
my @returned_keys;
my $parts = join('|', @$parts_graded);
- my $portfolio_root = '/userfiles/portfolio';
foreach my $key (keys(%$record)) {
my $new_portfiles;
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
my @versioned_portfiles;
my @portfiles = split(/\s*,\s*/,$$record{$key});
- foreach my $file (@portfiles) {
- &Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file);
- my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
- my ($answer_name,$answer_ver,$answer_ext) =
- &file_name_version_ext($answer_file);
- my $getpropath = 1;
- my ($dir_list,$listerror) =
- &Apache::lonnet::dirlist($portfolio_root.$directory,$domain,
- $stu_name,$getpropath);
- my $version = &get_next_version($answer_name,$answer_ext,$dir_list);
- my $new_answer = &version_selected_portfile($domain, $stu_name, $directory, $answer_file, $version);
- if ($new_answer ne 'problem getting file') {
- push(@versioned_portfiles, $directory.$new_answer);
- &Apache::lonnet::mark_as_readonly($domain,$stu_name,
- [$directory.$new_answer],
- [$symb,$env{'request.course.id'},'graded']);
- }
+ if (@portfiles) {
+ &Apache::lonnet::portfiles_versioning($symb,$domain,$stu_name,\@portfiles,
+ \@versioned_portfiles);
}
$$record{$key} = join(',',@versioned_portfiles);
push(@returned_keys,$key);
@@ -3866,64 +3377,6 @@ sub version_portfiles {
return (@returned_keys);
}
-sub get_next_version {
- my ($answer_name, $answer_ext, $dir_list) = @_;
- my $version;
- if (ref($dir_list) eq 'ARRAY') {
- foreach my $row (@{$dir_list}) {
- my ($file) = split(/\&/,$row,2);
- my ($file_name,$file_version,$file_ext) =
- &file_name_version_ext($file);
- if (($file_name eq $answer_name) &&
- ($file_ext eq $answer_ext)) {
- # gets here if filename and extension match,
- # regardless of version
- if ($file_version ne '') {
- # a versioned file is found so save it for later
- if ($file_version > $version) {
- $version = $file_version;
- }
- }
- }
- }
- }
- $version ++;
- return($version);
-}
-
-sub version_selected_portfile {
- my ($domain,$stu_name,$directory,$file_name,$version) = @_;
- my ($answer_name,$answer_ver,$answer_ext) =
- &file_name_version_ext($file_name);
- my $new_answer;
- $env{'form.copy'} = &Apache::lonnet::getfile("/uploaded/$domain/$stu_name/portfolio$directory$file_name");
- if($env{'form.copy'} eq '-1') {
- $new_answer = 'problem getting file';
- } else {
- $new_answer = $answer_name.'.'.$version.'.'.$answer_ext;
- my $copy_result = &Apache::lonnet::finishuserfileupload(
- $stu_name,$domain,'copy',
- '/portfolio'.$directory.$new_answer);
- }
- return ($new_answer);
-}
-
-sub file_name_version_ext {
- my ($file)=@_;
- my @file_parts = split(/\./, $file);
- my ($name,$version,$ext);
- if (@file_parts > 1) {
- $ext=pop(@file_parts);
- if (@file_parts > 1 && $file_parts[-1] =~ /^\d+$/) {
- $version=pop(@file_parts);
- }
- $name=join('.',@file_parts);
- } else {
- $name=join('.',@file_parts);
- }
- return($name,$version,$ext);
-}
-
#--------------------------------------------------------------------------------------
#
#-------------------------- Next few routines handles grading by section or whole class
@@ -4101,11 +3554,6 @@ VIEWJAVASCRIPT
#--- show scores for a section or whole class w/ option to change/update a score
sub viewgrades {
my ($request,$symb) = @_;
- my ($is_tool,$toolsymb);
- if ($symb =~ /ext\.tool$/) {
- $is_tool = 1;
- $toolsymb = $symb;
- }
&viewgrades_js($request);
#need to make sure we have the correct data for later EXT calls,
@@ -4128,92 +3576,19 @@ sub viewgrades {
&build_section_inputs().
'
'."\n".
- #retrieve selected groups
- my (@groups,$group_display);
- @groups = &Apache::loncommon::get_env_multiple('form.group');
- if (grep(/^all$/,@groups)) {
- @groups = ('all');
- } elsif (grep(/^none$/,@groups)) {
- @groups = ('none');
- } elsif (@groups > 0) {
- $group_display = join(', ',@groups);
- }
-
- my ($common_header,$specific_header,@sections,$section_display);
- if ($env{'request.course.sec'} ne '') {
- @sections = ($env{'request.course.sec'});
- } else {
- @sections = &Apache::loncommon::get_env_multiple('form.section');
- }
-
-# Check if Save button should be usable
- my $disabled = ' disabled="disabled"';
- if ($perm{'mgr'}) {
- if (grep(/^all$/,@sections)) {
- undef($disabled);
- } else {
- foreach my $sec (@sections) {
- if (&canmodify($sec)) {
- undef($disabled);
- last;
- }
- }
- }
- }
- if (grep(/^all$/,@sections)) {
- @sections = ('all');
- if ($group_display) {
- $common_header = &mt('Assign Common Grade to Students in Group(s) [_1]',$group_display);
- $specific_header = &mt('Assign Grade to Specific Students in Group(s) [_1]',$group_display);
- } elsif (grep(/^none$/,@groups)) {
- $common_header = &mt('Assign Common Grade to Students not assigned to any groups');
- $specific_header = &mt('Assign Grade to Specific Students not assigned to any groups');
- } else {
- $common_header = &mt('Assign Common Grade to Class');
- $specific_header = &mt('Assign Grade to Specific Students in Class');
- }
- } elsif (grep(/^none$/,@sections)) {
- @sections = ('none');
- if ($group_display) {
- $common_header = &mt('Assign Common Grade to Students in no Section and in Group(s) [_1]',$group_display);
- $specific_header = &mt('Assign Grade to Specific Students in no Section and in Group(s)',$group_display);
- } elsif (grep(/^none$/,@groups)) {
- $common_header = &mt('Assign Common Grade to Students in no Section and in no Group');
- $specific_header = &mt('Assign Grade to Specific Students in no Section and in no Group');
- } else {
- $common_header = &mt('Assign Common Grade to Students in no Section');
- $specific_header = &mt('Assign Grade to Specific Students in no Section');
- }
- } else {
- $section_display = join (", ",@sections);
- if ($group_display) {
- $common_header = &mt('Assign Common Grade to Students in Section(s) [_1], and in Group(s) [_2]',
- $section_display,$group_display);
- $specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1], and in Group(s) [_2]',
- $section_display,$group_display);
- } elsif (grep(/^none$/,@groups)) {
- $common_header = &mt('Assign Common Grade to Students in Section(s) [_1] and no Group',$section_display);
- $specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1] and no Group',$section_display);
- } else {
- $common_header = &mt('Assign Common Grade to Students in Section(s) [_1]',$section_display);
- $specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1]',$section_display);
- }
- }
- my %submit_types = &substatus_options();
- my $submission_status = $submit_types{$env{'form.submitonly'}};
-
- if ($env{'form.submitonly'} eq 'all') {
- $result.= '
'.$common_header.'
';
- } else {
- my $text;
- if ($is_tool) {
- $text = &mt('(transaction status: "[_1]")',$submission_status);
- } else {
- $text = &mt('(submission status: "[_1]")',$submission_status);
- }
- $result.= '
'.$common_header.' '.$text.'
';
+ my ($common_header,$specific_header);
+ if ($env{'form.section'} eq 'all') {
+ $common_header = &mt('Assign Common Grade to Class');
+ $specific_header = &mt('Assign Grade to Specific Students in Class');
+ } elsif ($env{'form.section'} eq 'none') {
+ $common_header = &mt('Assign Common Grade to Students in no Section');
+ $specific_header = &mt('Assign Grade to Specific Students in no Section');
+ } else {
+ my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
+ $common_header = &mt('Assign Common Grade to Students in Section(s) [_1]',$section_display);
+ $specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1]',$section_display);
}
- $result .= &Apache::loncommon::start_data_table();
+ $result.= '
'.$common_header.'
'.&Apache::loncommon::start_data_table();
#radio buttons/text box for assigning points for a section or class.
#handles different parts of a problem
my $res_error;
@@ -4224,17 +3599,13 @@ sub viewgrades {
my %weight = ();
my $ctsparts = 0;
my %seen = ();
- my @part_response_id;
- if ($is_tool) {
- @part_response_id = ([0,'']);
- } else {
- @part_response_id = &flatten_responseType($responseType);
- }
+ my @part_response_id = &flatten_responseType($responseType);
foreach my $part_response_id (@part_response_id) {
my ($partid,$respid) = @{ $part_response_id };
my $part_resp = join('_',@{ $part_response_id });
next if $seen{$partid};
$seen{$partid}++;
+ my $handgrade=$$handgrade{$part_resp};
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);
$weight{$partid} = $wgt eq '' ? '1' : $wgt;
@@ -4253,10 +3624,10 @@ sub viewgrades {
$partid.'" size="4" '.'onchange="javascript:writePoint(\''.
$partid.'\','.$weight{$partid}.',\'textval\')" /> /'.
$weight{$partid}.' '.&mt('(problem weight)').''."\n";
- $line.= '
'.&mt('Grade Status').':'.
- ' |