--- loncom/homework/grades.pm 2003/07/14 14:29:07 1.113 +++ loncom/homework/grades.pm 2003/07/16 19:28:08 1.117 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.113 2003/07/14 14:29:07 ng Exp $ +# $Id: grades.pm,v 1.117 2003/07/16 19:28:08 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -418,7 +418,7 @@ LISTJAVASCRIPT my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; my $gradeTable='
'."\n". - ' View Problem: no '."\n". + ' View Problem Text: no '."\n". ' one student '."\n". ' all students
'."\n". ' Submissions: '."\n"; @@ -1114,7 +1114,8 @@ sub submission { if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; } if (!&canview($usec)) { - $request->print('Unable to view requested student.('.$uname.$udom.$usec.$ENV{'request.course.id'}.')'); + $request->print('Unable to view requested student.('. + $uname.$udom.$usec.$ENV{'request.course.id'}.')'); $request->print(&show_grading_menu_form($symb,$url)); return; } @@ -1226,12 +1227,13 @@ KEYWORDS ''."\n" if ($ENV{'form.lastSub'} eq 'lastonly' || @@ -1352,7 +1357,8 @@ KEYWORDS } # return if view submission with no grading option - if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) { +# if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) { + if (!&canmodify($usec)) { $request->print('
'."\n"; $result.='Fullname: '.$ENV{'form.fullname'}. - '   Username: '.$uname.''. - '   Domain: '.$udom.'
'."\n"; + '   Username: '.$uname. + ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').'
'."\n"; +# '   Domain: '.$udom.'
'."\n"; $result.=''."\n"; - # If this is handgraded, then check for collaborators + # If this is an essay-response part(handgraded), then check for collaborators my @col_fullnames; my ($classlist,$fullname); if ($ENV{'form.handgrade'} eq 'yes') { @@ -1321,7 +1323,8 @@ KEYWORDS my ($oname,$odom,$ocrsid,$oessay,$osim)=&most_similar($uname,$udom,$subval); if ($osim) { $osim=int($osim*100.0); - $similar='

Essay is '.$osim.'% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom). + $similar='

Essay is '.$osim. + '% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom). '

'. &keywords_highlight($oessay).'

'; } @@ -1331,7 +1334,9 @@ KEYWORDS ($record{"resource.$partid.$respid.uploadedurl"}? ' File uploaded by student Like all files provided by users, this file may contain virusses
':''). + '"> File uploaded by student '. + 'Like all files provided by users, '. + 'this file may contain virusses
':''). 'Answer:
'. &keywords_highlight($subval).'

 '.$similar.'

