--- loncom/homework/grades.pm 2017/08/11 18:58:17 1.742 +++ loncom/homework/grades.pm 2018/10/08 19:04:06 1.751 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.742 2017/08/11 18:58:17 raeburn Exp $ +# $Id: grades.pm,v 1.751 2018/10/08 19:04:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -116,7 +116,11 @@ sub getpartlist { my $res = $navmap->getBySymb($symb); my $partlist = $res->parts(); my $url = $res->src(); - my @metakeys = split(/,/,&Apache::lonnet::metadata($url,'keys')); + my $toolsymb; + if ($url =~ /ext\.tool$/) { + $toolsymb = $symb; + } + my @metakeys = split(/,/,&Apache::lonnet::metadata($url,'keys',$toolsymb)); my @stores; foreach my $part (@{ $partlist }) { @@ -413,6 +417,7 @@ sub cleanRecord { $env{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : ''; $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob. } + $answer = &Apache::lontexconvert::msgtexconverted($answer); return '

'.&keywords_highlight($answer).'
'; } elsif ( $response eq 'organic') { @@ -498,7 +503,7 @@ COMMONJSFUNCTIONS #--- Dumps the class list with usernames,list of sections, #--- section, ids and fullnames for each user. sub getclasslist { - my ($getsec,$filterlist,$getgroup) = @_; + my ($getsec,$filterbyaccstatus,$getgroup,$symb,$submitonly,$filterbysubmstatus) = @_; my @getsec; my @getgroup; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); @@ -526,6 +531,13 @@ sub getclasslist { # my %sections; my %fullnames; + my ($cdom,$cnum,$partlist); + if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) { + $cdom = $env{"course.$env{'request.course.id'}.domain"}; + $cnum = $env{"course.$env{'request.course.id'}.num"}; + my $res_error; + ($partlist,my $handgrade,my $responseType) = &response_type($symb,\$res_error); + } foreach my $student (keys(%$classlist)) { my $end = $classlist->{$student}->[&Apache::loncoursedata::CL_END()]; @@ -542,7 +554,7 @@ sub getclasslist { my $group = $classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()]; # filter students according to status selected - if ($filterlist && (!($stu_status =~ /Any/))) { + if ($filterbyaccstatus && (!($stu_status =~ /Any/))) { if (!($stu_status =~ $status)) { delete($classlist->{$student}); next; @@ -559,13 +571,58 @@ sub getclasslist { } } if (($grp eq 'none') && !$group) { - $exclude = 0; + $exclude = 0; } } if ($exclude) { delete($classlist->{$student}); + next; } } + if (($filterbysubmstatus) && ($submitonly ne 'all') && ($symb ne '')) { + my $udom = + $classlist->{$student}->[&Apache::loncoursedata::CL_SDOM()]; + my $uname = + $classlist->{$student}->[&Apache::loncoursedata::CL_SNAME()]; + if (($symb ne '') && ($udom ne '') && ($uname ne '')) { + if ($submitonly eq 'queued') { + my %queue_status = + &Apache::bridgetask::get_student_status($symb,$cdom,$cnum, + $udom,$uname); + if (!defined($queue_status{'gradingqueue'})) { + delete($classlist->{$student}); + next; + } + } else { + my (%status) =&student_gradeStatus($symb,$udom,$uname,$partlist); + my $submitted = 0; + my $graded = 0; + my $incorrect = 0; + foreach (keys(%status)) { + $submitted = 1 if ($status{$_} ne 'nothing'); + $graded = 1 if ($status{$_} =~ /^ungraded/); + $incorrect = 1 if ($status{$_} =~ /^incorrect/); + + my ($foo,$partid,$foo1) = split(/\./,$_); + if ($status{'resource.'.$partid.'.submitted_by'} ne '') { + $submitted = 0; + } + } + if (!$submitted && ($submitonly eq 'yes' || + $submitonly eq 'incorrect' || + $submitonly eq 'graded')) { + delete($classlist->{$student}); + next; + } elsif (!$graded && ($submitonly eq 'graded')) { + delete($classlist->{$student}); + next; + } elsif (!$incorrect && $submitonly eq 'incorrect') { + delete($classlist->{$student}); + next; + } + } + } + } $section = ($section ne '' ? $section : 'none'); if (&canview($section)) { if (!@getsec || grep(/^\Q$section\E$/,@getsec)) { @@ -580,7 +637,6 @@ sub getclasslist { delete($classlist->{$student}); } } - my %seen = (); my @sections = sort(keys(%sections)); return ($classlist,\@sections,\%fullnames); } @@ -852,6 +908,7 @@ sub verifyreceipt { sub listStudents { my ($request,$symb,$submitonly) = @_; + my $is_tool = ($symb =~ /ext\.tool$/); my $cdom = $env{"course.$env{'request.course.id'}.domain"}; my $cnum = $env{"course.$env{'request.course.id'}.num"}; my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'}; @@ -907,38 +964,66 @@ LISTJAVASCRIPT "\n"; $gradeTable .= &Apache::lonhtmlcommon::start_pick_box(); - $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text')) - .''."\n" - .''."\n" - .'
'."\n" - .&Apache::lonhtmlcommon::row_closure(); - $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Answer')) - .''."\n" - .''."\n" - .'
'."\n" - .&Apache::lonhtmlcommon::row_closure(); + unless ($is_tool) { + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text')) + .''."\n" + .''."\n" + .'
'."\n" + .&Apache::lonhtmlcommon::row_closure(); + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Answer')) + .''."\n" + .''."\n" + .'
'."\n" + .&Apache::lonhtmlcommon::row_closure(); + } my $submission_options; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); my $saveStatus = $stu_status eq '' ? 'Active' : $stu_status; $env{'form.Status'} = $saveStatus; + my %optiontext; + if ($is_tool) { + %optiontext = &Apache::lonlocal::texthash ( + lastonly => 'last transaction', + last => 'last transaction with details', + datesub => 'all transactions', + all => 'all transactions with details', + ); + } else { + %optiontext = &Apache::lonlocal::texthash ( + lastonly => 'last submission', + last => 'last submission with details', + datesub => 'all submissions', + all => 'all submissions with details', + ); + } $submission_options.= ''. ''."\n". + $optiontext{'lastonly'}.' '."\n". ''. ''."\n". + $optiontext{'last'}.' '."\n". ''. ''."\n". + $optiontext{'datesub'}.''."\n". ''. ''; - $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Submissions')) + $optiontext{'all'}.''; + my $viewtitle; + if ($is_tool) { + $viewtitle = &mt('View Transactions'); + } else { + $viewtitle = &mt('View Submissions'); + } + $gradeTable .= &Apache::lonhtmlcommon::row_title($viewtitle) .$submission_options .&Apache::lonhtmlcommon::row_closure(); + my $closure; + if (($is_tool) && (exists($env{'form.Status'}))) { + $closure = 1; + } $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Grading Increments')) .'' - .&Apache::lonhtmlcommon::row_closure(); + .&Apache::lonhtmlcommon::row_closure($closure); $gradeTable .= &build_section_inputs(). @@ -957,19 +1042,30 @@ LISTJAVASCRIPT if (exists($env{'form.Status'})) { $gradeTable .= ''."\n"; } else { + if ($is_tool) { + $closure = 1; + } $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Student Status')) .&Apache::lonhtmlcommon::StatusOptions( $saveStatus,undef,1,'javascript:reLoadList(this.form);') - .&Apache::lonhtmlcommon::row_closure(); + .&Apache::lonhtmlcommon::row_closure($closure); } - $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Check For Plagiarism')) - .'' - .&Apache::lonhtmlcommon::row_closure(1) - .&Apache::lonhtmlcommon::end_pick_box(); - + unless ($is_tool) { + $closure = 1; + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Check For Plagiarism')) + .'' + .&Apache::lonhtmlcommon::row_closure($closure); + } + $gradeTable .= &Apache::lonhtmlcommon::end_pick_box(); + my $regrademsg; + if ($is_tool) { + $regrademsg =&mt("To view/grade/regrade, click on the check box(es) next to the student's name(s). Then click on the Next button."); + } else { + $regrademsg = &mt("To view/grade/regrade a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button."); + } $gradeTable .= '

