--- loncom/homework/grades.pm 2023/09/07 17:38:56 1.596.2.12.2.60.2.5
+++ loncom/homework/grades.pm 2021/12/17 20:10:21 1.787
@@ -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.5 2023/09/07 17:38:56 raeburn Exp $
+# $Id: grades.pm,v 1.787 2021/12/17 20:10:21 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.',
@@ -2205,7 +2206,7 @@ sub files_exist {
my ($uname,$udom,$fullname) = split(/:/,$student);
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
$udom,$uname);
- my ($string)= &get_last_submission(\%record);
+ my ($string,$timestamp)= &get_last_submission(\%record);
foreach my $submission (@$string) {
my ($partid,$respid) =
($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/);
@@ -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,19 +2558,176 @@ 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);
+ my ($string,$timestamp)= &get_last_submission(\%record,$is_tool);
+
+ my $lastsubonly;
+
+ if ($$timestamp eq '') {
+ $lastsubonly.='
';
+ 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.')').
+ '
';
- 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.')').
- '
'.
- ''.&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);
@@ -2925,45 +2903,17 @@ 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 (@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 =
@@ -3027,7 +2977,7 @@ sub get_last_submission {
$string[0] =
''.$msg.'';
}
- return (\@string,$timestamp,$lastgradetime,$lastsubmittime);
+ return (\@string,\$timestamp);
}
#--- High light keywords, with style choosen by user.
@@ -3057,11 +3007,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';
@@ -3263,7 +3214,7 @@ sub processHandGrade {
next;
}
if ($errorflag eq 'not_allowed') {
- $request->print(
+ $request->print(
''
.&mt('Not allowed to modify grades for [_1]',"$uname:$udom")
.'');
@@ -3364,9 +3315,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++;
}
@@ -3374,8 +3325,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
@@ -3477,7 +3428,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 '';
@@ -3673,19 +3624,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,
@@ -3703,8 +3654,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 +3665,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 +3785,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 +3801,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
@@ -4169,7 +4046,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)) {
@@ -4182,7 +4059,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);
@@ -4196,7 +4073,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();
@@ -4253,10 +4130,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;
@@ -5018,13 +4895,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) {
@@ -5061,8 +4937,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(<
@@ -5076,7 +4950,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; }
@@ -5114,11 +4988,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);
@@ -5140,13 +5013,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");
@@ -5174,7 +5079,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;
@@ -5210,13 +5115,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)."