--- loncom/homework/grades.pm 2013/12/14 00:22:27 1.596.2.12.2.24 +++ loncom/homework/grades.pm 2012/08/09 23:25:48 1.596.2.13 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.596.2.12.2.24 2013/12/14 00:22:27 raeburn Exp $ +# $Id: grades.pm,v 1.596.2.13 2012/08/09 23:25:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,16 +125,13 @@ sub getpartlist { # --- Get the symbolic name of a problem and the url sub get_symb { my ($request,$silent) = @_; - my $symb=$env{'form.symb'}; - unless ($symb) { - (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; - $symb = &Apache::lonnet::symbread($url); - if ($symb eq '') { - if (!$silent) { - $request->print(&mt("Unable to handle ambiguous references: [_1].",$url)); - return (); - } - } + (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; + my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url))); + if ($symb eq '') { + if (!$silent) { + $request->print(&mt("Unable to handle ambiguous references: [_1].",$url)); + return (); + } } &Apache::lonenc::check_decrypt(\$symb); return ($symb); @@ -253,7 +250,7 @@ sub showResourceInfo { $result.=''.$display_part.'' .''.''.$resID.'' .''.&mt($responsetype).'' -# .''.&mt('Handgrade: [_1]',$handgrade).'' +# .''.&mt('Handgrade: [_1]',$handgrade).'' .&Apache::loncommon::end_data_table_row(); } } @@ -277,7 +274,7 @@ sub reset_caches { } sub get_analyze { - my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed,$bubbles_per_row)=@_; + my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed)=@_; my $key = "$symb\0$uname\0$udom"; if ($type eq 'randomizetry') { if ($trial ne '') { @@ -311,9 +308,6 @@ sub reset_caches { 'grade_courseid' => $env{'request.course.id'}, 'grade_username' => $uname, 'grade_noincrement' => $no_increment); - if ($bubbles_per_row ne '') { - $form{'bubbles_per_row'} = $bubbles_per_row; - } if ($type eq 'randomizetry') { $form{'grade_questiontype'} = $type; if ($rndseed ne '') { @@ -354,7 +348,7 @@ sub reset_caches { } sub scantron_partids_tograde { - my ($resource,$cid,$uname,$udom,$check_for_randomlist,$bubbles_per_row) = @_; + my ($resource,$cid,$uname,$udom,$check_for_randomlist) = @_; my (%analysis,@parts); if (ref($resource)) { my $symb = $resource->symb(); @@ -362,9 +356,7 @@ sub reset_caches { if ($check_for_randomlist) { $add_to_form = { 'check_parts_withrandomlist' => 1,}; } - my $analyze = - &get_analyze($symb,$uname,$udom,undef,$add_to_form, - undef,undef,undef,$bubbles_per_row); + my $analyze = &get_analyze($symb,$uname,$udom,undef,$add_to_form); if (ref($analyze) eq 'HASH') { %analysis = %{$analyze}; } @@ -811,7 +803,7 @@ sub verifyreceipt { '

'. &mt('Verifying Receipt No. [_1]',$receipt). '

'."\n". - '

'.&mt('[_1]Resource: [_2]','',''.$env{'form.probTitle'}). + '

'.&mt('Resource: [_1]',$env{'form.probTitle'}). '

'."\n"; my ($string,$contents,$matches) = ('','',0); @@ -1162,7 +1154,7 @@ LISTJAVASCRIPT if ($submitonly eq 'graded' ) { $submissions = 'ungraded submissions'; } if ($submitonly eq 'queued' ) { $submissions = 'queued submissions'; } $gradeTable='
 '. - &mt('No '.$submissions.' found for this resource for any students. ([quant,_1,student] checked for '.$submissions.')', + &mt('No '.$submissions.' found for this resource for any students. ([_1] students checked for '.$submissions.')', $num_students). '
