--- loncom/homework/grades.pm 2017/12/18 14:46:10 1.744 +++ loncom/homework/grades.pm 2017/12/18 23:51:24 1.745 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.744 2017/12/18 14:46:10 raeburn Exp $ +# $Id: grades.pm,v 1.745 2017/12/18 23:51:24 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 }) { @@ -852,6 +856,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 +912,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 +990,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" .'' .'

'; @@ -1977,6 +2021,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 +2034,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 +2229,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 +2244,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 +2436,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 +2567,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 +2633,14 @@ sub get_last_submission { } } if (!@string) { + my $msg; + if ($is_tool) { + $msg = &mt('Nothing passed back - no attempts.'); + } else { + $msg = &mt('Nothing submitted - no attempts.'); + } $string[0] = - ''.&mt('Nothing submitted - no attempts.').''; + ''.$msg.''; } return (\@string,\$timestamp); } @@ -3561,6 +3627,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 +3712,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,7 +3731,12 @@ 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 }); @@ -3709,7 +3791,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 +3811,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 +3855,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 +3943,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 +4049,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').'

'; @@ -4006,7 +4098,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/; @@ -4257,7 +4349,7 @@ sub csvupload_javascript_forward_associa tw=eval('vf.f'+i+'.selectedIndex'); if (tw==1) { foundID=1; } if (tw==2) { founduname=1; } - if (tw==3) { foundclicker=1; } + if (tw==3) { foundclicker=1; } if (tw>4) { foundsomething=1; } } if (founduname==0 && foundID==0 && Ć’oundclicker==0) { @@ -4318,6 +4410,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) { @@ -4332,9 +4428,9 @@ sub csvupload_fields { 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]"]); @@ -4824,7 +4920,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 @@ -4921,10 +5017,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. @@ -4935,26 +5032,32 @@ 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; + unless ($is_tool) { + 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}) { @@ -4967,7 +5070,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' : ''); @@ -9658,12 +9760,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). '
@@ -9677,6 +9780,7 @@ sub submit_options_download { my ($request,$symb) = @_; if (!$symb) {return '';} + my ($is_tool) = ($symb =~ /ext\.tool$/); &commonJSfunctions($request); my $result=''."\n". @@ -9684,7 +9788,7 @@ sub submit_options_download { $result.='

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

'.&selectfield(1).' +'.&selectfield(1,$is_tool).'
@@ -9700,12 +9804,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).' @@ -9717,10 +9822,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='
@@ -9744,10 +9856,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). '
'; @@ -9766,6 +9882,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); } @@ -10396,7 +10520,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(''); }