'.
+ ''.
+ ' No '.
+ ' '.($ENV{'form.vProb'} eq 'no' ? 'Title' : 'Problem View').'/Grade ';
+
+ my ($depth,$ctr,$question) = (1,0,1);
+ $iterator->next(); # skip the first BEGIN_MAP
+ my $curRes = $iterator->next(); # for "current resource"
+ while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ if($curRes == $iterator->BEGIN_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth++; }
+
+ if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
+ my $parts = $curRes->parts();
+ $parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed
+ my $title = $curRes->compTitle();
+ my $symbx = $curRes->symb();
+ $studentTable.=''.$question.
+ (scalar(@{$parts}) == 1 ? '' : ' ('.scalar(@{$parts}).' parts)').' ';
+ $studentTable.='';
+ 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'});
+ $companswer=~s|||g;
+
+# while ($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 ';
+ } else {
+ $studentTable.=''.
+ ''.
+ 'Date/Time '.
+ 'Submission '.
+ 'Status ';
+ my ($version);
+ for ($version=1;$version<=$record{'version'};$version++) {
+ my $timestamp = scalar(localtime($record{$version.':timestamp'}));
+ $studentTable.=''.$timestamp.' ';
+ my @versionKeys = split(/\:/,$record{$version.':keys'});
+ my @displaySub = ();
+ foreach my $partid (@{$parts}) {
+ my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
+ $displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ?
+ 'Part: '.$partid.' Submission: '
+ .$record{$version.':'.$matchKey[0]}.' ' : '';
+ $displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ?
+ 'Part: '.$partid.' '.
+ $record{"$version:resource.$partid.award"}.'/'.
+ $record{"$version:resource.$partid.solved"}.' ' : '';
+ $displaySub[2].=(exists $record{"$version:resource.$partid.regrader"}) ?
+ $record{"$version:resource.$partid.regrader"}.' (Part: '.$partid.')' : '';
+ }
+ $displaySub[2].=(exists $record{"$version:resource.regrader"}) ?
+ $record{"$version:resource.regrader"} : '';
+ $studentTable.=''.$displaySub[0].' '.$displaySub[1].
+ ($displaySub[2] eq '' ? '' : 'Manually graded by '.$displaySub[2]).' ';
+ }
+ $studentTable.='
';
+ }
+ } elsif ($ENV{'form.lastSub'} eq 'all') {
+ my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
+ $studentTable.=&Apache::loncommon::get_previous_attempt($symbx,$uname,$udom,
+ $ENV{'request.course.id'},
+ '','.submission');
+
+ }
+
+ foreach my $partid (@{$parts}) {
+ $studentTable.=&gradeBox($request,$symbx,$uname,$udom,$question,$partid,\%record);
+ $studentTable.=' '."\n";
+ $question++;
+ }
+ $studentTable.='';
+
+ }
+ $curRes = $iterator->next();
+ $ctr++;
+ }
+
+ $studentTable.='
'."\n".
+ ' '.
+ ''."\n";
+ $studentTable.=&show_grading_menu_form($symb,$url);
+ $request->print($studentTable);
+
+ return '';
+}
+
+sub temp_parts_fix { #remove sub once lonnavmap is fixed
+ my $parts = shift;
+ my %seen = ();
+ my @correctParts = ();
+ foreach (@{$parts}) {
+ next if ($seen{$_} > 0);
+ $seen{$_}++;
+ push @correctParts,$_;
+ }
+ return \@correctParts;
+}
+
+sub updateGradeByPage {
+ my ($request) = shift;
+
+ 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'};
+ my $pageTitle = $ENV{'form.page'};
+ my (undef,undef,$fullname) = &getclasslist($getsec,'0');
+ my ($uname,$udom) = split(/:/,$ENV{'form.student'});
+
+ my $result=' '.$ENV{'form.title'}.' ';
+ $result.=' Student: '.$$fullname{$ENV{'form.student'}}.
+ ' ('.$uname.($udom eq $cdom ? '':':'.$udom).') '."\n";
+
+ $request->print($result);
+
+ my $navmap = Apache::lonnavmaps::navmap-> new(
+ $ENV{'request.course.fn'}.'.db',
+ $ENV{'request.course.fn'}.'_parms.db',1, 1);
+ my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'});
+ my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
+
+ my $iterator = $navmap->getIterator($map->map_start(),
+ $map->map_finish());
+
+ my $studentTable=''.
+ ''.
+ ' No '.
+ ' Title '.
+ ' Previous Score '.
+ ' New Score ';
+
+ $iterator->next(); # skip the first BEGIN_MAP
+ my $curRes = $iterator->next(); # for "current resource"
+ my ($depth,$ctr,$question,$changeflag)= (1,0,1,0);
+ while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ if($curRes == $iterator->BEGIN_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth++; }
+
+ if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
+ my $parts = $curRes->parts();
+ $parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed
+ my $title = $curRes->compTitle();
+ my $symbx = $curRes->symb();
+ $studentTable.=''.$question.
+ (scalar(@{$parts}) == 1 ? '' : ' ('.scalar(@{$parts}).' parts)').' ';
+ $studentTable.=' '.$title.' ';
+
+ my %newrecord=();
+ my @displayPts=();
+ foreach my $partid (@{$parts}) {
+ my $newpts = $ENV{'form.GD_BOX'.$question.'_'.$partid};
+ my $oldpts = $ENV{'form.oldpts'.$question.'_'.$partid};
+
+ my $wgt = $ENV{'form.WGT'.$question.'_'.$partid} != 0 ?
+ $ENV{'form.WGT'.$question.'_'.$partid} : 1;
+ my $partial = $newpts/$wgt;
+ my $score;
+ if ($partial > 0) {
+ $score = 'correct_by_override';
+ } elsif ($partial == 0) {
+ $score = 'incorrect_by_override';
+ }
+ if ($ENV{'form.GD_SEL'.$question.'_'.$partid} eq 'excused') {
+ $partial = '';
+ $score = 'excused';
+ }
+ my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid};
+ $displayPts[0].=' Part '.$partid.' = '.
+ (($oldstatus eq 'excused') ? 'excused' : $oldpts).
+ ' ';
+ $displayPts[1].=' Part '.$partid.' = '.
+ ($oldstatus eq 'correct_by_student' ? $oldpts :
+ (($score eq 'excused') ? 'excused' : $newpts)).
+ ' ';
+
+ $question++;
+ if (($oldstatus eq 'correct_by_student') ||
+ ($newpts eq $oldpts && $score eq $oldstatus))
+ {
+ next;
+ }
+ $newrecord{'resource.'.$partid.'.awarded'} = $partial if $partial ne '';
+ $newrecord{'resource.'.$partid.'.solved'} = $score;
+ $newrecord{'resource.'.$partid.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+
+ $changeflag++;
+ }
+ if (scalar(keys(%newrecord)) > 0) {
+ &Apache::lonnet::cstore(\%newrecord,$symbx,$ENV{'request.course.id'},
+ $udom,$uname);
+ }
+ $studentTable.=''.$displayPts[0].' '.
+ ''.$displayPts[1].' '.
+ ' ';
+
+ }
+ $curRes = $iterator->next();
+ $ctr++;
+ }
+
+ $studentTable.='
';
+ $studentTable.=($changeflag == 0 ? 'No score was changed or updated.' :
+ 'The scores were changed for '.
+ $changeflag.' problem'.($changeflag == 1 ? '.' : 's.'));
+ $studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'});
+ $request->print($studentTable);
+
+ return '';
+}
+
+#-------- end of section for handling grading by page/sequence ---------
+#
+#-------------------------------------------------------------------
#-------------------------- Menu interface -------------------------
#
@@ -2075,6 +2775,8 @@ sub show_grading_menu_form {
my $result.=''."\n";
@@ -2086,9 +2788,72 @@ sub gradingmenu {
my ($request) = @_;
my ($symb,$url)=&get_symb_and_url($request);
if (!$symb) {return '';}
- my $result=' Select a Grading Method ';
- $result.='';
- $result.='Resource: '.$url.' ';
+
+ $request->print(<
+ function checkChoice(formname) {
+ var cmd = formname.command;
+ formname.lastCmd.value = radioSelection(formname.command);
+ formname.lastSec.value = pullDownSelection(formname.section);
+ if (cmd[0].checked || cmd[1].checked || cmd[2].checked) {
+ formname.submit();
+ }
+
+ if (cmd[3].checked) {
+ var url = "/adm/grades?command=csvform&symb="+formname.symb.value+"&url="+formname.url.value;
+ var options = "width=620,height=340,screenx=70,screeny=75,";
+ options += "resizable=no,scrollbars=no,status=no,";
+ options += "menubar=no,toolbar=no,location=no,directories=no";
+ var newWin = window.open(url, "CSVFile", options);
+ newWin.focus();
+ }
+
+ if (cmd[4].checked) {
+ if (!checkReceiptNo(formname,'notOK')) { return false;}
+ formname.submit();
+ }
+ }
+
+ function checkReceiptNo(formname,nospace) {
+ var receiptNo = formname.receipt.value;
+ var checkOpt = false;
+ if (nospace == "OK" && isNaN(receiptNo)) {checkOpt = true;}
+ if (nospace == "notOK" && (isNaN(receiptNo) || receiptNo == "")) {checkOpt = true;}
+ if (checkOpt) {
+ alert("Please enter a receipt number given by a student in the receipt box.");
+ formname.receipt.value = "";
+ formname.receipt.focus();
+ return false;
+ }
+ formname.command[4].checked = true;
+ return true;
+ }
+
+ function radioSelection(radioButton) {
+ var selection=null;
+ for (var i=0; i
+GRADINGMENUJS
+
+ my $probTitle = &Apache::lonnet::metadata($ENV{'form.url'},'title');
+ my $result=' Manual Grading/View Submission '.
+ ''.
+ 'Problem: '.$probTitle.' ';
my ($partlist,$handgrade) = &response_type($url);
my ($resptype,$hdgrade)=('','no');
for (sort keys(%$handgrade)) {
@@ -2100,155 +2865,79 @@ sub gradingmenu {
'Handgrade: '.$handgrade.' ';
}
$result.='
';
- $result.=&view_edit_entire_class_form($symb,$url).' ';
- $result.=&upcsvScores_form($symb,$url).' ';
- $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).' ';
- $result.=&verifyReceipt_form($symb,$url)
- if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));
-
- return $result;
-}
-#--- Menu for grading a section or the whole class ---
-sub view_edit_entire_class_form {
- my ($symb,$url)=@_;
my ($classlist,$sections) = &getclasslist('all','0');
- my $result.=''."\n";
- $result.=''."\n";
- $result.=' View/Grade Entire Section/Class '."\n";
- $result.=''."\n";
- $result.=''."\n";
- $result.='
'."\n";
- $result.='
'."\n";
- return $result;
-}
+ my $lastCmd = ($ENV{'form.lastCmd'} eq '' ? 'pickStudentPage' : $ENV{'form.lastCmd'});
+ my $lastSec = ($ENV{'form.lastSec'} eq '' ? 'all' : $ENV{'form.lastSec'});
-#--- Menu to upload a csv scores ---
-sub upcsvScores_form {
- my ($symb,$url) = @_;
- if (!$symb) {return '';}
- my $result = ''."\n";
-
- $result.=''."\n";
- $result.=''."\n";
- $result.='
'."\n";
- return $result;
-}
+ $result.='