--- loncom/homework/grades.pm 2007/10/26 00:27:55 1.465 +++ loncom/homework/grades.pm 2007/10/31 18:01:34 1.473 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.465 2007/10/26 00:27:55 albertel Exp $ +# $Id: grades.pm,v 1.473 2007/10/31 18:01:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -332,8 +332,8 @@ sub cleanRecord { $bottomrow.=''.$grayFont.$foil.' '; } return '
'. - ''.$toprow.''. - ''. + ''.$toprow.''. + ''. $grayFont.$bottomrow.''.'
Answer
'.$grayFont.'Option ID
'.&mt('Answer').'
'.$grayFont.&mt('Option ID').'
'; } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); @@ -352,10 +352,10 @@ sub cleanRecord { $bottomrow.=''.$grayFont.$foil.' '; } return '
'. - ''.$toprow.''. - ''. + ''.$toprow.''. + ''. $middlerow.''. - ''. + ''. $bottomrow.''.'
Answer
'.$grayFont.'Item ID
'.&mt('Answer').'
'.$grayFont.&mt('Item ID').'
'.$grayFont.'Option ID
'.$grayFont.&mt('Option ID').'
'; } elsif ($response eq 'radiobutton') { my %answer=&Apache::lonnet::str2hash($answer); @@ -365,18 +365,18 @@ sub cleanRecord { foreach my $foil (@$order) { if (exists($answer{$foil})) { if ($foil eq $correct) { - $toprow.='true'; + $toprow.=''.&mt('true').''; } else { - $toprow.='true'; + $toprow.=''.&mt('true').''; } } else { - $toprow.='false'; + $toprow.=''.&mt('false').''; } $bottomrow.=''.$grayFont.$foil.' '; } return '
'. - ''.$toprow.''. - ''. + ''.$toprow.''. + ''. $grayFont.$bottomrow.''.'
Answer
'.$grayFont.'Option ID
'.&mt('Answer').'
'.$grayFont.&mt('Option ID').'
'; } elsif ($response eq 'essay') { if (! exists ($env{'form.'.$symb})) { @@ -1615,13 +1615,13 @@ sub gradeBox { '" src="'.$request->dir_config('lonIconsURL'). '/check.gif" height="16" border="0" />'; my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname); - my $wgtmsg = ($wgt > 0 ? '(problem weight)' : - 'problem weight assigned by computer'); + my $wgtmsg = ($wgt > 0) ? &mt('(problem weight)') + : ''.&mt('problem weight assigned by computer').''; $wgt = ($wgt > 0 ? $wgt : '1'); my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt)); my $result=''."\n"; - my $display_part=&get_display_part($partid,$symb); + my $display_part= &get_display_part($partid,$symb); my %last_resets = &get_last_resets($symb,$env{'request.course.id'}, [$partid]); my $aggtries = $$record{'resource.'.$partid.'.tries'}; @@ -1703,7 +1703,7 @@ sub handback_box { ''.$file_disp.''); $result.=''."\n"; $result.='
'; - $result.='(File will be uploaded when you click on Save & Next below.)
'; + $result.='(File will be uploaded when you click on Save & Next below.)
'; $file_counter++; } } @@ -1739,27 +1739,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 +1852,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 +1953,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 +1977,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 +2001,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 +2010,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 +2040,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 +2079,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 +2116,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 +2129,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 +2145,7 @@ KEYWORDS $msgfor .= ', '.(join ', ',@$col_fullnames).' and '.$lastone.'.'; } $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript - $result=''."\n". + $result.=''."\n". ''."\n"; $result.=' '. @@ -2146,24 +2154,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 +2179,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 @@ -2248,25 +2268,25 @@ sub check_collaborators { } } if (scalar(@good_collaborators) != 0) { - $result.='Collaborators: '; + $result.='
'.&mt('Collaborators: '); foreach my $name (@good_collaborators) { my ($lastname,$givenn) = split(/,/,$$fullname{$name}); push(@col_fullnames, $givenn.' '.$lastname); $result.=$fullname->{$name}.'     '; } $result.='
'."\n"; - my ($part)=split(/\./,$_); + my ($part)=split(/\./,$part); $result.=''. "\n"; } if (scalar(@bad_collaborators) > 0) { - $result.='
'; + $result.='
'; $result.=&mt('This student has submitted [quant,_1,invalid collaborator]: [_2]',scalar(@bad_collaborators),join(', ',@bad_collaborators)); $result .= '
'; } if (scalar(@bad_collaborators > $ncol)) { - $result .= '
'; + $result .= '
'; $result .= &mt('This student has submitted too many '. 'collaborators. Maximum is [_1].',$ncol); $result .= '
'; @@ -4273,30 +4293,33 @@ sub displaySubByDates { my $isCODE=0; my $isTask = ($symb =~/\.task$/); if (exists($record->{'resource.CODE'})) { $isCODE=1; } - my $studentTable='
'. - ''. - ''. - ($isCODE?'':''). - ''. - ''; + my $studentTable=&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + ($isCODE?'':''). + ''. + ''. + &Apache::loncommon::end_data_table_header_row(); my ($version); my %mark; my %orders; $mark{'correct_by_student'} = $checkIcon; if (!exists($$record{'1:timestamp'})) { - return '
 Nothing submitted - no attempts
