--- loncom/homework/grades.pm 2007/10/26 00:39:09 1.467 +++ loncom/homework/grades.pm 2007/11/01 00:47:42 1.474 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.467 2007/10/26 00:39:09 albertel Exp $ +# $Id: grades.pm,v 1.474 2007/11/01 00:47:42 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -865,7 +865,7 @@ LISTJAVASCRIPT my $saveStatus = $stu_status eq '' ? 'Active' : $stu_status; $env{'form.Status'} = $saveStatus; $gradeTable.=''."\n". - ''."\n". + ''."\n". ''."\n". '
'."\n". ' Grading Increments: Check For Plagiarism'; my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); - $gradeTable.='
'. - ''; + $gradeTable.= &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(); my $loop = 0; while ($loop < 2) { - $gradeTable.=''. - ''; + $gradeTable.=''. + ''; if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'queued' && $submitonly ne 'all') { foreach (sort(@$partlist)) { my $display_part=&get_display_part((split(/_/))[0],$symb); - $gradeTable.=''; + $gradeTable.=''; + $gradeTable.=''; } $loop++; # $gradeTable.='' if ($loop%2 ==1); } - $gradeTable.=''."\n"; + $gradeTable.=&Apache::loncommon::end_data_table_header_row()."\n"; my $ctr = 0; foreach my $student (sort @@ -978,13 +978,15 @@ LISTJAVASCRIPT my $section = $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()]; my $group = $classlist->{$student}->[&Apache::loncoursedata::CL_GROUP()]; if ( $perm{'vgr'} eq 'F' ) { - $gradeTable.='' if ($ctr%2 ==1); + if ($ctr%2 ==1) { + $gradeTable.= &Apache::loncommon::start_data_table_row(); + } $gradeTable.=''. ''."\n".''."\n"; + ' '.$section.($group ne '' ?'/'.$group:'').''."\n"; if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { foreach (sort keys(%status)) { @@ -993,7 +995,9 @@ LISTJAVASCRIPT } } # $gradeTable.='' if ($ctr%2 ==1); - $gradeTable.=''."\n" if ($ctr%2 ==0); + if ($ctr%2 ==0) { + $gradeTable.=&Apache::loncommon::end_data_table_row()."\n"; + } } } if ($ctr%2 ==1) { @@ -1007,10 +1011,10 @@ LISTJAVASCRIPT } elsif ($submitonly eq 'queued') { $gradeTable.=''; } - $gradeTable.=''; + $gradeTable.=&Apache::loncommon::end_data_table_row(); } - $gradeTable.='
 No.  Select '.&nameUserString('header').' Section/GroupNo.Select'.&nameUserString('header').' '.'Section/Group Part: '.$display_part. - ' Status Part: '.$display_part. + ' Status'; } } elsif ($submitonly eq 'queued') { - $gradeTable.=' '.&mt('Queue Status').' '.&mt('Queue Status').' 
'.$ctr.' '. &nameUserString(undef,$$fullname{$student},$uname,$udom). - ' '.$section.'/'.$group.'
 
'."\n". + $gradeTable.=&Apache::loncommon::end_data_table()."\n". ''."\n"; @@ -1028,7 +1032,7 @@ LISTJAVASCRIPT ' students checked for '.$submissions.')
'; } } elsif ($ctr == 1) { - $gradeTable =~ s/type=checkbox/type=checkbox checked/; + $gradeTable =~ s/type="checkbox"/type="checkbox" checked="checked"/; } $gradeTable.=&show_grading_menu_form($symb); $request->print($gradeTable); @@ -1739,27 +1743,27 @@ sub show_problem { $companswer=~s|||g; $companswer=~s|name="submit"|name="would_have_been_submit"|g; } - my $result.='
'; - $result.=''; - if ($viewon) { - $result.=''; - } + $rendered= + '
'. + &mt('View of the problem'). + '
'. + $rendered. + '
'; + $companswer= + '
'. + &mt('Correct answer'). + '
'. + $companswer. + '
'; + my $result; if ($mode eq 'both') { - $result.='
'; - if ($mode eq 'both' or $mode eq 'text') { - $result.='View of the problem - '; - } else { - $result.='Correct answer: '; - } - $result.=$env{'form.fullname'}.'
'.$rendered.'
'; - $result.='Correct answer:
'.$companswer; + $result=$rendered.$companswer; } elsif ($mode eq 'text') { - $result.='
'.$rendered; + $result=$rendered; } elsif ($mode eq 'answer') { - $result.='
'.$companswer; + $result=$companswer; } - $result.='
'; - $result.='

'; + $result='
'.$result.'
'; return $result; } @@ -1852,12 +1856,6 @@ sub submission { $request->print('

 Submission Record

'."\n". '

 Resource: '.$env{'form.probTitle'}.'

