--- loncom/homework/grades.pm 2024/08/23 20:52:28 1.596.2.12.2.60.2.6
+++ loncom/homework/grades.pm 2023/02/12 21:01:30 1.792
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.60.2.6 2024/08/23 20:52:28 raeburn Exp $
+# $Id: grades.pm,v 1.792 2023/02/12 21:01:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,6 +44,7 @@ use Apache::Constants qw(:common :http);
use Apache::lonlocal;
use Apache::lonenc;
use Apache::lonstathelpers;
+use Apache::lonquickgrades;
use Apache::bridgetask();
use Apache::lontexconvert();
use String::Similarity;
@@ -146,7 +147,6 @@ sub nameUserString {
}
#--- Get the partlist and the response type for a given problem. ---
-#--- Indicate if a response type is coded handgraded or not. ---
#--- Count responseIDs, essayresponse items, and dropbox items ---
#--- Sets response_error pointer to "1" if navmaps object broken ---
sub response_type {
@@ -1799,6 +1799,7 @@ INNERJS
function msgTail() {
pDoc = pWin.document;
+ //pDoc.write("<\\/table>");
pDoc.write("<\\/td><\\/tr><\\/table> ");
pDoc.write(" ");
pDoc.write("
");
@@ -2118,7 +2119,7 @@ sub handback_box {
if ($file =~ /\/portfolio\//) {
$file_counter++;
my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|);
- my ($name,$version,$ext) = &file_name_version_ext($file_disp);
+ my ($name,$version,$ext) = &Apache::lonnet::file_name_version_ext($file_disp);
$file_disp = "$name.$ext";
$file = $file_path.$file_disp;
$result.=&mt('Return commented version of [_1] to student.',
@@ -2330,7 +2331,7 @@ sub submission {
}
if (!$env{'form.lastSub'}) { $env{'form.lastSub'} = 'datesub'; }
- unless ($is_tool) {
+ unless ($is_tool) {
if (!$env{'form.vProb'}) { $env{'form.vProb'} = 'yes'; }
if (!$env{'form.vAns'}) { $env{'form.vAns'} = 'yes'; }
}
@@ -2557,144 +2558,13 @@ sub 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);
-
- if ($env{'form.lastSub'} eq 'datesub') {
- my ($parts,$handgrade,$responseType) = &response_type($symb,\$res_error);
- $request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
- }
- if ($env{'form.lastSub'} =~ /^(last|all)$/) {
- my $identifier = (&canmodify($usec)? $counter : '');
- $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
- $env{'request.course.id'},
- $last,'.submission',
- 'Apache::grades::keywords_highlight',
- $usec,$identifier));
- }
- $request->print(''."\n");
- # return if view submission with no grading option
- if (!&canmodify($usec)) {
- $request->print('
'.&mt('No grading privileges').'
');
- return;
- } else {
- $request->print(''."\n");
- }
-
- # grading message center
-
- if ($env{'form.compmsg'}) {
- my $result='
'.
- '
'.&mt('Send Message').'
'.
- '
';
- my ($lastname,$givenn) = split(/,/,$env{'form.fullname'});
- my $msgfor = $givenn.' '.$lastname;
- if (scalar(@$col_fullnames) > 0) {
- my $lastone = pop(@$col_fullnames);
- $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.';
- }
- $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
- $result.=''."\n".
- ''."\n".
- ' '.
- &mt('Compose message to student'.(scalar(@$col_fullnames) >= 1 ? 's' : '')).')'.
- ' '."\n".
- ' ('.
- &mt('Message will be sent when you click on Save & Next below.').")\n".
- '
';
- $request->print($result);
- }
-
- my %seen = ();
- my @partlist;
- my @gradePartRespid;
- my @part_response_id;
- if ($is_tool) {
- @part_response_id = ([0,'']);
- } else {
- @part_response_id = &flatten_responseType($responseType);
- }
- $request->print(
- '
'
- .'
'.&mt('Assign Grades').'
'
- );
- $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 });
- next if ($seen{$partid} > 0);
- $seen{$partid}++;
- push(@partlist,$partid);
- push(@gradePartRespid,$partid.'.'.$respid);
- $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
- }
- $request->print(&gradeBox_end()); #
- $request->print('');
-
- $request->print('
');
- $request->print('
');
-
- $result=''."\n";
- $result.=''."\n" if ($counter == 0);
- my $ctr = 0;
- while ($ctr < scalar(@partlist)) {
- $result.=''."\n";
- $ctr++;
- }
- $request->print($result.''."\n");
-
-# Done with printing info for one student
-
- $request->print('');#LC_grade_show_user
-
-
- # print end of form
- if ($counter == $total) {
- my $endform='
'."\n";
- $endform.=' '."\n";
- my $ntstu =''."\n";
- my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1');
- $ntstu =~ s/
';
- $request->print($endform);
- }
- 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);
+ &get_last_submission(\%record,$is_tool);
+
+ my $lastsubonly;
- my ($lastsubonly,$partinfo);
if ($timestamp eq '') {
- $lastsubonly.='
'.$string->[0].'
';
+ $lastsubonly.='
'.$string->[0].'
';
} elsif ($is_tool) {
$lastsubonly =
'
'
@@ -2716,56 +2586,56 @@ sub show_last_submission {
$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 .=
+ 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;
+ $request->print(
''.&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"})) {
+ ' ');
+ next;
+ }
+ my $responsetype = $responseType->{$partid}->{$respid};
+ if (!exists($record{"resource.$partid.$respid.submission"})) {
$lastsubonly.="\n".'
';
- 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
+ ''.&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"};
+ $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 ($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='';
+ $similar='';
if ($essayurl eq 'lib/templates/simpleproblem.problem') {
$similar .= '
'.
&mt('Essay is [_1]% similar to an essay by [_2]',
@@ -2775,8 +2645,8 @@ sub show_last_submission {
} else {
my %old_course_desc;
if ($ocrsid ne '') {
- if (ref($coursedesc_by_cid->{$ocrsid}) eq 'HASH') {
- %old_course_desc = %{$coursedesc_by_cid->{$ocrsid}};
+ 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'}) {
@@ -2784,7 +2654,7 @@ sub show_last_submission {
}
%old_course_desc =
&Apache::lonnet::coursedescription($ocrsid,$args);
- $coursedesc_by_cid->{$ocrsid} = \%old_course_desc;
+ $coursedesc_by_cid{$ocrsid} = \%old_course_desc;
}
$similar .=
'
'.
@@ -2808,21 +2678,21 @@ sub show_last_submission {
&keywords_highlight($oessay).
'';
}
- }
- }
- my $order=&get_order($partid,$respid,$symb,$uname,$udom,
+ }
+ }
+ 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);
+ if (($env{'form.lastSub'} eq 'lastonly') ||
+ ($env{'form.lastSub'} eq 'datesub') ||
+ ($env{'form.lastSub'} =~ /^(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) {
+ 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 {
@@ -2839,31 +2709,152 @@ sub show_last_submission {
$lastsubonly.=' '.$file.'';
}
}
- $lastsubonly.=' ';
+ $lastsubonly.=' ';
}
if ($hide eq 'anon') {
- $lastsubonly.=' '.&mt('Anonymous Survey').'';
+ $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);
+ &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.='';
+ }
}
+ }
+ $lastsubonly.=''."\n"; # End: LC_grade_submissions_body
+ }
+ $request->print($lastsubonly);
+ if ($env{'form.lastSub'} eq 'datesub') {
+ my ($parts,$handgrade,$responseType) = &response_type($symb,\$res_error);
+ $request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
+ }
+ if ($env{'form.lastSub'} =~ /^(last|all)$/) {
+ my $identifier = (&canmodify($usec)? $counter : '');
+ $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
+ $env{'request.course.id'},
+ $last,'.submission',
+ 'Apache::grades::keywords_highlight',
+ $usec,$identifier));
+ }
+ $request->print(''."\n");
+ # return if view submission with no grading option
+ if (!&canmodify($usec)) {
+ $request->print('
'.&mt('No grading privileges').'
');
+ return;
+ } else {
+ $request->print(''."\n");
+ }
+
+ # grading message center
+
+ if ($env{'form.compmsg'}) {
+ my $result='
'.
+ '
'.&mt('Send Message').'
'.
+ '
';
+ my ($lastname,$givenn) = split(/,/,$env{'form.fullname'});
+ my $msgfor = $givenn.' '.$lastname;
+ if (scalar(@$col_fullnames) > 0) {
+ my $lastone = pop(@$col_fullnames);
+ $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.';
}
- $lastsubonly.='
';
+ $request->print($result);
+ }
+
+ my %seen = ();
+ my @partlist;
+ my @gradePartRespid;
+ my @part_response_id;
+ if ($is_tool) {
+ @part_response_id = ([0,'']);
+ } else {
+ @part_response_id = &flatten_responseType($responseType);
}
- return ($lastsubonly,$partinfo);
+ $request->print(
+ '
'
+ .'
'.&mt('Assign Grades').'
'
+ );
+ $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 });
+ next if ($seen{$partid} > 0);
+ $seen{$partid}++;
+ push(@partlist,$partid);
+ push(@gradePartRespid,$partid.'.'.$respid);
+ $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
+ }
+ $request->print(&gradeBox_end()); #
+ $request->print('');
+
+ $request->print('
');
+ $request->print('
');
+
+ $result=''."\n";
+ $result.=''."\n" if ($counter == 0);
+ my $ctr = 0;
+ while ($ctr < scalar(@partlist)) {
+ $result.=''."\n";
+ $ctr++;
+ }
+ $request->print($result.''."\n");
+
+# Done with printing info for one student
+
+ $request->print('');#LC_grade_show_user
+
+
+ # print end of form
+ if ($counter == $total) {
+ my $endform='
'."\n";
+ $endform.=' '."\n";
+ my $ntstu =''."\n";
+ my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1');
+ $ntstu =~ s/
';
+ $request->print($endform);
+ }
+ return '';
}
sub check_collaborators {
@@ -2961,15 +2952,10 @@ sub get_last_submission {
if ($solved{$partid} ne '') {
$prevsolved{$partid} = $solved{$partid};
}
- }
+ }
+ $timestamp =
+ &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'});
}
-#
-# Timestamp is for last transaction for this resource, which does not
-# necessarily correspond to the time of last submission for problem (or part).
-#
- if ($lasthash{'timestamp'} ne '') {
- $timestamp = &Apache::lonlocal::locallocaltime($lasthash{'timestamp'});
- }
my (%typeparts,%randombytry);
my $showsurv =
&Apache::lonnet::allowed('vas',$env{'request.course.id'});
@@ -3062,11 +3048,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';
@@ -3268,7 +3255,7 @@ sub processHandGrade {
next;
}
if ($errorflag eq 'not_allowed') {
- $request->print(
+ $request->print(
''
.&mt('Not allowed to modify grades for [_1]',"$uname:$udom")
.'');
@@ -3369,9 +3356,9 @@ sub processHandGrade {
$ctr = 0;
while ($ctr < $ngrade) {
if ($env{'form.newmsg'.$ctr} ne '') {
- $keyhash{$symb.'_savemsg'.$idx} = $env{'form.newmsg'.$ctr};
- $env{'form.savemsg'.$idx} = $env{'form.newmsg'.$ctr};
- $idx++;
+ $keyhash{$symb.'_savemsg'.$idx} = $env{'form.newmsg'.$ctr};
+ $env{'form.savemsg'.$idx} = $env{'form.newmsg'.$ctr};
+ $idx++;
}
$ctr++;
}
@@ -3379,8 +3366,8 @@ sub processHandGrade {
$keyhash{$symb.'_savemsgN'} = $env{'form.savemsgN'};
}
if (($numessay) || ($env{'form.compmsg'})) {
- my $putresult = &Apache::lonnet::put
- ('nohist_handgrade',\%keyhash,$cdom,$cnum);
+ my $putresult = &Apache::lonnet::put
+ ('nohist_handgrade',\%keyhash,$cdom,$cnum);
}
# Called by Save & Refresh from Highlight Attribute Window
@@ -3482,7 +3469,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 '';
@@ -3678,19 +3665,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) =
&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,
@@ -3708,8 +3695,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}.''));
}
@@ -3720,7 +3706,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');
@@ -3840,93 +3826,20 @@ 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);
}
- }
- 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);
+ }
+ return (@returned_keys);
}
#--------------------------------------------------------------------------------------
@@ -4174,7 +4087,7 @@ sub viewgrades {
$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');
+ $common_header = &mt('Assign Common Grade to Class');
$specific_header = &mt('Assign Grade to Specific Students in Class');
}
} elsif (grep(/^none$/,@sections)) {
@@ -4187,7 +4100,7 @@ sub viewgrades {
$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');
+ $specific_header = &mt('Assign Grade to Specific Students in no Section');
}
} else {
$section_display = join (", ",@sections);
@@ -4201,7 +4114,7 @@ sub viewgrades {
$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);
+ $specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1]',$section_display);
}
}
my %submit_types = &substatus_options();
@@ -4258,10 +4171,10 @@ sub viewgrades {
$partid.'" size="4" '.'onchange="javascript:writePoint(\''.
$partid.'\','.$weight{$partid}.',\'textval\')" /> /'.
$weight{$partid}.' '.&mt('(problem weight)').''."\n";
- $line.= '
'.&mt('Grade Status').':'.
- '
'.
&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table();
return $result;
@@ -5023,13 +4936,12 @@ sub csvuploadmap {
if (!$env{'form.datatoken'}) {
$datatoken=&Apache::loncommon::upfile_store($request);
} else {
- $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
- if ($datatoken ne '') {
+ $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
+ if ($datatoken ne '') {
&Apache::loncommon::load_tmp_file($request,$datatoken);
}
}
my @records=&Apache::loncommon::upfile_record_sep();
- if ($env{'form.noFirstLine'}) { shift(@records); }
&csvuploadmap_header($request,$symb,$datatoken,$#records+1);
my ($i,$keyfields);
if (@records) {
@@ -5066,8 +4978,6 @@ sub csvuploadmap {
sub csvuploadoptions {
my ($request,$symb)= @_;
my $overwrite=&mt('Overwrite any existing score');
- my $checked=(($env{'form.noFirstLine'})?'1':'0');
- my $ignore=&mt('Ignore First Line');
$request->print(<
@@ -5081,7 +4991,7 @@ ENDPICK
my %fields=&get_fields();
if (!defined($fields{'domain'})) {
my $domform = &Apache::loncommon::select_dom_form($env{'request.role.domain'},'default_domain');
- $request->print("\n
".&mt('Users are in domain: [_1]',$domform)."
\n");
+ $request->print("\n
".&mt('Users are in domain: [_1]',$domform)."
\n");
}
foreach my $key (sort(keys(%env))) {
if ($key !~ /^form\.(.*)$/) { next; }
@@ -5119,11 +5029,10 @@ sub csvuploadassign {
if (!$symb) {return '';}
my $error_msg = '';
my $datatoken = &Apache::loncommon::valid_datatoken($env{'form.datatoken'});
- if ($datatoken ne '') {
+ if ($datatoken ne '') {
&Apache::loncommon::load_tmp_file($request,$datatoken);
}
my @gradedata = &Apache::loncommon::upfile_record_sep();
- if ($env{'form.noFirstLine'}) { shift(@gradedata); }
my %fields=&get_fields();
my $courseid=$env{'request.course.id'};
my ($classlist) = &getclasslist('all',0);
@@ -5145,13 +5054,45 @@ sub csvuploadassign {
if (!$username) {
my $id=$entries{$fields{'ID'}};
$id=~s/\s//g;
- my %ids=&Apache::lonnet::idget($domain,$id);
- $username=$ids{$id};
+ if ($id ne '') {
+ my %ids=&Apache::lonnet::idget($domain,[$id]);
+ $username=$ids{$id};
+ } else {
+ if ($entries{$fields{'clicker'}}) {
+ my $clicker = $entries{$fields{'clicker'}};
+ $clicker=~s/\s//g;
+ if ($clicker ne '') {
+ my %clickers = &Apache::lonnet::idget($domain,[$clicker],'clickers');
+ if ($clickers{$clicker} ne '') {
+ my $match = 0;
+ my @inclass;
+ foreach my $poss (split(/,/,$clickers{$clicker})) {
+ if (exists($$classlist{"$poss:$domain"})) {
+ $username = $poss;
+ push(@inclass,$poss);
+ $match ++;
+
+ }
+ }
+ if ($match > 1) {
+ undef($username);
+ $request->print('
'.
+ &mt('Score not saved for clicker: [_1] (matched multiple usernames: [_2])',
+ $clicker,join(', ',@inclass)).'
');
+ }
+ }
+ }
+ }
+ }
}
if (!exists($$classlist{"$username:$domain"})) {
my $id=$entries{$fields{'ID'}};
$id=~s/\s//g;
- if ($id) {
+ my $clicker = $entries{$fields{'clicker'}};
+ $clicker=~s/\s//g;
+ if ($clicker) {
+ push(@skipped,"$clicker:$domain");
+ } elsif ($id) {
push(@skipped,"$id:$domain");
} else {
push(@skipped,"$username:$domain");
@@ -5179,7 +5120,7 @@ sub csvuploadassign {
my $award=($pcr == 0) ? 'incorrect_by_override'
: 'correct_by_override';
if ($pcr>1) {
- push(@warnings,&mt("[_1]: point value larger than weight","$username:$domain"));
+ push(@warnings,&mt("[_1]: point value larger than weight","$username:$domain"));
}
$grades{"resource.$part.awarded"}=$pcr;
$grades{"resource.$part.solved"}=$award;
@@ -5215,13 +5156,13 @@ sub csvuploadassign {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'},
$domain,$username);
- } else {
+ $countdone++;
+ } else {
$request->print("
".
&mt("Failed to save data for student [_1]. Message when trying to save was: [_2]",
"$username:$domain",$result)."