'."\n"); $request->print(&show_grading_menu_form($symb,$url)) if (($ENV{'form.command'} eq 'submission') || @@ -1388,7 +1394,7 @@ KEYWORDS my ($partid,$respid) = split(/_/); next if ($seen{$partid} > 0); $seen{$partid}++; - next if ($$handgrade{$_} =~ /:no$/); +# next if ($$handgrade{$_} =~ /:no$/); push @partlist,$partid; $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); @@ -1977,6 +1983,7 @@ sub viewgrades { my (@parts) = sort(&getpartlist($url)); foreach my $part (@parts) { my $display=&Apache::lonnet::metadata($url,$part.'.display'); + next if ($display =~ /Number of Attempts/); if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } if ($display =~ /^Partial Credit Factor/) { my ($partid) = &split_part_type($part); @@ -2007,7 +2014,8 @@ sub viewgrades { 'onClick="javascript:submit();" TARGET=_self />'."\n"; if (scalar(%$fullname) eq 0) { my $colspan=3+scalar(@parts); - $result='There are no students in section "'.$ENV{'form.section'}.'" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.'; + $result='There are no students in section "'.$ENV{'form.section'}. + '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.'; } $result.=&show_grading_menu_form($symb,$url); return $result; @@ -2047,13 +2055,13 @@ sub viewstudentgrade { if ($status eq 'excused'); $result.=$optsel; $result.="\n"; - } else { - $result.=''. - "\n"; - $result.=''."\n"; +# } else { +# $result.=''. +# "\n"; +# $result.=''."\n"; } } $result.=''; @@ -2607,7 +2615,7 @@ LISTJAVASCRIPT $result.=''."\n". ''."\n"; - $result.=' View Problems: no '."\n". + $result.=' View Problems Text: no '."\n". ' yes '."
\n"; $result.=' Submission Details: '. @@ -2661,53 +2669,22 @@ LISTJAVASCRIPT sub getSymbMap { my ($request) = @_; my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', - $ENV{'request.course.fn'}.'_parms.db',1, 1); - - #my $res = $navmap->firstResource(); # temp resource to access constants + $ENV{'request.course.fn'}.'_parms.db'); $navmap->init(); - # End navmap using boilerplate - - my $iterator = Apache::lonnavmaps::iterator->new($navmap, undef, undef, undef, 1, undef, 1); - my $depth = 1; - my $curRes = $iterator->next(); - my %symbx = (); my @titles = (); - my $minder=0; - my $seenBeginMap = 0; - while ($depth > 0 && !$seenBeginMap) { - if ($curRes == $iterator->BEGIN_MAP()) {$depth++; $seenBeginMap = 1; } - if ($curRes == $iterator->END_MAP()) { $depth--; } - - if (ref($curRes) && $curRes->is_map()) { - my ($mapUrl, $id, $resUrl) = split(/___/, $curRes->symb()); # check map contains at least one problem - my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps - - my $mapiterator = $navmap->getIterator($map->map_start(), - $map->map_finish()); - - my $mapdepth = 1; - my $countProblems = 0; - $mapiterator->next(); # skip the first BEGIN_MAP - my $mapcurRes = $mapiterator->next(); # for "current resource" - while ($mapdepth > 0) { - if($mapcurRes == $mapiterator->BEGIN_MAP) { $mapdepth++; } - if($mapcurRes == $mapiterator->END_MAP) { $mapdepth--; } - - if (ref($mapcurRes) && $mapcurRes->is_problem() && !$mapcurRes->randomout) { - $countProblems++; - } - $mapcurRes = $mapiterator->next(); - } - if ($countProblems > 0) { - my $title = $curRes->compTitle(); - push @titles,$minder.'.'.$title; # minder, just in case two titles are identical - $symbx{$minder.'.'.$title} = $curRes->symb(); - $minder++; - } - } - $curRes = $iterator->next(); + my $minder = 0; + + # Gather every sequence that has problems. + my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1); + for my $sequence ($navmap->getById('0.0'), @sequences) { + if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) { + my $title = $minder.'.'.$sequence->compTitle(); + push @titles, $title; # minder in case two titles are identical + $symbx{$title} = $sequence->symb(); + $minder++; + } } $navmap->untieHashes(); @@ -2783,21 +2760,18 @@ sub displayPage { if ($ENV{'form.vProb'} eq 'yes') { $studentTable.=&show_problem($request,$symbx,$uname,$udom,1); } else { - my $companswer = &Apache::loncommon::get_student_answers( - $symbx,$uname,$udom,$ENV{'request.course.id'}); + my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$ENV{'request.course.id'}); $companswer =~ s|||g; $companswer =~ s|||g; - # while ($companswer =~ /()/s) { #\n"); # } -# $companswer =~ s//
/g; +# $companswer =~ s|
|
|g; $studentTable.=' '.$title.' 
 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.='
 No recorded submission for this problem