' - .&mt("To view/grade/regrade a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n" + .$regrademsg."\n" .'' .'

'; @@ -1908,7 +2004,6 @@ sub show_problem { sub files_exist { my ($r, $symb) = @_; my @students = &Apache::loncommon::get_env_multiple('form.stuinfo'); - foreach my $student (@students) { my ($uname,$udom,$fullname) = split(/:/,$student); my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'}, @@ -1931,7 +2026,6 @@ sub download_all_link { $r->print(&mt('There are currently no submitted documents.')); return; } - my $all_students = join("\n", &Apache::loncommon::get_env_multiple('form.stuinfo')); @@ -1951,7 +2045,55 @@ sub submit_download_link { my ($request,$symb) = @_; if (!$symb) { return ''; } #FIXME: Figure out which type of problem this is and provide appropriate download - &download_all_link($request,$symb); + my $res_error; + my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error); + if (ref($res_error)) { + if ($$res_error) { + $request->print(&mt('An error occurred retrieving response types')); + return; + } + } + my ($numupload,$numessay) = (0,0); + if (ref($responseType) eq 'HASH') { + foreach my $part (sort(keys(%$responseType))) { + foreach my $id (sort(keys(%{ $responseType->{$part} }))) { + my $responsetype = $responseType->{$part}->{$id}; + if ($responsetype eq 'essay') { + my $uploadedfiletypes = + &Apache::lonnet::EXT("resource.$part".'_'."$id.uploadedfiletypes",$symb); + if ($uploadedfiletypes) { + $numupload++; + } else { + $numessay++; + } + } + } + } + } + if (($numupload) || ($numessay)) { + my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; + my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'}; + my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'}; + (undef,undef,my $fullname) = &getclasslist($getsec,1,$getgroup,$symb,$submitonly,1); + if (ref($fullname) eq 'HASH') { + my @students = map { $_.':'.$fullname->{$_} } (keys(%{$fullname})); + if (@students) { + @{$env{'form.stuinfo'}} = @students; + if ($numupload) { + &download_all_link($request,$symb); + } +# FIXME Need to provide a mechanism to download essays, i.e., if $numessay > 0 +# Needs to omit user's identity if resource instance is for an anonymous survey. + } else { + $request->print(&mt('No students match the criteria you selected')); + } + } else { + $request->print(&mt('Could not retrieve student information')); + } + } else { + $request->print(&mt('No essayresponse items found')); + } + return; } sub build_section_inputs { @@ -1977,6 +2119,7 @@ sub submission { my $probtitle=&Apache::lonnet::gettitle($symb); if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } + my $is_tool = ($symb =~ /ext\.tool$/); if (!&canview($usec)) { $request->print( @@ -1989,8 +2132,10 @@ sub submission { } if (!$env{'form.lastSub'}) { $env{'form.lastSub'} = 'datesub'; } - if (!$env{'form.vProb'}) { $env{'form.vProb'} = 'yes'; } - if (!$env{'form.vAns'}) { $env{'form.vAns'} = 'yes'; } + unless ($is_tool) { + if (!$env{'form.vProb'}) { $env{'form.vProb'} = 'yes'; } + if (!$env{'form.vAns'}) { $env{'form.vAns'} = 'yes'; } + } my $last = ($env{'form.lastSub'} eq 'last' ? 'last' : ''); my $checkIcon = ''.&mt('Check Mark').
 	'' - .'

'.&mt('Submissions').'

'; + .'

'.$boxtitle.'

'; $result.=''."\n"; # if ($env{'form.handgrade'} eq 'no') { - if (1) { + unless ($is_tool) { $result.='

' .&mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon) ."

\n"; @@ -2178,7 +2327,7 @@ sub submission { my $fullname; my $col_fullnames = []; # if ($env{'form.handgrade'} eq 'yes') { - if (1) { + unless ($is_tool) { (my $sub_result,$fullname,$col_fullnames)= &check_collaborators($symb,$uname,$udom,\%record,$handgrade, $counter); @@ -2193,12 +2342,16 @@ sub submission { # (3) Last submission plus the parts info # (4) The whole record for this student - my ($string,$timestamp)= &get_last_submission(\%record); + my ($string,$timestamp)= &get_last_submission(\%record,$is_tool); my $lastsubonly; if ($$timestamp eq '') { $lastsubonly.='
'.$$string[0].'
'; + } elsif ($is_tool) { + $lastsubonly = + '
' + .''.&mt('Date Grade Passed Back:').' '.$$timestamp."
\n"; } else { $lastsubonly = '
' @@ -2381,7 +2534,12 @@ sub submission { my %seen = (); my @partlist; my @gradePartRespid; - my @part_response_id = &flatten_responseType($responseType); + my @part_response_id; + if ($is_tool) { + @part_response_id = ([0,'']); + } else { + @part_response_id = &flatten_responseType($responseType); + } $request->print( '
' .'

'.&mt('Assign Grades').'

' @@ -2507,7 +2665,7 @@ sub check_collaborators { #--- Retrieve the last submission for all the parts sub get_last_submission { - my ($returnhash)=@_; + my ($returnhash,$is_tool)=@_; my (@string,$timestamp,%lasthidden); if ($$returnhash{'version'}) { my %lasthash=(); @@ -2573,8 +2731,14 @@ 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] = - ''.&mt('Nothing submitted - no attempts.').''; + ''.$msg.''; } return (\@string,\$timestamp); } @@ -3561,6 +3725,11 @@ 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, @@ -3641,7 +3810,13 @@ sub viewgrades { if ($env{'form.submitonly'} eq 'all') { $result.= '

'.$common_header.'

'; } else { - $result.= '

'.$common_header.' '.&mt('(submission status: "[_1]")',$submission_status).'

'; + my $text; + if ($is_tool) { + $text = &mt('(transaction status: "[_1]")',$submission_status); + } else { + $text = &mt('(submission status: "[_1]")',$submission_status); + } + $result.= '

'.$common_header.' '.$text.'

'; } $result .= &Apache::loncommon::start_data_table(); #radio buttons/text box for assigning points for a section or class. @@ -3654,13 +3829,18 @@ sub viewgrades { my %weight = (); my $ctsparts = 0; my %seen = (); - my @part_response_id = &flatten_responseType($responseType); + my @part_response_id; + if ($is_tool) { + @part_response_id = ([0,'']); + } else { + @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 $handgrade=$$handgrade{$part_resp}; my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); $weight{$partid} = $wgt eq '' ? '1' : $wgt; @@ -3709,7 +3889,13 @@ sub viewgrades { if ($env{'form.submitonly'} eq 'all') { $result.= '

'.$specific_header.'

'; } else { - $result.= '

'.$specific_header.' '.&mt('(submission status: "[_1]")',$submission_status).'

'; + my $text; + if ($is_tool) { + $text = &mt('(transaction status: "[_1]")',$submission_status); + } else { + $text = &mt('(submission status: "[_1]")',$submission_status); + } + $result.= '

'.$specific_header.' '.$text.'

'; } $result.= &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). @@ -3723,10 +3909,10 @@ sub viewgrades { my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); my @partids = (); foreach my $part (@parts) { - my $display=&Apache::lonnet::metadata($url,$part.'.display'); + my $display=&Apache::lonnet::metadata($url,$part.'.display',$toolsymb); my $narrowtext = &mt('Tries'); $display =~ s|^Number of Attempts|$narrowtext
|; # makes the column narrower - if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } + if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name',$toolsymb); } my ($partid) = &split_part_type($part); push(@partids,$partid); # @@ -3767,7 +3953,7 @@ sub viewgrades { return $a cmp $b; } (keys(%$fullname))) { $result.=&viewstudentgrade($symb,$env{'request.course.id'}, - $_,$$fullname{$_},\@parts,\%weight,\$ctr,\%last_resets); + $_,$$fullname{$_},\@parts,\%weight,\$ctr,\%last_resets,$is_tool); } $result.=&Apache::loncommon::end_data_table(); $result.=''."\n"; @@ -3855,7 +4041,7 @@ sub viewgrades { #--- call by previous routine to display each student who satisfies submission filter. sub viewstudentgrade { - my ($symb,$courseid,$student,$fullname,$parts,$weight,$ctr,$last_resets) = @_; + my ($symb,$courseid,$student,$fullname,$parts,$weight,$ctr,$last_resets,$is_tool) = @_; my ($uname,$udom) = split(/:/,$student); my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname); my $submitonly = $env{'form.submitonly'}; @@ -3961,6 +4147,10 @@ sub viewstudentgrade { # record does not get update if unchanged sub editgrades { my ($request,$symb) = @_; + my $toolsymb; + if ($symb =~ /ext\.tool$/) { + $toolsymb = $symb; + } my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); my $title='

'.&mt('Current Grade Status').'

'; @@ -3998,6 +4188,7 @@ sub editgrades { $ctr++; } my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); + my $totcolspan = 0; foreach my $partid (@partid) { $header .= ''.&mt('Old Score').''. ''.&mt('New Score').''; @@ -4006,7 +4197,7 @@ sub editgrades { my ($part,$type) = &split_part_type($stores); if ($part !~ m/^\Q$partid\E/) { next;} if ($type eq 'awarded' || $type eq 'solved') { next; } - my $display=&Apache::lonnet::metadata($url,$stores.'.display'); + my $display=&Apache::lonnet::metadata($url,$stores.'.display',$toolsymb); $display =~ s/\[Part: \Q$part\E\]//; my $narrowtext = &mt('Tries'); $display =~ s/Number of Attempts/$narrowtext/; @@ -4014,6 +4205,7 @@ sub editgrades { ''.&mt('New').' '.$display.''; $columns{$partid}+=2; } + $totcolspan += $columns{$partid}; } foreach my $partid (@partid) { my $display_part=&get_display_part($partid,$symb); @@ -4029,18 +4221,18 @@ sub editgrades { my @noupdate; my ($updateCtr,$noupdateCtr) = (1,1); for ($i=0; $i<$env{'form.total'}; $i++) { - my $line; my $user = $env{'form.ctr'.$i}; my ($uname,$udom)=split(/:/,$user); my %newrecord; my $updateflag = 0; - $line .= ''.&nameUserString(undef,$$fullname{$user},$uname,$udom).''; my $usec=$classlist->{"$uname:$udom"}[5]; - if (!&canmodify($usec)) { - my $numcols=scalar(@partid)*4+2; + my $canmodify = &canmodify($usec); + my $line = ''. + &nameUserString(undef,$$fullname{$user},$uname,$udom).''; + if (!$canmodify) { push(@noupdate, - $line."". - &mt('Not allowed to modify student').""); + $line."". + &mt('Not allowed to modify student').""); next; } my %aggregate = (); @@ -4157,8 +4349,7 @@ sub editgrades { } } if (@noupdate) { -# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3; - my $numcols=scalar(@partid)*4+2; + my $numcols=$totcolspan+2; $result .= &Apache::loncommon::start_data_table_row('LC_empty_row'). ''. &mt('No Changes Occurred For the Students Below'). @@ -4199,7 +4390,7 @@ sub split_part_type { # #--- Javascript to handle csv upload sub csvupload_javascript_reverse_associate { - my $error1=&mt('You need to specify the username or the student/employee ID'); + my $error1=&mt('You need to specify the username, the student/employee ID, or the clicker ID'); my $error2=&mt('You need to specify at least one grading field'); &js_escape(\$error1); &js_escape(\$error2); @@ -4208,13 +4399,15 @@ sub csvupload_javascript_reverse_associa var foundsomething=0; var founduname=0; var foundID=0; + var foundclicker=0; for (i=0;i<=vf.nfields.value;i++) { tw=eval('vf.f'+i+'.selectedIndex'); if (i==0 && tw!=0) { foundID=1; } if (i==1 && tw!=0) { founduname=1; } - if (i!=0 && i!=1 && i!=2 && tw!=0) { foundsomething=1; } + if (i==2 && tw!=0) { foundclicker=1; } + if (i!=0 && i!=1 && i!=2 && i!=3 && tw!=0) { foundsomething=1; } } - if (founduname==0 && foundID==0) { + if (founduname==0 && foundID==0 && foundclicker==0) { alert('$error1'); return; } @@ -4241,7 +4434,7 @@ ENDPICK } sub csvupload_javascript_forward_associate { - my $error1=&mt('You need to specify the username or the student/employee ID'); + my $error1=&mt('You need to specify the username, the student/employee ID, or the clicker ID'); my $error2=&mt('You need to specify at least one grading field'); &js_escape(\$error1); &js_escape(\$error2); @@ -4250,13 +4443,15 @@ sub csvupload_javascript_forward_associa var foundsomething=0; var founduname=0; var foundID=0; + var foundclicker=0; for (i=0;i<=vf.nfields.value;i++) { tw=eval('vf.f'+i+'.selectedIndex'); if (tw==1) { foundID=1; } if (tw==2) { founduname=1; } - if (tw>3) { foundsomething=1; } + if (tw==3) { foundclicker=1; } + if (tw>4) { foundsomething=1; } } - if (founduname==0 && foundID==0) { + if (founduname==0 && foundID==0 && Ć’oundclicker==0) { alert('$error1'); return; } @@ -4314,6 +4509,10 @@ ENDPICK sub csvupload_fields { my ($symb,$errorref) = @_; + my $toolsymb; + if ($symb =~ /ext\.tool$/) { + $toolsymb = $symb; + } my (@parts) = &getpartlist($symb,$errorref); if (ref($errorref)) { if ($$errorref) { @@ -4322,15 +4521,15 @@ sub csvupload_fields { } my @fields=(['ID','Student/Employee ID'], - ['clicker','Clicker ID'], ['username','Student Username'], + ['clicker','Clicker ID'], ['domain','Student Domain']); my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); foreach my $part (sort(@parts)) { my @datum; - my $display=&Apache::lonnet::metadata($url,$part.'.display'); + my $display=&Apache::lonnet::metadata($url,$part.'.display',$toolsymb); my $name=$part; - if (!$display) { $display = $name; } + if (!$display) { $display = $name; } @datum=($name,$display); if ($name=~/^stores_(.*)_awarded/) { push(@fields,['stores_'.$1.'_points',"Points [Part: $1]"]); @@ -4820,7 +5019,7 @@ sub getSymbMap { my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1,0,1); for my $sequence ($navmap->getById('0.0'), @sequences) { - if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) { + if ($navmap->hasResource($sequence, sub { shift->is_gradable(); }, 0) ) { my $title = $minder.'.'. &HTML::Entities::encode($sequence->compTitle(),'"\'&'); push(@titles, $title); # minder in case two titles are identical @@ -4917,10 +5116,11 @@ sub displayPage { if($curRes == $iterator->BEGIN_MAP) { $depth++; } if($curRes == $iterator->END_MAP) { $depth--; } - if (ref($curRes) && $curRes->is_problem()) { + if (ref($curRes) && $curRes->is_gradable()) { my $parts = $curRes->parts(); my $title = $curRes->compTitle(); my $symbx = $curRes->symb(); + my $is_tool = ($symbx =~ /ext\.tool$/); $studentTable.= &Apache::loncommon::start_data_table_row(). ''.$prob. @@ -4931,26 +5131,34 @@ sub displayPage { ''; $studentTable.=''; my %form = ('CODE' => $env{'form.CODE'},); - if ($env{'form.vProb'} eq 'yes' ) { - $studentTable.=&show_problem($request,$symbx,$uname,$udom,1, - undef,'both',\%form); - } else { - my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$env{'request.course.id'},%form); - $companswer =~ s|||g; - $companswer =~ s|||g; -# while ($companswer =~ /()/s) { #\n"); -# } -# $companswer =~ s||
|g; - $studentTable.=' '.$title.' 
 '.&mt('Correct answer').':