'."\n"); - if ($env{'form.handgrade'} eq 'no') { - my $checkMark='

 Note: Part(s) graded correct by the computer is marked with a '. - $checkIcon.' symbol.'."\n"; - $request->print($checkMark); - } - # option to display problem, only once else it cause problems # with the form later since the problem has a form. if ($env{'form.vProb'} eq 'yes' or $env{'form.vAns'} eq 'yes') { @@ -1959,10 +1957,11 @@ KEYWORDS } # This is where output for one specific student would start - my $bgcolor='#DDEEDD'; - if ($counter%2) { $bgcolor='#DDDDEE'; } + my $add_class = ($counter%2) ? 'LC_grade_show_user_odd_row' : ''; $request->print("\n\n". - '

'.$env{'form.fullname'}.'
'); + '
'. + '
'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'
'. + '
'."\n"); if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') { my $mode; @@ -1982,12 +1981,19 @@ KEYWORDS # Display student info $request->print(($counter == 0 ? '' : '
')); - my $result='
'."\n". - '\n"; + + my $lastsubonly; + if ($$timestamp eq '') { - $lastsubonly.='
'."\n"; - - $result.='Fullname: '.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'
'."\n"; + my $result='
'; + + $result.='
'; + $result.= &mt('Submissions'); $result.=''."\n"; + if ($env{'form.handgrade'} eq 'no') { + $result.=''. + &mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)."\n"; + + } + + # If any part of the problem is an essay-response (handgraded), then check for collaborators my $fullname; @@ -1999,7 +2005,7 @@ KEYWORDS $result.=$sub_result; } $request->print($result."\n"); - + $request->print('
'."\n"); # print student answer/submission # Options are (1) Handgaded submission only # (2) Last submission, includes submission that is not handgraded @@ -2008,12 +2014,14 @@ KEYWORDS # (4) The whole record for this student if ($env{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) { my ($string,$timestamp)= &get_last_submission(\%record); - my $lastsubonly=''. - ($$timestamp eq '' ? '' : 'Date Submitted: '. - $$timestamp)."
'.$$string[0]; + $lastsubonly.='
'.$$string[0].'
'; } else { + $lastsubonly = '
Date Submitted: '.$$timestamp."\n"; + my %seenparts; my @part_response_id = &flatten_responseType($responseType); foreach my $part (@part_response_id) { @@ -2036,16 +2044,16 @@ KEYWORDS } my $responsetype = $responseType->{$partid}->{$respid}; if (!exists($record{"resource.$partid.$respid.submission"})) { - $lastsubonly.='
Part: '. + $lastsubonly.="\n".'
Part: '. $display_part.' ( ID '.$respid. ' )   '. - 'Nothing submitted - no attempts

'; + ''.&mt('Nothing submitted - no attempts').'

'; next; } - foreach (@$string) { - my ($partid,$respid) = /^resource\.([^\.]*)\.([^\.]*)\.submission/; + foreach my $submission (@$string) { + my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/); if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; } - my ($ressub,$subval) = split(/:/,$_,2); + my ($ressub,$subval) = split(/:/,$submission,2); # Similarity check my $similar=''; if($env{'form.checkPlag'}){ @@ -2075,31 +2083,32 @@ KEYWORDS ($env{'form.lastSub'} eq 'hdgrade' && $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { my $display_part=&get_display_part($partid,$symb); - $lastsubonly.='
Part: '. + $lastsubonly.='
Part: '. $display_part.' ( ID '.$respid. ' )   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - $lastsubonly.='
Like all files provided by users, this file may contain virusses
'; + $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain virusses').'
'; my $file_counter = 0; foreach my $file (@$files) { - $file_counter ++; + $file_counter++; &Apache::lonnet::allowuploaded('/adm/grades',$file); $lastsubonly.='
'.$file.''; } $lastsubonly.='
'; } - $lastsubonly.='Submitted Answer: '. + $lastsubonly.=''.&mt('Submitted Answer:').' '. &cleanRecord($subval,$responsetype,$symb,$partid, $respid,\%record,$order); if ($similar) {$lastsubonly.="

$similar\n";} + $lastsubonly.='
'; } } } + $lastsubonly.=''."\n"; } - $lastsubonly.='
'."\n"; $request->print($lastsubonly); - } elsif ($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)); } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) { @@ -2111,13 +2120,12 @@ KEYWORDS $request->print(''."\n"); - # return if view submission with no grading option if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) { my $toGrade.='  '."\n" if (&canmodify($usec)); - $toGrade.='
'."\n"; + $toGrade.='
'."\n"; if (($env{'form.command'} eq 'submission') || ($env{'form.command'} eq 'processGroup' && $counter == $total)) { $toGrade.=''.&show_grading_menu_form($symb); @@ -2125,11 +2133,15 @@ KEYWORDS $request->print($toGrade); return; } else { - $request->print('
'."\n"); + $request->print(''."\n"); } # essay grading message center if ($env{'form.handgrade'} eq 'yes') { + my $result='