'; @@ -2807,6 +2781,10 @@ sub displayPage { ''. ''. ''; + my %responseType = (); + foreach my $partid (@{$parts}) { + $responseType{$partid} = $curRes->responseType($partid); + } my ($version); for ($version=1;$version<=$record{'version'};$version++) { my $timestamp = scalar(localtime($record{$version.':timestamp'})); @@ -2816,13 +2794,11 @@ sub displayPage { foreach my $partid (@{$parts}) { my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys; next if ($record{"$version:resource.$partid.solved"} eq ''); -# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && -# $record{"$version:resource.$partid.solved"} eq ''); $displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? 'Part '.$partid.' '. ($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' : 'Trial '.$record{"$version:resource.$partid.tries"}).'  '. - $record{$version.':'.$matchKey[0]}.'
' : ''; + &cleanRecord($record{$version.':'.$matchKey[0]},$responseType{$partid}).'
' : ''; $displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? 'Part '.$partid.'  '. $record{"$version:resource.$partid.award"}.'/'. @@ -2869,6 +2845,26 @@ sub displayPage { return ''; } +sub cleanRecord { + my ($answer,$response) = @_; + if ($response eq 'option') { + my (@IDs,@ans); + foreach (split(/\&/,&Apache::lonnet::unescape($answer))) { + my ($optionID,$ans) = split(/=/); + push @IDs,$optionID.''; + push @ans,$ans; + } + my $grayFont = ''; + return '
Date/TimeSubmissionStatus 
'. + ''. + ''. + '
Answer'. + (join '',@ans).'
'.$grayFont.'Option ID'.$grayFont. + (join ''.$grayFont,@IDs).'
'; + } + return $answer; +} + sub updateGradeByPage { my ($request) = shift; @@ -3336,12 +3332,17 @@ sub gradingmenu { $request->print(< - function checkChoice(formname) { - var cmd = formname.command; - formname.saveState.value = "saveCmd="+radioSelection(cmd)+":saveSec="+pullDownSelection(formname.section)+ + function checkChoice(formname,val,cmdx) { + if (val <= 2) { + var cmd = radioSelection(formname.radioChoice); + } else { + cmd = cmdx; + } + formname.command.value = cmd; + formname.saveState.value = "saveCmd="+cmd+":saveSec="+pullDownSelection(formname.section)+ ":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status); - if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[3].checked || cmd[4].checked) formname.submit(); - if (cmd[5].checked) { + if (val < 5) formname.submit(); + if (val == 5) { if (!checkReceiptNo(formname,'notOK')) { return false;} formname.submit(); } @@ -3358,7 +3359,6 @@ sub gradingmenu { formname.receipt.focus(); return false; } - formname.command[5].checked = true; return true; } @@ -3402,8 +3402,8 @@ GRADINGMENUJS $resptype = $responsetype; $hdgrade = $handgrade if ($handgrade eq 'yes'); $result.='Part '.(split(/_/))[0].''. - 'Type: '.$responsetype.''. - 'Handgrade: '.$handgrade.''; + 'Type: '.$responsetype.''; +# 'Handgrade: '.$handgrade.''; } $result.=''."\n"; @@ -3420,75 +3420,75 @@ GRADINGMENUJS ''."\n". ''."\n". ''."\n". + ''."\n". ''."\n". ''."\n"; - $result.='
'."\n". - '
'."\n". + $result.='
'."\n". + ''."\n". - ''."\n"; + $result.='
'."\n". ' Select a Grading/Viewing Option
'."\n"; + '
'."\n"; - $result.=''. - ''; + + $result.=''."\n". + 'One student for whole page/sequence/folder'."\n"; - ''."\n". + 'All students in section/course for current resource'."\n"; - ''."\n". - ''."\n". + ($saveSub eq 'all' ? 'checked' : '').' /> everybody'."\n"; + + $result.='
'. - ''."\n"; + if (ref($sections)) { + foreach (sort (@$sections)) {$result.=''."\n";} + } + $result.= '
'. + ' '. - 'Handgrade/View Submission for a student by page/sequence
'. - ' '. - 'Grade by section or class
'. - ($hdgrade eq 'yes' ? 'View/Grade essay response of' : 'View'). - ' an individual student --> For students who has: '. + $result.='
'. + ' '.'One or more students for current resource'. + '
            -->For students who has: '. ' submitted'. ' everybody

'. + ''. + '
'."\n"; + + $result.='
'; - '
'. - ' '. - 'Upload scores from file
'; + $result.=''."\n"; $result.=''."\n"; + ' scantron forms'."\n"; if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) { $result.=''. - ''."\n"; } - $result.=''; - - $result.='
'. + ''. + ' scores from file
'. - ' '. - 'Grade scantron forms
'. - ' '. - 'Verify a submission receipt issued by this server--> Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}). + ''. + ' submission Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}). '-'. '

'."\n". - ' Select section:   '; - - $result.='Student Status:'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef); - $result.='   (Applies to the first three options only.)'."\n"; - - if (ref($sections)) { - $result.=' (Section "no" implies the students were not assigned a section.)
' - if (grep /no/,@$sections); - } - $result.='

'. - ''."\n". - '
'."\n". + $result.='
'."\n". '
'."\n". '
'."\n"; return $result;