'.$companswer; + if ($is_tool) { + $studentTable.=' '.$title.'
'; + } else { + if ($env{'form.vProb'} eq 'yes' ) { + $studentTable.=&show_problem($request,$symbx,$uname,$udom,1, + undef,'both',\%form); + } else { + my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$env{'request.course.id'},%form); + $companswer =~ s|||g; + $companswer =~ s|||g; +# while ($companswer =~ /()/s) { #\n"); +# } +# $companswer =~ s|
|
|g; + $studentTable.=' '.$title.' 
 '.&mt('Correct answer').':
'.$companswer; + } } my %record = &Apache::lonnet::restore($symbx,$env{'request.course.id'},$udom,$uname); if ($env{'form.lastSub'} eq 'datesub') { if ($record{'version'} eq '') { - $studentTable.='
 '.&mt('No recorded submission for this problem.').'
'; + my $msg = &mt('No recorded submission for this problem.'); + if ($is_tool) { + $msg = &mt('No recorded transactions for this external tool'); + } + $studentTable.='
 '.$msg.'
'; } else { my %responseType = (); foreach my $partid (@{$parts}) { @@ -4963,7 +5171,6 @@ sub displayPage { $responseType{$partid} = \%responseIds; } $studentTable.= &displaySubByDates($symbx,\%record,$parts,\%responseType,$checkIcon,$uname,$udom); - } } elsif ($env{'form.lastSub'} eq 'all') { my $last = ($env{'form.lastSub'} eq 'last' ? 'last' : ''); @@ -5004,13 +5211,14 @@ sub displaySubByDates { my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_; my $isCODE=0; my $isTask = ($symb =~/\.task$/); + my $is_tool = ($symb =~/\.tool$/); if (exists($record->{'resource.CODE'})) { $isCODE=1; } my $studentTable=&Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). '
'. ($isCODE?'':''). ($isTask?'':''). - ''. + ''. ''. &Apache::loncommon::end_data_table_header_row(); my ($version); @@ -5018,7 +5226,11 @@ sub displaySubByDates { my %orders; $mark{'correct_by_student'} = $checkIcon; if (!exists($$record{'1:timestamp'})) { - return '
 '.&mt('Nothing submitted - no attempts.').'