'; } @@ -1619,15 +1611,17 @@ INNERJS function savedMsgHeader(Nmsg,usrctr,fullname) { var height = 70*Nmsg+250; + var scrollbar = "no"; if (height > 600) { height = 600; + scrollbar = "yes"; } var xpos = (screen.width-600)/2; xpos = (xpos < 0) ? '0' : xpos; var ypos = (screen.height-height)/2-30; ypos = (ypos < 0) ? '0' : ypos; - pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars=yes,screenx='+xpos+',screeny='+ypos+',width=700,height='+height); + pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=700,height='+height); pWin.focus(); pDoc = pWin.document; pDoc.$docopen; @@ -1793,7 +1787,7 @@ sub gradeBox { $wgt = ($wgt > 0 ? $wgt : '1'); my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt)); - my $data_WGT=''."\n"; + my $result=''."\n"; my $display_part= &get_display_part($partid,$symb); my %last_resets = &get_last_resets($symb,$env{'request.course.id'}, [$partid]); @@ -1801,7 +1795,7 @@ sub gradeBox { if ($last_resets{$partid}) { $aggtries = &get_num_tries($record,$last_resets{$partid},$partid); } - my $result=&Apache::loncommon::start_data_table_row(); + $result.=&Apache::loncommon::start_data_table_row(); my $ctr = 0; my $thisweight = 0; my $increment = &get_increment(); @@ -1837,9 +1831,10 @@ sub gradeBox { $line.=''."\n"; + #&mt('Part:[_1]Points:[_2]or[_3]',$display_part,$radio,$line); $result .= - ''.$data_WGT.$display_part.''.$radio.''.&mt('or').''.$line.''; - $result.=&Apache::loncommon::end_data_table_row().''; + ''.$display_part.''.$radio.''.&mt('or').''.$line.''; + $result.=&Apache::loncommon::end_data_table_row(); $result.=''."\n". ''."\n". ''."\n"; my $res_error; $result.=&handback_box($symb,$uname,$udom,$counter,$partid,$record,\$res_error); - $result.=''.&Apache::loncommon::end_data_table_row(); if ($res_error) { return &navmap_errormsg(); } @@ -1924,27 +1918,14 @@ sub show_problem { $companswer=~s|||g; $companswer=~s|name="submit"|name="would_have_been_submit"|g; } - my $renderheading = &mt('View of the problem'); - my $answerheading = &mt('Correct answer'); - if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { - my $stu_fullname = $env{'form.fullname'}; - if ($stu_fullname eq '') { - $stu_fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); - } - my $forwhom = &nameUserString(undef,$stu_fullname,$uname,$udom); - if ($forwhom ne '') { - $renderheading = &mt('View of the problem for[_1]',$forwhom); - $answerheading = &mt('Correct answer for[_1]',$forwhom); - } - } $rendered= '
' - .'

'.$renderheading.'

' + .'

'.&mt('View of the problem').'

' .$rendered .'
'; $companswer= '
' - .'

'.$answerheading.'

' + .'

'.&mt('Correct answer').'