'; + + $result.='
'. + &mt('Send Message').'
'; my ($lastname,$givenn) = split(/,/,$env{'form.fullname'}); my $msgfor = $givenn.' '.$lastname; if (scalar(@$col_fullnames) > 0) { @@ -2137,7 +2149,7 @@ KEYWORDS $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.'; } $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript - $result=''."\n". + $result.=''."\n". ''."\n"; $result.=' '. @@ -2146,24 +2158,20 @@ KEYWORDS ''."\n". '
 ('. - &mt('Message will be sent when you click on Save & Next below.').")\n"; + &mt('Message will be sent when you click on Save & Next below.').")\n"; + $result.='
'; $request->print($result); } - if ($perm{'vgr'}) { - $request->print('
'. - &Apache::loncommon::track_student_link(&mt('View recent activity'), - $uname,$udom,'check')); - } - if ($perm{'opa'}) { - $request->print('
'. - &Apache::loncommon::pprmlink(&mt('Set/Change parameters'), - $uname,$udom,$symb,'check')); - } my %seen = (); my @partlist; my @gradePartRespid; my @part_response_id = &flatten_responseType($responseType); + $request->print('
'. + + '
'. + &mt('Assign Grades').'
'. + '
'); foreach my $part_response_id (@part_response_id) { my ($partid,$respid) = @{ $part_response_id }; my $part_resp = join('_',@{ $part_response_id }); @@ -2175,6 +2183,21 @@ KEYWORDS push @gradePartRespid,$partid.'.'.$respid; $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); } + $request->print('
'); + + $request->print(''); + $result=''."\n"; $result.=''."\n"; $ctr++; } - $request->print($result.''."\n"); + $request->print($result.''."\n"); # Done with printing info for one student - $request->print('

'); + $request->print('');#LC_grade_show_user_body + $request->print('');#LC_grade_show_user # print end of form @@ -3149,14 +3173,12 @@ sub viewgrades { $sectionClass=&mt('Students in Section(s) [_1]',$section_display).''; } $result.='

'.&mt('Assign Common Grade To [_1]',$sectionClass); - $result.= ''."\n"; } } - $result.=''; + $result.=&Apache::loncommon::end_data_table_row(); return $result; } @@ -5219,6 +5244,7 @@ sub scan_data { sub scantron_parse_scanline { my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_; + my %record; my $questions=substr($line,$$scantron_config{'Qstart'}-1); # Answers my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff @@ -5257,7 +5283,9 @@ sub scantron_parse_scanline { my $questnum=0; my $ansnum =1; # Multiple 'answer lines'/question. - while ($questions) { + chomp($questions); # Get rid of any trailing \n. + $questions =~ s/\r$//; # Get rid of trailing \r too (MAC or Win uploads). + while (length($questions)) { my $answers_needed = $bubble_lines_per_response{$questnum}; my $answer_length = $$scantron_config{'Qlength'} * $answers_needed; @@ -5300,9 +5328,8 @@ sub scantron_parse_scanline { } if (!&scan_data($scan_data,"$whichline.no_bubble.$questnum")) { push(@{$record{"scantron.missingerror"}},$questnum); - $ansnum += $answers_needed; + # $ansnum += $answers_needed; } - } else { for (my $ans = 0; $ans < $answers_needed; $ans++) { $record{"scantron.$ansnum.answer"} = substr($currentquest, $ans, 1); @@ -6460,7 +6487,8 @@ ENDSCRIPT join(',',@{$arg}).'" />'); foreach my $question (@{$arg}) { my $selected = &get_response_bubbles($scan_record, $question); - &scantron_bubble_selector($r,$scan_config,$question); + my @select_array = split(/:/,$selected); # ought to be an array of empties. + &scantron_bubble_selector($r,$scan_config,$question, @select_array); } } else { $r->print("\n
'."\n". - '
'; + $result.= &Apache::loncommon::start_data_table(); #radio buttons/text box for assigning points for a section or class. #handles different parts of a problem my ($partlist,$handgrade,$responseType) = &response_type($symb); my %weight = (); my $ctsparts = 0; - $result.=''; my %seen = (); my @part_response_id = &flatten_responseType($responseType); foreach my $part_response_id (@part_response_id) { @@ -3168,12 +3190,14 @@ sub viewgrades { my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); $weight{$partid} = $wgt eq '' ? '1' : $wgt; + $result.=&Apache::loncommon::start_data_table_row().'
'; $result.=''."\n"; $result.=''."\n"; my $display_part=&get_display_part($partid,$symb); - $result.='
Part: '.$display_part.'   Point: '; + $result.= + 'Part: '.$display_part.'   Point: '; $result.=''; my $ctr = 0; while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across @@ -3188,26 +3212,27 @@ sub viewgrades { $partid.'" size="4" '.'onChange="javascript:writePoint(\''. $partid.'\','.$weight{$partid}.',\'textval\')" /> /'. $weight{$partid}.' (problem weight)'."\n"; - $result.= ''. - ''."\n"; + ''.&Apache::loncommon::end_data_table_row()."\n"; $ctsparts++; } - $result.='
'.'
'.'
'."\n". + $result.=&Apache::loncommon::end_data_table()."\n". ''; $result.=''; + 'onClick="javascript:resetEntry('.$ctsparts.');" />'; #table listing all the students in a section/class #header of table $result.= '

Assign Grade to Specific Students in '.$sectionClass; - $result.= '
'."\n". - ''. - '\n"; + $result.= &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + '\n"; my (@parts) = sort(&getpartlist($symb)); my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); my @partids = (); @@ -3219,16 +3244,16 @@ sub viewgrades { push(@partids, $partid); my $display_part=&get_display_part($partid,$symb); if ($display =~ /^Partial Credit Factor/) { - $result.=''."\n"; + $result.=''."\n"; next; } else { $display =~s/\[Part: \Q$partid\E\]/Part:<\/b> $display_part/; } $display =~ s|Problem Status|Grade Status
|; - $result.=''."\n"; + $result.=''."\n"; } - $result.=''; + $result.=&Apache::loncommon::end_data_table_header_row(); my %last_resets = &get_last_resets($symb,$env{'request.course.id'},\@partids); @@ -3248,7 +3273,7 @@ sub viewgrades { $result.=&viewstudentgrade($symb,$env{'request.course.id'}, $_,$$fullname{$_},\@parts,\%weight,$ctr,\%last_resets); } - $result.='
 No. '.&nameUserString('header')."No.'.&nameUserString('header')."Score Part: '.$display_part. - '