'; + if ($is_tool) { + return '
 '.&mt('No grade passed back.').'
'; + } else { + return '
 '.&mt('Nothing submitted - no attempts.').'
'; + } } my $interaction; @@ -5051,56 +5263,64 @@ sub displaySubByDates { if (($type eq 'anonsurvey') || ($type eq 'anonsurveycred')) { $hidden = 1; } - my @matchKey = ($isTask ? sort(grep /^resource\.\d+\.\Q$partid\E\.award$/,@versionKeys) - : sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys)); - + my @matchKey; + if ($isTask) { + @matchKey = sort(grep /^resource\.\d+\.\Q$partid\E\.award$/,@versionKeys); + } elsif ($is_tool) { + @matchKey = sort(grep /^resource\.\Q$partid\E\.awarded$/,@versionKeys); + } else { + @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys); + } # next if ($$record{"$version:resource.$partid.solved"} eq ''); my $display_part=&get_display_part($partid,$symb); foreach my $matchKey (@matchKey) { if (exists($$record{$version.':'.$matchKey}) && $$record{$version.':'.$matchKey} ne '') { - - my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) - : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); - $displaySub[0].=''; - $displaySub[0].=''.&mt('Part: [_1]',$display_part).'' - .' ' - .'('.&mt('Response ID: [_1]',$responseId).')' - .'' - .' '; - if ($hidden) { - $displaySub[0].= &mt('Anonymous Survey').''; + if ($is_tool) { + $displaySub[0].=$$record{"$version:resource.$partid.awarded"}; } else { - my ($trial,$rndseed,$newvariation); - if ($type eq 'randomizetry') { - $trial = $$record{"$where.$partid.tries"}; - $rndseed = $$record{"$where.$partid.rndseed"}; - } - if ($$record{"$where.$partid.tries"} eq '') { - $displaySub[0].=&mt('Trial not counted'); - } else { - $displaySub[0].=&mt('Trial: [_1]', - $$record{"$where.$partid.tries"}); - if (($rndseed ne '') && ($lastrndseed{$partid} ne '')) { - if (($rndseed ne $lastrndseed{$partid}) && - (($type eq 'randomizetry') || ($lasttype{$partid} eq 'randomizetry'))) { - $newvariation = ' ('.&mt('New variation this try').')'; - } + my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) + : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); + $displaySub[0].=''; + $displaySub[0].=''.&mt('Part: [_1]',$display_part).'' + .' ' + .'('.&mt('Response ID: [_1]',$responseId).')' + .'' + .' '; + if ($hidden) { + $displaySub[0].= &mt('Anonymous Survey').''; + } else { + my ($trial,$rndseed,$newvariation); + if ($type eq 'randomizetry') { + $trial = $$record{"$where.$partid.tries"}; + $rndseed = $$record{"$where.$partid.rndseed"}; } - $lastrndseed{$partid} = $rndseed; - $lasttype{$partid} = $type; - } - my $responseType=($isTask ? 'Task' + if ($$record{"$where.$partid.tries"} eq '') { + $displaySub[0].=&mt('Trial not counted'); + } else { + $displaySub[0].=&mt('Trial: [_1]', + $$record{"$where.$partid.tries"}); + if (($rndseed ne '') && ($lastrndseed{$partid} ne '')) { + if (($rndseed ne $lastrndseed{$partid}) && + (($type eq 'randomizetry') || ($lasttype{$partid} eq 'randomizetry'))) { + $newvariation = ' ('.&mt('New variation this try').')'; + } + } + $lastrndseed{$partid} = $rndseed; + $lasttype{$partid} = $type; + } + my $responseType=($isTask ? 'Task' : $responseType->{$partid}->{$responseId}); - if (!exists($orders{$partid})) { $orders{$partid}={}; } - if ((!exists($orders{$partid}->{$responseId})) || ($trial)) { - $orders{$partid}->{$responseId}= - &get_order($partid,$responseId,$symb,$uname,$udom, - $no_increment,$type,$trial,$rndseed); - } - $displaySub[0].=''.$newvariation.''; # /nobreak - $displaySub[0].='  '. - &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom,$type,$trial,$rndseed).'
'; + if (!exists($orders{$partid})) { $orders{$partid}={}; } + if ((!exists($orders{$partid}->{$responseId})) || ($trial)) { + $orders{$partid}->{$responseId}= + &get_order($partid,$responseId,$symb,$uname,$udom, + $no_increment,$type,$trial,$rndseed); + } + $displaySub[0].=''.$newvariation.'
'; # /nobreak + $displaySub[0].='  '. + &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom,$type,$trial,$rndseed).'
'; + } } } } @@ -5115,14 +5335,22 @@ sub displaySubByDates { lc($$record{"$where.$partid.award"}).' '. $mark{$$record{"$where.$partid.solved"}}. '
'; + } elsif (($is_tool) && (exists($$record{"$version:resource.$partid.solved"}))) { + if ($$record{"$version:resource.$partid.solved"} =~ /^(in|)correct_by_passback$/) { + $displaySub[1].=&mt('Grade passed back by external tool'); + } } if (exists $$record{"$where.$partid.regrader"}) { - $displaySub[2].=$$record{"$where.$partid.regrader"}. - ' ('.&mt('Part').': '.$display_part.')'; + $displaySub[2].=$$record{"$where.$partid.regrader"}; + unless ($is_tool) { + $displaySub[2].=' ('.&mt('Part').': '.$display_part.')'; + } } elsif ($$record{"$version:resource.$partid.regrader"} =~ /\S/) { $displaySub[2].= - $$record{"$version:resource.$partid.regrader"}. - ' ('.&mt('Part').': '.$display_part.')'; + $$record{"$version:resource.$partid.regrader"}; + unless ($is_tool) { + $displaySub[2].=' ('.&mt('Part').': '.$display_part.')'; + } } } # needed because old essay regrader has not parts info @@ -9654,12 +9882,13 @@ sub submit_options_table { my ($request,$symb) = @_; if (!$symb) {return '';} &commonJSfunctions($request); + my $is_tool = ($symb =~ /ext\.tool$/); my $result; $result.='
'."\n". ''."\n"; - $result.=&selectfield(1). + $result.=&selectfield(1,$is_tool). '
@@ -9673,14 +9902,15 @@ sub submit_options_download { my ($request,$symb) = @_; if (!$symb) {return '';} + my $is_tool = ($symb =~ /ext\.tool$/); &commonJSfunctions($request); my $result=''."\n". ''."\n"; $result.='

- '.&mt('Select Students for Which to Download Submissions').' -

'.&selectfield(1).' + '.&mt('Select Students for whom to Download Submissions').' +'.&selectfield(1,$is_tool).'
@@ -9696,12 +9926,13 @@ sub submit_options { my ($request,$symb) = @_; if (!$symb) {return '';} + my $is_tool = ($symb =~ /ext\.tool$/); &commonJSfunctions($request); my $result; $result.=''."\n". ''."\n"; - $result.=&selectfield(1).' + $result.=&selectfield(1,$is_tool).' @@ -9713,10 +9944,17 @@ sub submit_options { } sub selectfield { - my ($full)=@_; - my %options = - (&substatus_options, - 'select_form_order' => ['yes','queued','graded','incorrect','all']); + my ($full,$is_tool)=@_; + my %options; + if ($is_tool) { + %options = + (&transtatus_options, + 'select_form_order' => ['yes','incorrect','all']); + } else { + %options = + (&substatus_options, + 'select_form_order' => ['yes','queued','graded','incorrect','all']); + } my $result='
@@ -9740,10 +9978,14 @@ sub selectfield { '.&Apache::lonhtmlcommon::StatusOptions(undef,undef,5,undef,'mult').'
'; if ($full) { - $result.=' + my $heading = &mt('Submission Status'); + if ($is_tool) { + $heading = &mt('Transaction Status'); + } + $result.='
- '.&mt('Submission Status').' + '.$heading.' '. &Apache::loncommon::select_form('all','submitonly',\%options). '
'; @@ -9762,6 +10004,14 @@ sub substatus_options { ); } +sub transtatus_options { + return &Apache::lonlocal::texthash( + 'yes' => 'with score transactions', + 'incorrect' => 'with less than full credit', + 'all' => 'with any status', + ); +} + sub reset_perm { undef(%perm); } @@ -10392,7 +10642,7 @@ sub startpage { sub select_problem { my ($r)=@_; $r->print('

'.&mt('Select the problem or one of the problems you want to grade').'

'); - $r->print(&Apache::lonstathelpers::problem_selector('.',undef,1)); + $r->print(&Apache::lonstathelpers::problem_selector('.',undef,1,undef,undef,undef,undef,1)); $r->print(''); $r->print(''); } @@ -10599,7 +10849,7 @@ sub handler { } elsif ($command eq 'downloadfileslink' && $perm{'vgr'}) { &startpage($request,$symb, [{href=>&href_symb_cmd($symb,'downloadfilesselect'), text=>'Select which submissions to download'}, - {href=>'', text=>'Download submissions'}]); + {href=>'', text=>'Download submitted files'}]); &submit_download_link($request,$symb); } elsif ($command) { &startpage($request,$symb,[{href=>'', text=>'Access denied'}]);
'.&mt('Date/Time').''.&mt('CODE').''.&mt('Version').''.&mt('Submission').''.($is_tool?&mt('Grade'):&mt('Submission')).''.&mt('Status').'