'; + return '
 '.&mt('Nothing submitted - no attempts').'
'; } my $interaction; for ($version=1;$version<=$$record{'version'};$version++) { - my $timestamp = scalar(localtime($$record{$version.':timestamp'})); + my $timestamp = + &Apache::lonlocal::locallocaltime($$record{$version.':timestamp'}); if (exists($$record{$version.':resource.0.version'})) { $interaction = $$record{$version.':resource.0.version'}; } my $where = ($isTask ? "$version:resource.$interaction" : "$version:resource"); - $studentTable.=''; + $studentTable.=&Apache::loncommon::start_data_table_row(). + ''; if ($isCODE) { $studentTable.=''; } @@ -4315,14 +4338,14 @@ sub displaySubByDates { my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); - $displaySub[0].='Part: '.$display_part.' '; - $displaySub[0].='(ID '. + $displaySub[0].=''.&mt('Part:').' '.$display_part.' '; + $displaySub[0].='('.&mt('ID').' '. $responseId.') '; if ($$record{"$where.$partid.tries"} eq '') { - $displaySub[0].='Trial not counted'; + $displaySub[0].=&mt('Trial not counted'); } else { - $displaySub[0].='Trial '. - $$record{"$where.$partid.tries"}; + $displaySub[0].=&mt('Trial [_1]', + $$record{"$where.$partid.tries"}); } my $responseType=($isTask ? 'Task' : $responseType->{$partid}->{$responseId}); @@ -4362,12 +4385,12 @@ sub displaySubByDates { } $studentTable.=''; - + $studentTable.=' '. + &Apache::loncommon::end_data_table_row(); } - $studentTable.='
Date/TimeCODESubmissionStatus 
'.&mt('Date/Time').''.&mt('CODE').''.&mt('Submission').''.&mt('Status').'
'.$timestamp.''.$timestamp.''.$record->{$version.':resource.CODE'}.''.$displaySub[0].' '.$displaySub[1]; if ($displaySub[2]) { - $studentTable.='Manually graded by '.$displaySub[2]; + $studentTable.=&mt('Manually graded by [_1]',$displaySub[2]); } - $studentTable.=' 
'; + $studentTable.=&Apache::loncommon::end_data_table(); return $studentTable; } @@ -5216,6 +5239,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 @@ -5254,7 +5278,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; @@ -5297,9 +5323,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); @@ -6457,7 +6482,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
    "); @@ -6477,7 +6503,7 @@ ENDSCRIPT $r - Apache request object $scan_config - hash from &get_scantron_config() $quest - number of the bubble line to make a corrector for - $lines - array of answer lines. + @lines - array of answer lines. =cut @@ -6848,6 +6874,9 @@ sub scantron_validate_missingbubbles { $scan_data); if (!defined($$scan_record{'scantron.missingerror'})) { next; } my @to_correct; + + # Probably here's where the error is... + foreach my $missing (@{$$scan_record{'scantron.missingerror'}}) { if ($missing > $max_bubble) { next; } push(@to_correct,$missing); @@ -7361,9 +7390,8 @@ sub submit_options { GRADINGMENUJS &commonJSfunctions($request); - my $result='

     Manual Grading/View Submission

    '; my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); - $result.=$table; + my $result; my (undef,$sections) = &getclasslist('all','0'); my $savedState = &savedState(); my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'}); @@ -7380,102 +7408,104 @@ GRADINGMENUJS ''."\n". ''."\n"; - $result.='
    '."\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; }