(weight = '.$weight{$partid}.')
Score Part: '.$display_part. + '
(weight = '.$weight{$partid}.')
'.$display.''.$display.'
'; + $result.=&Apache::loncommon::end_data_table(); $result.=''."\n"; $result.=''."\n"; @@ -3271,7 +3296,7 @@ sub viewstudentgrade { my ($uname,$udom) = split(/:/,$student); my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname); my %aggregates = (); - my $result='

'. + my $result=&Apache::loncommon::start_data_table_row().''. ''. "\n".$ctr.'  '. '
'."\n". - ''."\n". - ''; #'; - $result.= '
'."\n". - ' Select a Grading/Viewing Option
'."\n"; - - $result.=''; - $result.=''."\n"; - $result.=''; - $result.=''; - $result.=''."\n"; - $result.=''."\n"; - $result.=''; - $result.=''; - $result.=''; - - $result.=''."\n"; - - $result.=''."\n"; - - $result.=''."\n"; - - - $result.=''."\n"; - - $result.='
'.&mt('Sections').''.&mt('Groups').''.&mt('Access Status').''.&mt('Submission Status').'
'."\n". - ' '."\n"; if (ref($sections)) { - foreach (sort (@$sections)) { - $result.=''."\n"; + foreach my $section (sort (@$sections)) { + $result.=''."\n"; } } $result.= '   '; - $result.= ''."\n"; - $result.= &Apache::lonstatistics::GroupSelect('group','multiple',3); - $result.=''."\n"; - $result.=&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,3,undef,'mult'); - - $result.='
'. - '

'. - ''. - '
'. - '

'. - ''. - '
'."\n"; - - $result.='
'; - -# $result.=''; -# $result.=''."\n"; -# -# $result.=''."\n"; -# -# $result.=''."\n"; -# -# if ((&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) && ($symb)) { -# $result.=''."\n"; -# } -# $result.=''."\n"; -# $result.=''."\n"; -# -# $result.='
'. -# ''. -# ' '.&mt('scores from file').'
'. -# ''. -# ' '.&mt('clicker file').'
'. -# ' scantron forms
'. -# ''. -# ' '.&mt('receipt').': '. -# &Apache::lonnet::recprefix($env{'request.course.id'}). -# '-'. -# '
'. -# ' access times.
'. -# ' saved CODEs.
'."\n".'
'."\n". - '
'."\n"; + $result.=' + + +
+
+ '.&mt('Groups').' +
+
+ '.&Apache::lonstatistics::GroupSelect('group','multiple',5).' +
+
+
+
+ '.&mt('Access Status').' +
+
+ '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').' +
+
+
+
+ '.&mt('Submission Status').' +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+

+ '.&mt('Grade Complete Folder for One Student').' +

+
+
+
+ +
+
+ +
+
+
+
+ + '; return $result; }