' .$companswer .'
'; my $result; @@ -2015,7 +1996,7 @@ sub submission { $udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student? my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'}); $env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq ''; - my ($symb) = &get_symb($request); + my $symb = &get_symb($request); if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } if (!&canview($usec)) { @@ -2044,7 +2025,7 @@ sub submission { &download_all_link($request, $symb); } $request->print('

 '.&mt('Submission Record').'

'."\n". - '

 '.&mt('[_1]Resource: [_2]','',''.$env{'form.probTitle'}).'

'."\n"); + '

 '.&mt('Resource: [_1]',$env{'form.probTitle'}).'

'."\n"); # option to display problem, only once else it cause problems # with the form later since the problem has a form. @@ -2061,7 +2042,7 @@ sub submission { $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode)); } - # kwclr is the only variable that is guaranteed not to be blank + # kwclr is the only variable that is guaranteed to be non blank # if this subroutine has been called once. my %keyhash = (); if ($env{'form.kwclr'} eq '' && $env{'form.handgrade'} eq 'yes') { @@ -2139,7 +2120,7 @@ sub submission {  $lt{'keyw'}:  $lt{'list'}    $lt{'past'}    + CLASS="page">$lt{'past'}    $lt{'high'}

KEYWORDS # @@ -2149,7 +2130,7 @@ KEYWORDS my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); $apath=&escape($apath); $apath=~s/\W/\_/gs; - &init_old_essays($symb,$apath,$adom,$aname); + &init_old_essays($symb,$apath,$adom,$aname); } } @@ -2166,7 +2147,7 @@ KEYWORDS if ($perm{'vgr'}) { $request->print( &Apache::loncommon::track_student_link( - 'View recent activity', + &mt('View recent activity'), $uname,$udom,'check') .' ' ); @@ -2230,7 +2211,7 @@ KEYWORDS # (for multi-response type part) # (3) Last submission plus the parts info # (4) The whole record for this student - + if ($env{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) { my ($string,$timestamp)= &get_last_submission(\%record); my $lastsubonly; @@ -2253,14 +2234,13 @@ KEYWORDS 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"}}.''). - '
'); + my $submitby='Part: '.$display_part. + ' Collaborative submission by: '. + ''. + $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'
'; + $request->print($submitby); next; } my $responsetype = $responseType->{$partid}->{$respid}; @@ -2285,7 +2265,7 @@ KEYWORDS $trial = $record{"resource.$partid.tries"}; $rndseed = $record{"resource.$partid.rndseed"}; } - if ($env{'form.checkPlag'}) { + if($env{'form.checkPlag'}){ my ($oname,$odom,$ocrsid,$oessay,$osim)= &most_similar($uname,$udom,$symb,$subval); if ($osim) { @@ -2313,8 +2293,9 @@ KEYWORDS } my $order=&get_order($partid,$respid,$symb,$uname,$udom, undef,$type,$trial,$rndseed); - if ($env{'form.lastSub'} eq 'lastonly' || $env{'form.lastSub'} eq 'datesub' || $env{'form.lastSub'} =~ /^(last|all)$/ || ($env{'form.lastSub'} eq 'hdgrade' && - $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { + if ($env{'form.lastSub'} eq 'lastonly' || + ($env{'form.lastSub'} eq 'hdgrade' && + $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { my $display_part=&get_display_part($partid,$symb); $lastsubonly.='
'. ''.&mt('Part: [_1]',$display_part).''. @@ -2326,26 +2307,18 @@ KEYWORDS 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 .= ''; - + $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
'; foreach my $file (@$files) { &Apache::lonnet::allowuploaded('/adm/grades',$file); - $lastsubonly.='
'.$file.''; + $lastsubonly.='
'.$file.''; } } $lastsubonly.='
'; } if ($hide eq 'anon') { - $lastsubonly.='
'.&mt('Anonymous Survey').''; + $lastsubonly.=''.&mt('Anonymous Survey').''; } else { - $lastsubonly.='
'.&mt('Submitted Answer:').' '. + $lastsubonly.=''.&mt('Submitted Answer:').' '. &cleanRecord($subval,$responsetype,$symb,$partid, $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed); } @@ -2357,11 +2330,10 @@ KEYWORDS $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body } $request->print($lastsubonly); - if ($env{'form.lastSub'} eq 'datesub') { + } elsif ($env{'form.lastSub'} eq 'datesub') { my (undef,$responseType,undef,$parts) = &showResourceInfo($symb); $request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom)); - } - if ($env{'form.lastSub'} =~ /^(last|all)$/) { + } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) { $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, $env{'request.course.id'}, $last,'.submission', @@ -2403,9 +2375,9 @@ KEYWORDS ''."\n"; $result.=' '. - &mt('Compose message to student'.(scalar(@$col_fullnames) >= 1 ? 's' : '')).'